MCPcopy Create free account
hub / github.com/KhronosGroup/Vulkan-ValidationLayers / Write

Method Write

layers/utils/shader_utils.cpp:80–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78}
79
80void ValidationCache::Write(size_t* pDataSize, void* pData) {
81 const auto header_size = 2 * sizeof(uint32_t) + VK_UUID_SIZE; // 4 bytes for header size + 4 bytes for version number + UUID
82 if (!pData) {
83 *pDataSize = header_size + good_shader_hashes_.size() * sizeof(uint32_t);
84 return;
85 }
86
87 if (*pDataSize < header_size) {
88 *pDataSize = 0;
89 return; // Too small for even the header!
90 }
91
92 uint32_t* out = (uint32_t*)pData;
93 size_t actual_size = header_size;
94
95 // Write the header
96 *out++ = header_size;
97 *out++ = VK_VALIDATION_CACHE_HEADER_VERSION_ONE_EXT;
98 GetUUID(reinterpret_cast<uint8_t*>(out));
99 out = (uint32_t*)(reinterpret_cast<uint8_t*>(out) + VK_UUID_SIZE);
100
101 {
102 auto guard = ReadLock();
103 for (auto it = good_shader_hashes_.begin(); it != good_shader_hashes_.end() && actual_size < *pDataSize;
104 it++, out++, actual_size += sizeof(uint32_t)) {
105 *out = *it;
106 }
107 }
108
109 *pDataSize = actual_size;
110}
111
112void ValidationCache::Merge(ValidationCache const* other) {
113 // self-merging is invalid, but avoid deadlock below just in case.

Callers 1

Calls 4

ReadLockClass · 0.85
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected