aboutsummaryrefslogtreecommitdiffstats
path: root/src/amd/vulkan/radv_pipeline_cache.c
diff options
context:
space:
mode:
authorBas Nieuwenhuizen <[email protected]>2017-10-14 12:42:40 +1100
committerTimothy Arceri <[email protected]>2017-10-18 09:19:35 +1100
commited9218f1541ff35fb34b5e7dd60a509b5a4144a4 (patch)
tree9d3ed6ab83ee534a71a83db0a3546ad826d63d57 /src/amd/vulkan/radv_pipeline_cache.c
parent7f29055751e6b89f4c87bc5e4602046c2cbdc08c (diff)
radv: add radv_hash_shaders() helper
This will be used to create a hash of the combined shaders in the pipeline. Signed-off-by: Timothy Arceri <[email protected]> Acked-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src/amd/vulkan/radv_pipeline_cache.c')
-rw-r--r--src/amd/vulkan/radv_pipeline_cache.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/amd/vulkan/radv_pipeline_cache.c b/src/amd/vulkan/radv_pipeline_cache.c
index d721f8b9f9e..7924be0c909 100644
--- a/src/amd/vulkan/radv_pipeline_cache.c
+++ b/src/amd/vulkan/radv_pipeline_cache.c
@@ -122,6 +122,39 @@ radv_hash_shader(unsigned char *hash, struct radv_shader_module *module,
_mesa_sha1_final(&ctx, hash);
}
+void
+radv_hash_shaders(unsigned char *hash,
+ const VkPipelineShaderStageCreateInfo **stages,
+ const struct radv_pipeline_layout *layout,
+ const struct ac_shader_variant_key *keys,
+ uint32_t flags)
+{
+ struct mesa_sha1 ctx;
+
+ _mesa_sha1_init(&ctx);
+ if (keys)
+ _mesa_sha1_update(&ctx, keys, sizeof(*keys) * MESA_SHADER_STAGES);
+ if (layout)
+ _mesa_sha1_update(&ctx, layout->sha1, sizeof(layout->sha1));
+
+ for (int i = 0; i < MESA_SHADER_STAGES; ++i) {
+ if (stages[i]) {
+ RADV_FROM_HANDLE(radv_shader_module, module, stages[i]->module);
+ const VkSpecializationInfo *spec_info = stages[i]->pSpecializationInfo;
+
+ _mesa_sha1_update(&ctx, module->sha1, sizeof(module->sha1));
+ _mesa_sha1_update(&ctx, stages[i]->pName, strlen(stages[i]->pName));
+ if (spec_info) {
+ _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, &flags, 4);
+ _mesa_sha1_final(&ctx, hash);
+}
+
static struct cache_entry *
radv_pipeline_cache_search_unlocked(struct radv_pipeline_cache *cache,