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 <imirkin@alum.mit.edu>
This commit is contained in:
Ilia Mirkin
2015-03-29 19:59:38 -04:00
parent 70eed78cac
commit 8efa3e340d
9 changed files with 8 additions and 42 deletions
@@ -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),
@@ -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..
*/
@@ -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;
@@ -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: */
@@ -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);
@@ -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);
@@ -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:
*/
@@ -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;
@@ -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:
*/