diff options
| author | Cort Stratton <cort@google.com> | 2017-11-06 19:13:53 -0800 |
|---|---|---|
| committer | Chris Forbes <chrisf@ijw.co.nz> | 2017-11-28 16:27:21 -0800 |
| commit | 892762a4fa928b7f1ec2e2d5ecb32481cdb6cbdd (patch) | |
| tree | 1dd997690322a2f57a30b6343559df8fb2352673 /layers | |
| parent | 604b8697d2ab561e482e70db4ee9856e2fa0627a (diff) | |
| download | usermoji-892762a4fa928b7f1ec2e2d5ecb32481cdb6cbdd.tar.xz | |
Use SPIRV-Tools commit ID as validation cache version
Diffstat (limited to 'layers')
| -rw-r--r-- | layers/shader_validation.h | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/layers/shader_validation.h b/layers/shader_validation.h index 99a784ca..069d1da7 100644 --- a/layers/shader_validation.h +++ b/layers/shader_validation.h @@ -20,6 +20,8 @@ #ifndef VULKAN_SHADER_VALIDATION_H #define VULKAN_SHADER_VALIDATION_H +#include <spirv_tools_commit_id.h> + // A forward iterator over spirv instructions. Provides easy access to len, opcode, and content words // without the caller needing to care too much about the physical SPIRV module layout. struct spirv_inst_iter { @@ -100,9 +102,6 @@ struct shader_module { void build_def_index(); }; -// TODO: Wire this up to SPIRV-Tools commit hash -#define VALIDATION_CACHE_VERSION 1 - class ValidationCache { // hashes of shaders that have passed validation before, and can be skipped. // we don't store negative results, as we would have to also store what was @@ -128,8 +127,8 @@ public: return; if (data[1] != VK_VALIDATION_CACHE_HEADER_VERSION_ONE_EXT) return; - if (data[2] != VALIDATION_CACHE_VERSION || data[3] || data[4] || data[5]) - return; // different version + if (strncmp((const char*)&data[2], SPIRV_TOOLS_COMMIT_ID, 16) != 0) + return; // different version data += 6; @@ -157,10 +156,13 @@ public: // Write the header *out++ = headerSize; *out++ = VK_VALIDATION_CACHE_HEADER_VERSION_ONE_EXT; - *out++ = VALIDATION_CACHE_VERSION; - *out++ = 0; - *out++ = 0; - *out++ = 0; + size_t commitIdSize = strlen(SPIRV_TOOLS_COMMIT_ID); + if (commitIdSize > 16) { + commitIdSize = 16; + } + out[0] = out[1] = out[2] = out[3] = 0; + memcpy(out, SPIRV_TOOLS_COMMIT_ID, commitIdSize); + out += 4; for (auto it = good_shader_hashes.begin(); it != good_shader_hashes.end() && actualSize < *pDataSize; |
