mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-03 18:38:11 +02:00
r300g: atomize VS constant buffer
This commit is contained in:
parent
abc2f29dd2
commit
3da70606b3
7 changed files with 30 additions and 25 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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. */
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue