Mesa (master): mesa/main: prefer R8-textures instead of A8 for glBitmap in display lists

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Oct 9 10:32:39 UTC 2019


Module: Mesa
Branch: master
Commit: bbdbb02a5fc16dfd9bc4ff3142c3177e2051b87e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=bbdbb02a5fc16dfd9bc4ff3142c3177e2051b87e

Author: Erik Faye-Lund <erik.faye-lund at collabora.com>
Date:   Mon Jul 15 12:03:43 2019 +0200

mesa/main: prefer R8-textures instead of A8 for glBitmap in display lists

This allows drivers to communicate that they prefer R8 textures rather
than A8 for glBitmap usage.

Reviewed-by: Marek Olšák <marek.olsak at amd.com>

---

 src/mesa/main/dlist.c               | 11 ++++++++---
 src/mesa/main/mtypes.h              |  3 +++
 src/mesa/state_tracker/st_context.c |  5 +++++
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c
index 708c25f004e..622fb805660 100644
--- a/src/mesa/main/dlist.c
+++ b/src/mesa/main/dlist.c
@@ -941,9 +941,14 @@ build_bitmap_atlas(struct gl_context *ctx, struct gl_bitmap_atlas *atlas,
       goto out_of_memory;
    }
 
-   _mesa_init_teximage_fields(ctx, atlas->texImage,
-                              atlas->texWidth, atlas->texHeight, 1, 0,
-                              GL_ALPHA, MESA_FORMAT_A_UNORM8);
+   if (ctx->Const.BitmapUsesRed)
+      _mesa_init_teximage_fields(ctx, atlas->texImage,
+                                 atlas->texWidth, atlas->texHeight, 1, 0,
+                                 GL_RED, MESA_FORMAT_R_UNORM8);
+   else
+      _mesa_init_teximage_fields(ctx, atlas->texImage,
+                                 atlas->texWidth, atlas->texHeight, 1, 0,
+                                 GL_ALPHA, MESA_FORMAT_A_UNORM8);
 
    /* alloc image storage */
    if (!ctx->Driver.AllocTextureImageBuffer(ctx, atlas->texImage)) {
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index dcf0d6a5aab..ae93dff40da 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -4130,6 +4130,9 @@ struct gl_constants
    /** Is the drivers uniform storage packed or padded to 16 bytes. */
    bool PackedDriverUniformStorage;
 
+   /** Wether or not glBitmap uses red textures rather than alpha */
+   bool BitmapUsesRed;
+
    /** GL_ARB_gl_spirv */
    struct spirv_supported_capabilities SpirVCapabilities;
 
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index de106144de9..163f996d64c 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -621,6 +621,11 @@ st_create_context_priv(struct gl_context *ctx, struct pipe_context *pipe,
    ctx->Const.PackedDriverUniformStorage =
       screen->get_param(screen, PIPE_CAP_PACKED_UNIFORMS);
 
+   ctx->Const.BitmapUsesRed =
+      screen->is_format_supported(screen, PIPE_FORMAT_R8_UNORM,
+                                  PIPE_TEXTURE_2D, 0, 0,
+                                  PIPE_BIND_SAMPLER_VIEW);
+
    st->has_stencil_export =
       screen->get_param(screen, PIPE_CAP_SHADER_STENCIL_EXPORT);
    st->has_etc1 = screen->is_format_supported(screen, PIPE_FORMAT_ETC1_RGB8,




More information about the mesa-commit mailing list