From 780240e6979b198e7bd10feaad5399b8b4b63762 Mon Sep 17 00:00:00 2001 From: Wollnashorn Date: Wed, 5 Apr 2023 01:29:46 +0200 Subject: shader_recompiler: Add subpixel offset for correct rounding at `ImageGather` On AMD a subpixel offset of 1/512 of the texel size is applied to the texture coordinates at a ImageGather call to ensure the rounding at the texel centers is done the same way as in Maxwell or other Nvidia architectures. See https://www.reedbeta.com/blog/texture-gathers-and-coordinate-precision/ for more details why this might be necessary. This should fix shadow artifacts at object edges in Zelda: Breath of the Wild (#9957, #6956). --- src/shader_recompiler/profile.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/shader_recompiler/profile.h') diff --git a/src/shader_recompiler/profile.h b/src/shader_recompiler/profile.h index 253e0d0bd..31390e869 100644 --- a/src/shader_recompiler/profile.h +++ b/src/shader_recompiler/profile.h @@ -52,6 +52,10 @@ struct Profile { bool need_declared_frag_colors{}; /// Prevents fast math optimizations that may cause inaccuracies bool need_fastmath_off{}; + /// Some GPU vendors use a lower fixed point format of 16.8 when calculating pixel coordinates + /// in the ImageGather instruction than the Maxwell architecture does. Applying an offset does + /// fix this mismatching rounding behaviour. + bool need_gather_subpixel_offset{}; /// OpFClamp is broken and OpFMax + OpFMin should be used instead bool has_broken_spirv_clamp{}; -- cgit v1.2.3 From fe91066f4673f7a3ee87235f08b72db4910eb01c Mon Sep 17 00:00:00 2001 From: Wollnashorn Date: Wed, 5 Apr 2023 03:02:24 +0200 Subject: video_core: Enable ImageGather with subpixel offset on Intel --- src/shader_recompiler/profile.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/shader_recompiler/profile.h') diff --git a/src/shader_recompiler/profile.h b/src/shader_recompiler/profile.h index 31390e869..9f88fb440 100644 --- a/src/shader_recompiler/profile.h +++ b/src/shader_recompiler/profile.h @@ -52,9 +52,9 @@ struct Profile { bool need_declared_frag_colors{}; /// Prevents fast math optimizations that may cause inaccuracies bool need_fastmath_off{}; - /// Some GPU vendors use a lower fixed point format of 16.8 when calculating pixel coordinates - /// in the ImageGather instruction than the Maxwell architecture does. Applying an offset does - /// fix this mismatching rounding behaviour. + /// Some GPU vendors use a different rounding precision when calculating texture pixel + /// coordinates with the 16.8 format in the ImageGather instruction than the Maxwell + /// architecture. Applying an offset does fix this mismatching rounding behaviour. bool need_gather_subpixel_offset{}; /// OpFClamp is broken and OpFMax + OpFMin should be used instead -- cgit v1.2.3