From e49887535f545b6b236f254d19f1aff164dc8e7e Mon Sep 17 00:00:00 2001 From: Lander Gallastegi Date: Tue, 12 Nov 2024 22:44:02 +0100 Subject: [PATCH] Initial prep --- .../ir/passes/resource_tracking_pass.cpp | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/shader_recompiler/ir/passes/resource_tracking_pass.cpp b/src/shader_recompiler/ir/passes/resource_tracking_pass.cpp index 7d29c845d..215dd601b 100644 --- a/src/shader_recompiler/ir/passes/resource_tracking_pass.cpp +++ b/src/shader_recompiler/ir/passes/resource_tracking_pass.cpp @@ -417,6 +417,25 @@ IR::Value PatchCubeCoord(IR::IREmitter& ir, const IR::Value& s, const IR::Value& } } +bool ShouldPatchNormalization(const AmdGpu::Image& image) { + if (image.GetNumberFmt() == AmdGpu::NumberFormat::Unorm || + image.GetNumberFmt() == AmdGpu::NumberFormat::Snorm) { + switch (image.GetDataFmt()) { + case AmdGpu::DataFormat::Format32: + case AmdGpu::DataFormat::Format32_32: + case AmdGpu::DataFormat::Format32_32_32: + case AmdGpu::DataFormat::Format32_32_32_32: + return true; + default: + return false; + } + } + return false; +} + +void PatchNormalization(IR::Inst& inst, IR::IREmitter& ir, const AmdGpu::Image& image, + bool is_write) {} + void PatchImageSampleInstruction(IR::Block& block, IR::Inst& inst, Info& info, Descriptors& descriptors, const IR::Inst* producer, const u32 image_binding, const AmdGpu::Image& image) { @@ -598,6 +617,10 @@ void PatchImageSampleInstruction(IR::Block& block, IR::Inst& inst, Info& info, return ir.ImageSampleImplicitLod(handle, coords, bias, offset, inst_info); }(); inst.ReplaceUsesWith(new_inst); + + if (ShouldPatchNormalization(image)) { + PatchNormalization(*new_inst.Inst(), ir, image, false); + } } void PatchImageInstruction(IR::Block& block, IR::Inst& inst, Info& info, Descriptors& descriptors) { @@ -724,6 +747,10 @@ void PatchImageInstruction(IR::Block& block, IR::Inst& inst, Info& info, Descrip image.GetType() == AmdGpu::ImageType::Color2DMsaaArray) { inst.SetArg(4, arg); } + + if (ShouldPatchNormalization(image)) { + PatchNormalization(inst, ir, image, inst.GetOpcode() == IR::Opcode::ImageWrite); + } } void PatchDataRingInstruction(IR::Block& block, IR::Inst& inst, Info& info,