[PATCH v2 0/1] MR11688: wined3d: Fix some vulkan validation layer errors.
These are just small fixes to some of the Vulkan validation errors that appear when trying to run UE4 games. -- v2: https://gitlab.winehq.org/wine/wine/-/merge_requests/11688
From: Francisco Casas <fcasas@codeweavers.com> Otherwise we get Vulkan validation errors such as: VUID_Undefined(ERROR / SPEC): msgNum: 2044605652 - Validation Error: [ VUID_Undefined ] | MessageID = 0x79de34d4 | vkCmdSetColorBlendEnableEXT(): attachmentCount must be greater than 0. --- dlls/wined3d/context_vk.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/dlls/wined3d/context_vk.c b/dlls/wined3d/context_vk.c index 96d8c15ad7c..f70990eaac2 100644 --- a/dlls/wined3d/context_vk.c +++ b/dlls/wined3d/context_vk.c @@ -2694,8 +2694,11 @@ static void wined3d_context_vk_set_dynamic_blend_state(const struct wined3d_cont static const VkColorComponentFlags default_write_mask[WINED3D_MAX_RENDER_TARGETS] = {X, X, X, X, X, X, X, X}; #undef X - VK_CALL(vkCmdSetColorBlendEnableEXT(vk_command_buffer, 0, rt_count, default_enable)); - VK_CALL(vkCmdSetColorWriteMaskEXT(vk_command_buffer, 0, rt_count, default_write_mask)); + if (rt_count) + { + VK_CALL(vkCmdSetColorBlendEnableEXT(vk_command_buffer, 0, rt_count, default_enable)); + VK_CALL(vkCmdSetColorWriteMaskEXT(vk_command_buffer, 0, rt_count, default_write_mask)); + } return; } @@ -2713,9 +2716,12 @@ static void wined3d_context_vk_set_dynamic_blend_state(const struct wined3d_cont blend_equation_from_wined3d(context_vk, &equations[i], rt, state->fb.render_targets[i]); } - VK_CALL(vkCmdSetColorBlendEnableEXT(vk_command_buffer, 0, rt_count, enable)); - VK_CALL(vkCmdSetColorWriteMaskEXT(vk_command_buffer, 0, rt_count, write_mask)); - VK_CALL(vkCmdSetColorBlendEquationEXT(vk_command_buffer, 0, rt_count, equations)); + if (rt_count) + { + VK_CALL(vkCmdSetColorBlendEnableEXT(vk_command_buffer, 0, rt_count, enable)); + VK_CALL(vkCmdSetColorWriteMaskEXT(vk_command_buffer, 0, rt_count, write_mask)); + VK_CALL(vkCmdSetColorBlendEquationEXT(vk_command_buffer, 0, rt_count, equations)); + } } static VkFormat vk_format_from_component_type(enum wined3d_component_type component_type) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11688
I wouldn't fix the dynamic state validation errors this way, but any other validation errors seem useful to fix.
Got it. I removed 2/3 and 3/3 then. It makes sense to eventually fix these with the debug callback. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11688#note_149106
On Mon Aug 17 20:27:20 2026 +0000, Francisco Casas wrote:
I wouldn't fix the dynamic state validation errors this way, but any other validation errors seem useful to fix. Got it. I removed 2/3 and 3/3 then. It makes sense to eventually fix these with the debug callback. (hi Validation Layer lead here)
saw this on the linux dev discord So yes, this is invalid in the spec {width=695 height=70} But dynamic state has a been full of subtle things like this that we have changed in the pass Like for example, we [discussed before](https://gitlab.khronos.org/vulkan/vulkan/-/issues/4116) ``` vkCmdSetColorWriteEnableEXT(cb, 2, [true, true]); vkCmdSetColorWriteEnableEXT(cb, 1, [false]); ``` On some drivers will cause the `attachment[1]` to turn `false` due to some driver implementations But setting it with zero, **might** be different 1. I went ahead and created an issue in https://github.com/KhronosGroup/Vulkan-Docs/issues (we will go over it our next Wednesday group meeting) 2. There is a chance some driver will go "sorry, we will break if you pass zero" 3. There is a chance that we can write tests and agree that this is valid everywhere -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11688#note_149219
On Wed Aug 19 03:01:00 2026 +0000, Spencer Fricke wrote:
(hi Validation Layer lead here) saw this on the linux dev discord So yes, this is invalid in the spec {width=695 height=70} But dynamic state has a been full of subtle things like this that we have changed in the pass Like for example, we [discussed before](https://gitlab.khronos.org/vulkan/vulkan/-/issues/4116) ``` vkCmdSetColorWriteEnableEXT(cb, 2, [true, true]); vkCmdSetColorWriteEnableEXT(cb, 1, [false]); ``` On some drivers will cause the `attachment[1]` to turn `false` due to some driver implementations But setting it with zero, **might** be different 1. I went ahead and created an issue in https://github.com/KhronosGroup/Vulkan-Docs/issues (we will go over it our next Wednesday group meeting) 2. There is a chance some driver will go "sorry, we will break if you pass zero" 3. There is a chance that we can write tests and agree that this is valid everywhere (side note, please feel free to ping me around any Vulkan Spec/Validation questions, I don't follow the wine MR/Issues, but **VERY** happy to chime in if pinged)
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/11688#note_149220
On Wed Aug 19 03:01:47 2026 +0000, Spencer Fricke wrote:
(side note, please feel free to ping me around any Vulkan Spec/Validation questions, I don't follow the wine MR/Issues, but **VERY** happy to chime in if pinged) @spencer-lunarg I wasn't saying that one was invalid, rather the others which have now been removed from this merge request.
It's hard to be sure, without access to the repository anymore, but I believe [1] has or links to the discussion I was thinking of. [1] https://gitlab.khronos.org/Tracker/vk-gl-cts/-/issues/4675 -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11688#note_149249
On Wed Aug 19 14:30:01 2026 +0000, Elizabeth Figura wrote:
@spencer-lunarg I wasn't saying that one was invalid, rather the others which have now been removed from this merge request. It's hard to be sure, without access to the repository anymore, but I believe [1] has or links to the discussion I was thinking of. [1] https://gitlab.khronos.org/Tracker/vk-gl-cts/-/issues/4675 So we did just bring this up in the Working Group today and people agreed that we normally allow "zero"/"null" `vkCmd` calls. For example you can call `vkCmdDispatch(0)` and it is a no-op, so we feel this should be the same as well.
We will be writing CTS and if that comes back and everyone shows they support this, we will remove the validation check and then the original code here will
but it seems to me that what is or not a "spec bug" is more of a philosophical thing
rather the others which have now been removed from this merge request.
I started (another) effort last week to redo the dynamic state (in VVL and the spec) to have the concept of "dynamic", "static", and "ignored" which is more inline with your https://gitlab.khronos.org/Tracker/vk-gl-cts/-/issues/4675 which was around the question of "Do I need to set `vkCmdSet*` if the state is really ignored" while this MR is poking at 2 edge case dynamic state which is setting a "range of attachments", which means unlike others, you can have a "no-op" so you (and others) don't need these `if (count != 0)` wrapped everywhere. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11688#note_149278
I started (another) effort last week to redo the dynamic state (in VVL and the spec) to have the concept of "dynamic", "static", and "ignored" which is more inline with your https://gitlab.khronos.org/Tracker/vk-gl-cts/-/issues/4675 which was around the question of
"Do I need to set `vkCmdSet*` if the state is really ignored"
That's great; thank you for picking that up! -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11688#note_149284
This merge request was approved by Elizabeth Figura. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11688
participants (4)
-
Elizabeth Figura (@zfigura) -
Francisco Casas -
Francisco Casas (@fcasas) -
Spencer Fricke (@spencer-lunarg)