diff --git a/renderdoc/driver/vulkan/vk_info.cpp b/renderdoc/driver/vulkan/vk_info.cpp index 81d7ef6e0d..5ee2682153 100644 --- a/renderdoc/driver/vulkan/vk_info.cpp +++ b/renderdoc/driver/vulkan/vk_info.cpp @@ -1695,6 +1695,9 @@ void VulkanCreationInfo::Pipeline::Init(VulkanResourceManager *resourceMan, { attachments[i].blendEnable = pCreateInfo->pColorBlendState->pAttachments[i].blendEnable ? true : false; + // Write is implicitly enabled, unless overriden by VkPipelineColorWriteCreateInfoEXT + // (below) or dynamic state. + attachments[i].writeEnable = true; attachments[i].blend.Source = pCreateInfo->pColorBlendState->pAttachments[i].srcColorBlendFactor; @@ -1734,8 +1737,7 @@ void VulkanCreationInfo::Pipeline::Init(VulkanResourceManager *resourceMan, RDCASSERTEQUAL(attachments.size(), colorWriteEnable->attachmentCount); for(size_t i = 0; i < attachments.size() && i < colorWriteEnable->attachmentCount; i++) { - if(!colorWriteEnable->pColorWriteEnables[i]) - attachments[i].channelWriteMask = 0; + attachments[i].writeEnable = colorWriteEnable->pColorWriteEnables[i] ? true : false; } } diff --git a/renderdoc/driver/vulkan/vk_info.h b/renderdoc/driver/vulkan/vk_info.h index dbbbed3fcf..ee06aaae86 100644 --- a/renderdoc/driver/vulkan/vk_info.h +++ b/renderdoc/driver/vulkan/vk_info.h @@ -447,6 +447,7 @@ struct VulkanCreationInfo struct CBAttachment { bool blendEnable; + bool writeEnable; struct BlendOp { diff --git a/renderdoc/driver/vulkan/vk_shader_cache.cpp b/renderdoc/driver/vulkan/vk_shader_cache.cpp index 2b4273495d..ec9bc284ac 100644 --- a/renderdoc/driver/vulkan/vk_shader_cache.cpp +++ b/renderdoc/driver/vulkan/vk_shader_cache.cpp @@ -962,6 +962,7 @@ void VulkanShaderCache::MakeGraphicsPipelineInfo(VkGraphicsPipelineCreateInfo &p cb.attachmentCount = (uint32_t)pipeInfo.attachments.size(); cb.pAttachments = atts; + bool anyWriteDisables = false; for(uint32_t i = 0; i < cb.attachmentCount; i++) { atts[i].blendEnable = pipeInfo.attachments[i].blendEnable; @@ -972,6 +973,25 @@ void VulkanShaderCache::MakeGraphicsPipelineInfo(VkGraphicsPipelineCreateInfo &p atts[i].colorBlendOp = pipeInfo.attachments[i].blend.Operation; atts[i].srcColorBlendFactor = pipeInfo.attachments[i].blend.Source; atts[i].dstColorBlendFactor = pipeInfo.attachments[i].blend.Destination; + + anyWriteDisables = anyWriteDisables || !pipeInfo.attachments[i].writeEnable; + } + + static VkPipelineColorWriteCreateInfoEXT cw = { + VK_STRUCTURE_TYPE_PIPELINE_COLOR_WRITE_CREATE_INFO_EXT}; + + static VkBool32 writeEnables[32] = {}; + cw.attachmentCount = cb.attachmentCount; + cw.pColorWriteEnables = writeEnables; + + if(anyWriteDisables) + { + for(uint32_t i = 0; i < cb.attachmentCount; i++) + { + writeEnables[i] = pipeInfo.attachments[i].writeEnable; + } + cw.pNext = rs.pNext; + rs.pNext = &cw; } RDCASSERT(ARRAY_COUNT(atts) >= pipeInfo.attachments.size()); diff --git a/renderdoc/driver/vulkan/wrappers/vk_cmd_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_cmd_funcs.cpp index a83bb55b91..e9448ba612 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_cmd_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_cmd_funcs.cpp @@ -3575,7 +3575,7 @@ bool WrappedVulkan::Serialise_vkCmdBindPipeline(SerialiserType &ser, VkCommandBu { renderstate.colorWriteEnable.resize(pipeInfo.attachments.size()); for(size_t i = 0; i < renderstate.colorWriteEnable.size(); i++) - renderstate.colorWriteEnable[i] = pipeInfo.attachments[i].channelWriteMask != 0; + renderstate.colorWriteEnable[i] = pipeInfo.attachments[i].writeEnable; } if(!pipeInfo.dynamicStates[VkDynamicDepthBiasEnable]) {