[dxvk] Make DxvkShaderModuleCreateInfo usable with lookup tables

This commit is contained in:
Philip Rebohle 2022-07-31 00:01:12 +02:00
parent 9cb0d6d610
commit 32c2d91961
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 35 additions and 0 deletions

View File

@ -10,6 +10,37 @@
namespace dxvk {
bool DxvkShaderModuleCreateInfo::eq(const DxvkShaderModuleCreateInfo& other) const {
bool eq = fsDualSrcBlend == other.fsDualSrcBlend
&& undefinedInputs == other.undefinedInputs;
for (uint32_t i = 0; i < rtSwizzles.size() && eq; i++) {
eq = rtSwizzles[i].r == other.rtSwizzles[i].r
&& rtSwizzles[i].g == other.rtSwizzles[i].g
&& rtSwizzles[i].b == other.rtSwizzles[i].b
&& rtSwizzles[i].a == other.rtSwizzles[i].a;
}
return eq;
}
size_t DxvkShaderModuleCreateInfo::hash() const {
DxvkHashState hash;
hash.add(uint32_t(fsDualSrcBlend));
hash.add(undefinedInputs);
for (uint32_t i = 0; i < rtSwizzles.size(); i++) {
hash.add(rtSwizzles[i].r);
hash.add(rtSwizzles[i].g);
hash.add(rtSwizzles[i].b);
hash.add(rtSwizzles[i].a);
}
return hash;
}
DxvkShader::DxvkShader(
const DxvkShaderCreateInfo& info,
SpirvCodeBuffer&& spirv)

View File

@ -66,6 +66,10 @@ namespace dxvk {
uint32_t undefinedInputs = 0;
std::array<VkComponentMapping, MaxNumRenderTargets> rtSwizzles = { };
bool eq(const DxvkShaderModuleCreateInfo& other) const;
size_t hash() const;
};