diff options
author | Marek Olšák <[email protected]> | 2012-09-10 04:53:33 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2012-09-13 20:18:44 +0200 |
commit | f2eac1423a92ba47981ba50a4af22e6596059cf4 (patch) | |
tree | eb7a76c7832f835284fb1122a85349dbcffb7c93 | |
parent | 3fe78594b1221358f4ba96072d952e33a7e54a76 (diff) |
r600g: put sampler states and views into an array indexed by shader type
Reviewed-by: Jerome Glisse <[email protected]>
-rw-r--r-- | src/gallium/drivers/r600/evergreen_state.c | 16 | ||||
-rw-r--r-- | src/gallium/drivers/r600/r600_blit.c | 8 | ||||
-rw-r--r-- | src/gallium/drivers/r600/r600_hw_context.c | 24 | ||||
-rw-r--r-- | src/gallium/drivers/r600/r600_pipe.h | 3 | ||||
-rw-r--r-- | src/gallium/drivers/r600/r600_state.c | 16 | ||||
-rw-r--r-- | src/gallium/drivers/r600/r600_state_common.c | 49 |
6 files changed, 44 insertions, 72 deletions
diff --git a/src/gallium/drivers/r600/evergreen_state.c b/src/gallium/drivers/r600/evergreen_state.c index fda07905487..a29b0b4a472 100644 --- a/src/gallium/drivers/r600/evergreen_state.c +++ b/src/gallium/drivers/r600/evergreen_state.c @@ -2066,12 +2066,12 @@ static void evergreen_emit_sampler_views(struct r600_context *rctx, static void evergreen_emit_vs_sampler_views(struct r600_context *rctx, struct r600_atom *atom) { - evergreen_emit_sampler_views(rctx, &rctx->vs_samplers.views, 176 + R600_MAX_CONST_BUFFERS); + evergreen_emit_sampler_views(rctx, &rctx->samplers[PIPE_SHADER_VERTEX].views, 176 + R600_MAX_CONST_BUFFERS); } static void evergreen_emit_ps_sampler_views(struct r600_context *rctx, struct r600_atom *atom) { - evergreen_emit_sampler_views(rctx, &rctx->ps_samplers.views, R600_MAX_CONST_BUFFERS); + evergreen_emit_sampler_views(rctx, &rctx->samplers[PIPE_SHADER_FRAGMENT].views, R600_MAX_CONST_BUFFERS); } static void evergreen_emit_sampler_states(struct r600_context *rctx, @@ -2104,12 +2104,12 @@ static void evergreen_emit_sampler_states(struct r600_context *rctx, static void evergreen_emit_vs_sampler_states(struct r600_context *rctx, struct r600_atom *atom) { - evergreen_emit_sampler_states(rctx, &rctx->vs_samplers, 18, R_00A414_TD_VS_SAMPLER0_BORDER_INDEX); + evergreen_emit_sampler_states(rctx, &rctx->samplers[PIPE_SHADER_VERTEX], 18, R_00A414_TD_VS_SAMPLER0_BORDER_INDEX); } static void evergreen_emit_ps_sampler_states(struct r600_context *rctx, struct r600_atom *atom) { - evergreen_emit_sampler_states(rctx, &rctx->ps_samplers, 0, R_00A400_TD_PS_SAMPLER0_BORDER_INDEX); + evergreen_emit_sampler_states(rctx, &rctx->samplers[PIPE_SHADER_FRAGMENT], 0, R_00A400_TD_PS_SAMPLER0_BORDER_INDEX); } static void evergreen_emit_sample_mask(struct r600_context *rctx, struct r600_atom *a) @@ -2152,13 +2152,13 @@ void evergreen_init_state_functions(struct r600_context *rctx) /* shader program */ r600_init_atom(rctx, &rctx->cs_shader_state.atom, id++, evergreen_emit_cs_shader, 0); /* sampler */ - r600_init_atom(rctx, &rctx->vs_samplers.states.atom, id++, evergreen_emit_vs_sampler_states, 0); - r600_init_atom(rctx, &rctx->ps_samplers.states.atom, id++, evergreen_emit_ps_sampler_states, 0); + r600_init_atom(rctx, &rctx->samplers[PIPE_SHADER_VERTEX].states.atom, id++, evergreen_emit_vs_sampler_states, 0); + r600_init_atom(rctx, &rctx->samplers[PIPE_SHADER_FRAGMENT].states.atom, id++, evergreen_emit_ps_sampler_states, 0); /* resources */ r600_init_atom(rctx, &rctx->vertex_buffer_state.atom, id++, evergreen_fs_emit_vertex_buffers, 0); r600_init_atom(rctx, &rctx->cs_vertex_buffer_state.atom, id++, evergreen_cs_emit_vertex_buffers, 0); - r600_init_atom(rctx, &rctx->vs_samplers.views.atom, id++, evergreen_emit_vs_sampler_views, 0); - r600_init_atom(rctx, &rctx->ps_samplers.views.atom, id++, evergreen_emit_ps_sampler_views, 0); + r600_init_atom(rctx, &rctx->samplers[PIPE_SHADER_VERTEX].views.atom, id++, evergreen_emit_vs_sampler_views, 0); + r600_init_atom(rctx, &rctx->samplers[PIPE_SHADER_FRAGMENT].views.atom, id++, evergreen_emit_ps_sampler_views, 0); if (rctx->chip_class == EVERGREEN) { r600_init_atom(rctx, &rctx->sample_mask.atom, id++, evergreen_emit_sample_mask, 3); diff --git a/src/gallium/drivers/r600/r600_blit.c b/src/gallium/drivers/r600/r600_blit.c index 584b7fc1806..a49b4530078 100644 --- a/src/gallium/drivers/r600/r600_blit.c +++ b/src/gallium/drivers/r600/r600_blit.c @@ -79,12 +79,12 @@ static void r600_blitter_begin(struct pipe_context *ctx, enum r600_blitter_op op if (op & R600_SAVE_TEXTURES) { util_blitter_save_fragment_sampler_states( - rctx->blitter, util_last_bit(rctx->ps_samplers.states.enabled_mask), - (void**)rctx->ps_samplers.states.states); + rctx->blitter, util_last_bit(rctx->samplers[PIPE_SHADER_FRAGMENT].states.enabled_mask), + (void**)rctx->samplers[PIPE_SHADER_FRAGMENT].states.states); util_blitter_save_fragment_sampler_views( - rctx->blitter, util_last_bit(rctx->ps_samplers.views.enabled_mask), - (struct pipe_sampler_view**)rctx->ps_samplers.views.views); + rctx->blitter, util_last_bit(rctx->samplers[PIPE_SHADER_FRAGMENT].views.enabled_mask), + (struct pipe_sampler_view**)rctx->samplers[PIPE_SHADER_FRAGMENT].views.views); } if ((op & R600_DISABLE_RENDER_COND) && rctx->current_render_cond) { diff --git a/src/gallium/drivers/r600/r600_hw_context.c b/src/gallium/drivers/r600/r600_hw_context.c index 020f626cde9..f183b33c09e 100644 --- a/src/gallium/drivers/r600/r600_hw_context.c +++ b/src/gallium/drivers/r600/r600_hw_context.c @@ -1044,11 +1044,6 @@ void r600_context_flush(struct r600_context *ctx, unsigned flags) r600_atom_dirty(ctx, &ctx->cb_misc_state.atom); r600_atom_dirty(ctx, &ctx->db_misc_state.atom); - ctx->vs_samplers.states.dirty_mask = ctx->vs_samplers.states.enabled_mask; - ctx->ps_samplers.states.dirty_mask = ctx->ps_samplers.states.enabled_mask; - r600_sampler_states_dirty(ctx, &ctx->vs_samplers.states); - r600_sampler_states_dirty(ctx, &ctx->ps_samplers.states); - if (ctx->chip_class <= R700) { r600_atom_dirty(ctx, &ctx->seamless_cube_map.atom); } @@ -1057,16 +1052,19 @@ 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); + /* Re-emit shader resources. */ 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); - } + struct r600_constbuf_state *constbuf = &ctx->constbuf_state[shader]; + struct r600_textures_info *samplers = &ctx->samplers[shader]; - ctx->vs_samplers.views.dirty_mask = ctx->vs_samplers.views.enabled_mask; - ctx->ps_samplers.views.dirty_mask = ctx->ps_samplers.views.enabled_mask; - r600_sampler_views_dirty(ctx, &ctx->vs_samplers.views); - r600_sampler_views_dirty(ctx, &ctx->ps_samplers.views); + constbuf->dirty_mask = constbuf->enabled_mask; + samplers->views.dirty_mask = samplers->views.enabled_mask; + samplers->states.dirty_mask = samplers->states.enabled_mask; + + r600_constant_buffers_dirty(ctx, constbuf); + r600_sampler_views_dirty(ctx, &samplers->views); + r600_sampler_states_dirty(ctx, &samplers->states); + } if (streamout_suspended) { ctx->streamout_start = TRUE; diff --git a/src/gallium/drivers/r600/r600_pipe.h b/src/gallium/drivers/r600/r600_pipe.h index 8d1acd26504..b101db637b9 100644 --- a/src/gallium/drivers/r600/r600_pipe.h +++ b/src/gallium/drivers/r600/r600_pipe.h @@ -379,8 +379,7 @@ struct r600_context { /** Vertex buffers for compute shaders */ struct r600_vertexbuf_state cs_vertex_buffer_state; struct r600_constbuf_state constbuf_state[PIPE_SHADER_TYPES]; - struct r600_textures_info vs_samplers; - struct r600_textures_info ps_samplers; + struct r600_textures_info samplers[PIPE_SHADER_TYPES]; struct r600_seamless_cube_map seamless_cube_map; struct r600_cs_shader_state cs_shader_state; struct r600_sample_mask sample_mask; diff --git a/src/gallium/drivers/r600/r600_state.c b/src/gallium/drivers/r600/r600_state.c index 1e2e43e3081..05271e20132 100644 --- a/src/gallium/drivers/r600/r600_state.c +++ b/src/gallium/drivers/r600/r600_state.c @@ -1918,12 +1918,12 @@ static void r600_emit_sampler_views(struct r600_context *rctx, static void r600_emit_vs_sampler_views(struct r600_context *rctx, struct r600_atom *atom) { - r600_emit_sampler_views(rctx, &rctx->vs_samplers.views, 160 + R600_MAX_CONST_BUFFERS); + r600_emit_sampler_views(rctx, &rctx->samplers[PIPE_SHADER_VERTEX].views, 160 + R600_MAX_CONST_BUFFERS); } static void r600_emit_ps_sampler_views(struct r600_context *rctx, struct r600_atom *atom) { - r600_emit_sampler_views(rctx, &rctx->ps_samplers.views, R600_MAX_CONST_BUFFERS); + r600_emit_sampler_views(rctx, &rctx->samplers[PIPE_SHADER_FRAGMENT].views, R600_MAX_CONST_BUFFERS); } static void r600_emit_sampler_states(struct r600_context *rctx, @@ -1977,12 +1977,12 @@ static void r600_emit_sampler_states(struct r600_context *rctx, static void r600_emit_vs_sampler_states(struct r600_context *rctx, struct r600_atom *atom) { - r600_emit_sampler_states(rctx, &rctx->vs_samplers, 18, R_00A600_TD_VS_SAMPLER0_BORDER_RED); + r600_emit_sampler_states(rctx, &rctx->samplers[PIPE_SHADER_VERTEX], 18, R_00A600_TD_VS_SAMPLER0_BORDER_RED); } static void r600_emit_ps_sampler_states(struct r600_context *rctx, struct r600_atom *atom) { - r600_emit_sampler_states(rctx, &rctx->ps_samplers, 0, R_00A400_TD_PS_SAMPLER0_BORDER_RED); + r600_emit_sampler_states(rctx, &rctx->samplers[PIPE_SHADER_FRAGMENT], 0, R_00A400_TD_PS_SAMPLER0_BORDER_RED); } static void r600_emit_seamless_cube_map(struct r600_context *rctx, struct r600_atom *atom) @@ -2030,11 +2030,11 @@ void r600_init_state_functions(struct r600_context *rctx) /* 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) */ - r600_init_atom(rctx, &rctx->vs_samplers.states.atom, id++, r600_emit_vs_sampler_states, 0); - r600_init_atom(rctx, &rctx->ps_samplers.states.atom, id++, r600_emit_ps_sampler_states, 0); + r600_init_atom(rctx, &rctx->samplers[PIPE_SHADER_VERTEX].states.atom, id++, r600_emit_vs_sampler_states, 0); + r600_init_atom(rctx, &rctx->samplers[PIPE_SHADER_FRAGMENT].states.atom, id++, r600_emit_ps_sampler_states, 0); /* resource */ - r600_init_atom(rctx, &rctx->vs_samplers.views.atom, id++, r600_emit_vs_sampler_views, 0); - r600_init_atom(rctx, &rctx->ps_samplers.views.atom, id++, r600_emit_ps_sampler_views, 0); + r600_init_atom(rctx, &rctx->samplers[PIPE_SHADER_VERTEX].views.atom, id++, r600_emit_vs_sampler_views, 0); + r600_init_atom(rctx, &rctx->samplers[PIPE_SHADER_FRAGMENT].views.atom, id++, r600_emit_ps_sampler_views, 0); r600_init_atom(rctx, &rctx->vertex_buffer_state.atom, id++, r600_emit_vertex_buffers, 0); r600_init_atom(rctx, &rctx->seamless_cube_map.atom, id++, r600_emit_seamless_cube_map, 3); diff --git a/src/gallium/drivers/r600/r600_state_common.c b/src/gallium/drivers/r600/r600_state_common.c index 87183169a2a..7899e6cce8e 100644 --- a/src/gallium/drivers/r600/r600_state_common.c +++ b/src/gallium/drivers/r600/r600_state_common.c @@ -366,7 +366,7 @@ static void r600_bind_sampler_states(struct pipe_context *pipe, unsigned count, void **states) { struct r600_context *rctx = (struct r600_context *)pipe; - struct r600_textures_info *dst; + struct r600_textures_info *dst = &rctx->samplers[shader]; struct r600_pipe_sampler_state **rstates = (struct r600_pipe_sampler_state**)states; int seamless_cube_map = -1; unsigned i; @@ -377,18 +377,6 @@ static void r600_bind_sampler_states(struct pipe_context *pipe, assert(start == 0); /* XXX fix below */ - switch (shader) { - case PIPE_SHADER_VERTEX: - dst = &rctx->vs_samplers; - break; - case PIPE_SHADER_FRAGMENT: - dst = &rctx->ps_samplers; - break; - default: - debug_error("bad shader in r600_bind_samplers()"); - return; - } - for (i = 0; i < count; i++) { struct r600_pipe_sampler_state *rstate = rstates[i]; @@ -571,7 +559,7 @@ static void r600_set_sampler_views(struct pipe_context *pipe, unsigned shader, struct pipe_sampler_view **views) { struct r600_context *rctx = (struct r600_context *) pipe; - struct r600_textures_info *dst; + struct r600_textures_info *dst = &rctx->samplers[shader]; struct r600_pipe_sampler_view **rviews = (struct r600_pipe_sampler_view **)views; uint32_t dirty_sampler_states_mask = 0; unsigned i; @@ -585,18 +573,6 @@ static void r600_set_sampler_views(struct pipe_context *pipe, unsigned shader, assert(start == 0); /* XXX fix below */ - switch (shader) { - case PIPE_SHADER_VERTEX: - dst = &rctx->vs_samplers; - break; - case PIPE_SHADER_FRAGMENT: - dst = &rctx->ps_samplers; - break; - default: - debug_error("bad shader in r600_set_sampler_views()"); - return; - } - remaining_mask = dst->views.enabled_mask & disable_mask; while (remaining_mask) { @@ -1069,18 +1045,17 @@ static void r600_update_derived_state(struct r600_context *rctx) unsigned ps_dirty = 0, blend_override; if (!rctx->blitter->running) { + unsigned i; + /* Decompress textures if needed. */ - if (rctx->vs_samplers.views.compressed_depthtex_mask) { - r600_decompress_depth_textures(rctx, &rctx->vs_samplers.views); - } - if (rctx->ps_samplers.views.compressed_depthtex_mask) { - r600_decompress_depth_textures(rctx, &rctx->ps_samplers.views); - } - if (rctx->vs_samplers.views.compressed_colortex_mask) { - r600_decompress_color_textures(rctx, &rctx->vs_samplers.views); - } - if (rctx->ps_samplers.views.compressed_colortex_mask) { - r600_decompress_color_textures(rctx, &rctx->ps_samplers.views); + for (i = 0; i < PIPE_SHADER_TYPES; i++) { + struct r600_samplerview_state *views = &rctx->samplers[i].views; + if (views->compressed_depthtex_mask) { + r600_decompress_depth_textures(rctx, views); + } + if (views->compressed_colortex_mask) { + r600_decompress_color_textures(rctx, views); + } } } |