From 28a994035bee79d2d504413942da824f80365d34 Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 21 Nov 2022 15:36:21 +0000 Subject: [PATCH] Ensure pNext chain structs are properly reset when making create infos --- renderdoc/driver/vulkan/vk_shader_cache.cpp | 35 +++++++++++++-------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/renderdoc/driver/vulkan/vk_shader_cache.cpp b/renderdoc/driver/vulkan/vk_shader_cache.cpp index 66906927e..fa2f2f070 100644 --- a/renderdoc/driver/vulkan/vk_shader_cache.cpp +++ b/renderdoc/driver/vulkan/vk_shader_cache.cpp @@ -661,6 +661,8 @@ void VulkanShaderCache::MakeGraphicsPipelineInfo(VkGraphicsPipelineCreateInfo &p static VkPipelineInputAssemblyStateCreateInfo ia = { VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO}; + ia.pNext = NULL; + ia.topology = pipeInfo.topology; ia.primitiveRestartEnable = pipeInfo.primitiveRestartEnable; @@ -685,10 +687,11 @@ void VulkanShaderCache::MakeGraphicsPipelineInfo(VkGraphicsPipelineCreateInfo &p static VkPipelineViewportStateCreateInfo vp = { VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO}; - static VkViewport views[32] = {}; static VkRect2D scissors[32] = {}; + vp.pNext = NULL; + memcpy(views, &pipeInfo.viewports[0], pipeInfo.viewports.size() * sizeof(VkViewport)); vp.pViewports = &views[0]; @@ -702,6 +705,18 @@ void VulkanShaderCache::MakeGraphicsPipelineInfo(VkGraphicsPipelineCreateInfo &p RDCASSERT(ARRAY_COUNT(views) >= pipeInfo.viewports.size()); RDCASSERT(ARRAY_COUNT(scissors) >= pipeInfo.scissors.size()); + static VkPipelineViewportDepthClipControlCreateInfoEXT depthClipControl = { + VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_DEPTH_CLIP_CONTROL_CREATE_INFO_EXT, + }; + + if(m_pDriver->GetExtensions(GetRecord(m_Device)).ext_EXT_depth_clip_control) + { + depthClipControl.negativeOneToOne = pipeInfo.negativeOneToOne; + + depthClipControl.pNext = vp.pNext; + vp.pNext = &depthClipControl; + } + static VkPipelineRasterizationStateCreateInfo rs = { VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO, }; @@ -807,6 +822,8 @@ void VulkanShaderCache::MakeGraphicsPipelineInfo(VkGraphicsPipelineCreateInfo &p static VkPipelineDepthStencilStateCreateInfo ds = { VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO}; + ds.pNext = NULL; + ds.depthTestEnable = pipeInfo.depthTestEnable; ds.depthWriteEnable = pipeInfo.depthWriteEnable; ds.depthCompareOp = pipeInfo.depthCompareOp; @@ -820,6 +837,8 @@ void VulkanShaderCache::MakeGraphicsPipelineInfo(VkGraphicsPipelineCreateInfo &p static VkPipelineColorBlendStateCreateInfo cb = { VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO}; + cb.pNext = NULL; + cb.logicOpEnable = pipeInfo.logicOpEnable; cb.logicOp = pipeInfo.logicOp; memcpy(cb.blendConstants, pipeInfo.blendConst, sizeof(cb.blendConstants)); @@ -847,6 +866,8 @@ void VulkanShaderCache::MakeGraphicsPipelineInfo(VkGraphicsPipelineCreateInfo &p static VkPipelineDynamicStateCreateInfo dyn = {VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO}; + dyn.pNext = NULL; + dyn.dynamicStateCount = 0; dyn.pDynamicStates = dynSt; @@ -962,18 +983,6 @@ void VulkanShaderCache::MakeGraphicsPipelineInfo(VkGraphicsPipelineCreateInfo &p ret.pNext = &shadingRate; } - static VkPipelineViewportDepthClipControlCreateInfoEXT depthClipControl = { - VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_DEPTH_CLIP_CONTROL_CREATE_INFO_EXT, - }; - - if(m_pDriver->GetExtensions(GetRecord(m_Device)).ext_EXT_depth_clip_control) - { - depthClipControl.negativeOneToOne = pipeInfo.negativeOneToOne; - - depthClipControl.pNext = vp.pNext; - vp.pNext = &depthClipControl; - } - // never create derivatives ret.flags &= ~VK_PIPELINE_CREATE_DERIVATIVE_BIT;