driconf: Add ignore_discard_framebuffer option
authorRob Clark <robdclark@chromium.org>
Tue, 14 Mar 2023 23:07:43 +0000 (16:07 -0700)
committerMarge Bot <emma+marge@anholt.net>
Thu, 16 Mar 2023 00:56:37 +0000 (00:56 +0000)
Some apps use glDiscardFramebuffer()/glInvalidateFramebuffer() when they
only kidding.  Add a knob to disable that.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Mike Blumenkrantz <michael.blumenkrantz@gmail.com>

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21916>

src/gallium/auxiliary/pipe-loader/driinfo_gallium.h
src/gallium/auxiliary/util/u_driconf.c
src/gallium/include/frontend/api.h
src/mesa/main/fbobject.c
src/util/driconf.h

index 1e9f90a..1eb9c88 100644 (file)
@@ -52,6 +52,7 @@ DRI_CONF_SECTION_DEBUG
    DRI_CONF_FORCE_DIRECT_GLX_CONTEXT(false)
    DRI_CONF_ALLOW_INVALID_GLX_DESTROY_WINDOW(false)
    DRI_CONF_KEEP_NATIVE_WINDOW_GLX_DRAWABLE(false)
+   DRI_CONF_IGNORE_DISCARD_FRAMEBUFFER(false)
 DRI_CONF_SECTION_END
 
 DRI_CONF_SECTION_MISCELLANEOUS
index 64692bf..98c995d 100644 (file)
@@ -64,6 +64,7 @@ u_driconf_fill_st_options(struct st_config_options *options,
    query_bool_option(allow_draw_out_of_order);
    query_bool_option(glthread_nop_check_framebuffer_status);
    query_bool_option(ignore_map_unsynchronized);
+   query_bool_option(ignore_discard_framebuffer);
    query_bool_option(force_gl_names_reuse);
    query_bool_option(force_gl_map_buffer_synchronized);
    query_bool_option(transcode_etc);
index 2ae5d0b..263792a 100644 (file)
@@ -192,6 +192,7 @@ struct st_config_options
    bool allow_draw_out_of_order;
    bool glthread_nop_check_framebuffer_status;
    bool ignore_map_unsynchronized;
+   bool ignore_discard_framebuffer;
    bool force_integer_tex_nearest;
    bool force_gl_names_reuse;
    bool force_gl_map_buffer_synchronized;
index 4b6fc23..e011453 100644 (file)
@@ -5386,6 +5386,9 @@ discard_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb,
 {
    uint32_t mask = 0;
 
+   if (unlikely(ctx->st_opts->ignore_discard_framebuffer))
+      return;
+
    for (int i = 0; i < numAttachments; i++) {
       GLenum att = attachments[i];
 
index eb5393f..c5de0c1 100644 (file)
    DRI_CONF_OPT_B(no_16bit, def, \
                   "Disable 16-bit instructions")
 
+#define DRI_CONF_IGNORE_DISCARD_FRAMEBUFFER(def) \
+   DRI_CONF_OPT_B(ignore_discard_framebuffer, def, \
+                  "Ignore glDiscardFramebuffer/glInvalidateFramebuffer, workaround for games that use it incorrectly")
+
 /**
  * \brief Image quality-related options
  */