r600: Handle texcoord semantics in LDS index evaluation
authorGert Wollny <gert.wollny@collabora.com>
Sun, 12 Apr 2020 14:42:07 +0000 (16:42 +0200)
committerMarge Bot <eric+marge@anholt.net>
Tue, 28 Apr 2020 08:06:33 +0000 (08:06 +0000)
With NIR the texcoord semantic is enabled, and hence we have to handle
index evaluation differently here.

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4714>

src/gallium/drivers/r600/r600_shader.c
src/gallium/drivers/r600/r600_shader.h
src/gallium/drivers/r600/r600_state_common.c

index 734565baa22d98c754ca629ea7d81f993578e12e..ed0db0e114abce4779135929a7c21fb37513284e 100644 (file)
@@ -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;
index 1e00a9527b521bb1c4afc1ca3e6a49e551bddc2e..06ff97fe9e06d206e49a73a29d706989482febcb 100644 (file)
@@ -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,
index 16d73f619dc717fdd095daba5f6dc53246a2e8be..76dd931413220436c37d5a4f2f8e21dc4e38e0f6 100644 (file)
@@ -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;