mesa: reorder and pack gl_buffer_object
authorMarek Olšák <marek.olsak@amd.com>
Mon, 22 Aug 2022 04:43:36 +0000 (00:43 -0400)
committerMarge Bot <emma+marge@anholt.net>
Mon, 26 Sep 2022 22:58:16 +0000 (22:58 +0000)
The frequently-accessed fields are at the beginning, hoping
we only need to load 1 cache line to get them all.

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18828>

src/mesa/main/mtypes.h

index a671f58..7b3d30e 100644 (file)
@@ -1408,7 +1408,6 @@ struct gl_buffer_object
 {
    GLint RefCount;
    GLuint Name;
-   GLchar *Label;       /**< GL_KHR_debug */
 
    /**
     * The context that holds a global buffer reference for the lifetime of
@@ -1438,28 +1437,8 @@ struct gl_buffer_object
    struct gl_context *Ctx;
    GLint CtxRefCount;   /**< Non-atomic references held by Ctx. */
 
-   GLenum16 Usage;      /**< GL_STREAM_DRAW_ARB, GL_STREAM_READ_ARB, etc. */
-   GLbitfield StorageFlags; /**< GL_MAP_PERSISTENT_BIT, etc. */
-   GLsizeiptrARB Size;  /**< Size of buffer storage in bytes */
-   GLboolean DeletePending;   /**< true if buffer object is removed from the hash */
-   GLboolean Immutable; /**< GL_ARB_buffer_storage */
    gl_buffer_usage UsageHistory; /**< How has this buffer been used so far? */
 
-   /** Counters used for buffer usage warnings */
-   GLuint NumSubDataCalls;
-   GLuint NumMapBufferWriteCalls;
-
-   struct gl_buffer_mapping Mappings[MAP_COUNT];
-
-   /** Memoization of min/max index computations for static index buffers */
-   simple_mtx_t MinMaxCacheMutex;
-   struct hash_table *MinMaxCache;
-   unsigned MinMaxCacheHitIndices;
-   unsigned MinMaxCacheMissIndices;
-   bool MinMaxCacheDirty;
-
-   bool HandleAllocated; /**< GL_ARB_bindless_texture */
-
    struct pipe_resource *buffer;
    struct gl_context *private_refcount_ctx;
    /* This mechanism allows passing buffer references to the driver without
@@ -1478,6 +1457,27 @@ struct gl_buffer_object
     */
    int private_refcount;
 
+   GLbitfield StorageFlags; /**< GL_MAP_PERSISTENT_BIT, etc. */
+
+   /** Memoization of min/max index computations for static index buffers */
+   unsigned MinMaxCacheHitIndices;
+   unsigned MinMaxCacheMissIndices;
+   struct hash_table *MinMaxCache;
+   simple_mtx_t MinMaxCacheMutex;
+   bool MinMaxCacheDirty:1;
+
+   bool DeletePending:1;  /**< true if buffer object is removed from the hash */
+   bool Immutable:1;    /**< GL_ARB_buffer_storage */
+   bool HandleAllocated:1; /**< GL_ARB_bindless_texture */
+   GLenum16 Usage;      /**< GL_STREAM_DRAW_ARB, GL_STREAM_READ_ARB, etc. */
+   GLchar *Label;       /**< GL_KHR_debug */
+   GLsizeiptrARB Size;  /**< Size of buffer storage in bytes */
+
+   /** Counters used for buffer usage warnings */
+   GLuint NumSubDataCalls;
+   GLuint NumMapBufferWriteCalls;
+
+   struct gl_buffer_mapping Mappings[MAP_COUNT];
    struct pipe_transfer *transfer[MAP_COUNT];
 };