[Mesa-dev] [PATCH v4 2/4] r600 shader: Add extra function to evaluate array index

Gert Wollny gw.fossdev at gmail.com
Mon Jul 16 08:26:18 UTC 2018


From: Gert Wollny <gert.wollny at collabora.com>

The added function evaluates the array index according to the function

    idx = floor(ai + 0.5);

Signed-off-by: Gert Wollny <gert.wollny at collabora.com>
---
 src/gallium/drivers/r600/r600_shader.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/src/gallium/drivers/r600/r600_shader.c b/src/gallium/drivers/r600/r600_shader.c
index 6655b000aa..e2f44afc05 100644
--- a/src/gallium/drivers/r600/r600_shader.c
+++ b/src/gallium/drivers/r600/r600_shader.c
@@ -7448,6 +7448,40 @@ static int r600_do_buffer_txq(struct r600_shader_ctx *ctx, int reg_idx, int offs
 	}
 }
 
+/* Evaluate the texture array index according to floor(z+0.5) */
+static int r600_shader_evaluate_array_index(struct r600_bytecode_alu *alu,
+														  int reg, int chan, int rel,
+														  struct r600_bytecode *bc)
+{
+	int r;
+
+	/* evaluate array index according to floor(z+0.5) */
+	alu->op = ALU_OP2_ADD;
+	alu->src[1].sel = V_SQ_ALU_SRC_0_5;
+	alu->dst.sel = reg;
+	alu->dst.chan = chan;
+	alu->dst.rel = rel;
+	alu->dst.write = 1;
+	alu->last = 1;
+	r = r600_bytecode_add_alu(bc, alu);
+	if (r)
+		return r;
+
+	memset(alu, 0, sizeof(struct r600_bytecode_alu));
+	alu->op = ALU_OP1_FLOOR;
+	alu->src[0].sel = reg;
+	alu->src[0].chan = chan;
+	alu->src[0].rel = rel;
+	alu->dst.sel = reg;
+	alu->dst.chan = chan;
+	alu->dst.rel = rel;
+	alu->dst.write = 1;
+	alu->last = 1;
+	r = r600_bytecode_add_alu(bc, alu);
+	if (r)
+		return r;
+	return 0;
+}
 
 static int tgsi_tex(struct r600_shader_ctx *ctx)
 {
-- 
2.16.4



More information about the mesa-dev mailing list