radeonsi: store compute local_size into tgsi_shader_info
authorMarek Olšák <marek.olsak@amd.com>
Thu, 14 Jun 2018 06:25:00 +0000 (02:25 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Fri, 29 Jun 2018 02:27:25 +0000 (22:27 -0400)
This is kinda a hack, but it's enough for the shader cache.

src/gallium/drivers/radeonsi/si_compute.c
src/gallium/drivers/radeonsi/si_shader.c
src/gallium/drivers/radeonsi/si_shader.h
src/gallium/drivers/radeonsi/si_shader_nir.c

index fc419823bfa8af6b480a5cc18fbfc40e76f309c2..6096766f694571b1787fae62626bd010310181d7 100644 (file)
@@ -109,9 +109,12 @@ static void si_create_compute_state_async(void *job, int thread_index)
                si_lower_nir(&sel);
        }
 
+       /* Store the declared LDS size into tgsi_shader_info for the shader
+        * cache to include it.
+        */
+       sel.info.properties[TGSI_PROPERTY_CS_LOCAL_SIZE] = program->local_size;
 
        sel.type = PIPE_SHADER_COMPUTE;
-       sel.local_size = program->local_size;
        si_get_active_slot_masks(&sel.info,
                                 &program->active_const_and_shader_buffers,
                                 &program->active_samplers_and_images);
index 332e316b6746d05666272c03f563fc9738fdb397..74a1855c976ac0390698ed9c9021db3805e6ac3d 100644 (file)
@@ -2297,6 +2297,7 @@ void si_load_system_value(struct si_shader_context *ctx,
 void si_declare_compute_memory(struct si_shader_context *ctx)
 {
        struct si_shader_selector *sel = ctx->shader->selector;
+       unsigned lds_size = sel->info.properties[TGSI_PROPERTY_CS_LOCAL_SIZE];
 
        LLVMTypeRef i8p = LLVMPointerType(ctx->i8, AC_LOCAL_ADDR_SPACE);
        LLVMValueRef var;
@@ -2304,7 +2305,7 @@ void si_declare_compute_memory(struct si_shader_context *ctx)
        assert(!ctx->ac.lds);
 
        var = LLVMAddGlobalInAddressSpace(ctx->ac.module,
-                                         LLVMArrayType(ctx->i8, sel->local_size),
+                                         LLVMArrayType(ctx->i8, lds_size),
                                          "compute_lds",
                                          AC_LOCAL_ADDR_SPACE);
        LLVMSetAlignment(var, 4);
index 0ca0a6b9679279d1b3c8c1122fd8399075e7c03b..fd2f71bed74da53472b21b3dc36d9054522bd65e 100644 (file)
@@ -277,6 +277,9 @@ enum {
 };
 
 enum {
+       /* Use a property enum that CS wouldn't use. */
+       TGSI_PROPERTY_CS_LOCAL_SIZE = TGSI_PROPERTY_FS_COORD_ORIGIN,
+
        /* Use a property enum that VS wouldn't use. */
        TGSI_PROPERTY_VS_BLIT_SGPRS = TGSI_PROPERTY_FS_COORD_ORIGIN,
 
@@ -390,9 +393,6 @@ struct si_shader_selector {
         */
        unsigned        colors_written_4bit;
 
-       /* CS parameters */
-       unsigned local_size;
-
        uint64_t        outputs_written_before_ps; /* "get_unique_index" bits */
        uint64_t        outputs_written;        /* "get_unique_index" bits */
        uint32_t        patch_outputs_written;  /* "get_unique_index_patch" bits */
index d7e8ccd304739ff2457abb4ff99a0e8a837c9f2f..6eb114ad5c086870c1f492b89d0a4a56f7f47efa 100644 (file)
@@ -999,7 +999,7 @@ bool si_nir_build_llvm(struct si_shader_context *ctx, struct nir_shader *nir)
        ctx->num_samplers = util_last_bit(info->samplers_declared);
        ctx->num_images = util_last_bit(info->images_declared);
 
-       if (ctx->shader->selector->local_size) {
+       if (ctx->shader->selector->info.properties[TGSI_PROPERTY_CS_LOCAL_SIZE]) {
                assert(nir->info.stage == MESA_SHADER_COMPUTE);
                si_declare_compute_memory(ctx);
        }