diff options
author | Christian König <[email protected]> | 2011-01-21 21:51:24 +0100 |
---|---|---|
committer | Christian König <[email protected]> | 2011-01-21 21:51:24 +0100 |
commit | 86e5b79a274ad4ed5c169aa5626106331273311c (patch) | |
tree | 31bc98df0e79c453c5ff143ac8e6ddaa846799c1 /src/gallium/drivers/i915/i915_state.c | |
parent | 78faf8d0e9c276a0ff1465e501d58fb3d66de2f7 (diff) | |
parent | 8af583f6e844ef2d173eb3c5c2e378cd1da018a8 (diff) |
Merge remote branch 'origin/master' into pipe-video
Conflicts:
src/gallium/drivers/r600/r600_texture.c
Diffstat (limited to 'src/gallium/drivers/i915/i915_state.c')
-rw-r--r-- | src/gallium/drivers/i915/i915_state.c | 45 |
1 files changed, 28 insertions, 17 deletions
diff --git a/src/gallium/drivers/i915/i915_state.c b/src/gallium/drivers/i915/i915_state.c index f5b60ed5942..4a1a4a04f6d 100644 --- a/src/gallium/drivers/i915/i915_state.c +++ b/src/gallium/drivers/i915/i915_state.c @@ -525,29 +525,40 @@ static void i915_set_constant_buffer(struct pipe_context *pipe, struct pipe_resource *buf) { struct i915_context *i915 = i915_context(pipe); - draw_flush(i915->draw); + unsigned new_num = 0; + boolean diff = TRUE; - /* Make a copy of shader constants. - * During fragment program translation we may add additional - * constants to the array. - * - * We want to consider the situation where some user constants - * (ex: a material color) may change frequently but the shader program - * stays the same. In that case we should only be updating the first - * N constants, leaving any extras from shader translation alone. - */ + + /* XXX don't support geom shaders now */ + if (shader == PIPE_SHADER_GEOMETRY) + return; + + /* if we have a new buffer compare it with the old one */ if (buf) { struct i915_buffer *ir = i915_buffer(buf); - memcpy(i915->current.constants[shader], ir->data, ir->b.b.width0); - i915->current.num_user_constants[shader] = (ir->b.b.width0 / - 4 * sizeof(float)); - } - else { - i915->current.num_user_constants[shader] = 0; + struct pipe_resource *old_buf = i915->constants[shader]; + struct i915_buffer *old = old_buf ? i915_buffer(old_buf) : NULL; + + new_num = ir->b.b.width0 / 4 * sizeof(float); + + if (old && new_num != i915->current.num_user_constants[shader]) + diff = memcmp(old->data, ir->data, ir->b.b.width0); + } else { + diff = i915->current.num_user_constants[shader] != 0; } + /* + * flush before updateing the state. + * XXX: looks like its okay to skip the flush for vertex cbufs + */ + if (diff && shader == PIPE_SHADER_FRAGMENT) + draw_flush(i915->draw); + + pipe_resource_reference(&i915->constants[shader], buf); + i915->current.num_user_constants[shader] = new_num; - i915->dirty |= I915_NEW_CONSTANTS; + if (diff) + i915->dirty |= shader == PIPE_SHADER_VERTEX ? I915_NEW_VS_CONSTANTS : I915_NEW_FS_CONSTANTS; } |