From e9a45a6d06aef9a79e5b626f46fd1179e866d3c7 Mon Sep 17 00:00:00 2001 From: kd-11 Date: Thu, 3 Oct 2024 04:34:13 +0300 Subject: [PATCH] rsx: Clarify OGL and VK difference when handling border texels --- rpcs3/Emu/RSX/GL/glutils/sampler.cpp | 12 ++++++++---- rpcs3/Emu/RSX/VK/VKDraw.cpp | 5 +++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/rpcs3/Emu/RSX/GL/glutils/sampler.cpp b/rpcs3/Emu/RSX/GL/glutils/sampler.cpp index 6ff60b6f95..144aab97d4 100644 --- a/rpcs3/Emu/RSX/GL/glutils/sampler.cpp +++ b/rpcs3/Emu/RSX/GL/glutils/sampler.cpp @@ -81,11 +81,13 @@ namespace gl if (rsx::is_border_clamped_texture(tex)) { - const auto border_color = tex.remapped_border_color(); - const auto encoded_color = rsx::encode_color_to_storage_key(border_color); + // NOTE: In OpenGL, the border texels are processed by the pipeline and will be swizzled by the texture view. + // Therefore, we pass the raw value here, and the texture view will handle the rest for us. + const auto encoded_color = tex.border_color(); if (get_parameteri(GL_TEXTURE_BORDER_COLOR) != encoded_color) { m_propertiesi[GL_TEXTURE_BORDER_COLOR] = encoded_color; + const auto border_color = rsx::decode_border_color(encoded_color); glSamplerParameterfv(sampler_handle, GL_TEXTURE_BORDER_COLOR, border_color.rgba); } } @@ -154,11 +156,13 @@ namespace gl { if (rsx::is_border_clamped_texture(tex)) { - const auto border_color = tex.remapped_border_color(); - const auto encoded_color = rsx::encode_color_to_storage_key(border_color); + // NOTE: In OpenGL, the border texels are processed by the pipeline and will be swizzled by the texture view. + // Therefore, we pass the raw value here, and the texture view will handle the rest for us. + const auto encoded_color = tex.border_color(); if (get_parameteri(GL_TEXTURE_BORDER_COLOR) != encoded_color) { m_propertiesi[GL_TEXTURE_BORDER_COLOR] = encoded_color; + const auto border_color = rsx::decode_border_color(encoded_color); glSamplerParameterfv(sampler_handle, GL_TEXTURE_BORDER_COLOR, border_color.rgba); } } diff --git a/rpcs3/Emu/RSX/VK/VKDraw.cpp b/rpcs3/Emu/RSX/VK/VKDraw.cpp index fd23d0fb8d..ad0bca997f 100644 --- a/rpcs3/Emu/RSX/VK/VKDraw.cpp +++ b/rpcs3/Emu/RSX/VK/VKDraw.cpp @@ -303,6 +303,9 @@ void VKGSRender::load_texture_env() const auto wrap_s = vk::vk_wrap_mode(tex.wrap_s()); const auto wrap_t = vk::vk_wrap_mode(tex.wrap_t()); const auto wrap_r = vk::vk_wrap_mode(tex.wrap_r()); + + // NOTE: In vulkan, the border color bypasses the swizzling defined in the image view. + // It is a direct texel replacement and must be remapped before attaching to the sampler. const auto border_color = rsx::is_border_clamped_texture(tex) ? vk::border_color_t(tex.remapped_border_color()) : vk::border_color_t(VK_BORDER_COLOR_FLOAT_OPAQUE_BLACK); @@ -446,6 +449,8 @@ void VKGSRender::load_texture_env() const auto wrap_s = vk::vk_wrap_mode(tex.wrap_s()); const auto wrap_t = vk::vk_wrap_mode(tex.wrap_t()); + // NOTE: In vulkan, the border color bypasses the swizzling defined in the image view. + // It is a direct texel replacement and must be remapped before attaching to the sampler. const auto border_color = is_border_clamped_texture(tex) ? vk::border_color_t(tex.remapped_border_color()) : vk::border_color_t(VK_BORDER_COLOR_FLOAT_OPAQUE_BLACK);