Merge pull request #5862 from SachinVin/bargain-bin-gpu

Skip D24S8 to RGBA8 reinterpretation fast path for older nvidia GPU
This commit is contained in:
bunnei 2021-10-13 15:51:16 -07:00 committed by GitHub
commit 90192124cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -373,14 +373,19 @@ class CopyImageSubData final : public FormatReinterpreterBase {
}; };
FormatReinterpreterOpenGL::FormatReinterpreterOpenGL() { FormatReinterpreterOpenGL::FormatReinterpreterOpenGL() {
std::string_view vendor{reinterpret_cast<const char*>(glGetString(GL_VENDOR))}; // Older Nvidia GPUs don't seem to properly support using glCopyImageSubData to copy D24S8 to
if (vendor.find("NVIDIA") != vendor.npos) { // RGBA8. This is a heuristic check that relies on the newer drivers returning something similar
// to `3.3.0 NVIDIA 471.41`, and older, buggy ones returning just `3.3.0`.
std::string_view version{reinterpret_cast<const char*>(glGetString(GL_VERSION))};
if (version.find("NVIDIA") != version.npos) {
reinterpreters.emplace(PixelFormatPair{PixelFormat::RGBA8, PixelFormat::D24S8}, reinterpreters.emplace(PixelFormatPair{PixelFormat::RGBA8, PixelFormat::D24S8},
std::make_unique<CopyImageSubData>()); std::make_unique<CopyImageSubData>());
// Nvidia bends the spec and allows direct copies between color and depth formats // Nvidia bends the spec and allows direct copies between color and depth formats
// might as well take advantage of it // might as well take advantage of it
LOG_INFO(Render_OpenGL, "Using glCopyImageSubData for D24S8 to RGBA8 reinterpretation"); LOG_INFO(Render_OpenGL, "Using glCopyImageSubData for D24S8 to RGBA8 reinterpretation");
} else if ((GLAD_GL_ARB_stencil_texturing && GLAD_GL_ARB_texture_storage) || GLES) { } else if ((GLAD_GL_ARB_stencil_texturing && GLAD_GL_ARB_texture_storage &&
GLAD_GL_ARB_copy_image) ||
GLES) {
reinterpreters.emplace(PixelFormatPair{PixelFormat::RGBA8, PixelFormat::D24S8}, reinterpreters.emplace(PixelFormatPair{PixelFormat::RGBA8, PixelFormat::D24S8},
std::make_unique<ShaderD24S8toRGBA8>()); std::make_unique<ShaderD24S8toRGBA8>());
LOG_INFO(Render_OpenGL, "Using shader for D24S8 to RGBA8 reinterpretation"); LOG_INFO(Render_OpenGL, "Using shader for D24S8 to RGBA8 reinterpretation");