summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorMichel Dänzer <[email protected]>2012-10-05 16:59:10 +0200
committerMichel Dänzer <[email protected]>2012-10-26 15:51:17 +0200
commit44ef033c25ee0dde97a2339d4439560885d52cad (patch)
treebd4147b322bd0ad4b02aa146639c95aebbcc1542 /src/gallium
parentf3257d80b0e3885607afda642d326e47db48ed62 (diff)
radeonsi: Don't snoop context state while building shaders.
Let's use the shader key describing the state. Ported from r600g commit b6521801070d52bdd5908824e82c1ce2dde16e8e. Signed-off-by: Michel Dänzer <[email protected]> Reviewed-by: Tom Stellard <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/drivers/radeonsi/radeonsi_shader.c7
-rw-r--r--src/gallium/drivers/radeonsi/radeonsi_shader.h10
-rw-r--r--src/gallium/drivers/radeonsi/si_state.c27
3 files changed, 27 insertions, 17 deletions
diff --git a/src/gallium/drivers/radeonsi/radeonsi_shader.c b/src/gallium/drivers/radeonsi/radeonsi_shader.c
index 8a55e0dfab0..32755127b58 100644
--- a/src/gallium/drivers/radeonsi/radeonsi_shader.c
+++ b/src/gallium/drivers/radeonsi/radeonsi_shader.c
@@ -55,6 +55,7 @@ struct si_shader_context
struct tgsi_parse_context parse;
struct tgsi_token * tokens;
struct si_pipe_shader *shader;
+ struct si_shader_key key;
unsigned type; /* TGSI_PROCESSOR_* specifies the type of shader. */
unsigned ninput_emitted;
/* struct list_head inputs; */
@@ -405,7 +406,7 @@ static void si_llvm_init_export_args(struct lp_build_tgsi_context *bld_base,
if (cbuf >= 0 && cbuf < 8) {
struct r600_context *rctx = si_shader_ctx->rctx;
- compressed = (rctx->export_16bpc >> cbuf) & 0x1;
+ compressed = (si_shader_ctx->key.export_16bpc >> cbuf) & 0x1;
}
}
@@ -681,7 +682,8 @@ static const struct lp_build_tgsi_action tex_action = {
int si_pipe_shader_create(
struct pipe_context *ctx,
- struct si_pipe_shader *shader)
+ struct si_pipe_shader *shader,
+ struct si_shader_key key)
{
struct r600_context *rctx = (struct r600_context*)ctx;
struct si_pipe_shader_selector *sel = shader->selector;
@@ -718,6 +720,7 @@ int si_pipe_shader_create(
si_shader_ctx.tokens = sel->tokens;
tgsi_parse_init(&si_shader_ctx.parse, si_shader_ctx.tokens);
si_shader_ctx.shader = shader;
+ si_shader_ctx.key = key;
si_shader_ctx.type = si_shader_ctx.parse.FullHeader.Processor.Processor;
si_shader_ctx.rctx = rctx;
diff --git a/src/gallium/drivers/radeonsi/radeonsi_shader.h b/src/gallium/drivers/radeonsi/radeonsi_shader.h
index 4583e62b9c4..9d382d56286 100644
--- a/src/gallium/drivers/radeonsi/radeonsi_shader.h
+++ b/src/gallium/drivers/radeonsi/radeonsi_shader.h
@@ -77,6 +77,11 @@ struct si_shader {
unsigned nr_cbufs;
};
+struct si_shader_key {
+ unsigned export_16bpc:8;
+ unsigned nr_cbufs:4;
+};
+
struct si_pipe_shader {
struct si_pipe_shader_selector *selector;
struct si_pipe_shader *next_variant;
@@ -88,11 +93,12 @@ struct si_pipe_shader {
unsigned spi_ps_input_ena;
unsigned sprite_coord_enable;
unsigned so_strides[4];
- unsigned key;
+ struct si_shader_key key;
};
/* radeonsi_shader.c */
-int si_pipe_shader_create(struct pipe_context *ctx, struct si_pipe_shader *shader);
+int si_pipe_shader_create(struct pipe_context *ctx, struct si_pipe_shader *shader,
+ struct si_shader_key key);
void si_pipe_shader_destroy(struct pipe_context *ctx, struct si_pipe_shader *shader);
#endif
diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c
index c4c529fe2ab..20f4be3d8f2 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -1830,19 +1830,20 @@ static void si_set_framebuffer_state(struct pipe_context *ctx,
*/
/* Compute the key for the hw shader variant */
-static INLINE unsigned si_shader_selector_key(struct pipe_context *ctx,
- struct si_pipe_shader_selector *sel)
+static INLINE struct si_shader_key si_shader_selector_key(struct pipe_context *ctx,
+ struct si_pipe_shader_selector *sel)
{
struct r600_context *rctx = (struct r600_context *)ctx;
- unsigned key = 0;
+ struct si_shader_key key;
+ memset(&key, 0, sizeof(key));
if (sel->type == PIPE_SHADER_FRAGMENT) {
if (sel->fs_write_all)
- key |= rctx->framebuffer.nr_cbufs;
- key |= rctx->export_16bpc << 4;
+ key.nr_cbufs = rctx->framebuffer.nr_cbufs;
+ key.export_16bpc = rctx->export_16bpc;
/*if (rctx->queued.named.rasterizer)
- key |= rctx->queued.named.rasterizer->flatshade << 12;*/
- /*key |== rctx->two_side << 13;*/
+ key.flatshade = rctx->queued.named.rasterizer->flatshade;*/
+ /*key.color_two_side |== rctx->two_side;*/
}
return key;
@@ -1854,7 +1855,7 @@ int si_shader_select(struct pipe_context *ctx,
struct si_pipe_shader_selector *sel,
unsigned *dirty)
{
- unsigned key;
+ struct si_shader_key key;
struct si_pipe_shader * shader = NULL;
int r;
@@ -1864,7 +1865,7 @@ int si_shader_select(struct pipe_context *ctx,
* This path is also used for most shaders that don't need multiple
* variants, it will cost just a computation of the key and this
* test. */
- if (likely(sel->current && sel->current->key == key)) {
+ if (likely(sel->current && memcmp(&sel->current->key, &key, sizeof(key)) == 0)) {
return 0;
}
@@ -1872,7 +1873,7 @@ int si_shader_select(struct pipe_context *ctx,
if (sel->num_shaders > 1) {
struct si_pipe_shader *p = sel->current, *c = p->next_variant;
- while (c && c->key != key) {
+ while (c && memcmp(&c->key, &key, sizeof(key)) != 0) {
p = c;
c = c->next_variant;
}
@@ -1887,10 +1888,10 @@ int si_shader_select(struct pipe_context *ctx,
shader = CALLOC(1, sizeof(struct si_pipe_shader));
shader->selector = sel;
- r = si_pipe_shader_create(ctx, shader);
+ r = si_pipe_shader_create(ctx, shader, key);
if (unlikely(r)) {
- R600_ERR("Failed to build shader variant (type=%u, key=%u) %d\n",
- sel->type, key, r);
+ R600_ERR("Failed to build shader variant (type=%u) %d\n",
+ sel->type, r);
sel->current = NULL;
return r;
}