diff options
author | Iago Toral Quiroga <[email protected]> | 2019-07-16 10:28:53 +0200 |
---|---|---|
committer | Iago Toral Quiroga <[email protected]> | 2019-07-18 08:59:35 +0200 |
commit | b96c2219caa982cce2220505fded5473c6a3f71e (patch) | |
tree | d125fba947f0c82fb62b59f3b5482a2e54d6d920 /src/broadcom | |
parent | fd3ec6f55d0db0f350ef944e8d4a4d8c3a0af740 (diff) |
v3d: refactor the tlb color write code
We want to split the tlb specifier setup from the color writes, because when
we implement per-sample color writes we want to do the latter for all the
samples, but the former only once.
Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/broadcom')
-rw-r--r-- | src/broadcom/compiler/nir_to_vir.c | 88 |
1 files changed, 39 insertions, 49 deletions
diff --git a/src/broadcom/compiler/nir_to_vir.c b/src/broadcom/compiler/nir_to_vir.c index 34c8d5438e1..0f832254a55 100644 --- a/src/broadcom/compiler/nir_to_vir.c +++ b/src/broadcom/compiler/nir_to_vir.c @@ -1131,32 +1131,21 @@ vir_emit_tlb_color_write(struct v3d_compile *c, unsigned rt) if (c->fs_key->swap_color_rb & (1 << rt)) num_components = MAX2(num_components, 3); - assert(num_components != 0); - switch (glsl_get_base_type(var->type)) { - case GLSL_TYPE_UINT: - case GLSL_TYPE_INT: + + enum glsl_base_type type = glsl_get_base_type(var->type); + bool is_int_format = type == GLSL_TYPE_INT || type == GLSL_TYPE_UINT; + bool is_32b_tlb_format = is_int_format || + (c->fs_key->f32_color_rb & (1 << rt)); + + if (is_int_format) { /* The F32 vs I32 distinction was dropped in 4.2. */ if (c->devinfo->ver < 42) conf |= TLB_TYPE_I32_COLOR; else conf |= TLB_TYPE_F32_COLOR; conf |= ((num_components - 1) << TLB_VEC_SIZE_MINUS_1_SHIFT); - - inst = vir_MOV_dest(c, tlbu_reg, color[0]); - inst->uniform = - vir_get_uniform_index(c, QUNIFORM_CONSTANT, conf); - - for (int i = 1; i < num_components; i++) - inst = vir_MOV_dest(c, tlb_reg, color[i]); - break; - - default: { - struct qreg r = color[0]; - struct qreg g = color[1]; - struct qreg b = color[2]; - struct qreg a = color[3]; - + } else { if (c->fs_key->f32_color_rb & (1 << rt)) { conf |= TLB_TYPE_F32_COLOR; conf |= ((num_components - 1) << @@ -1169,43 +1158,44 @@ vir_emit_tlb_color_write(struct v3d_compile *c, unsigned rt) else conf |= TLB_VEC_SIZE_2_F16; } + } - if (c->fs_key->swap_color_rb & (1 << rt)) { - r = color[2]; - b = color[0]; - } + struct qreg r = color[0]; + struct qreg g = color[1]; + struct qreg b = color[2]; + struct qreg a = color[3]; - if (c->fs_key->sample_alpha_to_one) - a = vir_uniform_f(c, 1.0); + if (c->fs_key->swap_color_rb & (1 << rt)) { + r = color[2]; + b = color[0]; + } - if (c->fs_key->f32_color_rb & (1 << rt)) { - inst = vir_MOV_dest(c, tlbu_reg, r); - inst->uniform = - vir_get_uniform_index(c, QUNIFORM_CONSTANT, - conf); + if (c->fs_key->sample_alpha_to_one) + a = vir_uniform_f(c, 1.0); - if (num_components >= 2) - vir_MOV_dest(c, tlb_reg, g); - if (num_components >= 3) - vir_MOV_dest(c, tlb_reg, b); - if (num_components >= 4) - vir_MOV_dest(c, tlb_reg, a); - } else { - inst = vir_VFPACK_dest(c, tlb_reg, r, g); - if (conf != ~0) { - inst->dst = tlbu_reg; - inst->uniform = - vir_get_uniform_index(c, + if (is_32b_tlb_format) { + inst = vir_MOV_dest(c, tlbu_reg, r); + inst->uniform = + vir_get_uniform_index(c, QUNIFORM_CONSTANT, conf); + + if (num_components >= 2) + vir_MOV_dest(c, tlb_reg, g); + if (num_components >= 3) + vir_MOV_dest(c, tlb_reg, b); + if (num_components >= 4) + vir_MOV_dest(c, tlb_reg, a); + } else { + inst = vir_VFPACK_dest(c, tlb_reg, r, g); + if (conf != ~0) { + inst->dst = tlbu_reg; + inst->uniform = vir_get_uniform_index(c, QUNIFORM_CONSTANT, conf); - } - - if (num_components >= 3) - inst = vir_VFPACK_dest(c, tlb_reg, b, a); } - break; - } /* default */ - } /* Switch */ + + if (num_components >= 3) + inst = vir_VFPACK_dest(c, tlb_reg, b, a); + } } static void |