summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIago Toral Quiroga <[email protected]>2019-07-16 10:58:12 +0200
committerIago Toral Quiroga <[email protected]>2019-07-18 08:59:35 +0200
commit0c9919710e17746620cd310ab43e7b82ede53cb4 (patch)
treed06ce8a1c409fe0a2ca4ba5f5a14ea2820d5f394
parent3adc32df922753363d964b637196157587d57565 (diff)
v3d: implement per-sample tlb color reads
Reviewed-by: Eric Anholt <[email protected]>
-rw-r--r--src/broadcom/compiler/nir_to_vir.c91
1 files changed, 52 insertions, 39 deletions
diff --git a/src/broadcom/compiler/nir_to_vir.c b/src/broadcom/compiler/nir_to_vir.c
index 45e34c70a49..256f6a01675 100644
--- a/src/broadcom/compiler/nir_to_vir.c
+++ b/src/broadcom/compiler/nir_to_vir.c
@@ -1652,7 +1652,7 @@ vir_emit_tlb_color_read(struct v3d_compile *c, nir_intrinsic_instr *instr)
assert(rt < V3D_MAX_DRAW_BUFFERS);
int sample_index = nir_intrinsic_base(instr) ;
- assert(sample_index == 0); /* XXX: multisample */
+ assert(sample_index < V3D_MAX_SAMPLES);
int component = nir_intrinsic_component(instr);
assert(component < 4);
@@ -1678,10 +1678,10 @@ vir_emit_tlb_color_read(struct v3d_compile *c, nir_intrinsic_instr *instr)
c->emitted_tlb_load = true;
}
- struct qreg *color_reads =
+ struct qreg *color_reads_for_sample =
&c->color_reads[(rt * V3D_MAX_SAMPLES + sample_index) * 4];
- if (color_reads[component].file == QFILE_NULL) {
+ if (color_reads_for_sample[component].file == QFILE_NULL) {
enum pipe_format rt_format = c->fs_key->color_fmt[rt].format;
int num_components =
util_format_get_nr_components(rt_format);
@@ -1699,8 +1699,11 @@ vir_emit_tlb_color_read(struct v3d_compile *c, nir_intrinsic_instr *instr)
bool is_32b_tlb_format = is_int_format ||
(c->fs_key->f32_color_rb & (1 << rt));
+ int num_samples = c->fs_key->msaa ? V3D_MAX_SAMPLES : 1;
+
uint32_t conf = 0xffffff00;
- conf |= TLB_SAMPLE_MODE_PER_PIXEL; /* XXX: multisample */
+ conf |= c->fs_key->msaa ? TLB_SAMPLE_MODE_PER_SAMPLE :
+ TLB_SAMPLE_MODE_PER_PIXEL;
conf |= (7 - rt) << TLB_RENDER_TARGET_SHIFT;
if (is_32b_tlb_format) {
@@ -1720,47 +1723,57 @@ vir_emit_tlb_color_read(struct v3d_compile *c, nir_intrinsic_instr *instr)
conf |= TLB_VEC_SIZE_2_F16;
}
- struct qreg r, g, b, a;
- if (is_32b_tlb_format) {
- r = conf != 0xffffffff ? vir_TLBU_COLOR_READ(c, conf) :
- vir_TLB_COLOR_READ(c);
+
+ for (int i = 0; i < num_samples; i++) {
+ struct qreg r, g, b, a;
+ if (is_32b_tlb_format) {
+ r = conf != 0xffffffff && i == 0?
+ vir_TLBU_COLOR_READ(c, conf) :
+ vir_TLB_COLOR_READ(c);
+ if (num_components >= 2)
+ g = vir_TLB_COLOR_READ(c);
+ if (num_components >= 3)
+ b = vir_TLB_COLOR_READ(c);
+ if (num_components >= 4)
+ a = vir_TLB_COLOR_READ(c);
+ } else {
+ struct qreg rg = conf != 0xffffffff && i == 0 ?
+ vir_TLBU_COLOR_READ(c, conf) :
+ vir_TLB_COLOR_READ(c);
+ r = vir_FMOV(c, rg);
+ vir_set_unpack(c->defs[r.index], 0,
+ V3D_QPU_UNPACK_L);
+ g = vir_FMOV(c, rg);
+ vir_set_unpack(c->defs[g.index], 0,
+ V3D_QPU_UNPACK_H);
+
+ if (num_components > 2) {
+ struct qreg ba = vir_TLB_COLOR_READ(c);
+ b = vir_FMOV(c, ba);
+ vir_set_unpack(c->defs[b.index], 0,
+ V3D_QPU_UNPACK_L);
+ a = vir_FMOV(c, ba);
+ vir_set_unpack(c->defs[a.index], 0,
+ V3D_QPU_UNPACK_H);
+ }
+ }
+
+ struct qreg *color_reads =
+ &c->color_reads[(rt * V3D_MAX_SAMPLES + i) * 4];
+
+ color_reads[0] = swap_rb ? b : r;
if (num_components >= 2)
- g = vir_TLB_COLOR_READ(c);
+ color_reads[1] = g;
if (num_components >= 3)
- b = vir_TLB_COLOR_READ(c);
+ color_reads[2] = swap_rb ? r : b;
if (num_components >= 4)
- a = vir_TLB_COLOR_READ(c);
- } else {
- struct qreg rg = conf != 0xffffffff ?
- vir_TLBU_COLOR_READ(c, conf) :
- vir_TLB_COLOR_READ(c);
- r = vir_FMOV(c, rg);
- vir_set_unpack(c->defs[r.index], 0, V3D_QPU_UNPACK_L);
- g = vir_FMOV(c, rg);
- vir_set_unpack(c->defs[g.index], 0, V3D_QPU_UNPACK_H);
-
- if (num_components > 2) {
- struct qreg ba = vir_TLB_COLOR_READ(c);
- b = vir_FMOV(c, ba);
- vir_set_unpack(c->defs[b.index], 0,
- V3D_QPU_UNPACK_L);
- a = vir_FMOV(c, ba);
- vir_set_unpack(c->defs[a.index], 0,
- V3D_QPU_UNPACK_H);
- }
+ color_reads[3] = a;
}
-
- color_reads[0] = swap_rb ? b : r;
- if (num_components >= 2)
- color_reads[1] = g;
- if (num_components >= 3)
- color_reads[2] = swap_rb ? r : b;
- if (num_components >= 4)
- color_reads[3] = a;
}
- assert(color_reads[component].file != QFILE_NULL);
- ntq_store_dest(c, &instr->dest, 0, vir_MOV(c, color_reads[component]));
+ assert(color_reads_for_sample[component].file != QFILE_NULL);
+ ntq_store_dest(c, &instr->dest, 0,
+ vir_MOV(c, color_reads_for_sample[component]));
}
static void