Cleanup: Move specialization constant default hash #120889

Merged
Jeroen Bakker merged 1 commits from Jeroen-Bakker/blender:gpu/cleanup/move-specialization-default-hash into main 2024-04-21 16:56:14 +02:00
2 changed files with 18 additions and 17 deletions

View File

@ -13,6 +13,7 @@
#pragma once
#include "BLI_hash.hh"
#include "BLI_string_ref.hh"
#include "BLI_vector.hh"
#include "GPU_material.hh"
@ -1223,3 +1224,18 @@ struct ShaderCreateInfo {
};
} // namespace blender::gpu::shader
namespace blender {
template<>
struct DefaultHash<Vector<gpu::shader::ShaderCreateInfo::SpecializationConstant::Value>> {
uint64_t operator()(
const Vector<gpu::shader::ShaderCreateInfo::SpecializationConstant::Value> &key) const
{
uint64_t hash = 0;
for (const gpu::shader::ShaderCreateInfo::SpecializationConstant::Value &value : key) {
hash = hash * 33 + value.u;
}
return hash;
}
};
} // namespace blender

View File

@ -17,21 +17,7 @@
#include "gpu_shader_create_info.hh"
#include "gpu_shader_private.hh"
namespace blender {
template<>
struct DefaultHash<Vector<gpu::shader::ShaderCreateInfo::SpecializationConstant::Value>> {
uint64_t operator()(
const Vector<gpu::shader::ShaderCreateInfo::SpecializationConstant::Value> &key) const
{
uint64_t hash = 0;
for (const gpu::shader::ShaderCreateInfo::SpecializationConstant::Value &value : key) {
hash = hash * 33 + value.u;
}
return hash;
}
};
namespace gpu {
namespace blender::gpu {
/**
* Shaders that uses specialization constants must keep track of the sources in order to rebuild
@ -231,5 +217,4 @@ class GLLogParser : public GPULogParser {
MEM_CXX_CLASS_ALLOC_FUNCS("GLLogParser");
};
} // namespace gpu
} // namespace blender
} // namespace blender::gpu