[PATCH 0/2] MR10331: wined3d: Two Vulkan fixes.
From: Elizabeth Figura <zfigura@codeweavers.com> --- dlls/wined3d/adapter_vk.c | 1 + dlls/wined3d/context_vk.c | 20 ++++++++++++++++++++ dlls/wined3d/wined3d_vk.h | 3 ++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/dlls/wined3d/adapter_vk.c b/dlls/wined3d/adapter_vk.c index 131d197ce7a..55c7b167156 100644 --- a/dlls/wined3d/adapter_vk.c +++ b/dlls/wined3d/adapter_vk.c @@ -2383,6 +2383,7 @@ static void wined3d_adapter_vk_init_d3d_info(struct wined3d_adapter_vk *adapter_ && dynamic_state3->extendedDynamicState3ColorWriteMask; /* Rasterizer state needs EDS2, for rasterizer discard, and EDS1, for cull mode and front face. */ vk_info->dynamic_rasterizer_state = dynamic_state3->extendedDynamicState3DepthClampEnable + && dynamic_state3->extendedDynamicState3PolygonMode && vk_info->dynamic_state2 && adapter_vk->vk_info.supported[WINED3D_VK_EXT_EXTENDED_DYNAMIC_STATE]; } diff --git a/dlls/wined3d/context_vk.c b/dlls/wined3d/context_vk.c index 7fea48d83d2..119c498c78b 100644 --- a/dlls/wined3d/context_vk.c +++ b/dlls/wined3d/context_vk.c @@ -167,6 +167,22 @@ static VkColorComponentFlags vk_colour_write_mask_from_wined3d(uint32_t wined3d_ return vk_mask; } +static VkPolygonMode vk_polygon_mode_from_wined3d(enum wined3d_fill_mode mode) +{ + switch (mode) + { + case WINED3D_FILL_POINT: + return VK_POLYGON_MODE_POINT; + case WINED3D_FILL_SOLID: + return VK_POLYGON_MODE_FILL; + case WINED3D_FILL_WIREFRAME: + return VK_POLYGON_MODE_LINE; + default: + FIXME("Unhandled fill mode %#x.\n", mode); + return VK_POLYGON_MODE_FILL; + } +} + static VkCullModeFlags vk_cull_mode_from_wined3d(enum wined3d_cull mode) { switch (mode) @@ -2403,6 +2419,7 @@ static void wined3d_context_vk_init_graphics_pipeline_key(struct wined3d_context { dynamic_states[dynamic_state_count++] = VK_DYNAMIC_STATE_DEPTH_CLAMP_ENABLE_EXT; dynamic_states[dynamic_state_count++] = VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT; + dynamic_states[dynamic_state_count++] = VK_DYNAMIC_STATE_POLYGON_MODE_EXT; dynamic_states[dynamic_state_count++] = VK_DYNAMIC_STATE_CULL_MODE_EXT; dynamic_states[dynamic_state_count++] = VK_DYNAMIC_STATE_FRONT_FACE_EXT; dynamic_states[dynamic_state_count++] = VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT; @@ -2486,6 +2503,7 @@ static void rasterizer_state_from_wined3d(VkPipelineRasterizationStateCreateInfo { desc->depthClampEnable = VK_FALSE; desc->rasterizerDiscardEnable = is_rasterization_disabled(state->shader[WINED3D_SHADER_TYPE_GEOMETRY]); + desc->polygonMode = VK_POLYGON_MODE_FILL; desc->cullMode = VK_CULL_MODE_BACK_BIT; desc->frontFace = VK_FRONT_FACE_CLOCKWISE; desc->depthBiasEnable = VK_FALSE; @@ -2499,6 +2517,7 @@ static void rasterizer_state_from_wined3d(VkPipelineRasterizationStateCreateInfo r = &state->rasterizer_state->desc; desc->depthClampEnable = !r->depth_clip; desc->rasterizerDiscardEnable = is_rasterization_disabled(state->shader[WINED3D_SHADER_TYPE_GEOMETRY]); + desc->polygonMode = vk_polygon_mode_from_wined3d(r->fill_mode); desc->cullMode = vk_cull_mode_from_wined3d(r->cull_mode); desc->frontFace = r->front_ccw ? VK_FRONT_FACE_COUNTER_CLOCKWISE : VK_FRONT_FACE_CLOCKWISE; @@ -2547,6 +2566,7 @@ static void wined3d_context_vk_set_dynamic_rasterizer_state(const struct wined3d VK_CALL(vkCmdSetRasterizerDiscardEnableEXT(vk_command_buffer, desc.rasterizerDiscardEnable)); VK_CALL(vkCmdSetDepthClampEnableEXT(vk_command_buffer, desc.depthClampEnable)); + VK_CALL(vkCmdSetPolygonModeEXT(vk_command_buffer, desc.polygonMode)); VK_CALL(vkCmdSetCullModeEXT(vk_command_buffer, desc.cullMode)); VK_CALL(vkCmdSetFrontFaceEXT(vk_command_buffer, desc.frontFace)); VK_CALL(vkCmdSetDepthBiasEnableEXT(vk_command_buffer, desc.depthBiasEnable)); diff --git a/dlls/wined3d/wined3d_vk.h b/dlls/wined3d/wined3d_vk.h index aa5976bb730..937a958760c 100644 --- a/dlls/wined3d/wined3d_vk.h +++ b/dlls/wined3d/wined3d_vk.h @@ -200,6 +200,7 @@ struct wined3d_device_vk; VK_DEVICE_EXT_PFN(vkCmdSetDepthBiasEnableEXT) \ VK_DEVICE_EXT_PFN(vkCmdSetDepthClampEnableEXT) \ VK_DEVICE_EXT_PFN(vkCmdSetFrontFaceEXT) \ + VK_DEVICE_EXT_PFN(vkCmdSetPolygonModeEXT) \ VK_DEVICE_EXT_PFN(vkCmdSetRasterizationSamplesEXT) \ VK_DEVICE_EXT_PFN(vkCmdSetRasterizerDiscardEnableEXT) \ VK_DEVICE_EXT_PFN(vkCmdSetSampleMaskEXT) \ @@ -653,7 +654,7 @@ struct wined3d_context_vk const struct wined3d_vk_info *vk_info; - VkDynamicState dynamic_states[27]; + VkDynamicState dynamic_states[28]; uint32_t update_compute_pipeline : 1; uint32_t update_stream_output : 1; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10331
From: Elizabeth Figura <zfigura@codeweavers.com> --- dlls/wined3d/ffp_hlsl.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/dlls/wined3d/ffp_hlsl.c b/dlls/wined3d/ffp_hlsl.c index 7f834e72d10..aec03f47649 100644 --- a/dlls/wined3d/ffp_hlsl.c +++ b/dlls/wined3d/ffp_hlsl.c @@ -53,7 +53,12 @@ static void generate_lighting_footer(struct wined3d_string_buffer *buffer, shader_addline(buffer, " t = dot(normal, ffp_normalize(dir + float3(0.0, 0.0, -1.0)));\n"); if (settings->specular_enable) { - shader_addline(buffer, " if (dot(dir, normal) > 0.0 && t > 0.0"); + /* pow() of a negative number yields NaN. If the compiler decides to + * flatten this branch, it relies on multiplication to do so, which + * only works if 0 * NaN = 0. That breaks shaders anyway, but we don't + * yet have a way to avoid it, so don't make the problem any worse. + * Forcing branching saves the compiler some pointless work anyway. */ + shader_addline(buffer, " [branch] if (dot(dir, normal) > 0.0 && t > 0.0"); if (legacy_lighting) shader_addline(buffer, " && c.material.power > 0.0"); shader_addline(buffer, ")\n"); @@ -146,8 +151,9 @@ static void generate_lighting(struct wined3d_string_buffer *buffer, } shader_addline(buffer, " dir = ffp_normalize(dir);\n"); shader_addline(buffer, " t = dot(-dir, ffp_normalize(c.lights[%u].direction.xyz));\n", idx); - shader_addline(buffer, " if (t > cos_htheta) att = 1.0;\n"); - shader_addline(buffer, " else if (t <= cos_hphi) att = 0.0;\n"); + /* Force branching here. See the similar case in generate_lighting_footer(). */ + shader_addline(buffer, " [branch] if (t > cos_htheta) att = 1.0;\n"); + shader_addline(buffer, " else [branch] if (t <= cos_hphi) att = 0.0;\n"); shader_addline(buffer, " else att = pow((t - cos_hphi) / (cos_htheta - cos_hphi), falloff);\n"); if (legacy_lighting) shader_addline(buffer, " att *= dot(dst.xyz, c.lights[%u].attenuation.xyz);\n", idx); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10331
participants (2)
-
Elizabeth Figura -
Elizabeth Figura (@zfigura)