@@ -51,6 +51,14 @@ i915_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) | |||
struct draw_context *draw = i915->draw; | |||
void *mapped_indices = NULL; | |||
unsigned i; | |||
unsigned cbuf_dirty; | |||
/* | |||
* Ack vs contants here, helps ipers a lot. | |||
*/ | |||
cbuf_dirty = i915->dirty & I915_NEW_VS_CONSTANTS; | |||
i915->dirty &= ~I915_NEW_VS_CONSTANTS; | |||
if (i915->dirty) | |||
i915_update_derived(i915); | |||
@@ -70,10 +78,12 @@ i915_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) | |||
mapped_indices = i915_buffer(i915->index_buffer.buffer)->data; | |||
draw_set_mapped_index_buffer(draw, mapped_indices); | |||
draw_set_mapped_constant_buffer(draw, PIPE_SHADER_VERTEX, 0, | |||
i915->current.constants[PIPE_SHADER_VERTEX], | |||
(i915->current.num_user_constants[PIPE_SHADER_VERTEX] * | |||
4 * sizeof(float))); | |||
if (cbuf_dirty) { | |||
draw_set_mapped_constant_buffer(draw, PIPE_SHADER_VERTEX, 0, | |||
i915->current.constants[PIPE_SHADER_VERTEX], | |||
(i915->current.num_user_constants[PIPE_SHADER_VERTEX] * | |||
4 * sizeof(float))); | |||
} | |||
/* | |||
* Do the drawing |
@@ -257,9 +257,11 @@ struct i915_context { | |||
#define I915_NEW_DEPTH_STENCIL 0x200 | |||
#define I915_NEW_SAMPLER 0x400 | |||
#define I915_NEW_SAMPLER_VIEW 0x800 | |||
#define I915_NEW_CONSTANTS 0x1000 | |||
#define I915_NEW_VBO 0x2000 | |||
#define I915_NEW_VS 0x4000 | |||
#define I915_NEW_VS_CONSTANTS 0x1000 | |||
#define I915_NEW_FS_CONSTANTS 0x2000 | |||
#define I915_NEW_GS_CONSTANTS 0x4000 | |||
#define I915_NEW_VBO 0x8000 | |||
#define I915_NEW_VS 0x10000 | |||
/* Driver's internally generated state flags: |
@@ -948,7 +948,8 @@ i915_dump_dirty(struct i915_context *i915, const char *func) | |||
{I915_NEW_DEPTH_STENCIL, "depth_stencil"}, | |||
{I915_NEW_SAMPLER, "sampler"}, | |||
{I915_NEW_SAMPLER_VIEW, "sampler_view"}, | |||
{I915_NEW_CONSTANTS, "constants"}, | |||
{I915_NEW_VS_CONSTANTS, "vs_const"}, | |||
{I915_NEW_FS_CONSTANTS, "fs_const"}, | |||
{I915_NEW_VBO, "vbo"}, | |||
{I915_NEW_VS, "vs"}, | |||
{0, NULL}, |
@@ -527,6 +527,10 @@ static void i915_set_constant_buffer(struct pipe_context *pipe, | |||
struct i915_context *i915 = i915_context(pipe); | |||
draw_flush(i915->draw); | |||
/* XXX don't support geom shaders now */ | |||
if (shader == PIPE_SHADER_GEOMETRY) | |||
return; | |||
/* Make a copy of shader constants. | |||
* During fragment program translation we may add additional | |||
* constants to the array. | |||
@@ -538,6 +542,10 @@ static void i915_set_constant_buffer(struct pipe_context *pipe, | |||
*/ | |||
if (buf) { | |||
struct i915_buffer *ir = i915_buffer(buf); | |||
if (!memcmp(i915->current.constants[shader], ir->data, ir->b.b.width0)) | |||
return; | |||
memcpy(i915->current.constants[shader], ir->data, ir->b.b.width0); | |||
i915->current.num_user_constants[shader] = (ir->b.b.width0 / | |||
4 * sizeof(float)); | |||
@@ -546,8 +554,7 @@ static void i915_set_constant_buffer(struct pipe_context *pipe, | |||
i915->current.num_user_constants[shader] = 0; | |||
} | |||
i915->dirty |= I915_NEW_CONSTANTS; | |||
i915->dirty |= shader == PIPE_SHADER_VERTEX ? I915_NEW_VS_CONSTANTS : I915_NEW_FS_CONSTANTS; | |||
} | |||
@@ -40,7 +40,7 @@ static void update_hw_constants(struct i915_context *i915) | |||
struct i915_tracked_state i915_hw_constants = { | |||
"hw_constants", | |||
update_hw_constants, | |||
I915_NEW_CONSTANTS | I915_NEW_FS | |||
I915_NEW_FS_CONSTANTS | I915_NEW_FS | |||
}; | |||