From 9a0e2f66878246ea851ddbc31eb9c1d58d5e1e0b Mon Sep 17 00:00:00 2001 From: crosire Date: Sat, 27 Aug 2022 16:28:56 +0200 Subject: [PATCH] Fix potential crash on old drivers or incorrect format returned by OpenGL "get_resource_view_format" --- source/opengl/opengl_impl_device.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/opengl/opengl_impl_device.cpp b/source/opengl/opengl_impl_device.cpp index 7a977887c7..e60bc84932 100644 --- a/source/opengl/opengl_impl_device.cpp +++ b/source/opengl/opengl_impl_device.cpp @@ -998,6 +998,7 @@ reshade::api::format reshade::opengl::device_impl::get_resource_view_format(api: if (_supports_dsa) { gl.GetTextureLevelParameteriv(object, 0, GL_TEXTURE_INTERNAL_FORMAT, &internal_format); + gl.GetTextureParameteriv(object, GL_TEXTURE_SWIZZLE_RGBA, swizzle_mask); } else { @@ -1010,8 +1011,7 @@ reshade::api::format reshade::opengl::device_impl::get_resource_view_format(api: level_target = GL_TEXTURE_CUBE_MAP_POSITIVE_X; gl.GetTexLevelParameteriv(level_target, 0, GL_TEXTURE_INTERNAL_FORMAT, &internal_format); - - gl.GetTextureParameteriv(object, GL_TEXTURE_SWIZZLE_RGBA, swizzle_mask); + gl.GetTexParameteriv(target, GL_TEXTURE_SWIZZLE_RGBA, swizzle_mask); gl.BindTexture(target, prev_binding); } @@ -1035,6 +1035,9 @@ reshade::api::format reshade::opengl::device_impl::get_resource_view_format(api: case GL_FRAMEBUFFER_DEFAULT: internal_format = (object == GL_DEPTH_STENCIL_ATTACHMENT || object == GL_DEPTH_ATTACHMENT || object == GL_STENCIL_ATTACHMENT) ? _default_depth_format : _default_color_format; break; + default: + assert(false); + break; } return convert_format(internal_format, swizzle_mask);