From 096a026354cb31a1c858e5ffe18ba9a2a02a9d65 Mon Sep 17 00:00:00 2001 From: Gert Wollny Date: Sun, 12 Apr 2020 16:42:07 +0200 Subject: [PATCH] r600: Handle texcoord semantics in LDS index evaluation With NIR the texcoord semantic is enabled, and hence we have to handle index evaluation differently here. Signed-off-by: Gert Wollny Part-of: --- src/gallium/drivers/r600/r600_shader.c | 15 ++++++++------- src/gallium/drivers/r600/r600_shader.h | 2 +- src/gallium/drivers/r600/r600_state_common.c | 5 +++-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/gallium/drivers/r600/r600_shader.c b/src/gallium/drivers/r600/r600_shader.c index 734565baa22..ed0db0e114a 100644 --- a/src/gallium/drivers/r600/r600_shader.c +++ b/src/gallium/drivers/r600/r600_shader.c @@ -703,7 +703,7 @@ static int r600_spi_sid(struct r600_shader_io * io) }; /* we need this to get a common lds index for vs/tcs/tes input/outputs */ -int r600_get_lds_unique_index(unsigned semantic_name, unsigned index) +int r600_get_lds_unique_index(unsigned semantic_name, unsigned index, bool texcoord_semantics) { switch (semantic_name) { case TGSI_SEMANTIC_POSITION: @@ -715,7 +715,7 @@ int r600_get_lds_unique_index(unsigned semantic_name, unsigned index) return 2 + index; case TGSI_SEMANTIC_GENERIC: if (index <= 63-4) - return 4 + index - 9; + return 4 + index - (texcoord_semantics ? 0 : 9); else /* same explanation as in the default statement, * the only user hitting this is st/nine. @@ -1183,7 +1183,7 @@ static int tgsi_declaration(struct r600_shader_ctx *ctx) break; else if (d->Semantic.Name == TGSI_SEMANTIC_TESSINNER || d->Semantic.Name == TGSI_SEMANTIC_TESSOUTER) { - int param = r600_get_lds_unique_index(d->Semantic.Name, 0); + int param = r600_get_lds_unique_index(d->Semantic.Name, 0, false); int dreg = d->Semantic.Name == TGSI_SEMANTIC_TESSINNER ? 3 : 2; unsigned temp_reg = r600_get_temp(ctx); @@ -2089,11 +2089,11 @@ static int r600_get_byte_address(struct r600_shader_ctx *ctx, int temp_reg, return r; param = r600_get_lds_unique_index(name[first], - index[first]); + index[first], false); } else { param = r600_get_lds_unique_index(name[reg.Register.Index], - index[reg.Register.Index]); + index[reg.Register.Index], false); } /* add to base_addr - passed in temp_reg.x */ @@ -3036,7 +3036,8 @@ static int emit_lds_vs_writes(struct r600_shader_ctx *ctx) for (i = 0; i < ctx->shader->noutput; i++) { struct r600_bytecode_alu alu; - int param = r600_get_lds_unique_index(ctx->shader->output[i].name, ctx->shader->output[i].sid); + int param = r600_get_lds_unique_index(ctx->shader->output[i].name, + ctx->shader->output[i].sid, false); if (param) { r = single_alu_op2(ctx, ALU_OP2_ADD_INT, @@ -3170,7 +3171,7 @@ static int r600_tess_factor_read(struct r600_shader_ctx *ctx, int dreg = ctx->shader->output[output_idx].gpr; int r; - param = r600_get_lds_unique_index(name, 0); + param = r600_get_lds_unique_index(name, 0, false); r = get_lds_offset0(ctx, 1, temp_reg, true); if (r) return r; diff --git a/src/gallium/drivers/r600/r600_shader.h b/src/gallium/drivers/r600/r600_shader.h index 1e00a9527b5..06ff97fe9e0 100644 --- a/src/gallium/drivers/r600/r600_shader.h +++ b/src/gallium/drivers/r600/r600_shader.h @@ -189,7 +189,7 @@ struct r600_pipe_shader { TGSI_INTERPOLATE_LOC_CENTER/SAMPLE/COUNT. Other input values return -1. */ int eg_get_interpolator_index(unsigned interpolate, unsigned location); -int r600_get_lds_unique_index(unsigned semantic_name, unsigned index); +int r600_get_lds_unique_index(unsigned semantic_name, unsigned index, bool texcoord_semantics); int generate_gs_copy_shader(struct r600_context *rctx, struct r600_pipe_shader *gs, diff --git a/src/gallium/drivers/r600/r600_state_common.c b/src/gallium/drivers/r600/r600_state_common.c index 16d73f619dc..76dd9314132 100644 --- a/src/gallium/drivers/r600/r600_state_common.c +++ b/src/gallium/drivers/r600/r600_state_common.c @@ -956,6 +956,7 @@ static void *r600_create_shader_state(struct pipe_context *ctx, case PIPE_SHADER_TESS_CTRL: sel->lds_patch_outputs_written_mask = 0; sel->lds_outputs_written_mask = 0; + bool texxcoord_semantic = ctx->screen->get_param(ctx->screen, PIPE_CAP_TGSI_TEXCOORD); for (i = 0; i < sel->info.num_outputs; i++) { unsigned name = sel->info.output_semantic_name[i]; @@ -966,11 +967,11 @@ static void *r600_create_shader_state(struct pipe_context *ctx, case TGSI_SEMANTIC_TESSOUTER: case TGSI_SEMANTIC_PATCH: sel->lds_patch_outputs_written_mask |= - 1ull << r600_get_lds_unique_index(name, index); + 1ull << r600_get_lds_unique_index(name, index, texxcoord_semantic); break; default: sel->lds_outputs_written_mask |= - 1ull << r600_get_lds_unique_index(name, index); + 1ull << r600_get_lds_unique_index(name, index, texxcoord_semantic); } } break; -- 2.30.2