From c09774e2254f98188a491c33ddbb7b6ce9d0b920 Mon Sep 17 00:00:00 2001 From: Shahbaz Youssefi Date: Fri, 6 Nov 2026 15:55:15 -0500 Subject: [PATCH] Fix color mask display when color write enable is static When the color write enable state (from VK_EXT_color_write_enable) is not dynamic (i.e the extension is not used), VulkanRenderState::colorWriteEnable was initialized from pipeline's color mask info. However, this information should be ignored if color write mask is dynamic (with shader object / EDS3). Instead, if color write enable state is not dynamic, it can be implicitly considered to be true if VkPipelineColorWriteCreateInfoEXT is not provided, or otherwise it's taken from that. This change fixes the UI (and HTML export) where the color mask was output as `____` in such situations regardless of what mask was dynamically set. --- renderdoc/driver/vulkan/vk_info.cpp | 6 ++++-- renderdoc/driver/vulkan/vk_info.h | 1 + renderdoc/driver/vulkan/vk_shader_cache.cpp | 20 +++++++++++++++++++ .../driver/vulkan/wrappers/vk_cmd_funcs.cpp | 2 +- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/renderdoc/driver/vulkan/vk_info.cpp b/renderdoc/driver/vulkan/vk_info.cpp index 81d7ef6e0d5..5ee2682153c 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 dbbbed3fcfd..ee06aaae866 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 2b4273495dd..ec9bc284ac1 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 a83bb55b91c..e9448ba6128 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]) {