diff options
author | Marek Olšák <[email protected]> | 2012-09-10 00:56:45 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2012-09-13 20:18:44 +0200 |
commit | 1bce17ee01fb2ad77e37a600c2cacda57d0067ef (patch) | |
tree | 9fd51779ab7d541bd948698ed9c781f5dd148281 | |
parent | 3bffd8a5eb30d993c7f56a12b9936e17fb4523de (diff) |
r600g: put constant buffer state into an array indexed by shader type
to easily and robustly handle multiple shader stages
Reviewed-by: Jerome Glisse <[email protected]>
-rw-r--r-- | src/gallium/drivers/r600/evergreen_state.c | 8 | ||||
-rw-r--r-- | src/gallium/drivers/r600/r600_buffer.c | 31 | ||||
-rw-r--r-- | src/gallium/drivers/r600/r600_hw_context.c | 10 | ||||
-rw-r--r-- | src/gallium/drivers/r600/r600_pipe.h | 3 | ||||
-rw-r--r-- | src/gallium/drivers/r600/r600_state.c | 8 | ||||
-rw-r--r-- | src/gallium/drivers/r600/r600_state_common.c | 13 |
6 files changed, 33 insertions, 40 deletions
diff --git a/src/gallium/drivers/r600/evergreen_state.c b/src/gallium/drivers/r600/evergreen_state.c index 4d88e83c5e4..baeedaeeed7 100644 --- a/src/gallium/drivers/r600/evergreen_state.c +++ b/src/gallium/drivers/r600/evergreen_state.c @@ -2057,14 +2057,14 @@ static void evergreen_emit_constant_buffers(struct r600_context *rctx, static void evergreen_emit_vs_constant_buffers(struct r600_context *rctx, struct r600_atom *atom) { - evergreen_emit_constant_buffers(rctx, &rctx->vs_constbuf_state, 176, + evergreen_emit_constant_buffers(rctx, &rctx->constbuf_state[PIPE_SHADER_VERTEX], 176, R_028180_ALU_CONST_BUFFER_SIZE_VS_0, R_028980_ALU_CONST_CACHE_VS_0); } static void evergreen_emit_ps_constant_buffers(struct r600_context *rctx, struct r600_atom *atom) { - evergreen_emit_constant_buffers(rctx, &rctx->ps_constbuf_state, 0, + evergreen_emit_constant_buffers(rctx, &rctx->constbuf_state[PIPE_SHADER_FRAGMENT], 0, R_028140_ALU_CONST_BUFFER_SIZE_PS_0, R_028940_ALU_CONST_CACHE_PS_0); } @@ -2179,8 +2179,8 @@ void evergreen_init_state_functions(struct r600_context *rctx) */ /* shader const */ - r600_init_atom(rctx, &rctx->vs_constbuf_state.atom, id++, evergreen_emit_vs_constant_buffers, 0); - r600_init_atom(rctx, &rctx->ps_constbuf_state.atom, id++, evergreen_emit_ps_constant_buffers, 0); + r600_init_atom(rctx, &rctx->constbuf_state[PIPE_SHADER_VERTEX].atom, id++, evergreen_emit_vs_constant_buffers, 0); + r600_init_atom(rctx, &rctx->constbuf_state[PIPE_SHADER_FRAGMENT].atom, id++, evergreen_emit_ps_constant_buffers, 0); /* shader program */ r600_init_atom(rctx, &rctx->cs_shader_state.atom, id++, evergreen_emit_cs_shader, 0); /* sampler */ diff --git a/src/gallium/drivers/r600/r600_buffer.c b/src/gallium/drivers/r600/r600_buffer.c index 88d67dfaf49..0b0ac3460e1 100644 --- a/src/gallium/drivers/r600/r600_buffer.c +++ b/src/gallium/drivers/r600/r600_buffer.c @@ -65,21 +65,25 @@ static struct pipe_transfer *r600_get_transfer(struct pipe_context *ctx, } static void r600_set_constants_dirty_if_bound(struct r600_context *rctx, - struct r600_constbuf_state *state, struct r600_resource *rbuffer) { - bool found = false; - uint32_t mask = state->enabled_mask; - - while (mask) { - unsigned i = u_bit_scan(&mask); - if (state->cb[i].buffer == &rbuffer->b.b) { - found = true; - state->dirty_mask |= 1 << i; + unsigned shader; + + for (shader = 0; shader < PIPE_SHADER_TYPES; shader++) { + struct r600_constbuf_state *state = &rctx->constbuf_state[shader]; + bool found = false; + uint32_t mask = state->enabled_mask; + + while (mask) { + unsigned i = u_bit_scan(&mask); + if (state->cb[i].buffer == &rbuffer->b.b) { + found = true; + state->dirty_mask |= 1 << i; + } + } + if (found) { + r600_constant_buffers_dirty(rctx, state); } - } - if (found) { - r600_constant_buffers_dirty(rctx, state); } } @@ -126,8 +130,7 @@ static void *r600_buffer_transfer_map(struct pipe_context *pipe, } } /* Constant buffers. */ - r600_set_constants_dirty_if_bound(rctx, &rctx->vs_constbuf_state, rbuffer); - r600_set_constants_dirty_if_bound(rctx, &rctx->ps_constbuf_state, rbuffer); + r600_set_constants_dirty_if_bound(rctx, rbuffer); } } #if 0 /* this is broken (see Bug 53130) */ diff --git a/src/gallium/drivers/r600/r600_hw_context.c b/src/gallium/drivers/r600/r600_hw_context.c index d40f6b60933..1db5f0d645c 100644 --- a/src/gallium/drivers/r600/r600_hw_context.c +++ b/src/gallium/drivers/r600/r600_hw_context.c @@ -989,6 +989,7 @@ void r600_context_flush(struct r600_context *ctx, unsigned flags) bool timer_queries_suspended = false; bool nontimer_queries_suspended = false; bool streamout_suspended = false; + unsigned shader; if (cs->cdw == ctx->start_cs_cmd.atom.num_dw) return; @@ -1053,10 +1054,11 @@ void r600_context_flush(struct r600_context *ctx, unsigned flags) ctx->vertex_buffer_state.dirty_mask = ctx->vertex_buffer_state.enabled_mask; r600_vertex_buffers_dirty(ctx); - ctx->vs_constbuf_state.dirty_mask = ctx->vs_constbuf_state.enabled_mask; - ctx->ps_constbuf_state.dirty_mask = ctx->ps_constbuf_state.enabled_mask; - r600_constant_buffers_dirty(ctx, &ctx->vs_constbuf_state); - r600_constant_buffers_dirty(ctx, &ctx->ps_constbuf_state); + for (shader = 0; shader < PIPE_SHADER_TYPES; shader++) { + struct r600_constbuf_state *state = &ctx->constbuf_state[shader]; + state->dirty_mask = state->enabled_mask; + r600_constant_buffers_dirty(ctx, state); + } ctx->vs_samplers.views.dirty_mask = ctx->vs_samplers.views.enabled_mask; ctx->ps_samplers.views.dirty_mask = ctx->ps_samplers.views.enabled_mask; diff --git a/src/gallium/drivers/r600/r600_pipe.h b/src/gallium/drivers/r600/r600_pipe.h index 8fb0972bfd0..57861358b35 100644 --- a/src/gallium/drivers/r600/r600_pipe.h +++ b/src/gallium/drivers/r600/r600_pipe.h @@ -372,8 +372,7 @@ struct r600_context { struct r600_vertexbuf_state vertex_buffer_state; /** Vertex buffers for compute shaders */ struct r600_vertexbuf_state cs_vertex_buffer_state; - struct r600_constbuf_state vs_constbuf_state; - struct r600_constbuf_state ps_constbuf_state; + struct r600_constbuf_state constbuf_state[PIPE_SHADER_TYPES]; struct r600_textures_info vs_samplers; struct r600_textures_info ps_samplers; struct r600_seamless_cube_map seamless_cube_map; diff --git a/src/gallium/drivers/r600/r600_state.c b/src/gallium/drivers/r600/r600_state.c index aca5e3cb8e5..9a9d8276102 100644 --- a/src/gallium/drivers/r600/r600_state.c +++ b/src/gallium/drivers/r600/r600_state.c @@ -1909,14 +1909,14 @@ static void r600_emit_constant_buffers(struct r600_context *rctx, static void r600_emit_vs_constant_buffers(struct r600_context *rctx, struct r600_atom *atom) { - r600_emit_constant_buffers(rctx, &rctx->vs_constbuf_state, 160, + r600_emit_constant_buffers(rctx, &rctx->constbuf_state[PIPE_SHADER_VERTEX], 160, R_028180_ALU_CONST_BUFFER_SIZE_VS_0, R_028980_ALU_CONST_CACHE_VS_0); } static void r600_emit_ps_constant_buffers(struct r600_context *rctx, struct r600_atom *atom) { - r600_emit_constant_buffers(rctx, &rctx->ps_constbuf_state, 0, + r600_emit_constant_buffers(rctx, &rctx->constbuf_state[PIPE_SHADER_FRAGMENT], 0, R_028140_ALU_CONST_BUFFER_SIZE_PS_0, R_028940_ALU_CONST_CACHE_PS_0); } @@ -2054,8 +2054,8 @@ void r600_init_state_functions(struct r600_context *rctx) */ /* shader const */ - r600_init_atom(rctx, &rctx->vs_constbuf_state.atom, id++, r600_emit_vs_constant_buffers, 0); - r600_init_atom(rctx, &rctx->ps_constbuf_state.atom, id++, r600_emit_ps_constant_buffers, 0); + r600_init_atom(rctx, &rctx->constbuf_state[PIPE_SHADER_VERTEX].atom, id++, r600_emit_vs_constant_buffers, 0); + r600_init_atom(rctx, &rctx->constbuf_state[PIPE_SHADER_FRAGMENT].atom, id++, r600_emit_ps_constant_buffers, 0); /* sampler must be emited before TA_CNTL_AUX otherwise DISABLE_CUBE_WRAP change * does not take effect (TA_CNTL_AUX emited by r600_emit_seamless_cube_map) diff --git a/src/gallium/drivers/r600/r600_state_common.c b/src/gallium/drivers/r600/r600_state_common.c index 4df3c78e163..28972274b0c 100644 --- a/src/gallium/drivers/r600/r600_state_common.c +++ b/src/gallium/drivers/r600/r600_state_common.c @@ -864,21 +864,10 @@ static void r600_set_constant_buffer(struct pipe_context *ctx, uint shader, uint struct pipe_constant_buffer *input) { struct r600_context *rctx = (struct r600_context *)ctx; - struct r600_constbuf_state *state; + struct r600_constbuf_state *state = &rctx->constbuf_state[shader]; struct pipe_constant_buffer *cb; const uint8_t *ptr; - switch (shader) { - case PIPE_SHADER_VERTEX: - state = &rctx->vs_constbuf_state; - break; - case PIPE_SHADER_FRAGMENT: - state = &rctx->ps_constbuf_state; - break; - default: - return; - } - /* Note that the state tracker can unbind constant buffers by * passing NULL here. */ |