[Mesa-dev] [PATCH 2/3] r600g: take into account offset to system inputs at tgsi_interp_egcm()

Constantine Kharlamov Hi-Angel at yandex.ru
Sat Jun 24 12:52:04 UTC 2017


Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=100785

Signed-off-by: Constantine Kharlamov <Hi-Angel at yandex.ru>
---
 src/gallium/drivers/r600/r600_shader.c | 8 ++++----
 src/gallium/drivers/r600/r600_shader.h | 5 +++--
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_shader.c b/src/gallium/drivers/r600/r600_shader.c
index 156dba085d..a431e937ef 100644
--- a/src/gallium/drivers/r600/r600_shader.c
+++ b/src/gallium/drivers/r600/r600_shader.c
@@ -1127,6 +1127,7 @@ static int allocate_system_value_inputs(struct r600_shader_ctx *ctx, int gpr_off
 
 	tgsi_parse_free(&parse);
 
+	ctx->shader->nsys_inputs = 0;
 	for (i = 0; i < ARRAY_SIZE(inputs); i++) {
 		boolean enabled = inputs[i].enabled;
 		int *reg = inputs[i].reg;
@@ -1134,9 +1135,10 @@ static int allocate_system_value_inputs(struct r600_shader_ctx *ctx, int gpr_off
 
 		if (enabled) {
 			int gpr = gpr_offset + num_regs++;
+			ctx->shader->nsys_inputs++;
 
 			// add to inputs, allocate a gpr
-			k = ctx->shader->ninput ++;
+			k = ctx->shader->ninput++;
 			ctx->shader->input[k].name = name;
 			ctx->shader->input[k].sid = 0;
 			ctx->shader->input[k].interpolate = TGSI_INTERPOLATE_CONSTANT;
@@ -6322,12 +6324,10 @@ static int tgsi_interp_egcm(struct r600_shader_ctx *ctx)
 	struct r600_bytecode_alu alu;
 	int r, i = 0, k, interp_gpr, interp_base_chan, tmp, lasti;
 	unsigned location;
-	int input;
+	const int input = inst->Src[0].Register.Index + ctx->shader->nsys_inputs;
 
 	assert(inst->Src[0].Register.File == TGSI_FILE_INPUT);
 
-	input = inst->Src[0].Register.Index;
-
 	/* Interpolators have been marked for use already by allocate_system_value_inputs */
 	if (inst->Instruction.Opcode == TGSI_OPCODE_INTERP_OFFSET ||
 		inst->Instruction.Opcode == TGSI_OPCODE_INTERP_SAMPLE) {
diff --git a/src/gallium/drivers/r600/r600_shader.h b/src/gallium/drivers/r600/r600_shader.h
index cfdb020033..9032d50838 100644
--- a/src/gallium/drivers/r600/r600_shader.h
+++ b/src/gallium/drivers/r600/r600_shader.h
@@ -49,11 +49,11 @@ struct r600_shader_io {
 	int			spi_sid;
 	unsigned		interpolate;
 	unsigned		ij_index;
-	unsigned        interpolate_location; //  TGSI_INTERPOLATE_LOC_CENTER, CENTROID, SAMPLE
+	unsigned		interpolate_location; //  TGSI_INTERPOLATE_LOC_CENTER, CENTROID, SAMPLE
 	unsigned		lds_pos; /* for evergreen */
 	unsigned		back_color_input;
 	unsigned		write_mask;
-	int				ring_offset;
+	int			ring_offset;
 };
 
 struct r600_shader {
@@ -62,6 +62,7 @@ struct r600_shader {
 	unsigned		ninput;
 	unsigned		noutput;
 	unsigned		nlds;
+	unsigned		nsys_inputs;
 	struct r600_shader_io	input[64];
 	struct r600_shader_io	output[64];
 	boolean			uses_kill;
-- 
2.13.1



More information about the mesa-dev mailing list