[dxvk] Compute SHA-1 hash of generated shaders

This commit is contained in:
Philip Rebohle 2018-05-03 20:07:42 +02:00
parent 3a3b1eda59
commit 33357f1f36
3 changed files with 19 additions and 0 deletions

View File

@ -12,6 +12,8 @@
#include "../util/rc/util_rc.h"
#include "../util/rc/util_rc_ptr.h"
#include "../util/sha1/sha1_util.h"
#include "../util/sync/sync_spinlock.h"
#include "./vulkan/dxvk_vulkan_extensions.h"

View File

@ -47,6 +47,12 @@ namespace dxvk {
const DxvkInterfaceSlots& iface,
const SpirvCodeBuffer& code)
: m_stage(stage), m_code(code), m_interface(iface) {
// Compute shader hash once
m_hash = Sha1Hash::compute(
reinterpret_cast<const uint8_t*>(code.data()),
code.size());
// Write back resource slot infos
for (uint32_t i = 0; i < slotCount; i++)
m_slots.push_back(slotInfos[i]);

View File

@ -170,10 +170,21 @@ namespace dxvk {
m_debugName = name;
}
/**
* \brief Shader hash
*
* The SHA-1 hash of the generated SPIR-V shader.
* \returns SHA-1 hash of this shader
*/
Sha1Hash hash() const {
return m_hash;
}
private:
VkShaderStageFlagBits m_stage;
SpirvCodeBuffer m_code;
Sha1Hash m_hash;
std::vector<DxvkResourceSlot> m_slots;
std::vector<size_t> m_idOffsets;