Module: Mesa
Branch: staging/22.2
Commit: 9a43a1f1d144485998bda88267262d56a27134f5
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9a43a1f1d144485998bda88267262d56a27134f5

Author: Mike Blumenkrantz <[email protected]>
Date:   Tue Aug  2 09:24:35 2022 -0400

mesa: require render target bind for A/L/I in format selection

these are required framebuffer formats in certain versions of GL,
so don't create a texture that can't later be bound to a framebuffer

see also spec@!opengl 3.0@required-texture-attachment-formats

cc: mesa-stable

Reviewed-by: Marek Olšák <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17687>
(cherry picked from commit 28d033b34fe3c52f4720235449a0a1fd5fe683b0)

---

 .pick_status.json                  |  2 +-
 src/mesa/state_tracker/st_format.c | 16 ++++++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/.pick_status.json b/.pick_status.json
index 442e12d3491..11fd55b0fb9 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -229,7 +229,7 @@
         "description": "mesa: require render target bind for A/L/I in format 
selection",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": null
     },
diff --git a/src/mesa/state_tracker/st_format.c 
b/src/mesa/state_tracker/st_format.c
index 978d7fbe23d..f951c81cf95 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -1294,6 +1294,22 @@ st_ChooseTextureFormat(struct gl_context *ctx, GLenum 
target,
             internalFormat == GL_R8UI)
       bindings |= PIPE_BIND_RENDER_TARGET;
 
+   if ((_mesa_is_desktop_gl(ctx) && ctx->Version >= 30) &&
+       (internalFormat == GL_ALPHA4 ||
+        internalFormat == GL_ALPHA8 ||
+        internalFormat == GL_ALPHA12 ||
+        internalFormat == GL_ALPHA16 ||
+        /* ARB_texture_float */
+        internalFormat == GL_ALPHA32F_ARB ||
+        internalFormat == GL_INTENSITY32F_ARB ||
+        internalFormat == GL_LUMINANCE32F_ARB ||
+        internalFormat == GL_LUMINANCE_ALPHA32F_ARB ||
+        internalFormat == GL_ALPHA16F_ARB ||
+        internalFormat == GL_INTENSITY16F_ARB ||
+        internalFormat == GL_LUMINANCE16F_ARB ||
+        internalFormat == GL_LUMINANCE_ALPHA16F_ARB))
+      bindings |= PIPE_BIND_RENDER_TARGET;
+
    /* GLES allows the driver to choose any format which matches
     * the format+type combo, because GLES only supports unsized internal
     * formats and expects the driver to choose whatever suits it.

Reply via email to