mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2025-06-15 09:48:57 -05:00
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).
This commit is contained in:
@ -169,6 +169,7 @@ Device::Device(Core::Frontend::EmuWindow& emu_window) {
|
||||
has_draw_texture = GLAD_GL_NV_draw_texture;
|
||||
warp_size_potentially_larger_than_guest = !is_nvidia && !is_intel;
|
||||
need_fastmath_off = is_nvidia;
|
||||
need_gather_subpixel_offset = is_amd;
|
||||
can_report_memory = GLAD_GL_NVX_gpu_memory_info;
|
||||
|
||||
// At the moment of writing this, only Nvidia's driver optimizes BufferSubData on exclusive
|
||||
|
@ -160,6 +160,10 @@ public:
|
||||
return need_fastmath_off;
|
||||
}
|
||||
|
||||
bool NeedsGatherSubpixelOffset() const {
|
||||
return need_gather_subpixel_offset;
|
||||
}
|
||||
|
||||
bool HasCbufFtouBug() const {
|
||||
return has_cbuf_ftou_bug;
|
||||
}
|
||||
@ -225,6 +229,7 @@ private:
|
||||
bool has_draw_texture{};
|
||||
bool warp_size_potentially_larger_than_guest{};
|
||||
bool need_fastmath_off{};
|
||||
bool need_gather_subpixel_offset{};
|
||||
bool has_cbuf_ftou_bug{};
|
||||
bool has_bool_ref_bug{};
|
||||
bool can_report_memory{};
|
||||
|
@ -218,6 +218,7 @@ ShaderCache::ShaderCache(RasterizerOpenGL& rasterizer_, Core::Frontend::EmuWindo
|
||||
.lower_left_origin_mode = true,
|
||||
.need_declared_frag_colors = true,
|
||||
.need_fastmath_off = device.NeedsFastmathOff(),
|
||||
.need_gather_subpixel_offset = device.NeedsGatherSubpixelOffset(),
|
||||
|
||||
.has_broken_spirv_clamp = true,
|
||||
.has_broken_unsigned_image_offsets = true,
|
||||
|
Reference in New Issue
Block a user