[PATCH 0/3] 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. -- 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
From: Francisco Casas <fcasas@codeweavers.com> Since the pipeline is created with VK_DYNAMIC_STATE_STENCIL_OP, this function needs to be called before submitting drawing commands. Otherwise we get the following Vulkan validation error: VUID-vkCmdDrawIndexed-None-07848(ERROR / SPEC): msgNum: -2099106103 - Validation Error: [ VUID-vkCmdDrawIndexed-None-07848 ] [...] vkCmdDrawIndexed(): VK_DYNAMIC_STATE_STENCIL_OP state not set for this command buffer. The Vulkan spec states: If the bound graphics pipeline state was created with the VK_DYNAMIC_STATE_STENCIL_OP dynamic state enabled then vkCmdSetStencilOp must have been called in the current command buffer prior to this drawing command [...]. --- dlls/wined3d/context_vk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/wined3d/context_vk.c b/dlls/wined3d/context_vk.c index f70990eaac2..629b3c3e974 100644 --- a/dlls/wined3d/context_vk.c +++ b/dlls/wined3d/context_vk.c @@ -4304,7 +4304,7 @@ VkCommandBuffer wined3d_context_vk_apply_draw_state(struct wined3d_context_vk *c VK_CALL(vkCmdSetDepthWriteEnableEXT(vk_command_buffer, d->desc.depth_write)); VK_CALL(vkCmdSetDepthCompareOpEXT(vk_command_buffer, vk_compare_op_from_wined3d(d->desc.depth_func))); VK_CALL(vkCmdSetStencilTestEnableEXT(vk_command_buffer, stencil_enable)); - if (stencil_enable) + if (state->fb.depth_stencil) { VK_CALL(vkCmdSetStencilOpEXT(vk_command_buffer, VK_STENCIL_FACE_FRONT_BIT, vk_stencil_op_from_wined3d(d->desc.front.fail_op), -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11688
From: Francisco Casas <fcasas@codeweavers.com> This command must always be submitted (with patchControlPoints >= 0) before drawing commands when the graphics pipeline is created with VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT. Otherwise we get the following Vulkan validation layer error: VUID-vkCmdDrawIndexed-None-04875(ERROR / SPEC): msgNum: -2003020972 - Validation Error: [ VUID-vkCmdDrawIndexed-None-04875 ] [...] | vkCmdDrawIndexed(): VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT state not set for this command buffer. The Vulkan spec states: If there is a shader object bound to the VK_SHADER_STAGE_VERTEX_BIT stage and the most recent call to vkCmdSetPrimitiveTopology in the current command buffer set primitiveTopology to VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, or the bound graphics pipeline state was created with the VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT dynamic state enabled then vkCmdSetPatchControlPointsEXT must have been called in the current command buffer prior to this drawing command [...] --- dlls/wined3d/context_vk.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dlls/wined3d/context_vk.c b/dlls/wined3d/context_vk.c index 629b3c3e974..689908afda3 100644 --- a/dlls/wined3d/context_vk.c +++ b/dlls/wined3d/context_vk.c @@ -4266,8 +4266,7 @@ VkCommandBuffer wined3d_context_vk_apply_draw_state(struct wined3d_context_vk *c if (vk_info->dynamic_patch_vertex_count && context_vk->c.update_patch_vertex_count) { - if (state->patch_vertex_count) - VK_CALL(vkCmdSetPatchControlPointsEXT(vk_command_buffer, state->patch_vertex_count)); + VK_CALL(vkCmdSetPatchControlPointsEXT(vk_command_buffer, max(state->patch_vertex_count, 1))); context_vk->c.update_patch_vertex_count = 0; } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11688
1/3 is probably fine, but 2/3 and 3/3 are either validation layer bugs or spec bugs. I was intending to fix them upstream at some point years ago, but I don't currently have access to Khronos' internal repositories. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11688#note_149072
On Mon Aug 17 19:15:11 2026 +0000, Elizabeth Figura wrote:
1/3 is probably fine, but 2/3 and 3/3 are either validation layer bugs or spec bugs. I was intending to fix them upstream at some point years ago, but I don't currently have access to Khronos' internal repositories. I checked the Vulkan documentation and these validation errors match the documented "Valid usage", so I would say that they are spec bugs, but it seems to me that what is or not a "spec bug" is more of a philosophical thing.
The concrete upside of these patches is that we clean the logs a bit, so the validation errors that matter are more evident. But I accept your judgement, shall I remove 2/3 and 3/3 from the MR then? Also, there are many other validation errors of this nature that I intended to address later. Should I stop working on this direction? -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11688#note_149094
I checked the Vulkan documentation and these validation errors match the documented "Valid usage", so I would say that they are spec bugs, but it seems to me that what is or not a "spec bug" is more of a philosophical thing.
I had brought it up as a question in the internal Khronos repository, and the consensus was that it was a spec bug. I don't have access to that anymore, though.
The concrete upside of these patches is that we clean the logs a bit, so the validation errors that matter are more evident. But I accept your judgement, shall I remove 2/3 and 3/3 from the MR then?
I'm tempted to take them anyway, but these are only two cases of the same dynamic state problem; there are a lot more. Plus increasing the number of Vulkan calls probably isn't great. It may be better to just supply a debug callback that manually suppresses them. I actually have a patch like that that I can find and send.
Also, there are many other validation errors of this nature that I intended to address later. Should I stop working on this direction?
I wouldn't fix the dynamic state validation errors this way, but any other validation errors seem useful to fix. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11688#note_149100
participants (3)
-
Elizabeth Figura (@zfigura) -
Francisco Casas -
Francisco Casas (@fcasas)