[Mesa-dev] [PATCH 06/13] mesa: reduce the size of gl_image_unit (v2)

Marek Olšák maraeo at gmail.com
Fri Feb 9 01:18:41 UTC 2018


From: Marek Olšák <marek.olsak at amd.com>

gl_context::ImageUnits: 6144 -> 4608 bytes

v2: use ASSERT_BITFIELD_SIZE
---
 src/mesa/main/mtypes.h      | 13 ++++++-------
 src/mesa/main/shaderimage.c |  2 ++
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 23fe459..f829fa3 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -4678,59 +4678,58 @@ struct gl_buffer_binding
 struct gl_image_unit
 {
    /**
     * Texture object bound to this unit.
     */
    struct gl_texture_object *TexObj;
 
    /**
     * Level of the texture object bound to this unit.
     */
-   GLuint Level;
+   GLubyte Level;
 
    /**
     * \c GL_TRUE if the whole level is bound as an array of layers, \c
     * GL_FALSE if only some specific layer of the texture is bound.
     * \sa Layer
     */
    GLboolean Layered;
 
    /**
     * Layer of the texture object bound to this unit as specified by the
     * application.
     */
-   GLuint Layer;
+   GLushort Layer;
 
    /**
-    * Layer of the texture object bound to this unit, or zero if the
-    * whole level is bound.
+    * Layer of the texture object bound to this unit, or zero if
+    * Layered == false.
     */
-   GLuint _Layer;
+   GLushort _Layer;
 
    /**
     * Access allowed to this texture image.  Either \c GL_READ_ONLY,
     * \c GL_WRITE_ONLY or \c GL_READ_WRITE.
     */
    GLenum16 Access;
 
    /**
     * GL internal format that determines the interpretation of the
     * image memory when shader image operations are performed through
     * this unit.
     */
    GLenum16 Format;
 
    /**
     * Mesa format corresponding to \c Format.
     */
-   mesa_format _ActualFormat;
-
+   mesa_format _ActualFormat:16;
 };
 
 /**
  * Shader subroutines storage
  */
 struct gl_subroutine_index_binding
 {
    GLuint NumIndex;
    GLuint *IndexPtr;
 };
diff --git a/src/mesa/main/shaderimage.c b/src/mesa/main/shaderimage.c
index c722b32..596eadd 100644
--- a/src/mesa/main/shaderimage.c
+++ b/src/mesa/main/shaderimage.c
@@ -457,20 +457,22 @@ _mesa_default_image_unit(struct gl_context *ctx)
       ._ActualFormat = _mesa_get_shader_image_format(format)
    };
    return u;
 }
 
 void
 _mesa_init_image_units(struct gl_context *ctx)
 {
    unsigned i;
 
+   ASSERT_BITFIELD_SIZE(struct gl_image_unit, Format, MESA_FORMAT_COUNT);
+
    for (i = 0; i < ARRAY_SIZE(ctx->ImageUnits); ++i)
       ctx->ImageUnits[i] = _mesa_default_image_unit(ctx);
 }
 
 GLboolean
 _mesa_is_image_unit_valid(struct gl_context *ctx, struct gl_image_unit *u)
 {
    struct gl_texture_object *t = u->TexObj;
    mesa_format tex_format;
 
-- 
2.7.4



More information about the mesa-dev mailing list