Add input primitive topology to D3D12 and Metal pipeline states
This commit is contained in:
parent
2a0792b5f0
commit
c2def461a1
|
@ -42,6 +42,21 @@ namespace d3d12 {
|
||||||
UNREACHABLE();
|
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)
|
RenderPipeline::RenderPipeline(RenderPipelineBuilder* builder)
|
||||||
|
@ -142,7 +157,7 @@ namespace d3d12 {
|
||||||
descriptor.DepthStencilState.DepthEnable = false;
|
descriptor.DepthStencilState.DepthEnable = false;
|
||||||
descriptor.DepthStencilState.StencilEnable = false;
|
descriptor.DepthStencilState.StencilEnable = false;
|
||||||
descriptor.SampleMask = UINT_MAX;
|
descriptor.SampleMask = UINT_MAX;
|
||||||
descriptor.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE;
|
descriptor.PrimitiveTopologyType = D3D12PrimitiveTopologyType(GetPrimitiveTopology());
|
||||||
descriptor.NumRenderTargets = 1;
|
descriptor.NumRenderTargets = 1;
|
||||||
descriptor.RTVFormats[0] = DXGI_FORMAT_R8G8B8A8_UNORM;
|
descriptor.RTVFormats[0] = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||||
descriptor.SampleDesc.Count = 1;
|
descriptor.SampleDesc.Count = 1;
|
||||||
|
|
|
@ -38,6 +38,19 @@ namespace metal {
|
||||||
return MTLPrimitiveTypeTriangleStrip;
|
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)
|
RenderPipeline::RenderPipeline(RenderPipelineBuilder* builder)
|
||||||
|
@ -68,6 +81,7 @@ namespace metal {
|
||||||
// TODO(cwallez@chromium.org): get the attachment formats from the subpass
|
// TODO(cwallez@chromium.org): get the attachment formats from the subpass
|
||||||
descriptor.colorAttachments[0].pixelFormat = MTLPixelFormatRGBA8Unorm;
|
descriptor.colorAttachments[0].pixelFormat = MTLPixelFormatRGBA8Unorm;
|
||||||
descriptor.depthAttachmentPixelFormat = MTLPixelFormatDepth32Float;
|
descriptor.depthAttachmentPixelFormat = MTLPixelFormatDepth32Float;
|
||||||
|
descriptor.inputPrimitiveTopology = MTLInputPrimitiveTopology(GetPrimitiveTopology());
|
||||||
|
|
||||||
InputState* inputState = ToBackend(GetInputState());
|
InputState* inputState = ToBackend(GetInputState());
|
||||||
descriptor.vertexDescriptor = inputState->GetMTLVertexDescriptor();
|
descriptor.vertexDescriptor = inputState->GetMTLVertexDescriptor();
|
||||||
|
|
Loading…
Reference in New Issue