Mesa (master): freedreno/a3xx: fix TOTALATTRTOVS

Rob Clark robclark at kemper.freedesktop.org
Wed Apr 23 11:34:55 UTC 2014


Module: Mesa
Branch: master
Commit: 05b3cea77badffa84ba0fe7b233b2be70239d618
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=05b3cea77badffa84ba0fe7b233b2be70239d618

Author: Rob Clark <robclark at freedesktop.org>
Date:   Tue Apr 22 15:43:51 2014 -0400

freedreno/a3xx: fix TOTALATTRTOVS

In cases where varying fetches are optimized away (just pass-through in
vertex shader, but unused in fragment shader) we need to calculate the
correct TOTALATTROVS based on the actual number of varyings fetched,
otherwise lockup.

Signed-off-by: Rob Clark <robclark at freedesktop.org>

---

 src/gallium/drivers/freedreno/a3xx/fd3_compiler.c     |    2 ++
 src/gallium/drivers/freedreno/a3xx/fd3_compiler_old.c |    1 +
 src/gallium/drivers/freedreno/a3xx/fd3_emit.c         |    4 +++-
 src/gallium/drivers/freedreno/a3xx/fd3_program.h      |    1 +
 4 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_compiler.c b/src/gallium/drivers/freedreno/a3xx/fd3_compiler.c
index fd385d7..4f8dcc5 100644
--- a/src/gallium/drivers/freedreno/a3xx/fd3_compiler.c
+++ b/src/gallium/drivers/freedreno/a3xx/fd3_compiler.c
@@ -2317,12 +2317,14 @@ fd3_compile_shader(struct fd3_shader_variant *so,
 	actual_in = 0;
 	for (i = 0; i < so->inputs_count; i++) {
 		unsigned j, regid = ~0, compmask = 0;
+		so->inputs[i].ncomp = 0;
 		for (j = 0; j < 4; j++) {
 			struct ir3_instruction *in = inputs[(i*4) + j];
 			if (in) {
 				compmask |= (1 << j);
 				regid = in->regs[0]->num - j;
 				actual_in++;
+				so->inputs[i].ncomp++;
 			}
 		}
 		so->inputs[i].regid = regid;
diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_compiler_old.c b/src/gallium/drivers/freedreno/a3xx/fd3_compiler_old.c
index ee58591..ddb6924 100644
--- a/src/gallium/drivers/freedreno/a3xx/fd3_compiler_old.c
+++ b/src/gallium/drivers/freedreno/a3xx/fd3_compiler_old.c
@@ -1326,6 +1326,7 @@ decl_in(struct fd3_compile_context *ctx, struct tgsi_full_declaration *decl)
 
 		so->inputs[n].semantic = decl_semantic(&decl->Semantic);
 		so->inputs[n].compmask = (1 << ncomp) - 1;
+		so->inputs[n].ncomp = ncomp;
 		so->inputs[n].regid = r;
 		so->inputs[n].inloc = ctx->next_inloc;
 		so->inputs[n].bary = true;   /* all that is supported */
diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_emit.c b/src/gallium/drivers/freedreno/a3xx/fd3_emit.c
index b1cf3fd..c78d5e8 100644
--- a/src/gallium/drivers/freedreno/a3xx/fd3_emit.c
+++ b/src/gallium/drivers/freedreno/a3xx/fd3_emit.c
@@ -311,6 +311,7 @@ fd3_emit_vertex_bufs(struct fd_ringbuffer *ring,
 		struct fd3_vertex_buf *vbufs, uint32_t n)
 {
 	uint32_t i, j, last = 0;
+	uint32_t total_in = 0;
 
 	n = MIN2(n, vp->inputs_count);
 
@@ -343,12 +344,13 @@ fd3_emit_vertex_bufs(struct fd_ringbuffer *ring,
 					A3XX_VFD_DECODE_INSTR_LASTCOMPVALID |
 					COND(switchnext, A3XX_VFD_DECODE_INSTR_SWITCHNEXT));
 
+			total_in += vp->inputs[i].ncomp;
 			j++;
 		}
 	}
 
 	OUT_PKT0(ring, REG_A3XX_VFD_CONTROL_0, 2);
-	OUT_RING(ring, A3XX_VFD_CONTROL_0_TOTALATTRTOVS(vp->total_in) |
+	OUT_RING(ring, A3XX_VFD_CONTROL_0_TOTALATTRTOVS(total_in) |
 			A3XX_VFD_CONTROL_0_PACKETSIZE(2) |
 			A3XX_VFD_CONTROL_0_STRMDECINSTRCNT(j) |
 			A3XX_VFD_CONTROL_0_STRMFETCHINSTRCNT(j));
diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_program.h b/src/gallium/drivers/freedreno/a3xx/fd3_program.h
index e0866c1..0439d39 100644
--- a/src/gallium/drivers/freedreno/a3xx/fd3_program.h
+++ b/src/gallium/drivers/freedreno/a3xx/fd3_program.h
@@ -100,6 +100,7 @@ struct fd3_shader_variant {
 		fd3_semantic semantic;
 		uint8_t regid;
 		uint8_t compmask;
+		uint8_t ncomp;
 		/* in theory inloc of fs should match outloc of vs: */
 		uint8_t inloc;
 		uint8_t bary;




More information about the mesa-commit mailing list