[Mesa-dev] [PATCH 5/5] utils/sha1: make _mesa_sha1_final a simple define around SHA1Final

Emil Velikov emil.l.velikov at gmail.com
Tue Jan 24 21:21:12 UTC 2017


From: Emil Velikov <emil.velikov at collabora.com>

Swap the argument order as applicable.

Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
---
Similar patch for _mesa_sha1_update will require a bunch of casting due
to the data type, which imho makes things uglier.
---
 src/amd/vulkan/radv_descriptor_set.c  | 2 +-
 src/amd/vulkan/radv_pipeline_cache.c  | 2 +-
 src/intel/vulkan/anv_descriptor_set.c | 2 +-
 src/intel/vulkan/anv_pipeline_cache.c | 2 +-
 src/util/mesa-sha1.h                  | 8 ++------
 5 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/src/amd/vulkan/radv_descriptor_set.c b/src/amd/vulkan/radv_descriptor_set.c
index 435b7394a3..e35ed99d71 100644
--- a/src/amd/vulkan/radv_descriptor_set.c
+++ b/src/amd/vulkan/radv_descriptor_set.c
@@ -219,7 +219,7 @@ VkResult radv_CreatePipelineLayout(
 	layout->push_constant_size = align(layout->push_constant_size, 16);
 	_mesa_sha1_update(&ctx, &layout->push_constant_size,
 			  sizeof(layout->push_constant_size));
-	_mesa_sha1_final(&ctx, layout->sha1);
+	_mesa_sha1_final(layout->sha1, &ctx);
 	*pPipelineLayout = radv_pipeline_layout_to_handle(layout);
 
 	return VK_SUCCESS;
diff --git a/src/amd/vulkan/radv_pipeline_cache.c b/src/amd/vulkan/radv_pipeline_cache.c
index 1bfdbe804c..164d38fc96 100644
--- a/src/amd/vulkan/radv_pipeline_cache.c
+++ b/src/amd/vulkan/radv_pipeline_cache.c
@@ -104,7 +104,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_final(&ctx, hash);
+	_mesa_sha1_final(hash, &ctx);
 }
 
 
diff --git a/src/intel/vulkan/anv_descriptor_set.c b/src/intel/vulkan/anv_descriptor_set.c
index 29bb67c5c3..05a9828aab 100644
--- a/src/intel/vulkan/anv_descriptor_set.c
+++ b/src/intel/vulkan/anv_descriptor_set.c
@@ -271,7 +271,7 @@ VkResult anv_CreatePipelineLayout(
       _mesa_sha1_update(&ctx, &layout->stage[s].has_dynamic_offsets,
                         sizeof(layout->stage[s].has_dynamic_offsets));
    }
-   _mesa_sha1_final(&ctx, layout->sha1);
+   _mesa_sha1_final(layout->sha1, &ctx);
 
    *pPipelineLayout = anv_pipeline_layout_to_handle(layout);
 
diff --git a/src/intel/vulkan/anv_pipeline_cache.c b/src/intel/vulkan/anv_pipeline_cache.c
index 0b677a49f3..b34bffaca4 100644
--- a/src/intel/vulkan/anv_pipeline_cache.c
+++ b/src/intel/vulkan/anv_pipeline_cache.c
@@ -221,7 +221,7 @@ anv_hash_shader(unsigned char *hash, const void *key, size_t key_size,
                         spec_info->mapEntryCount * sizeof spec_info->pMapEntries[0]);
       _mesa_sha1_update(&ctx, spec_info->pData, spec_info->dataSize);
    }
-   _mesa_sha1_final(&ctx, hash);
+   _mesa_sha1_final(hash, &ctx);
 }
 
 static struct anv_shader_bin *
diff --git a/src/util/mesa-sha1.h b/src/util/mesa-sha1.h
index 02dd5f81bf..bab81299c6 100644
--- a/src/util/mesa-sha1.h
+++ b/src/util/mesa-sha1.h
@@ -40,11 +40,7 @@ _mesa_sha1_update(struct mesa_sha1 *ctx, const void *data, int size)
    SHA1Update(ctx, data, size);
 }
 
-static inline void
-_mesa_sha1_final(struct mesa_sha1 *ctx, unsigned char result[20])
-{
-   SHA1Final(result, ctx);
-}
+#define _mesa_sha1_final SHA1Final
 
 static inline void
 _mesa_sha1_format(char *buf, const unsigned char *sha1)
@@ -66,7 +62,7 @@ _mesa_sha1_compute(const void *data, size_t size, unsigned char result[20])
 
    _mesa_sha1_init(&ctx);
    _mesa_sha1_update(&ctx, data, size);
-   _mesa_sha1_final(&ctx, result);
+   _mesa_sha1_final(result, &ctx);
 }
 
 
-- 
2.11.0



More information about the mesa-dev mailing list