hi, thank you for reply
Keep the view mapping offsets, and write output.layer = 0 in the vertex shader.
Keep output.layer = ampID, and pass view mappings with zero offsets, or pass nil for the view mappings.
If your host code doesn't pass view mapping offsets, please post your setVertexAmplificationCount call and render pass setup, and I'll take another look.
I forgot about posting configuration for MTLPipelineState, MTLRenderPassDescriptor and setup for drawing, i'm using metal-cpp:
//MTLPipelineState::setMaxVertexAmplificationCount(4):
mtlPSODesc->setMaxVertexAmplificationCount(desc.viewInstanceCount); // 4
MTLRenderPassDescriptor configuration:
mtlRenderPassDescriptor->setRenderTargetArrayLength(renderTargetArrayLength); //4
Setup for drawing: MTLRenderCommandEncoder::setVertexAmplificationCount:
const MTLVertexAmplificationViewMapping VertexAmplificationViewMappings[] = {
{ 0u, 0u }, // amplification_id 0 -> Viewport 0, RT Array Layer 0
{ 0u, 1u }, // amplification_id 1 -> Viewport 0, RT Array Layer 1
{ 0u, 2u }, // amplification_id 2 -> Viewport 0, RT Array Layer 2
{ 0u, 3u } // amplification_id 3 -> Viewport 0, RT Array Layer 3
};
for (const auto& vertexAmplificationViewMapping : VertexAmplificationViewMappings) {
mtlRenderToTexture.vertexAmplifications.push_back(vertexAmplificationViewMapping);
}
mtlCurRenderCommandEncoder->setVertexAmplificationCount(mtlRenderToTexture.vertexAmplifications.size(), mtlRenderToTexture.vertexAmplifications.data());
Keep the view mapping offsets, and write output.layer = 0 in the vertex shader.
It has been fixed problem! I can remove at all the output declaration
uint layer [[render_target_array_index]];
Also, HLSL shader doesn't use code for writing SV_RenderTargetArrayIndex index for Direct3D12/Vulkan.
Thank you for you answer!
Topic:
Graphics & Games
SubTopic:
Metal