Implement Shader Compiler Input Topology

Sets the input toplogy in the runtime information for the shader compiler correctly based on the Maxwell3D input topology.
This commit is contained in:
PixelyIon 2021-12-07 12:35:35 +05:30
parent 06f8369958
commit b0f084ae32

View File

@ -1082,24 +1082,27 @@ namespace skyline::gpu::interconnect {
public: public:
void SetPrimitiveTopology(maxwell3d::PrimitiveTopology topology) { void SetPrimitiveTopology(maxwell3d::PrimitiveTopology topology) {
inputAssemblyState.topology = [topology]() { auto[vkTopology, shaderTopology] = [topology]() -> std::tuple<vk::PrimitiveTopology, ShaderCompiler::InputTopology> {
using MaxwellTopology = maxwell3d::PrimitiveTopology;
using VkTopology = vk::PrimitiveTopology;
using ShaderTopology = ShaderCompiler::InputTopology;
switch (topology) { switch (topology) {
// @fmt:off // @fmt:off
case maxwell3d::PrimitiveTopology::PointList: return vk::PrimitiveTopology::ePointList; case MaxwellTopology::PointList: return {VkTopology::ePointList, ShaderTopology::Points};
case maxwell3d::PrimitiveTopology::LineList: return vk::PrimitiveTopology::eLineList; case MaxwellTopology::LineList: return {VkTopology::eLineList, ShaderTopology::Lines};
case maxwell3d::PrimitiveTopology::LineListWithAdjacency: return vk::PrimitiveTopology::eLineListWithAdjacency; case MaxwellTopology::LineStrip: return {VkTopology::eLineStrip, ShaderTopology::Lines};
case maxwell3d::PrimitiveTopology::LineStrip: return vk::PrimitiveTopology::eLineStrip; case MaxwellTopology::LineListWithAdjacency: return {VkTopology::eLineListWithAdjacency, ShaderTopology::LinesAdjacency};
case maxwell3d::PrimitiveTopology::LineStripWithAdjacency: return vk::PrimitiveTopology::eLineStripWithAdjacency; case MaxwellTopology::LineStripWithAdjacency: return {VkTopology::eLineStripWithAdjacency, ShaderTopology::LinesAdjacency};
case maxwell3d::PrimitiveTopology::TriangleList: return vk::PrimitiveTopology::eTriangleList; case MaxwellTopology::TriangleList: return {VkTopology::eTriangleList, ShaderTopology::Triangles};
case maxwell3d::PrimitiveTopology::TriangleListWithAdjacency: return vk::PrimitiveTopology::eTriangleListWithAdjacency; case MaxwellTopology::TriangleStrip: return {VkTopology::eTriangleStrip, ShaderTopology::Triangles};
case maxwell3d::PrimitiveTopology::TriangleStrip: return vk::PrimitiveTopology::eTriangleStrip; case MaxwellTopology::TriangleFan: return {VkTopology::eTriangleFan, ShaderTopology::Triangles};
case maxwell3d::PrimitiveTopology::TriangleStripWithAdjacency: return vk::PrimitiveTopology::eTriangleStripWithAdjacency; case MaxwellTopology::TriangleListWithAdjacency: return {VkTopology::eTriangleListWithAdjacency, ShaderTopology::TrianglesAdjacency};
case maxwell3d::PrimitiveTopology::TriangleFan: return vk::PrimitiveTopology::eTriangleFan; case MaxwellTopology::TriangleStripWithAdjacency: return {VkTopology::eTriangleStripWithAdjacency, ShaderTopology::TrianglesAdjacency};
case maxwell3d::PrimitiveTopology::PatchList: return vk::PrimitiveTopology::ePatchList; case MaxwellTopology::PatchList: return {VkTopology::ePatchList, ShaderTopology::Triangles};
// @fmt:on // @fmt:on
@ -1107,6 +1110,9 @@ namespace skyline::gpu::interconnect {
throw exception("Unimplemented Maxwell3D Primitive Topology: {}", maxwell3d::ToString(topology)); throw exception("Unimplemented Maxwell3D Primitive Topology: {}", maxwell3d::ToString(topology));
} }
}(); }();
inputAssemblyState.topology = vkTopology;
runtimeInfo.input_topology = shaderTopology;
} }
/* Multisampling */ /* Multisampling */
@ -1216,7 +1222,7 @@ namespace skyline::gpu::interconnect {
vk::raii::PipelineLayout pipelineLayout; vk::raii::PipelineLayout pipelineLayout;
vk::raii::Pipeline pipeline; vk::raii::Pipeline pipeline;
Storage(vk::raii::PipelineLayout&& pipelineLayout, vk::raii::Pipeline&& pipeline) : pipelineLayout(std::move(pipelineLayout)), pipeline(std::move(pipeline)) {} Storage(vk::raii::PipelineLayout &&pipelineLayout, vk::raii::Pipeline &&pipeline) : pipelineLayout(std::move(pipelineLayout)), pipeline(std::move(pipeline)) {}
}; };
cycle->AttachObject(std::make_shared<Storage>(std::move(pipelineLayout), vk::raii::Pipeline(vkDevice, pipeline.value))); cycle->AttachObject(std::make_shared<Storage>(std::move(pipelineLayout), vk::raii::Pipeline(vkDevice, pipeline.value)));