diff --git a/src/dxvk/dxvk_graphics.cpp b/src/dxvk/dxvk_graphics.cpp index 0dee2c28c..bcefd0c4c 100644 --- a/src/dxvk/dxvk_graphics.cpp +++ b/src/dxvk/dxvk_graphics.cpp @@ -340,6 +340,32 @@ namespace dxvk { } + DxvkGraphicsPipelineFragmentShaderState::DxvkGraphicsPipelineFragmentShaderState() { + + } + + + DxvkGraphicsPipelineFragmentShaderState::DxvkGraphicsPipelineFragmentShaderState( + const DxvkDevice* device, + const DxvkGraphicsPipelineStateInfo& state) { + dsInfo.depthTestEnable = state.ds.enableDepthTest(); + dsInfo.depthWriteEnable = state.ds.enableDepthWrite(); + dsInfo.depthCompareOp = state.ds.depthCompareOp(); + dsInfo.depthBoundsTestEnable = state.ds.enableDepthBoundsTest(); + dsInfo.stencilTestEnable = state.ds.enableStencilTest(); + dsInfo.front = state.dsFront.state(); + dsInfo.back = state.dsBack.state(); + + if ((state.rt.getDepthStencilReadOnlyAspects() & VK_IMAGE_ASPECT_DEPTH_BIT)) + dsInfo.depthWriteEnable = VK_FALSE; + + if ((state.rt.getDepthStencilReadOnlyAspects() & VK_IMAGE_ASPECT_STENCIL_BIT)) { + dsInfo.front.writeMask = 0; + dsInfo.back.writeMask = 0; + } + } + + DxvkGraphicsPipeline::DxvkGraphicsPipeline( DxvkPipelineManager* pipeMgr, DxvkGraphicsPipelineShaders shaders, @@ -517,20 +543,9 @@ namespace dxvk { DxvkGraphicsPipelineVertexInputState viState(device, state); DxvkGraphicsPipelinePreRasterizationState prState(device, state, m_shaders.gs.ptr()); + DxvkGraphicsPipelineFragmentShaderState fsState(device, state); DxvkGraphicsPipelineFragmentOutputState foState(device, state, m_shaders.fs.ptr()); - VkPipelineDepthStencilStateCreateInfo dsInfo = { VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO }; - dsInfo.depthTestEnable = state.ds.enableDepthTest(); - dsInfo.depthWriteEnable = state.ds.enableDepthWrite(); - dsInfo.depthCompareOp = state.ds.depthCompareOp(); - dsInfo.depthBoundsTestEnable = state.ds.enableDepthBoundsTest(); - dsInfo.stencilTestEnable = state.ds.enableStencilTest(); - dsInfo.front = state.dsFront.state(); - dsInfo.back = state.dsBack.state(); - - if ((state.rt.getDepthStencilReadOnlyAspects() & VK_IMAGE_ASPECT_DEPTH_BIT)) - dsInfo.depthWriteEnable = VK_FALSE; - VkPipelineDynamicStateCreateInfo dyInfo = { VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO }; dyInfo.dynamicStateCount = dynamicStateCount; dyInfo.pDynamicStates = dynamicStates.data(); @@ -544,7 +559,7 @@ namespace dxvk { info.pViewportState = &prState.vpInfo; info.pRasterizationState = &prState.rsInfo; info.pMultisampleState = &foState.msInfo; - info.pDepthStencilState = &dsInfo; + info.pDepthStencilState = &fsState.dsInfo; info.pColorBlendState = &foState.cbInfo; info.pDynamicState = &dyInfo; info.layout = m_bindings->getPipelineLayout(); diff --git a/src/dxvk/dxvk_graphics.h b/src/dxvk/dxvk_graphics.h index 1bd2b9880..20e63787b 100644 --- a/src/dxvk/dxvk_graphics.h +++ b/src/dxvk/dxvk_graphics.h @@ -98,6 +98,23 @@ namespace dxvk { VkPipelineRasterizationConservativeStateCreateInfoEXT rsConservativeInfo = { VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_CONSERVATIVE_STATE_CREATE_INFO_EXT }; }; + + /** + * \brief Fragment shader state info for graphics pipelines + * + * Can only be used when compiling full graphics pipelines + * when all pipeline state is known. + */ + struct DxvkGraphicsPipelineFragmentShaderState { + DxvkGraphicsPipelineFragmentShaderState(); + + DxvkGraphicsPipelineFragmentShaderState( + const DxvkDevice* device, + const DxvkGraphicsPipelineStateInfo& state); + + VkPipelineDepthStencilStateCreateInfo dsInfo = { VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO }; + }; + /** * \brief Flags that describe pipeline properties