From: Marek Olšák Date: Thu, 14 Jun 2018 06:25:00 +0000 (-0400) Subject: radeonsi: store compute local_size into tgsi_shader_info X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d77557c9db21099b73e11ee9f88ffa5105cd184c;p=mesa.git radeonsi: store compute local_size into tgsi_shader_info This is kinda a hack, but it's enough for the shader cache. --- diff --git a/src/gallium/drivers/radeonsi/si_compute.c b/src/gallium/drivers/radeonsi/si_compute.c index fc419823bfa..6096766f694 100644 --- a/src/gallium/drivers/radeonsi/si_compute.c +++ b/src/gallium/drivers/radeonsi/si_compute.c @@ -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); diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c index 332e316b674..74a1855c976 100644 --- a/src/gallium/drivers/radeonsi/si_shader.c +++ b/src/gallium/drivers/radeonsi/si_shader.c @@ -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); diff --git a/src/gallium/drivers/radeonsi/si_shader.h b/src/gallium/drivers/radeonsi/si_shader.h index 0ca0a6b9679..fd2f71bed74 100644 --- a/src/gallium/drivers/radeonsi/si_shader.h +++ b/src/gallium/drivers/radeonsi/si_shader.h @@ -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 */ diff --git a/src/gallium/drivers/radeonsi/si_shader_nir.c b/src/gallium/drivers/radeonsi/si_shader_nir.c index d7e8ccd3047..6eb114ad5c0 100644 --- a/src/gallium/drivers/radeonsi/si_shader_nir.c +++ b/src/gallium/drivers/radeonsi/si_shader_nir.c @@ -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); }