diff options
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/drivers/r300/r300_context.c | 3 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_context.h | 4 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_defines.h | 1 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_emit.c | 24 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_emit.h | 4 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_flush.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_state.c | 17 |
7 files changed, 30 insertions, 25 deletions
diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index bdc1ebedcc..9a235baf7d 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -67,6 +67,7 @@ static void r300_destroy_context(struct pipe_context* context) FREE(r300->viewport_state.state); FREE(r300->ztop_state.state); FREE(r300->fs_constants.state); + FREE(r300->vs_constants.state); FREE(r300); } @@ -114,6 +115,7 @@ static void r300_setup_atoms(struct r300_context* r300) R300_INIT_ATOM(vap_output_state, 6); R300_INIT_ATOM(pvs_flush, 2); R300_INIT_ATOM(vs_state, 0); + R300_INIT_ATOM(vs_constants, 0); R300_INIT_ATOM(texture_cache_inval, 2); R300_INIT_ATOM(textures_state, 0); R300_INIT_ATOM(fs, 0); @@ -138,6 +140,7 @@ static void r300_setup_atoms(struct r300_context* r300) r300->viewport_state.state = CALLOC_STRUCT(r300_viewport_state); r300->ztop_state.state = CALLOC_STRUCT(r300_ztop_state); r300->fs_constants.state = CALLOC_STRUCT(r300_constant_buffer); + r300->vs_constants.state = CALLOC_STRUCT(r300_constant_buffer); } struct pipe_context* r300_create_context(struct pipe_screen* screen, diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 6ab10c874d..2655e7e0e1 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -362,8 +362,6 @@ struct r300_context { struct r300_atom blend_color_state; /* User clip planes. */ struct r300_atom clip_state; - /* Shader constants. */ - struct r300_constant_buffer shader_constants[PIPE_SHADER_TYPES]; /* Depth, stencil, and alpha state. */ struct r300_atom dsa_state; /* Fragment shader. */ @@ -388,6 +386,8 @@ struct r300_context { struct r300_atom vap_output_state; /* Vertex shader. */ struct r300_atom vs_state; + /* Vertex shader constant buffer. */ + struct r300_atom vs_constants; /* Viewport state. */ struct r300_atom viewport_state; /* ZTOP state. */ diff --git a/src/gallium/drivers/r300/r300_defines.h b/src/gallium/drivers/r300/r300_defines.h index da85137625..0c3b970501 100644 --- a/src/gallium/drivers/r300/r300_defines.h +++ b/src/gallium/drivers/r300/r300_defines.h @@ -31,7 +31,6 @@ #define R300_RESOURCE_FLAG_TRANSFER PIPE_RESOURCE_FLAG_DRV_PRIV /* Non-atom dirty state flags. */ -#define R300_NEW_VERTEX_SHADER_CONSTANTS 0x10000000 #define R300_NEW_QUERY 0x40000000 #define R300_NEW_KITCHEN_SINK 0x7fffffff diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index b337cd9603..afb47ead9c 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -1025,21 +1025,25 @@ void r300_emit_vs_state(struct r300_context* r300, unsigned size, void* state) END_CS; } -void r300_emit_vs_constant_buffer(struct r300_context* r300, - struct rc_constant_list* constants) +void r300_emit_vs_constants(struct r300_context* r300, + unsigned size, void *state) { unsigned i; - unsigned count = ((struct r300_vertex_shader*)r300->vs_state.state)->externals_count; + unsigned count = + ((struct r300_vertex_shader*)r300->vs_state.state)->externals_count; + struct r300_constant_buffer *buf = (struct r300_constant_buffer*)state; CS_LOCALS(r300); - BEGIN_CS(count * 4 + 3); + if (!count) + return; + + BEGIN_CS(size); OUT_CS_REG(R300_VAP_PVS_VECTOR_INDX_REG, (r300->screen->caps.is_r500 ? R500_PVS_CONST_START : R300_PVS_CONST_START)); OUT_CS_ONE_REG(R300_VAP_PVS_UPLOAD_DATA, count * 4); for (i = 0; i < count; i++) { - const float *data = - r300->shader_constants[PIPE_SHADER_VERTEX].constants[i]; + const float *data = buf->constants[i]; OUT_CS_32F(data[0]); OUT_CS_32F(data[1]); OUT_CS_32F(data[2]); @@ -1227,14 +1231,6 @@ void r300_emit_dirty_state(struct r300_context* r300) } } - if (r300->dirty_state & R300_NEW_VERTEX_SHADER_CONSTANTS) { - struct r300_vertex_shader* vs = r300->vs_state.state; - if (vs->code.constants.Count) { - r300_emit_vs_constant_buffer(r300, &vs->code.constants); - } - r300->dirty_state &= ~R300_NEW_VERTEX_SHADER_CONSTANTS; - } - /* Emit the VBO for SWTCL. */ if (!r300screen->caps.has_tcl) { r300_emit_vertex_buffer(r300); diff --git a/src/gallium/drivers/r300/r300_emit.h b/src/gallium/drivers/r300/r300_emit.h index d275bb211a..678e182212 100644 --- a/src/gallium/drivers/r300/r300_emit.h +++ b/src/gallium/drivers/r300/r300_emit.h @@ -84,8 +84,8 @@ void r300_emit_vertex_stream_state(struct r300_context* r300, void r300_emit_vap_output_state(struct r300_context* r300, unsigned size, void* state); -void r300_emit_vs_constant_buffer(struct r300_context* r300, - struct rc_constant_list* constants); +void r300_emit_vs_constants(struct r300_context* r300, + unsigned size, void *state); void r300_emit_vs_state(struct r300_context* r300, unsigned size, void* state); diff --git a/src/gallium/drivers/r300/r300_flush.c b/src/gallium/drivers/r300/r300_flush.c index 0aa2e35735..0d8158e199 100644 --- a/src/gallium/drivers/r300/r300_flush.c +++ b/src/gallium/drivers/r300/r300_flush.c @@ -65,7 +65,7 @@ static void r300_flush(struct pipe_context* pipe, /* Unmark HWTCL state for SWTCL. */ if (!r300->screen->caps.has_tcl) { r300->vs_state.dirty = FALSE; - r300->dirty_state &= ~R300_NEW_VERTEX_SHADER_CONSTANTS; + r300->vs_constants.dirty = FALSE; } } diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index a732ef3a10..a10953c04a 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -1383,9 +1383,14 @@ static void r300_bind_vs_state(struct pipe_context* pipe, void* shader) vs->code.length + 9 + (vs->immediates_count ? vs->immediates_count * 4 + 3 : 0); - r300->pvs_flush.dirty = TRUE; + if (vs->externals_count) { + r300->vs_constants.dirty = TRUE; + r300->vs_constants.size = vs->externals_count * 4 + 3; + } else { + r300->vs_constants.size = 0; + } - r300->dirty_state |= R300_NEW_VERTEX_SHADER_CONSTANTS; + r300->pvs_flush.dirty = TRUE; } else { draw_flush(r300->draw); draw_bind_vertex_shader(r300->draw, @@ -1421,7 +1426,7 @@ static void r300_set_constant_buffer(struct pipe_context *pipe, switch (shader) { case PIPE_SHADER_VERTEX: - cbuf = &r300->shader_constants[PIPE_SHADER_VERTEX]; + cbuf = (struct r300_constant_buffer*)r300->vs_constants.state; max_size = 256; break; case PIPE_SHADER_FRAGMENT: @@ -1434,7 +1439,7 @@ static void r300_set_constant_buffer(struct pipe_context *pipe, break; default: assert(0); - cbuf = NULL; + return; } if (buf == NULL || buf->width0 == 0 || @@ -1460,7 +1465,9 @@ static void r300_set_constant_buffer(struct pipe_context *pipe, if (shader == PIPE_SHADER_VERTEX) { if (r300->screen->caps.has_tcl) { - r300->dirty_state |= R300_NEW_VERTEX_SHADER_CONSTANTS; + if (r300->vs_constants.size) { + r300->vs_constants.dirty = TRUE; + } r300->pvs_flush.dirty = TRUE; } else if (r300->draw) { draw_set_mapped_constant_buffer(r300->draw, PIPE_SHADER_VERTEX, |