diff --git a/renderdoc/driver/vulkan/vk_core.h b/renderdoc/driver/vulkan/vk_core.h index 0a3e36f83..e168d1e79 100644 --- a/renderdoc/driver/vulkan/vk_core.h +++ b/renderdoc/driver/vulkan/vk_core.h @@ -308,8 +308,6 @@ private: } // dynamic state - // VKTODOHIGH this needs to come from the pipeline state - // first, then get overridden by dynamic state. vector views; vector scissors; float lineWidth; diff --git a/renderdoc/driver/vulkan/vk_info.cpp b/renderdoc/driver/vulkan/vk_info.cpp index 05a9393f4..caf423205 100644 --- a/renderdoc/driver/vulkan/vk_info.cpp +++ b/renderdoc/driver/vulkan/vk_info.cpp @@ -65,12 +65,29 @@ void VulkanCreationInfo::Pipeline::Init(const VkGraphicsPipelineCreateInfo* pCre viewportCount = pCreateInfo->pViewportState->viewportCount; + viewports.resize(viewportCount); + scissors.resize(viewportCount); + + for(size_t i=0; i < viewports.size(); i++) + { + if(pCreateInfo->pViewportState->pViewports) + viewports[i] = pCreateInfo->pViewportState->pViewports[i]; + + if(pCreateInfo->pViewportState->pScissors) + scissors[i] = pCreateInfo->pViewportState->pScissors[i]; + } + // VkPipelineRasterStateCreateInfo depthClipEnable = pCreateInfo->pRasterState->depthClipEnable ? true : false; rasterizerDiscardEnable = pCreateInfo->pRasterState->rasterizerDiscardEnable ? true : false; fillMode = pCreateInfo->pRasterState->fillMode; cullMode = pCreateInfo->pRasterState->cullMode; frontFace = pCreateInfo->pRasterState->frontFace; + depthBiasEnable = pCreateInfo->pRasterState->depthBiasEnable ? true : false; + depthBias = pCreateInfo->pRasterState->depthBias; + depthBiasClamp = pCreateInfo->pRasterState->depthBiasClamp; + slopeScaledDepthBias = pCreateInfo->pRasterState->slopeScaledDepthBias; + lineWidth = pCreateInfo->pRasterState->lineWidth; // VkPipelineMultisampleStateCreateInfo rasterSamples = pCreateInfo->pMultisampleState->rasterSamples; @@ -86,11 +103,15 @@ void VulkanCreationInfo::Pipeline::Init(const VkGraphicsPipelineCreateInfo* pCre stencilTestEnable = pCreateInfo->pDepthStencilState->stencilTestEnable ? true : false; front = pCreateInfo->pDepthStencilState->front; back = pCreateInfo->pDepthStencilState->back; + minDepthBounds = pCreateInfo->pDepthStencilState->minDepthBounds; + maxDepthBounds = pCreateInfo->pDepthStencilState->maxDepthBounds; // VkPipelineColorBlendStateCreateInfo alphaToCoverageEnable = pCreateInfo->pColorBlendState->alphaToCoverageEnable ? true : false; + alphaToOneEnable = pCreateInfo->pColorBlendState->alphaToOneEnable ? true : false; logicOpEnable = pCreateInfo->pColorBlendState->logicOpEnable ? true : false; logicOp = pCreateInfo->pColorBlendState->logicOp; + memcpy(blendConst, pCreateInfo->pColorBlendState->blendConst, sizeof(blendConst)); attachments.resize(pCreateInfo->pColorBlendState->attachmentCount); @@ -108,6 +129,13 @@ void VulkanCreationInfo::Pipeline::Init(const VkGraphicsPipelineCreateInfo* pCre attachments[i].channelWriteMask = pCreateInfo->pColorBlendState->pAttachments[i].channelWriteMask; } + + RDCEraseEl(dynamicStates); + if(pCreateInfo->pDynamicState) + { + for(uint32_t i=0; i < pCreateInfo->pDynamicState->dynamicStateCount; i++) + dynamicStates[ pCreateInfo->pDynamicState->pDynamicStates[i] ] = true; + } } void VulkanCreationInfo::Pipeline::Init(const VkComputePipelineCreateInfo* pCreateInfo) diff --git a/renderdoc/driver/vulkan/vk_info.h b/renderdoc/driver/vulkan/vk_info.h index c6878325e..8a8342f40 100644 --- a/renderdoc/driver/vulkan/vk_info.h +++ b/renderdoc/driver/vulkan/vk_info.h @@ -67,6 +67,8 @@ struct VulkanCreationInfo // VkPipelineViewportStateCreateInfo uint32_t viewportCount; + vector viewports; + vector scissors; // VkPipelineRasterStateCreateInfo bool depthClipEnable; @@ -74,6 +76,11 @@ struct VulkanCreationInfo VkFillMode fillMode; VkCullMode cullMode; VkFrontFace frontFace; + bool depthBiasEnable; + float depthBias; + float depthBiasClamp; + float slopeScaledDepthBias; + float lineWidth; // VkPipelineMultisampleStateCreateInfo uint32_t rasterSamples; @@ -89,11 +96,15 @@ struct VulkanCreationInfo bool stencilTestEnable; VkStencilOpState front; VkStencilOpState back; + float minDepthBounds; + float maxDepthBounds; // VkPipelineColorBlendStateCreateInfo bool alphaToCoverageEnable; + bool alphaToOneEnable; bool logicOpEnable; VkLogicOp logicOp; + float blendConst[4]; struct Attachment { @@ -109,6 +120,9 @@ struct VulkanCreationInfo uint8_t channelWriteMask; }; vector attachments; + + // VkPipelineDynamicStateCreateInfo + bool dynamicStates[VK_DYNAMIC_STATE_NUM]; }; map m_Pipeline; diff --git a/renderdoc/driver/vulkan/wrappers/vk_cmd_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_cmd_funcs.cpp index 42acad945..d4ca55f36 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_cmd_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_cmd_funcs.cpp @@ -771,6 +771,49 @@ bool WrappedVulkan::Serialise_vkCmdBindPipeline( m_PartialReplayData.state.graphics.pipeline = pipeid; else m_PartialReplayData.state.compute.pipeline = pipeid; + + if(!m_CreationInfo.m_Pipeline[pipeid].dynamicStates[VK_DYNAMIC_STATE_VIEWPORT]) + { + m_PartialReplayData.state.views = m_CreationInfo.m_Pipeline[pipeid].viewports; + } + if(!m_CreationInfo.m_Pipeline[pipeid].dynamicStates[VK_DYNAMIC_STATE_SCISSOR]) + { + m_PartialReplayData.state.scissors = m_CreationInfo.m_Pipeline[pipeid].scissors; + } + if(!m_CreationInfo.m_Pipeline[pipeid].dynamicStates[VK_DYNAMIC_STATE_LINE_WIDTH]) + { + m_PartialReplayData.state.lineWidth = m_CreationInfo.m_Pipeline[pipeid].lineWidth; + } + if(!m_CreationInfo.m_Pipeline[pipeid].dynamicStates[VK_DYNAMIC_STATE_DEPTH_BIAS]) + { + m_PartialReplayData.state.bias.depth = m_CreationInfo.m_Pipeline[pipeid].depthBias; + m_PartialReplayData.state.bias.biasclamp = m_CreationInfo.m_Pipeline[pipeid].depthBiasClamp; + m_PartialReplayData.state.bias.slope = m_CreationInfo.m_Pipeline[pipeid].slopeScaledDepthBias; + } + if(!m_CreationInfo.m_Pipeline[pipeid].dynamicStates[VK_DYNAMIC_STATE_BLEND_CONSTANTS]) + { + memcpy(m_PartialReplayData.state.blendConst, m_CreationInfo.m_Pipeline[pipeid].blendConst, sizeof(float)*4); + } + if(!m_CreationInfo.m_Pipeline[pipeid].dynamicStates[VK_DYNAMIC_STATE_DEPTH_BOUNDS]) + { + m_PartialReplayData.state.mindepth = m_CreationInfo.m_Pipeline[pipeid].minDepthBounds; + m_PartialReplayData.state.maxdepth = m_CreationInfo.m_Pipeline[pipeid].maxDepthBounds; + } + if(!m_CreationInfo.m_Pipeline[pipeid].dynamicStates[VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK]) + { + m_PartialReplayData.state.front.compare = m_CreationInfo.m_Pipeline[pipeid].front.stencilCompareMask; + m_PartialReplayData.state.back.compare = m_CreationInfo.m_Pipeline[pipeid].back.stencilCompareMask; + } + if(!m_CreationInfo.m_Pipeline[pipeid].dynamicStates[VK_DYNAMIC_STATE_STENCIL_WRITE_MASK]) + { + m_PartialReplayData.state.front.write = m_CreationInfo.m_Pipeline[pipeid].front.stencilWriteMask; + m_PartialReplayData.state.back.write = m_CreationInfo.m_Pipeline[pipeid].back.stencilWriteMask; + } + if(!m_CreationInfo.m_Pipeline[pipeid].dynamicStates[VK_DYNAMIC_STATE_STENCIL_REFERENCE]) + { + m_PartialReplayData.state.front.ref = m_CreationInfo.m_Pipeline[pipeid].front.stencilReference; + m_PartialReplayData.state.back.ref = m_CreationInfo.m_Pipeline[pipeid].back.stencilReference; + } } } else if(m_State == READING)