From f698d475718562918329471f7c038717f50d1d75 Mon Sep 17 00:00:00 2001 From: Illia Polishchuk Date: Mon, 27 Mar 2023 20:11:15 +0300 Subject: [PATCH] drirc: add allow_sampled_tex_copy option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From OpenGL spec 8.6 "An INVALID_OPERATION error is generated if the object bound to READ_FRAMEBUFFER_BINDING is framebuffer complete and its effective value of SAMPLE_BUFFERS (see section 9.2.3.1) is one" But some games might do this Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/8425 Reviewed-by: Emma Anholt Reviewed-by: Marek Olšák Signed-off-by: Illia Polishchuk Part-of: --- src/gallium/auxiliary/pipe-loader/driinfo_gallium.h | 1 + src/gallium/auxiliary/util/u_driconf.c | 1 + src/gallium/include/frontend/api.h | 2 ++ src/mesa/main/teximage.c | 10 ++++++---- src/util/00-mesa-defaults.conf | 5 +++++ src/util/driconf.h | 7 +++++++ 6 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h b/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h index 53440b60af7..c4f34c6ea5f 100644 --- a/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h +++ b/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h @@ -55,6 +55,7 @@ DRI_CONF_SECTION_DEBUG DRI_CONF_ALLOW_INVALID_GLX_DESTROY_WINDOW(false) DRI_CONF_KEEP_NATIVE_WINDOW_GLX_DRAWABLE(false) DRI_CONF_IGNORE_DISCARD_FRAMEBUFFER(false) + DRI_CONF_ALLOW_MULTISAMPLED_COPYTEXIMAGE(false) DRI_CONF_SECTION_END DRI_CONF_SECTION_MISCELLANEOUS diff --git a/src/gallium/auxiliary/util/u_driconf.c b/src/gallium/auxiliary/util/u_driconf.c index 98c995d024f..7280cfb6e18 100644 --- a/src/gallium/auxiliary/util/u_driconf.c +++ b/src/gallium/auxiliary/util/u_driconf.c @@ -72,6 +72,7 @@ u_driconf_fill_st_options(struct st_config_options *options, query_string_option(force_gl_vendor); query_string_option(force_gl_renderer); query_string_option(mesa_extension_override); + query_bool_option(allow_multisampled_copyteximage); driComputeOptionsSha1(optionCache, options->config_options_sha1); } diff --git a/src/gallium/include/frontend/api.h b/src/gallium/include/frontend/api.h index 263792a58b4..bef0a8d7cd1 100644 --- a/src/gallium/include/frontend/api.h +++ b/src/gallium/include/frontend/api.h @@ -201,6 +201,8 @@ struct st_config_options char *force_gl_vendor; char *force_gl_renderer; char *mesa_extension_override; + bool allow_multisampled_copyteximage; + unsigned char config_options_sha1[20]; }; diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 0a320073d7e..53b1e368fd1 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -2424,7 +2424,8 @@ copytexture_error_check( struct gl_context *ctx, GLuint dimensions, return GL_TRUE; } - if (ctx->ReadBuffer->Visual.samples > 0) { + if (!ctx->st_opts->allow_multisampled_copyteximage && + ctx->ReadBuffer->Visual.samples > 0) { _mesa_error(ctx, GL_INVALID_OPERATION, "glCopyTexImage%dD(multisample FBO)", dimensions); return GL_TRUE; @@ -2691,9 +2692,10 @@ copytexsubimage_error_check(struct gl_context *ctx, GLuint dimensions, return GL_TRUE; } - if (ctx->ReadBuffer->Visual.samples > 0) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "%s(multisample FBO)", caller); + if (!ctx->st_opts->allow_multisampled_copyteximage && + ctx->ReadBuffer->Visual.samples > 0) { + _mesa_error(ctx, GL_INVALID_OPERATION, "%s(multisample FBO)", + caller); return GL_TRUE; } } diff --git a/src/util/00-mesa-defaults.conf b/src/util/00-mesa-defaults.conf index 6801fbd197b..1f69544ca9d 100644 --- a/src/util/00-mesa-defaults.conf +++ b/src/util/00-mesa-defaults.conf @@ -352,6 +352,11 @@ TODO: document the other workarounds.