[PATCH v3] wined3d: Do not bind buffers in state_cb() if the shader is not set.

Conor McCarthy cmccarthy at codeweavers.com
Wed Dec 15 08:16:25 CST 2021


Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52020
Signed-off-by: Conor McCarthy <cmccarthy at codeweavers.com>
---
v3: Set the constant buffer dirty flag when shaders change from null to non-null.
---
 dlls/wined3d/cs.c    | 3 +++
 dlls/wined3d/state.c | 4 ++++
 2 files changed, 7 insertions(+)

diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
index bb629d9b2..009ad561b 100644
--- a/dlls/wined3d/cs.c
+++ b/dlls/wined3d/cs.c
@@ -1768,6 +1768,9 @@ static void wined3d_cs_exec_set_shader(struct wined3d_cs *cs, const void *data)
 {
     const struct wined3d_cs_set_shader *op = data;
 
+    /* CB binding may have been skipped earlier if the shader wasn't set, so make it happen. */
+    if (!cs->state.shader[op->type] && op->shader)
+        device_invalidate_state(cs->c.device, STATE_CONSTANT_BUFFER(op->type));
     cs->state.shader[op->type] = op->shader;
     device_invalidate_state(cs->c.device, STATE_SHADER(op->type));
     if (op->type != WINED3D_SHADER_TYPE_COMPUTE)
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index 865c60d18..208014e20 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -4579,6 +4579,10 @@ static void state_cb(struct wined3d_context *context, const struct wined3d_state
     else
         shader_type = WINED3D_SHADER_TYPE_COMPUTE;
 
+    /* If a shader has not been set, buffer objects are not yet initialised. */
+    if (!state->shader[shader_type])
+        return;
+
     wined3d_gl_limits_get_uniform_block_range(&gl_info->limits, shader_type, &base, &count);
     for (i = 0; i < count; ++i)
     {
-- 
2.33.0




More information about the wine-devel mailing list