Add input primitive topology to D3D12 and Metal pipeline states

This commit is contained in:
Austin Eng 2017-07-26 14:41:26 -04:00 committed by Austin Eng
parent 2a0792b5f0
commit c2def461a1
2 changed files with 30 additions and 1 deletions

View File

@ -42,6 +42,21 @@ namespace d3d12 {
UNREACHABLE();
}
}
D3D12_PRIMITIVE_TOPOLOGY_TYPE D3D12PrimitiveTopologyType(nxt::PrimitiveTopology primitiveTopology) {
switch (primitiveTopology) {
case nxt::PrimitiveTopology::Point:
return D3D12_PRIMITIVE_TOPOLOGY_TYPE_POINT;
case nxt::PrimitiveTopology::Line:
case nxt::PrimitiveTopology::LineStrip:
return D3D12_PRIMITIVE_TOPOLOGY_TYPE_LINE;
case nxt::PrimitiveTopology::Triangle:
case nxt::PrimitiveTopology::TriangleStrip:
return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE;
default:
UNREACHABLE();
}
}
}
RenderPipeline::RenderPipeline(RenderPipelineBuilder* builder)
@ -142,7 +157,7 @@ namespace d3d12 {
descriptor.DepthStencilState.DepthEnable = false;
descriptor.DepthStencilState.StencilEnable = false;
descriptor.SampleMask = UINT_MAX;
descriptor.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE;
descriptor.PrimitiveTopologyType = D3D12PrimitiveTopologyType(GetPrimitiveTopology());
descriptor.NumRenderTargets = 1;
descriptor.RTVFormats[0] = DXGI_FORMAT_R8G8B8A8_UNORM;
descriptor.SampleDesc.Count = 1;

View File

@ -38,6 +38,19 @@ namespace metal {
return MTLPrimitiveTypeTriangleStrip;
}
}
MTLPrimitiveTopologyClass MTLInputPrimitiveTopology(nxt::PrimitiveTopology primitiveTopology) {
switch (primitiveTopology) {
case nxt::PrimitiveTopology::Point:
return MTLPrimitiveTopologyClassPoint;
case nxt::PrimitiveTopology::Line:
case nxt::PrimitiveTopology::LineStrip:
return MTLPrimitiveTopologyClassLine;
case nxt::PrimitiveTopology::Triangle:
case nxt::PrimitiveTopology::TriangleStrip:
return MTLPrimitiveTopologyClassTriangle;
}
}
}
RenderPipeline::RenderPipeline(RenderPipelineBuilder* builder)
@ -68,6 +81,7 @@ namespace metal {
// TODO(cwallez@chromium.org): get the attachment formats from the subpass
descriptor.colorAttachments[0].pixelFormat = MTLPixelFormatRGBA8Unorm;
descriptor.depthAttachmentPixelFormat = MTLPixelFormatDepth32Float;
descriptor.inputPrimitiveTopology = MTLInputPrimitiveTopology(GetPrimitiveTopology());
InputState* inputState = ToBackend(GetInputState());
descriptor.vertexDescriptor = inputState->GetMTLVertexDescriptor();