freedreno: remove alpha key from ir3_shader
authorIlia Mirkin <imirkin@alum.mit.edu>
Sun, 29 Mar 2015 23:59:38 +0000 (19:59 -0400)
committerIlia Mirkin <imirkin@alum.mit.edu>
Thu, 2 Apr 2015 04:09:14 +0000 (00:09 -0400)
This complication is unnecessary and makes MRTs more complicated and
likely to generate tons of variants.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
src/gallium/drivers/freedreno/a3xx/fd3_draw.c
src/gallium/drivers/freedreno/a3xx/fd3_program.c
src/gallium/drivers/freedreno/a4xx/fd4_draw.c
src/gallium/drivers/freedreno/a4xx/fd4_emit.h
src/gallium/drivers/freedreno/a4xx/fd4_program.c
src/gallium/drivers/freedreno/ir3/ir3_cmdline.c
src/gallium/drivers/freedreno/ir3/ir3_compiler.c
src/gallium/drivers/freedreno/ir3/ir3_shader.c
src/gallium/drivers/freedreno/ir3/ir3_shader.h

index a3f954902a7ba317be974cbba7c084269b95542c..6ff762e2ae45ef3800df1dedf484a94df12883e1 100644 (file)
@@ -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),
index 1250dffe29e929830859163422cc2e48d99b0a34..442b47dea9fe741b72480d44371f6bd58c9fa542 100644 (file)
@@ -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..
         */
index 57f257478a792910605ad8a23b8ad97df68096bc..6c54f61cc6625d0a7a0290e93637153e75f67561 100644 (file)
@@ -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;
 
index 5dc3db8880e39e69ab0464ff4bbad96f65b72245..7d059f8e5322b520d6263fa4bddb5542b3350017 100644 (file)
@@ -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: */
index 776e4a16b1419f89ada8ab52237e7bbcf6e4342a..9ee47fbdb665505566f1b0107a9207e7db38338d 100644 (file)
@@ -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);
index bf6bcb8213106b3aed2fb81985616dd2dcf0f542..11bfe34fc18accee46c9c1f467a4c4d571066a09 100644 (file)
@@ -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);
index f6bdc06130e69bb2e1af470172198b3763452fab..c60025298a67fb6081952e991e16862302cc7821 100644 (file)
@@ -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:
         */
index 122a44767b5c51f1085ba144d8dce550a5f71593..b1dff3818130afac39a78a35c1bc48a7f271d2aa 100644 (file)
@@ -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;
index 7f38067972b08f627eb7c7aa179735491df46a10..4b7d03899d657eedc2f02e9d4c4a2ca38ecc2f95 100644 (file)
@@ -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:
                         */