shader_recompiler: Emulate unnormalized sampler coordinates in shader. (#1762)

* shader_recompiler: Emulate unnormalized sampler coordinates in shader.

* Address review comments.
This commit is contained in:
squidbus 2024-12-13 11:49:07 -08:00 committed by GitHub
parent 306279901f
commit 028be3ba5d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 78 additions and 12 deletions

View file

@ -49,6 +49,12 @@ struct FMaskSpecialization {
auto operator<=>(const FMaskSpecialization&) const = default;
};
struct SamplerSpecialization {
bool force_unnormalized = false;
auto operator<=>(const SamplerSpecialization&) const = default;
};
/**
* Alongside runtime information, this structure also checks bound resources
* for compatibility. Can be used as a key for storing shader permutations.
@ -67,6 +73,7 @@ struct StageSpecialization {
boost::container::small_vector<TextureBufferSpecialization, 8> tex_buffers;
boost::container::small_vector<ImageSpecialization, 16> images;
boost::container::small_vector<FMaskSpecialization, 8> fmasks;
boost::container::small_vector<SamplerSpecialization, 16> samplers;
Backend::Bindings start{};
explicit StageSpecialization(const Info& info_, RuntimeInfo runtime_info_,
@ -107,6 +114,10 @@ struct StageSpecialization {
spec.width = sharp.width;
spec.height = sharp.height;
});
ForEachSharp(samplers, info->samplers,
[](auto& spec, const auto& desc, AmdGpu::Sampler sharp) {
spec.force_unnormalized = sharp.force_unnormalized;
});
}
void ForEachSharp(auto& spec_list, auto& desc_list, auto&& func) {
@ -175,6 +186,11 @@ struct StageSpecialization {
return false;
}
}
for (u32 i = 0; i < samplers.size(); i++) {
if (samplers[i] != other.samplers[i]) {
return false;
}
}
return true;
}
};