mesa: change gl_vertex_format::Format to bool Bgra to free bits
authorMarek Olšák <marek.olsak@amd.com>
Mon, 12 Dec 2022 05:28:16 +0000 (00:28 -0500)
committerMarek Olšák <marek.olsak@amd.com>
Sun, 18 Dec 2022 19:35:59 +0000 (14:35 -0500)
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20287>

src/mesa/main/get.c
src/mesa/main/mtypes.h
src/mesa/main/varray.c
src/mesa/vbo/vbo_save_api.c

index 20b1cc0..1102f55 100644 (file)
@@ -1053,11 +1053,11 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu
    /* ARB_vertex_array_bgra */
    case GL_COLOR_ARRAY_SIZE:
       array = &ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_COLOR0];
-      v->value_int = array->Format.Format == GL_BGRA ? GL_BGRA : array->Format.Size;
+      v->value_int = array->Format.Bgra ? GL_BGRA : array->Format.Size;
       break;
    case GL_SECONDARY_COLOR_ARRAY_SIZE:
       array = &ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_COLOR1];
-      v->value_int = array->Format.Format == GL_BGRA ? GL_BGRA : array->Format.Size;
+      v->value_int = array->Format.Bgra ? GL_BGRA : array->Format.Size;
       break;
 
    /* ARB_copy_buffer */
index bf39a08..a1fc78a 100644 (file)
@@ -326,13 +326,13 @@ struct gl_colorbuffer_attrib
 struct gl_vertex_format
 {
    GLenum16 Type;        /**< datatype: GL_FLOAT, GL_INT, etc */
-   GLenum16 Format;      /**< default: GL_RGBA, but may be GL_BGRA */
-   enum pipe_format _PipeFormat:16; /**< pipe_format for Gallium */
+   bool Bgra;            /**< true if GL_BGRA, else GL_RGBA */
    GLubyte Size:5;       /**< components per element (1,2,3,4) */
    GLubyte Normalized:1; /**< GL_ARB_vertex_program */
    GLubyte Integer:1;    /**< Integer-valued? */
    GLubyte Doubles:1;    /**< double values are not converted to floats */
-   GLubyte _ElementSize; /**< Size of each element in bytes */
+   enum pipe_format _PipeFormat:16; /**< pipe_format for Gallium */
+   GLushort _ElementSize; /**< Size of each element in bytes */
 };
 
 
index 5990b9a..f0933a6 100644 (file)
@@ -652,7 +652,7 @@ _mesa_set_vertex_format(struct gl_vertex_format *vertex_format,
 {
    assert(size <= 4);
    vertex_format->Type = type;
-   vertex_format->Format = format;
+   vertex_format->Bgra = format == GL_BGRA;
    vertex_format->Size = size;
    vertex_format->Normalized = normalized;
    vertex_format->Integer = integer;
@@ -2300,7 +2300,7 @@ get_vertex_array_attrib(struct gl_context *ctx,
    case GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB:
       return !!(vao->Enabled & VERT_BIT_GENERIC(index));
    case GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB:
-      return (array->Format.Format == GL_BGRA) ? GL_BGRA : array->Format.Size;
+      return array->Format.Bgra ? GL_BGRA : array->Format.Size;
    case GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB:
       return array->Stride;
    case GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB:
index 5f92a4d..5947b05 100644 (file)
@@ -322,7 +322,7 @@ compare_vao(gl_vertex_processing_mode mode,
          return false;
       if (attrib->Format.Size != size[vbo_attr])
          return false;
-      assert(attrib->Format.Format == GL_RGBA);
+      assert(!attrib->Format.Bgra);
       assert(attrib->Format.Normalized == GL_FALSE);
       assert(attrib->Format.Integer == vbo_attrtype_to_integer_flag(tp));
       assert(attrib->Format.Doubles == vbo_attrtype_to_double_flag(tp));