diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index d288ccc6451..a5b8c3b0515 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -507,6 +507,7 @@ static void shader_glsl_load_vsamplers(const struct wined3d_gl_info *gl_info, static inline void walk_constant_heap(const struct wined3d_gl_info *gl_info, const float *constants, const GLint *constant_locations, const struct constant_heap *heap, unsigned char *stack, DWORD version) { + unsigned int start = ~0U, end = 0; int stack_idx = 0; unsigned int heap_idx = 1; unsigned int idx; @@ -514,7 +515,8 @@ static inline void walk_constant_heap(const struct wined3d_gl_info *gl_info, con if (heap->entries[heap_idx].version <= version) return; idx = heap->entries[heap_idx].idx; - if (constant_locations[idx] != -1) GL_EXTCALL(glUniform4fvARB(constant_locations[idx], 1, &constants[idx * 4])); + if (constant_locations[idx] != -1) + start = end = idx; stack[stack_idx] = HEAP_NODE_TRAVERSE_LEFT; while (stack_idx >= 0) @@ -530,7 +532,12 @@ static inline void walk_constant_heap(const struct wined3d_gl_info *gl_info, con heap_idx = left_idx; idx = heap->entries[heap_idx].idx; if (constant_locations[idx] != -1) - GL_EXTCALL(glUniform4fvARB(constant_locations[idx], 1, &constants[idx * 4])); + { + if (start > idx) + start = idx; + if (end < idx) + end = idx; + } stack[stack_idx++] = HEAP_NODE_TRAVERSE_RIGHT; stack[stack_idx] = HEAP_NODE_TRAVERSE_LEFT; @@ -546,7 +553,12 @@ static inline void walk_constant_heap(const struct wined3d_gl_info *gl_info, con heap_idx = right_idx; idx = heap->entries[heap_idx].idx; if (constant_locations[idx] != -1) - GL_EXTCALL(glUniform4fvARB(constant_locations[idx], 1, &constants[idx * 4])); + { + if (start > idx) + start = idx; + if (end < idx) + end = idx; + } stack[stack_idx++] = HEAP_NODE_POP; stack[stack_idx] = HEAP_NODE_TRAVERSE_LEFT; @@ -560,6 +572,8 @@ static inline void walk_constant_heap(const struct wined3d_gl_info *gl_info, con break; } } + if (start <= end) + GL_EXTCALL(glUniform4fvARB(constant_locations[start], end - start + 1, &constants[start * 4])); checkGLcall("walk_constant_heap()"); }