Shader specialization

This commit is contained in:
Lander Gallastegi 2024-11-13 23:19:46 +01:00
parent 008d2ac1db
commit fe3b41c64b

View File

@ -26,8 +26,15 @@ struct TextureBufferSpecialization {
}; };
struct ImageSpecialization { struct ImageSpecialization {
enum class Normalization : u8 {
None,
Signed,
Unsigned,
};
AmdGpu::ImageType type = AmdGpu::ImageType::Color2D; AmdGpu::ImageType type = AmdGpu::ImageType::Color2D;
bool is_integer = false; bool is_integer = false;
Normalization normalization = Normalization::None;
auto operator<=>(const ImageSpecialization&) const = default; auto operator<=>(const ImageSpecialization&) const = default;
}; };
@ -73,11 +80,17 @@ struct StageSpecialization {
[](auto& spec, const auto& desc, AmdGpu::Buffer sharp) { [](auto& spec, const auto& desc, AmdGpu::Buffer sharp) {
spec.is_integer = AmdGpu::IsInteger(sharp.GetNumberFmt()); spec.is_integer = AmdGpu::IsInteger(sharp.GetNumberFmt());
}); });
ForEachSharp(binding, images, info->images, ForEachSharp(
[](auto& spec, const auto& desc, AmdGpu::Image sharp) { binding, images, info->images, [](auto& spec, const auto& desc, AmdGpu::Image sharp) {
spec.type = sharp.IsPartialCubemap() ? AmdGpu::ImageType::Color2DArray spec.type =
: sharp.GetType(); sharp.IsPartialCubemap() ? AmdGpu::ImageType::Color2DArray : sharp.GetType();
spec.is_integer = AmdGpu::IsInteger(sharp.GetNumberFmt()); spec.is_integer = AmdGpu::IsInteger(sharp.GetNumberFmt());
if (sharp.NeedsNormalizationPatch()) {
spec.normalization = sharp.GetNumberFmt() == AmdGpu::NumberFormat::Snorm
? ImageSpecialization::Normalization::Signed
: ImageSpecialization::Normalization::Unsigned;
}
}); });
ForEachSharp(binding, fmasks, info->fmasks, ForEachSharp(binding, fmasks, info->fmasks,
[](auto& spec, const auto& desc, AmdGpu::Image sharp) { [](auto& spec, const auto& desc, AmdGpu::Image sharp) {