wined3d: Just update a range of constants in walk_constant_heap().

The call overhead from separate calls typically ends up being more expensive
than just updating a few more constants.
This commit is contained in:
Henri Verbeet 2013-08-16 09:12:31 +02:00 committed by Alexandre Julliard
parent 37d1e8b79c
commit ad147d638c
1 changed files with 17 additions and 3 deletions

View File

@ -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()");
}