From fe3b41c64bfd50f15cf7f1ede6b6a2fe4d2b20f1 Mon Sep 17 00:00:00 2001 From: Lander Gallastegi Date: Wed, 13 Nov 2024 23:19:46 +0100 Subject: [PATCH] Shader specialization --- src/shader_recompiler/specialization.h | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/shader_recompiler/specialization.h b/src/shader_recompiler/specialization.h index 225b164b5..e64df5766 100644 --- a/src/shader_recompiler/specialization.h +++ b/src/shader_recompiler/specialization.h @@ -26,8 +26,15 @@ struct TextureBufferSpecialization { }; struct ImageSpecialization { + enum class Normalization : u8 { + None, + Signed, + Unsigned, + }; + AmdGpu::ImageType type = AmdGpu::ImageType::Color2D; bool is_integer = false; + Normalization normalization = Normalization::None; auto operator<=>(const ImageSpecialization&) const = default; }; @@ -73,12 +80,18 @@ struct StageSpecialization { [](auto& spec, const auto& desc, AmdGpu::Buffer sharp) { spec.is_integer = AmdGpu::IsInteger(sharp.GetNumberFmt()); }); - ForEachSharp(binding, images, info->images, - [](auto& spec, const auto& desc, AmdGpu::Image sharp) { - spec.type = sharp.IsPartialCubemap() ? AmdGpu::ImageType::Color2DArray - : sharp.GetType(); - spec.is_integer = AmdGpu::IsInteger(sharp.GetNumberFmt()); - }); + ForEachSharp( + binding, images, info->images, [](auto& spec, const auto& desc, AmdGpu::Image sharp) { + spec.type = + sharp.IsPartialCubemap() ? AmdGpu::ImageType::Color2DArray : sharp.GetType(); + 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, [](auto& spec, const auto& desc, AmdGpu::Image sharp) { spec.width = sharp.width;