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

Author: Eric Anholt <[email protected]>
Date:   Mon Jul  1 15:43:19 2019 -0700

mesa: Give _mesa_format_get_color_encoding a clearer name.

It only returned one of two values.

Reviewed-by: Thomas Helland <[email protected]>
Reviewed-by: Kristian H. Kristensen <[email protected]>

---

 src/mesa/drivers/common/meta_blit.c            |  3 +--
 src/mesa/drivers/common/meta_generate_mipmap.c |  5 ++---
 src/mesa/drivers/dri/common/utils.c            |  2 +-
 src/mesa/drivers/dri/i965/intel_fbo.c          |  4 ++--
 src/mesa/main/fbobject.c                       |  4 ++--
 src/mesa/main/formats.c                        | 12 +++---------
 src/mesa/main/formats.h                        |  4 ++--
 src/mesa/main/framebuffer.c                    |  2 +-
 src/mesa/main/glformats.c                      |  2 +-
 src/mesa/main/texcompress_astc.cpp             |  2 +-
 src/mesa/main/teximage.c                       |  8 ++------
 src/mesa/state_tracker/st_atom_framebuffer.c   |  2 +-
 src/mesa/state_tracker/st_cb_fbo.c             |  5 ++---
 src/mesa/state_tracker/st_format.c             |  2 +-
 14 files changed, 22 insertions(+), 35 deletions(-)

diff --git a/src/mesa/drivers/common/meta_blit.c 
b/src/mesa/drivers/common/meta_blit.c
index 496ef285d02..fec4db3af5c 100644
--- a/src/mesa/drivers/common/meta_blit.c
+++ b/src/mesa/drivers/common/meta_blit.c
@@ -741,8 +741,7 @@ blitframebuffer_texture(struct gl_context *ctx,
        * defaults it to on for ES contexts, so we can safely check it.
        */
       const bool decode =
-         ctx->Color.sRGBEnabled &&
-         _mesa_get_format_color_encoding(rb->Format) == GL_SRGB;
+         ctx->Color.sRGBEnabled && _mesa_is_format_srgb(rb->Format);
 
       _mesa_set_sampler_srgb_decode(ctx, fb_tex_blit.samp_obj,
                                     decode ? GL_DECODE_EXT
diff --git a/src/mesa/drivers/common/meta_generate_mipmap.c 
b/src/mesa/drivers/common/meta_generate_mipmap.c
index 99d0931694d..5fac4078f81 100644
--- a/src/mesa/drivers/common/meta_generate_mipmap.c
+++ b/src/mesa/drivers/common/meta_generate_mipmap.c
@@ -86,7 +86,7 @@ fallback_required(struct gl_context *ctx, GLenum target,
       return true;
    }
 
-   if (_mesa_get_format_color_encoding(baseImage->TexFormat) == GL_SRGB &&
+   if (_mesa_is_format_srgb(baseImage->TexFormat) &&
        !ctx->Extensions.EXT_texture_sRGB_decode) {
       /* The texture format is sRGB but we can't turn off sRGB->linear
        * texture sample conversion.  So we won't be able to generate the
@@ -227,8 +227,7 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum 
target,
    if (ctx->Extensions.EXT_texture_sRGB_decode) {
       const struct gl_texture_image *baseImage =
          _mesa_select_tex_image(texObj, target, texObj->BaseLevel);
-      const bool srgb =
-         _mesa_get_format_color_encoding(baseImage->TexFormat) == GL_SRGB;
+      const bool srgb = _mesa_is_format_srgb(baseImage->TexFormat);
 
       _mesa_set_sampler_srgb_decode(ctx, mipmap->samp_obj,
                                     srgb ? GL_DECODE_EXT : GL_SKIP_DECODE_EXT);
diff --git a/src/mesa/drivers/dri/common/utils.c 
b/src/mesa/drivers/dri/common/utils.c
index 5a66bcf8e05..30ff237d00e 100644
--- a/src/mesa/drivers/dri/common/utils.c
+++ b/src/mesa/drivers/dri/common/utils.c
@@ -256,7 +256,7 @@ driCreateConfigs(mesa_format format,
    green_bits = _mesa_get_format_bits(format, GL_GREEN_BITS);
    blue_bits = _mesa_get_format_bits(format, GL_BLUE_BITS);
    alpha_bits = _mesa_get_format_bits(format, GL_ALPHA_BITS);
-   is_srgb = _mesa_get_format_color_encoding(format) == GL_SRGB;
+   is_srgb = _mesa_is_format_srgb(format);
 
    num_modes = num_depth_stencil_bits * num_db_modes * num_accum_bits * 
num_msaa_modes;
    configs = calloc(num_modes + 1, sizeof *configs);
diff --git a/src/mesa/drivers/dri/i965/intel_fbo.c 
b/src/mesa/drivers/dri/i965/intel_fbo.c
index b3ba09f2174..a313d445355 100644
--- a/src/mesa/drivers/dri/i965/intel_fbo.c
+++ b/src/mesa/drivers/dri/i965/intel_fbo.c
@@ -860,8 +860,8 @@ intel_blit_framebuffer_with_blitter(struct gl_context *ctx,
          }
 
          if (ctx->Color.sRGBEnabled &&
-             _mesa_get_format_color_encoding(src_irb->mt->format) !=
-             _mesa_get_format_color_encoding(dst_irb->mt->format)) {
+             _mesa_is_format_srgb(src_irb->mt->format) !=
+             _mesa_is_format_srgb(dst_irb->mt->format)) {
             perf_debug("glBlitFramebuffer() with sRGB conversion cannot be "
                        "handled by BLT path.\n");
             return mask;
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 09143d30af5..d95f2444f00 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -4282,8 +4282,8 @@ get_framebuffer_attachment_parameter(struct gl_context 
*ctx,
       }
       else {
          if (ctx->Extensions.EXT_sRGB) {
-            *params =
-               _mesa_get_format_color_encoding(att->Renderbuffer->Format);
+            *params = (_mesa_is_format_srgb(att->Renderbuffer->Format) ?
+                       GL_SRGB : GL_LINEAR);
          }
          else {
             /* According to ARB_framebuffer_sRGB, we should return LINEAR
diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c
index 4a08d1a0158..fb1f47bd11b 100644
--- a/src/mesa/main/formats.c
+++ b/src/mesa/main/formats.c
@@ -590,19 +590,13 @@ _mesa_is_format_color_format(mesa_format format)
    }
 }
 
-
-/**
- * Return color encoding for given format.
- * \return GL_LINEAR or GL_SRGB
- */
-GLenum
-_mesa_get_format_color_encoding(mesa_format format)
+bool
+_mesa_is_format_srgb(mesa_format format)
 {
    const struct mesa_format_info *info = _mesa_get_format_info(format);
-   return info->IsSRGBFormat ? GL_SRGB : GL_LINEAR;
+   return info->IsSRGBFormat;
 }
 
-
 /**
  * Return TRUE if format is an ETC2 compressed format specified
  * by GL_ARB_ES3_compatibility.
diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h
index 60d6b58ae33..abfd73313ef 100644
--- a/src/mesa/main/formats.h
+++ b/src/mesa/main/formats.h
@@ -736,8 +736,8 @@ _mesa_is_format_astc_2d(mesa_format format);
 bool
 _mesa_is_format_color_format(mesa_format format);
 
-extern GLenum
-_mesa_get_format_color_encoding(mesa_format format);
+bool
+_mesa_is_format_srgb(mesa_format format);
 
 extern uint32_t
 _mesa_format_image_size(mesa_format format, int width,
diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index 0abfdd83902..96efc0a4b54 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -458,7 +458,7 @@ _mesa_update_framebuffer_visual(struct gl_context *ctx,
             fb->Visual.alphaBits = _mesa_get_format_bits(fmt, GL_ALPHA_BITS);
             fb->Visual.rgbBits = fb->Visual.redBits
                + fb->Visual.greenBits + fb->Visual.blueBits;
-            if (_mesa_get_format_color_encoding(fmt) == GL_SRGB)
+            if (_mesa_is_format_srgb(fmt))
                 fb->Visual.sRGBCapable = ctx->Extensions.EXT_sRGB;
             break;
          }
diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
index bd087848803..3e493cd5c2d 100644
--- a/src/mesa/main/glformats.c
+++ b/src/mesa/main/glformats.c
@@ -1373,7 +1373,7 @@ _mesa_is_compressed_format(const struct gl_context *ctx, 
GLenum format)
 
    switch (_mesa_get_format_layout(m_format)) {
    case MESA_FORMAT_LAYOUT_S3TC:
-      if (_mesa_get_format_color_encoding(m_format) == GL_LINEAR) {
+      if (!_mesa_is_format_srgb(m_format)) {
          return _mesa_has_EXT_texture_compression_s3tc(ctx);
       } else {
          return (_mesa_has_EXT_texture_sRGB(ctx) ||
diff --git a/src/mesa/main/texcompress_astc.cpp 
b/src/mesa/main/texcompress_astc.cpp
index 23540c47017..63676dfa64c 100644
--- a/src/mesa/main/texcompress_astc.cpp
+++ b/src/mesa/main/texcompress_astc.cpp
@@ -1830,7 +1830,7 @@ _mesa_unpack_astc_2d_ldr(uint8_t *dst_row,
                          mesa_format format)
 {
    assert(_mesa_is_format_astc_2d(format));
-   bool srgb = _mesa_get_format_color_encoding(format) == GL_SRGB;
+   bool srgb = _mesa_is_format_srgb(format);
 
    unsigned blk_w, blk_h;
    _mesa_get_format_block_size(format, &blk_w, &blk_h);
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 253183da815..336a9592b56 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -2416,14 +2416,10 @@ copytexture_error_check( struct gl_context *ctx, GLuint 
dimensions,
    }
 
    if (_mesa_is_gles3(ctx)) {
-      bool rb_is_srgb = false;
+      bool rb_is_srgb = (ctx->Extensions.EXT_sRGB &&
+                         _mesa_is_format_srgb(rb->Format));
       bool dst_is_srgb = false;
 
-      if (ctx->Extensions.EXT_sRGB &&
-          _mesa_get_format_color_encoding(rb->Format) == GL_SRGB) {
-         rb_is_srgb = true;
-      }
-
       if (_mesa_get_linear_internalformat(internalFormat) != internalFormat) {
          dst_is_srgb = true;
       }
diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c 
b/src/mesa/state_tracker/st_atom_framebuffer.c
index 15727fa9d80..4a82c63e8dc 100644
--- a/src/mesa/state_tracker/st_atom_framebuffer.c
+++ b/src/mesa/state_tracker/st_atom_framebuffer.c
@@ -146,7 +146,7 @@ st_update_framebuffer_state( struct st_context *st )
 
       if (strb) {
          if (strb->is_rtt || (strb->texture &&
-             _mesa_get_format_color_encoding(strb->Base.Format) == GL_SRGB)) {
+             _mesa_is_format_srgb(strb->Base.Format))) {
             /* rendering to a GL texture, may have to update surface */
             st_update_renderbuffer_surface(st, strb);
          }
diff --git a/src/mesa/state_tracker/st_cb_fbo.c 
b/src/mesa/state_tracker/st_cb_fbo.c
index 5e3425a73a6..bf23f4f3a8d 100644
--- a/src/mesa/state_tracker/st_cb_fbo.c
+++ b/src/mesa/state_tracker/st_cb_fbo.c
@@ -465,7 +465,7 @@ st_update_renderbuffer_surface(struct st_context *st,
     * to determine if the rb is sRGB-capable.
     */
    boolean enable_srgb = st->ctx->Color.sRGBEnabled &&
-      _mesa_get_format_color_encoding(strb->Base.Format) == GL_SRGB;
+      _mesa_is_format_srgb(strb->Base.Format);
    enum pipe_format format = resource->format;
 
    if (strb->is_rtt) {
@@ -669,8 +669,7 @@ st_validate_attachment(struct gl_context *ctx,
    /* If the encoding is sRGB and sRGB rendering cannot be enabled,
     * check for linear format support instead.
     * Later when we create a surface, we change the format to a linear one. */
-   if (!ctx->Extensions.EXT_sRGB &&
-       _mesa_get_format_color_encoding(texFormat) == GL_SRGB) {
+   if (!ctx->Extensions.EXT_sRGB && _mesa_is_format_srgb(texFormat)) {
       const mesa_format linearFormat = _mesa_get_srgb_format_linear(texFormat);
       format = st_mesa_format_to_pipe_format(st_context(ctx), linearFormat);
    }
diff --git a/src/mesa/state_tracker/st_format.c 
b/src/mesa/state_tracker/st_format.c
index 9e6f76739f7..4edb6782473 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -2251,7 +2251,7 @@ st_choose_matching_format(struct st_context *st, unsigned 
bind,
    mesa_format mesa_format;
 
    for (mesa_format = 1; mesa_format < MESA_FORMAT_COUNT; mesa_format++) {
-      if (_mesa_get_format_color_encoding(mesa_format) == GL_SRGB) {
+      if (_mesa_is_format_srgb(mesa_format)) {
          continue;
       }
       if (_mesa_get_format_bits(mesa_format, GL_TEXTURE_INTENSITY_SIZE) > 0) {

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to