radv: store the shader sha1 to radv_pipeline_stage

To remove use of shader modules completely in the next commit.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15847>
This commit is contained in:
Samuel Pitoiset
2022-04-08 15:55:19 +02:00
committed by Marge Bot
parent c1b9c1269d
commit b48231cb90
3 changed files with 35 additions and 16 deletions
+24 -1
View File
@@ -4086,6 +4086,25 @@ radv_lower_fs_output(nir_shader *nir, const struct radv_pipeline_key *pipeline_k
return progress;
}
static void
radv_pipeline_hash_shader(const unsigned char *spirv_sha1, const uint32_t spirv_sha1_size,
const char *entrypoint, gl_shader_stage stage,
const VkSpecializationInfo *spec_info, unsigned char *sha1_out)
{
struct mesa_sha1 ctx;
_mesa_sha1_init(&ctx);
_mesa_sha1_update(&ctx, spirv_sha1, spirv_sha1_size);
_mesa_sha1_update(&ctx, entrypoint, strlen(entrypoint));
if (spec_info) {
_mesa_sha1_update(&ctx, spec_info->pMapEntries,
spec_info->mapEntryCount * sizeof(*spec_info->pMapEntries));
_mesa_sha1_update(&ctx, spec_info->pData, spec_info->dataSize);
}
_mesa_sha1_final(&ctx, sha1_out);
}
VkResult
radv_create_shaders(struct radv_pipeline *pipeline, struct radv_pipeline_layout *pipeline_layout,
struct radv_device *device, struct radv_pipeline_cache *cache,
@@ -4134,6 +4153,10 @@ radv_create_shaders(struct radv_pipeline *pipeline, struct radv_pipeline_layout
stages[stage].module->sha1);
}
radv_pipeline_hash_shader(stages[stage].module->sha1, sizeof(stages[stage].module->sha1),
stages[stage].entrypoint, stage, stages[stage].spec_info,
stages[stage].shader_sha1);
pipeline->active_stages |= sinfo->stage;
}
@@ -4161,7 +4184,7 @@ radv_create_shaders(struct radv_pipeline *pipeline, struct radv_pipeline_layout
if (custom_hash)
memcpy(hash, custom_hash, 20);
else {
radv_hash_shaders(hash, pStages, stageCount, pipeline_layout, pipeline_key,
radv_hash_shaders(hash, stages, pipeline_layout, pipeline_key,
radv_get_hash_flags(device, keep_statistic_info));
}
+7 -13
View File
@@ -118,9 +118,9 @@ entry_size(struct cache_entry *entry)
}
void
radv_hash_shaders(unsigned char *hash, const VkPipelineShaderStageCreateInfo *stages,
uint32_t stageCount, const struct radv_pipeline_layout *layout,
const struct radv_pipeline_key *key, uint32_t flags)
radv_hash_shaders(unsigned char *hash, const struct radv_pipeline_stage *stages,
const struct radv_pipeline_layout *layout, const struct radv_pipeline_key *key,
uint32_t flags)
{
struct mesa_sha1 ctx;
@@ -130,17 +130,11 @@ radv_hash_shaders(unsigned char *hash, const VkPipelineShaderStageCreateInfo *st
if (layout)
_mesa_sha1_update(&ctx, layout->sha1, sizeof(layout->sha1));
for (uint32_t i = 0; i < stageCount; i++) {
RADV_FROM_HANDLE(vk_shader_module, module, stages[i].module);
const VkSpecializationInfo *spec_info = stages[i].pSpecializationInfo;
for (unsigned s = 0; s < MESA_VULKAN_SHADER_STAGES; s++) {
if (!stages[s].entrypoint)
continue;
_mesa_sha1_update(&ctx, module->sha1, sizeof(module->sha1));
_mesa_sha1_update(&ctx, stages[i].pName, strlen(stages[i].pName));
if (spec_info && spec_info->mapEntryCount) {
_mesa_sha1_update(&ctx, spec_info->pMapEntries,
spec_info->mapEntryCount * sizeof spec_info->pMapEntries[0]);
_mesa_sha1_update(&ctx, spec_info->pData, spec_info->dataSize);
}
_mesa_sha1_update(&ctx, stages[s].shader_sha1, sizeof(stages[s].shader_sha1));
}
_mesa_sha1_update(&ctx, &flags, 4);
_mesa_sha1_final(&ctx, hash);
+4 -2
View File
@@ -1746,8 +1746,8 @@ struct radv_event {
struct radv_pipeline_key;
void radv_hash_shaders(unsigned char *hash, const VkPipelineShaderStageCreateInfo *stages,
uint32_t stageCount, const struct radv_pipeline_layout *layout,
void radv_hash_shaders(unsigned char *hash, const struct radv_pipeline_stage *stages,
const struct radv_pipeline_layout *layout,
const struct radv_pipeline_key *key, uint32_t flags);
void radv_hash_rt_shaders(unsigned char *hash, const VkRayTracingPipelineCreateInfoKHR *pCreateInfo,
@@ -1932,6 +1932,8 @@ struct radv_pipeline_stage {
const char *entrypoint;
const VkSpecializationInfo *spec_info;
unsigned char shader_sha1[20];
nir_shader *nir;
struct radv_shader_info info;