aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/r600/r600_state_common.c
diff options
context:
space:
mode:
authorVadim Girlin <vadimgirlin@gmail.com>2011-11-04 21:24:03 +0400
committerAlex Deucher <alexander.deucher@amd.com>2011-11-05 17:23:29 -0400
commite532c710c60f0895e32af6562ac2855aa7d5eb63 (patch)
tree3356f91b417695a4da1a84d8348df1b923e28fd4 /src/gallium/drivers/r600/r600_state_common.c
parent5b27b63de64167a84a03d820550e56c4b7bbc69d (diff)
r600g: move SPI setup to PS setup
SPI semantic indices for PS/VS are now static, so we don't need to update spi config for every shaders combination. We can move the functionality of r600_spi_update to r600(evergreen)_pipe_shader_ps. Flatshade state is now controlled by the global FLAT_SHADE_ENA flag instead of updating FLAT_SHADE for all inputs. Sprite coord still requires the update of spi setup when sprite_coord_enable is first changed from zero (enabled), and then only when it's changed to other non-zero value (enabled for other input). Change to zero (disabling) and back to the same value is handled via global SPRITE_COORD_ENA. New field "sprite_coord_enable" added to "struct r600_pipe_shader" to track current state for the pixel shader. It's checked in the r600_update_derived_state. Signed-off-by: Vadim Girlin <vadimgirlin@gmail.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'src/gallium/drivers/r600/r600_state_common.c')
-rw-r--r--src/gallium/drivers/r600/r600_state_common.c84
1 files changed, 16 insertions, 68 deletions
diff --git a/src/gallium/drivers/r600/r600_state_common.c b/src/gallium/drivers/r600/r600_state_common.c
index 3d0345addce..b81fba10467 100644
--- a/src/gallium/drivers/r600/r600_state_common.c
+++ b/src/gallium/drivers/r600/r600_state_common.c
@@ -34,8 +34,6 @@
#include "r600_pipe.h"
#include "r600d.h"
-static void r600_spi_update(struct r600_pipe_context *rctx);
-
static bool r600_conv_pipe_prim(unsigned pprim, unsigned *prim)
{
static const int prim_conv[] = {
@@ -103,8 +101,9 @@ void r600_bind_rs_state(struct pipe_context *ctx, void *state)
rctx->clamp_vertex_color = rs->clamp_vertex_color;
rctx->clamp_fragment_color = rs->clamp_fragment_color;
- rctx->flatshade = rs->flatshade;
+
rctx->sprite_coord_enable = rs->sprite_coord_enable;
+
rctx->rasterizer = rs;
rctx->states[rs->rstate.id] = &rs->rstate;
@@ -115,8 +114,6 @@ void r600_bind_rs_state(struct pipe_context *ctx, void *state)
} else {
r600_polygon_offset_update(rctx);
}
- if (rctx->ps_shader && rctx->vs_shader)
- rctx->spi_dirty = true;
}
void r600_delete_rs_state(struct pipe_context *ctx, void *state)
@@ -280,7 +277,6 @@ void r600_bind_ps_shader(struct pipe_context *ctx, void *state)
r600_context_pipe_state_set(&rctx->ctx, &rctx->ps_shader->rstate);
}
if (rctx->ps_shader && rctx->vs_shader) {
- rctx->spi_dirty = true;
r600_adjust_gprs(rctx);
}
}
@@ -295,7 +291,6 @@ void r600_bind_vs_shader(struct pipe_context *ctx, void *state)
r600_context_pipe_state_set(&rctx->ctx, &rctx->vs_shader->rstate);
}
if (rctx->ps_shader && rctx->vs_shader) {
- rctx->spi_dirty = true;
r600_adjust_gprs(rctx);
}
}
@@ -343,63 +338,6 @@ static void r600_update_alpha_ref(struct r600_pipe_context *rctx)
rctx->alpha_ref_dirty = false;
}
-/* FIXME optimize away spi update when it's not needed */
-static void r600_spi_block_init(struct r600_pipe_context *rctx, struct r600_pipe_state *rstate)
-{
- int i;
- rstate->nregs = 0;
- rstate->id = R600_PIPE_STATE_SPI;
- for (i = 0; i < 32; i++) {
- r600_pipe_state_add_reg(rstate, R_028644_SPI_PS_INPUT_CNTL_0 + i * 4, 0, 0xFFFFFFFF, NULL, 0);
- }
-}
-
-static void r600_spi_update(struct r600_pipe_context *rctx)
-{
- struct r600_pipe_shader *shader = rctx->ps_shader;
- struct r600_pipe_state *rstate = &rctx->spi;
- struct r600_shader *rshader = &shader->shader;
- unsigned i, tmp, sid;
-
- if (rctx->spi.id == 0)
- r600_spi_block_init(rctx, &rctx->spi);
-
- rstate->nregs = 0;
- for (i = 0; i < rshader->ninput; i++) {
-
- sid = rshader->input[i].spi_sid;
-
- if (!sid && (rctx->chip_class >= EVERGREEN))
- continue;
-
- tmp = S_028644_SEMANTIC(sid);
-
- if (rshader->input[i].name == TGSI_SEMANTIC_COLOR ||
- rshader->input[i].name == TGSI_SEMANTIC_BCOLOR ||
- rshader->input[i].name == TGSI_SEMANTIC_POSITION) {
- tmp |= S_028644_FLAT_SHADE(rctx->flatshade);
- }
-
- if (rshader->input[i].name == TGSI_SEMANTIC_GENERIC &&
- rctx->sprite_coord_enable & (1 << rshader->input[i].sid)) {
- tmp |= S_028644_PT_SPRITE_TEX(1);
- }
-
- if (rctx->chip_class < EVERGREEN) {
- if (rshader->input[i].centroid)
- tmp |= S_028644_SEL_CENTROID(1);
-
- if (rshader->input[i].interpolate == TGSI_INTERPOLATE_LINEAR)
- tmp |= S_028644_SEL_LINEAR(1);
- }
-
- r600_pipe_state_mod_reg(rstate, tmp);
- }
-
- rctx->spi_dirty = false;
- r600_context_pipe_state_set(&rctx->ctx, rstate);
-}
-
void r600_set_constant_buffer(struct pipe_context *ctx, uint shader, uint index,
struct pipe_resource *buffer)
{
@@ -552,6 +490,8 @@ static int r600_shader_rebuild(struct pipe_context * ctx, struct r600_pipe_shade
static void r600_update_derived_state(struct r600_pipe_context *rctx)
{
+ struct pipe_context * ctx = (struct pipe_context*)rctx;
+
if (!rctx->blitter->running) {
if (rctx->have_depth_fb || rctx->have_depth_texture)
r600_flush_depth_textures(rctx);
@@ -571,13 +511,21 @@ static void r600_update_derived_state(struct r600_pipe_context *rctx)
r600_shader_rebuild(&rctx->context, rctx->ps_shader);
}
- if (rctx->spi_dirty) {
- r600_spi_update(rctx);
- }
-
if (rctx->alpha_ref_dirty) {
r600_update_alpha_ref(rctx);
}
+
+ if (rctx->ps_shader && rctx->sprite_coord_enable &&
+ (rctx->ps_shader->sprite_coord_enable != rctx->sprite_coord_enable)) {
+
+ if (rctx->chip_class >= EVERGREEN)
+ evergreen_pipe_shader_ps(ctx, rctx->ps_shader);
+ else
+ r600_pipe_shader_ps(ctx, rctx->ps_shader);
+
+ r600_context_pipe_state_set(&rctx->ctx, &rctx->ps_shader->rstate);
+ }
+
}
void r600_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *dinfo)