[Mesa-dev] [PATCH] radv: take unsafe_math and sisched into account when hashing shaders.
Timothy Arceri
tarceri at itsqueeze.com
Thu Oct 12 05:01:10 UTC 2017
Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>
On 12/10/17 15:11, Dave Airlie wrote:
> From: Dave Airlie <airlied at redhat.com>
>
> We want to generate different variants for sisched and unsafe_math
> shader variants, so add them to the hash key.
>
> Signed-off-by: Dave Airlie <airlied at redhat.com>
> ---
> src/amd/vulkan/radv_pipeline.c | 24 ++++++++++++++++++------
> src/amd/vulkan/radv_pipeline_cache.c | 4 ++--
> src/amd/vulkan/radv_private.h | 5 ++++-
> 3 files changed, 24 insertions(+), 9 deletions(-)
>
> diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c
> index 6219ad44ac6..5e409ce7670 100644
> --- a/src/amd/vulkan/radv_pipeline.c
> +++ b/src/amd/vulkan/radv_pipeline.c
> @@ -88,6 +88,17 @@ static void radv_dump_pipeline_stats(struct radv_device *device, struct radv_pip
> }
> }
>
> +static uint32_t get_hash_flags(struct radv_device *device)
> +{
> + uint32_t hash_flags = 0;
> +
> + if (device->instance->debug_flags & RADV_DEBUG_UNSAFE_MATH)
> + hash_flags |= RADV_HASH_SHADER_UNSAFE_MATH;
> + if (device->instance->perftest_flags & RADV_PERFTEST_SISCHED)
> + hash_flags |= RADV_HASH_SHADER_SISCHED;
> + return hash_flags;
> +}
> +
> static struct radv_shader_variant *
> radv_pipeline_compile(struct radv_pipeline *pipeline,
> struct radv_pipeline_cache *cache,
> @@ -104,16 +115,16 @@ radv_pipeline_compile(struct radv_pipeline *pipeline,
> nir_shader *nir;
> void *code = NULL;
> unsigned code_size = 0;
> -
> + unsigned hash_flags = get_hash_flags(pipeline->device);
> if (module->nir)
> _mesa_sha1_compute(module->nir->info.name,
> strlen(module->nir->info.name),
> module->sha1);
>
> - radv_hash_shader(sha1, module, entrypoint, spec_info, layout, key, 0);
> + radv_hash_shader(sha1, module, entrypoint, spec_info, layout, key, hash_flags);
> if (stage == MESA_SHADER_GEOMETRY)
> radv_hash_shader(gs_copy_sha1, module, entrypoint, spec_info,
> - layout, key, 1);
> + layout, key, hash_flags | RADV_HASH_SHADER_IS_GEOM_COPY_SHADER);
>
> variant = radv_create_shader_variant_from_pipeline_cache(pipeline->device,
> cache,
> @@ -218,6 +229,7 @@ radv_tess_pipeline_compile(struct radv_pipeline *pipeline,
> unsigned tes_code_size = 0, tcs_code_size = 0;
> struct ac_shader_variant_key tes_key;
> struct ac_shader_variant_key tcs_key;
> + unsigned hash_flags = get_hash_flags(pipeline->device);
>
> tes_key = radv_compute_tes_key(radv_pipeline_has_gs(pipeline),
> pipeline->shaders[MESA_SHADER_FRAGMENT]->info.fs.prim_id_input);
> @@ -226,7 +238,7 @@ radv_tess_pipeline_compile(struct radv_pipeline *pipeline,
> _mesa_sha1_compute(tes_module->nir->info.name,
> strlen(tes_module->nir->info.name),
> tes_module->sha1);
> - radv_hash_shader(tes_sha1, tes_module, tes_entrypoint, tes_spec_info, layout, &tes_key, 0);
> + radv_hash_shader(tes_sha1, tes_module, tes_entrypoint, tes_spec_info, layout, &tes_key, hash_flags);
>
> tes_variant = radv_create_shader_variant_from_pipeline_cache(pipeline->device,
> cache,
> @@ -240,7 +252,7 @@ radv_tess_pipeline_compile(struct radv_pipeline *pipeline,
> strlen(tcs_module->nir->info.name),
> tcs_module->sha1);
>
> - radv_hash_shader(tcs_sha1, tcs_module, tcs_entrypoint, tcs_spec_info, layout, &tcs_key, 0);
> + radv_hash_shader(tcs_sha1, tcs_module, tcs_entrypoint, tcs_spec_info, layout, &tcs_key, hash_flags);
>
> tcs_variant = radv_create_shader_variant_from_pipeline_cache(pipeline->device,
> cache,
> @@ -278,7 +290,7 @@ radv_tess_pipeline_compile(struct radv_pipeline *pipeline,
> strlen(tcs_module->nir->info.name),
> tcs_module->sha1);
>
> - radv_hash_shader(tcs_sha1, tcs_module, tcs_entrypoint, tcs_spec_info, layout, &tcs_key, 0);
> + radv_hash_shader(tcs_sha1, tcs_module, tcs_entrypoint, tcs_spec_info, layout, &tcs_key, hash_flags);
>
> tcs_variant = radv_shader_variant_create(pipeline->device, tcs_module, tcs_nir,
> layout, &tcs_key, &tcs_code,
> diff --git a/src/amd/vulkan/radv_pipeline_cache.c b/src/amd/vulkan/radv_pipeline_cache.c
> index 51fa3f1b31f..50d6646f6f0 100644
> --- a/src/amd/vulkan/radv_pipeline_cache.c
> +++ b/src/amd/vulkan/radv_pipeline_cache.c
> @@ -93,7 +93,7 @@ radv_hash_shader(unsigned char *hash, struct radv_shader_module *module,
> const VkSpecializationInfo *spec_info,
> const struct radv_pipeline_layout *layout,
> const struct ac_shader_variant_key *key,
> - uint32_t is_geom_copy_shader)
> + uint32_t flags)
> {
> struct mesa_sha1 ctx;
>
> @@ -109,7 +109,7 @@ radv_hash_shader(unsigned char *hash, struct radv_shader_module *module,
> spec_info->mapEntryCount * sizeof spec_info->pMapEntries[0]);
> _mesa_sha1_update(&ctx, spec_info->pData, spec_info->dataSize);
> }
> - _mesa_sha1_update(&ctx, &is_geom_copy_shader, 4);
> + _mesa_sha1_update(&ctx, &flags, 4);
> _mesa_sha1_final(&ctx, hash);
> }
>
> diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h
> index e673527811f..b82c3e0ed62 100644
> --- a/src/amd/vulkan/radv_private.h
> +++ b/src/amd/vulkan/radv_private.h
> @@ -962,13 +962,16 @@ struct radv_event {
> struct radv_shader_module;
> struct ac_shader_variant_key;
>
> +#define RADV_HASH_SHADER_IS_GEOM_COPY_SHADER (1 << 0)
> +#define RADV_HASH_SHADER_SISCHED (1 << 1)
> +#define RADV_HASH_SHADER_UNSAFE_MATH (1 << 2)
> void
> radv_hash_shader(unsigned char *hash, struct radv_shader_module *module,
> const char *entrypoint,
> const VkSpecializationInfo *spec_info,
> const struct radv_pipeline_layout *layout,
> const struct ac_shader_variant_key *key,
> - uint32_t is_geom_copy_shader);
> + uint32_t flags);
>
> static inline gl_shader_stage
> vk_to_mesa_shader_stage(VkShaderStageFlagBits vk_stage)
>
More information about the mesa-dev
mailing list