diff options
author | Ilia Mirkin <[email protected]> | 2015-03-29 19:59:38 -0400 |
---|---|---|
committer | Ilia Mirkin <[email protected]> | 2015-04-02 00:09:14 -0400 |
commit | 8efa3e340d13a9f373e7b2834f12d9fae43e6867 (patch) | |
tree | 90bd7831f58242b63ac14d6a130d00f7493af507 /src | |
parent | 70eed78cacd711e663068e78a8430372cc5fabf1 (diff) |
freedreno: remove alpha key from ir3_shader
This complication is unnecessary and makes MRTs more complicated and
likely to generate tons of variants.
Signed-off-by: Ilia Mirkin <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/drivers/freedreno/a3xx/fd3_draw.c | 4 | ||||
-rw-r--r-- | src/gallium/drivers/freedreno/a3xx/fd3_program.c | 3 | ||||
-rw-r--r-- | src/gallium/drivers/freedreno/a4xx/fd4_draw.c | 5 | ||||
-rw-r--r-- | src/gallium/drivers/freedreno/a4xx/fd4_emit.h | 1 | ||||
-rw-r--r-- | src/gallium/drivers/freedreno/a4xx/fd4_program.c | 3 | ||||
-rw-r--r-- | src/gallium/drivers/freedreno/ir3/ir3_cmdline.c | 8 | ||||
-rw-r--r-- | src/gallium/drivers/freedreno/ir3/ir3_compiler.c | 17 | ||||
-rw-r--r-- | src/gallium/drivers/freedreno/ir3/ir3_shader.c | 1 | ||||
-rw-r--r-- | src/gallium/drivers/freedreno/ir3/ir3_shader.h | 8 |
9 files changed, 8 insertions, 42 deletions
diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_draw.c b/src/gallium/drivers/freedreno/a3xx/fd3_draw.c index a3f954902a7..6ff762e2ae4 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_draw.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_draw.c @@ -121,9 +121,6 @@ fixup_shader_state(struct fd_context *ctx, struct ir3_shader_key *key) if (last_key->half_precision != key->half_precision) ctx->prog.dirty |= FD_SHADER_DIRTY_FP; - if (last_key->alpha != key->alpha) - ctx->prog.dirty |= FD_SHADER_DIRTY_FP; - fd3_ctx->last_key = *key; } } @@ -141,7 +138,6 @@ fd3_draw_vbo(struct fd_context *ctx, const struct pipe_draw_info *info) /* do binning pass first: */ .binning_pass = true, .color_two_side = ctx->rasterizer ? ctx->rasterizer->light_twoside : false, - .alpha = util_format_is_alpha(pipe_surface_format(pfb->cbufs[0])), // TODO set .half_precision based on render target format, // ie. float16 and smaller use half, float32 use full.. .half_precision = !!(fd_mesa_debug & FD_DBG_FRAGHALF), diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_program.c b/src/gallium/drivers/freedreno/a3xx/fd3_program.c index 1250dffe29e..442b47dea9f 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_program.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_program.c @@ -202,6 +202,9 @@ fd3_program_emit(struct fd_ringbuffer *ring, struct fd3_emit *emit) color_regid = ir3_find_output_regid(fp, ir3_semantic_name(TGSI_SEMANTIC_COLOR, 0)); + if (util_format_is_alpha(emit->format)) + color_regid += 3; + /* we could probably divide this up into things that need to be * emitted if frag-prog is dirty vs if vert-prog is dirty.. */ diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_draw.c b/src/gallium/drivers/freedreno/a4xx/fd4_draw.c index 57f257478a7..6c54f61cc66 100644 --- a/src/gallium/drivers/freedreno/a4xx/fd4_draw.c +++ b/src/gallium/drivers/freedreno/a4xx/fd4_draw.c @@ -97,9 +97,6 @@ fixup_shader_state(struct fd_context *ctx, struct ir3_shader_key *key) if (last_key->half_precision != key->half_precision) ctx->prog.dirty |= FD_SHADER_DIRTY_FP; - if (last_key->alpha != key->alpha) - ctx->prog.dirty |= FD_SHADER_DIRTY_FP; - if (last_key->rasterflat != key->rasterflat) ctx->prog.dirty |= FD_SHADER_DIRTY_FP; @@ -120,7 +117,6 @@ fd4_draw_vbo(struct fd_context *ctx, const struct pipe_draw_info *info) /* do binning pass first: */ .binning_pass = true, .color_two_side = ctx->rasterizer ? ctx->rasterizer->light_twoside : false, - .alpha = util_format_is_alpha(pipe_surface_format(pfb->cbufs[0])), .rasterflat = ctx->rasterizer && ctx->rasterizer->flatshade, // TODO set .half_precision based on render target format, // ie. float16 and smaller use half, float32 use full.. @@ -134,6 +130,7 @@ fd4_draw_vbo(struct fd_context *ctx, const struct pipe_draw_info *info) .fsaturate_r = fd4_ctx->fsaturate_r, }, .format = fd4_emit_format(pfb->cbufs[0]), + .pformat = pipe_surface_format(pfb->cbufs[0]), }; unsigned dirty; diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_emit.h b/src/gallium/drivers/freedreno/a4xx/fd4_emit.h index 5dc3db8880e..7d059f8e532 100644 --- a/src/gallium/drivers/freedreno/a4xx/fd4_emit.h +++ b/src/gallium/drivers/freedreno/a4xx/fd4_emit.h @@ -54,6 +54,7 @@ struct fd4_emit { const struct pipe_draw_info *info; struct ir3_shader_key key; enum a4xx_color_fmt format; + enum pipe_format pformat; uint32_t dirty; /* cached to avoid repeated lookups of same variants: */ diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_program.c b/src/gallium/drivers/freedreno/a4xx/fd4_program.c index 776e4a16b14..9ee47fbdb66 100644 --- a/src/gallium/drivers/freedreno/a4xx/fd4_program.c +++ b/src/gallium/drivers/freedreno/a4xx/fd4_program.c @@ -218,6 +218,9 @@ fd4_program_emit(struct fd_ringbuffer *ring, struct fd4_emit *emit) color_regid = ir3_find_output_regid(s[FS].v, ir3_semantic_name(TGSI_SEMANTIC_COLOR, 0)); + if (util_format_is_alpha(emit->pformat)) + color_regid += 3; + /* TODO get these dynamically: */ face_regid = s[FS].v->frag_face ? regid(0,0) : regid(63,0); coord_regid = s[FS].v->frag_coord ? regid(0,0) : regid(63,0); diff --git a/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c b/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c index bf6bcb82131..11bfe34fc18 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c @@ -225,7 +225,6 @@ static void print_usage(void) printf(" --binning-pass - generate binning pass shader (VERT)\n"); printf(" --color-two-side - emulate two-sided color (FRAG)\n"); printf(" --half-precision - use half-precision\n"); - printf(" --alpha - generate render-to-alpha shader (FRAG)\n"); printf(" --saturate-s MASK - bitmask of samplers to saturate S coord\n"); printf(" --saturate-t MASK - bitmask of samplers to saturate T coord\n"); printf(" --saturate-r MASK - bitmask of samplers to saturate R coord\n"); @@ -282,13 +281,6 @@ int main(int argc, char **argv) continue; } - if (!strcmp(argv[n], "--alpha")) { - debug_printf(" %s", argv[n]); - key.alpha = true; - n++; - continue; - } - if (!strcmp(argv[n], "--saturate-s")) { debug_printf(" %s %s", argv[n], argv[n+1]); key.vsaturate_s = key.fsaturate_s = strtol(argv[n+1], NULL, 0); diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler.c b/src/gallium/drivers/freedreno/ir3/ir3_compiler.c index f6bdc06130e..c60025298a6 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_compiler.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_compiler.c @@ -3496,23 +3496,6 @@ ir3_compile_shader(struct ir3_shader_variant *so, block->noutputs = j * 4; } - /* for rendering to alpha format, we only need the .w component, - * and we need it to be in the .x position: - */ - if (key.alpha) { - for (i = 0, j = 0; i < so->outputs_count; i++) { - unsigned name = sem2name(so->outputs[i].semantic); - - /* move .w component to .x and discard others: */ - if (name == TGSI_SEMANTIC_COLOR) { - block->outputs[(i*4)+0] = block->outputs[(i*4)+3]; - block->outputs[(i*4)+1] = NULL; - block->outputs[(i*4)+2] = NULL; - block->outputs[(i*4)+3] = NULL; - } - } - } - /* if we want half-precision outputs, mark the output registers * as half: */ diff --git a/src/gallium/drivers/freedreno/ir3/ir3_shader.c b/src/gallium/drivers/freedreno/ir3/ir3_shader.c index 122a44767b5..b1dff381813 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_shader.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_shader.c @@ -236,7 +236,6 @@ ir3_shader_variant(struct ir3_shader *shader, struct ir3_shader_key key) case SHADER_VERTEX: key.color_two_side = false; key.half_precision = false; - key.alpha = false; key.rasterflat = false; if (key.has_per_samp) { key.fsaturate_s = 0; diff --git a/src/gallium/drivers/freedreno/ir3/ir3_shader.h b/src/gallium/drivers/freedreno/ir3/ir3_shader.h index 7f38067972b..4b7d03899d6 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_shader.h +++ b/src/gallium/drivers/freedreno/ir3/ir3_shader.h @@ -69,14 +69,6 @@ struct ir3_shader_key { */ unsigned color_two_side : 1; unsigned half_precision : 1; - /* For rendering to alpha, we need a bit of special handling - * since the hw always takes gl_FragColor starting from x - * component, rather than figuring out to take the w component. - * We could be more clever and generate variants for other - * render target formats (ie. luminance formats are xxx1), but - * let's start with this and see how it goes: - */ - unsigned alpha : 1; /* used when shader needs to handle flat varyings (a4xx), * for TGSI_INTERPOLATE_COLOR: */ |