From 5e42230b954353d5643f02791bfafe2256dee7c7 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Mon, 9 Jan 2023 14:54:55 +0100 Subject: [PATCH] [dxvk] Add patch vertex count to shader info struct --- src/dxvk/dxvk_graphics.cpp | 7 +++++++ src/dxvk/dxvk_shader.cpp | 7 +++++++ src/dxvk/dxvk_shader.h | 2 ++ 3 files changed, 16 insertions(+) diff --git a/src/dxvk/dxvk_graphics.cpp b/src/dxvk/dxvk_graphics.cpp index 424e5c36..1a653c87 100644 --- a/src/dxvk/dxvk_graphics.cpp +++ b/src/dxvk/dxvk_graphics.cpp @@ -1093,6 +1093,13 @@ namespace dxvk { || state.rs.conservativeMode() != VK_CONSERVATIVE_RASTERIZATION_MODE_DISABLED_EXT) return false; + if (m_shaders.tcs != nullptr) { + // If tessellation shaders are present, the input patch + // vertex count must match the shader's definition. + if (m_shaders.tcs->info().patchVertexCount != state.ia.patchVertexCount()) + return false; + } + if (m_shaders.fs != nullptr) { // If the fragment shader has inputs not produced by the last // pre-rasterization stage, we need to patch the fragment shader diff --git a/src/dxvk/dxvk_shader.cpp b/src/dxvk/dxvk_shader.cpp index 740276da..7a51eda8 100644 --- a/src/dxvk/dxvk_shader.cpp +++ b/src/dxvk/dxvk_shader.cpp @@ -1107,6 +1107,12 @@ namespace dxvk { dyInfo.dynamicStateCount = dynamicStateCount; dyInfo.pDynamicStates = dynamicStates.data(); + // If a tessellation control shader is present, grab the patch vertex count + VkPipelineTessellationStateCreateInfo tsInfo = { VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO }; + + if (m_shaders.tcs) + tsInfo.patchControlPoints = m_shaders.tcs->info().patchVertexCount; + // All viewport state is dynamic, so we do not need to initialize this. VkPipelineViewportStateCreateInfo vpInfo = { VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO }; @@ -1140,6 +1146,7 @@ namespace dxvk { info.flags = VK_PIPELINE_CREATE_LIBRARY_BIT_KHR | flags; info.stageCount = stageInfo.getStageCount(); info.pStages = stageInfo.getStageInfos(); + info.pTessellationState = m_shaders.tcs ? &tsInfo : nullptr; info.pViewportState = &vpInfo; info.pRasterizationState = &rsInfo; info.pDynamicState = &dyInfo; diff --git a/src/dxvk/dxvk_shader.h b/src/dxvk/dxvk_shader.h index 9ab46fb4..b3f6123a 100644 --- a/src/dxvk/dxvk_shader.h +++ b/src/dxvk/dxvk_shader.h @@ -58,6 +58,8 @@ namespace dxvk { const char* uniformData = nullptr; /// Rasterized stream, or -1 int32_t xfbRasterizedStream = 0; + /// Tess control patch vertex count + uint32_t patchVertexCount = 0; /// Transform feedback vertex strides uint32_t xfbStrides[MaxNumXfbBuffers] = { }; };