From 6d43fcf8fbdbf5ee8478b39a15b20c86d063e05d Mon Sep 17 00:00:00 2001 From: kd-11 Date: Sun, 16 Oct 2022 14:20:29 +0300 Subject: [PATCH] gl: Fall back to renderpass decoder on ATI drivers --- rpcs3/Emu/RSX/GL/GLOverlays.cpp | 8 ++- rpcs3/Emu/RSX/GL/GLTexture.cpp | 30 ++++++----- rpcs3/Emu/RSX/GL/glutils/capabilities.hpp | 2 + .../CopyBufferToGenericImage.glsl | 54 +++++++++++++++++++ 4 files changed, 80 insertions(+), 14 deletions(-) diff --git a/rpcs3/Emu/RSX/GL/GLOverlays.cpp b/rpcs3/Emu/RSX/GL/GLOverlays.cpp index b0f20c3b72..4fe7b726fa 100644 --- a/rpcs3/Emu/RSX/GL/GLOverlays.cpp +++ b/rpcs3/Emu/RSX/GL/GLOverlays.cpp @@ -631,13 +631,17 @@ namespace gl #include "../Program/GLSLSnippets/CopyBufferToGenericImage.glsl" ; - const bool stencil_export_supported = gl::get_driver_caps().ARB_shader_stencil_export_supported; + const auto& caps = gl::get_driver_caps(); + const bool stencil_export_supported = caps.ARB_shader_stencil_export_supported; + const bool legacy_format_support = caps.subvendor_ATI; + std::pair repl_list[] = { { "%set, ", "" }, { "%loc", std::to_string(GL_COMPUTE_BUFFER_SLOT(0)) }, { "%push_block", fmt::format("binding=%d, std140", GL_COMPUTE_BUFFER_SLOT(1)) }, - { "%stencil_export_supported", stencil_export_supported ? "1" : "0" } + { "%stencil_export_supported", stencil_export_supported ? "1" : "0" }, + { "%legacy_format_support", legacy_format_support ? "1" : "0" } }; fs_src = fmt::replace_all(fs_src, repl_list); diff --git a/rpcs3/Emu/RSX/GL/GLTexture.cpp b/rpcs3/Emu/RSX/GL/GLTexture.cpp index 7e2226d45f..924fc9f625 100644 --- a/rpcs3/Emu/RSX/GL/GLTexture.cpp +++ b/rpcs3/Emu/RSX/GL/GLTexture.cpp @@ -384,6 +384,7 @@ namespace gl bool skip_barrier = false; u32 in_offset = static_cast(reinterpret_cast(src_offset)); u32 out_offset = in_offset; + const auto& caps = gl::get_driver_caps(); auto initialize_scratch_mem = [&]() { @@ -409,7 +410,6 @@ namespace gl transfer_buf = &scratch_mem; }; - const auto caps = gl::get_driver_caps(); if ((dst->aspect() & image_aspect::stencil) == 0 || caps.ARB_shader_stencil_export_supported) { // We do not need to use the driver's builtin transport mechanism @@ -469,18 +469,24 @@ namespace gl } // If possible, decode using a compute transform to potentially have asynchronous scheduling - bool use_compute_transform = (dst->aspect() == gl::image_aspect::color); - switch (dst->get_internal_format()) + bool use_compute_transform = ( + dst->aspect() == gl::image_aspect::color && // Cannot use image_load_store with depth images + caps.subvendor_ATI == false); // The old AMD/ATI driver does not support image writeonly without format specifier + + if (use_compute_transform) { - case texture::internal_format::bgr5a1: - case texture::internal_format::rgb5a1: - case texture::internal_format::rgb565: - case texture::internal_format::rgba4: - // Packed formats are a problem with image_load_store - use_compute_transform = false; - break; - default: - break; + switch (dst->get_internal_format()) + { + case texture::internal_format::bgr5a1: + case texture::internal_format::rgb5a1: + case texture::internal_format::rgb565: + case texture::internal_format::rgba4: + // Packed formats are a problem with image_load_store + use_compute_transform = false; + break; + default: + break; + } } if (use_compute_transform) diff --git a/rpcs3/Emu/RSX/GL/glutils/capabilities.hpp b/rpcs3/Emu/RSX/GL/glutils/capabilities.hpp index 1a9e1ad01c..44a2207696 100644 --- a/rpcs3/Emu/RSX/GL/glutils/capabilities.hpp +++ b/rpcs3/Emu/RSX/GL/glutils/capabilities.hpp @@ -32,6 +32,7 @@ namespace gl bool vendor_MESA = false; // requires CLIENT_STORAGE bit set for streaming buffers bool subvendor_RADEONSI = false; bool subvendor_NOUVEAU = false; + bool subvendor_ATI = false; bool check(const std::string& ext_name, const char* test) { @@ -230,6 +231,7 @@ namespace gl else if (vendor_string.find("amd") != umax || vendor_string.find("ati") != umax) { vendor_AMD = true; + subvendor_ATI = vendor_string.find("ati") != umax; } #endif diff --git a/rpcs3/Emu/RSX/Program/GLSLSnippets/CopyBufferToGenericImage.glsl b/rpcs3/Emu/RSX/Program/GLSLSnippets/CopyBufferToGenericImage.glsl index 64d29d37f9..07928485b3 100644 --- a/rpcs3/Emu/RSX/Program/GLSLSnippets/CopyBufferToGenericImage.glsl +++ b/rpcs3/Emu/RSX/Program/GLSLSnippets/CopyBufferToGenericImage.glsl @@ -3,12 +3,27 @@ R"( #extension GL_ARB_shader_stencil_export : enable #define ENABLE_DEPTH_STENCIL_LOAD %stencil_export_supported +#define LEGACY_FORMAT_SUPPORT %legacy_format_support #define FMT_GL_DEPTH_COMPONENT16 0x81A5 #define FMT_GL_DEPTH_COMPONENT32F 0x8CAC #define FMT_GL_DEPTH24_STENCIL8 0x88F0 #define FMT_GL_DEPTH32F_STENCIL8 0x8CAD +#if LEGACY_FORMAT_SUPPORT + #define FMT_GL_RGBA8 0x8058 + #define FMT_GL_BGRA8 0x80E1 + #define FMT_GL_R8 0x8229 + #define FMT_GL_R16 0x822A + #define FMT_GL_R32F 0x822E + #define FMT_GL_RG8 0x822B + #define FMT_GL_RG8_SNORM 0x8F95 + #define FMT_GL_RG16 0x822C + #define FMT_GL_RG16F 0x822F + #define FMT_GL_RGBA16F 0x881A + #define FMT_GL_RGBA32F 0x8814 +#endif + #define FMT_GL_RGB565 0x8D62 #define FMT_GL_RGB5_A1 0x8057 #define FMT_GL_BGR5_A1 0x99F0 @@ -144,6 +159,45 @@ void main() gl_FragStencilRefARB = int(utmp2.y); break; +#endif + +#if LEGACY_FORMAT_SUPPORT + + // Simple color. Provided for compatibility with old drivers. + case FMT_GL_RGBA8: + outColor = readFixed8x4(invocation_id); + break; + case FMT_GL_BGRA8: + outColor = readFixed8x4(invocation_id).bgra; + break; + case FMT_GL_R8: + outColor.r = readFixed8(invocation_id); + break; + case FMT_GL_R16: + outColor.r = readFixed16(invocation_id); + break; + case FMT_GL_R32F: + outColor.r = readFloat32(invocation_id); + break; + case FMT_GL_RG8: + outColor.rg = readFixed8x2(invocation_id); + break; + case FMT_GL_RG8_SNORM: + outColor.rg = readFixed8x2Snorm(invocation_id); + break; + case FMT_GL_RG16: + outColor.rg = readFixed16x2(invocation_id); + break; + case FMT_GL_RG16F: + outColor.rg = readFloat16x2(invocation_id); + break; + case FMT_GL_RGBA16F: + outColor = readFloat16x4(invocation_id); + break; + case FMT_GL_RGBA32F: + outColor = readFloat32x4(invocation_id); + break; + #endif // Packed color