summaryrefslogtreecommitdiff
path: root/src/video_core/vulkan_common
diff options
context:
space:
mode:
authorGravatar Wollnashorn2023-04-05 01:29:46 +0200
committerGravatar Wollnashorn2023-04-08 16:12:30 +0200
commit780240e6979b198e7bd10feaad5399b8b4b63762 (patch)
treec145f48c66cf003e618cefc63496e3f5b7637f56 /src/video_core/vulkan_common
parentMerge pull request #10024 from german77/crysis (diff)
downloadyuzu-780240e6979b198e7bd10feaad5399b8b4b63762.tar.gz
yuzu-780240e6979b198e7bd10feaad5399b8b4b63762.tar.xz
yuzu-780240e6979b198e7bd10feaad5399b8b4b63762.zip
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).
Diffstat (limited to 'src/video_core/vulkan_common')
-rw-r--r--src/video_core/vulkan_common/vulkan_device.cpp1
-rw-r--r--src/video_core/vulkan_common/vulkan_device.h5
2 files changed, 6 insertions, 0 deletions
diff --git a/src/video_core/vulkan_common/vulkan_device.cpp b/src/video_core/vulkan_common/vulkan_device.cpp
index 6f288b3f8..0939b62c9 100644
--- a/src/video_core/vulkan_common/vulkan_device.cpp
+++ b/src/video_core/vulkan_common/vulkan_device.cpp
@@ -431,6 +431,7 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR
431 "AMD GCN4 and earlier have broken VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT"); 431 "AMD GCN4 and earlier have broken VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT");
432 has_broken_cube_compatibility = true; 432 has_broken_cube_compatibility = true;
433 } 433 }
434 need_gather_subpixel_offset = true;
434 } 435 }
435 if (extensions.sampler_filter_minmax && is_amd) { 436 if (extensions.sampler_filter_minmax && is_amd) {
436 // Disable ext_sampler_filter_minmax on AMD GCN4 and lower as it is broken. 437 // Disable ext_sampler_filter_minmax on AMD GCN4 and lower as it is broken.
diff --git a/src/video_core/vulkan_common/vulkan_device.h b/src/video_core/vulkan_common/vulkan_device.h
index 41b5da18a..50e95bcca 100644
--- a/src/video_core/vulkan_common/vulkan_device.h
+++ b/src/video_core/vulkan_common/vulkan_device.h
@@ -554,6 +554,10 @@ public:
554 return features.robustness2.nullDescriptor; 554 return features.robustness2.nullDescriptor;
555 } 555 }
556 556
557 bool NeedsGatherSubpixelOffset() const {
558 return need_gather_subpixel_offset;
559 }
560
557 u32 GetMaxVertexInputAttributes() const { 561 u32 GetMaxVertexInputAttributes() const {
558 return properties.properties.limits.maxVertexInputAttributes; 562 return properties.properties.limits.maxVertexInputAttributes;
559 } 563 }
@@ -664,6 +668,7 @@ private:
664 bool must_emulate_bgr565{}; ///< Emulates BGR565 by swizzling RGB565 format. 668 bool must_emulate_bgr565{}; ///< Emulates BGR565 by swizzling RGB565 format.
665 bool dynamic_state3_blending{}; ///< Has all blending features of dynamic_state3. 669 bool dynamic_state3_blending{}; ///< Has all blending features of dynamic_state3.
666 bool dynamic_state3_enables{}; ///< Has all enables features of dynamic_state3. 670 bool dynamic_state3_enables{}; ///< Has all enables features of dynamic_state3.
671 bool need_gather_subpixel_offset{}; ///< Needs offset at ImageGather for correct rounding.
667 u64 device_access_memory{}; ///< Total size of device local memory in bytes. 672 u64 device_access_memory{}; ///< Total size of device local memory in bytes.
668 u32 sets_per_pool{}; ///< Sets per Description Pool 673 u32 sets_per_pool{}; ///< Sets per Description Pool
669 674