[Mesa-dev] [PATCH 37/53] r600/shader: add get_lds_offset0 helper

Dave Airlie airlied at gmail.com
Sun Nov 29 22:20:46 PST 2015


From: Dave Airlie <airlied at redhat.com>

This retrievs the offset into the LDS for a patch or
non-patch variable, it takes the RelPatch channel
and a temporary register.

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 src/gallium/drivers/r600/r600_shader.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/src/gallium/drivers/r600/r600_shader.c b/src/gallium/drivers/r600/r600_shader.c
index 950bbf9..a5fb80d 100644
--- a/src/gallium/drivers/r600/r600_shader.c
+++ b/src/gallium/drivers/r600/r600_shader.c
@@ -724,6 +724,34 @@ static int single_alu_op2(struct r600_shader_ctx *ctx, int op,
 	return 0;
 }
 
+/* put it in temp_reg.x */
+static int get_lds_offset0(struct r600_shader_ctx *ctx,
+			   int rel_patch_chan,
+			   int temp_reg, bool is_patch_var)
+{
+	int r;
+
+	/* MUL temp.x, patch_stride (input_vals.x), rel_patch_id (r0.y (tcs)) */
+	r = single_alu_op2(ctx, ALU_OP2_MULLO_INT,
+			   temp_reg, 0,
+			   ctx->tess_output_info, 0,
+			   0, rel_patch_chan);
+	if (r)
+		return r;
+
+	/* ADD temp.x, temp.x,
+	   Dimension - patch0_offset (input_vals.z),
+	   Non-dim - patch0_data_offset (input_vals.w)
+	*/
+	r = single_alu_op2(ctx, ALU_OP2_ADD_INT,
+			   temp_reg, 0,
+			   temp_reg, 0,
+			   ctx->tess_output_info, is_patch_var ? 3 : 2);
+	if (r)
+		return r;
+	return 0;
+}
+
 static inline int get_address_file_reg(struct r600_shader_ctx *ctx, int index)
 {
 	return index > 0 ? ctx->bc->index_reg[index - 1] : ctx->bc->ar_reg;
-- 
2.5.0



More information about the mesa-dev mailing list