gallium: decrease the size of pipe_resource - 64 -> 48 bytes
authorMarek Olšák <marek.olsak@amd.com>
Sun, 2 Apr 2017 00:13:12 +0000 (02:13 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 4 Apr 2017 09:14:43 +0000 (11:14 +0200)
Some other changes needed here.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
src/gallium/auxiliary/rbug/rbug_texture.c
src/gallium/auxiliary/rbug/rbug_texture.h
src/gallium/auxiliary/vl/vl_video_buffer.c
src/gallium/drivers/rbug/rbug_core.c
src/gallium/include/pipe/p_state.h
src/mesa/state_tracker/st_cb_texture.c
src/mesa/state_tracker/st_texture.c
src/mesa/state_tracker/st_texture.h

index ca051473504e3325d1b3085a2f96b511e859dc1a..3ee5e142b767d79df6c75e9126b37d87b49401ca 100644 (file)
@@ -283,9 +283,9 @@ int rbug_send_texture_info_reply(struct rbug_connection *__con,
                                  uint32_t format,
                                  uint32_t *width,
                                  uint32_t width_len,
-                                 uint32_t *height,
+                                 uint16_t *height,
                                  uint32_t height_len,
-                                 uint32_t *depth,
+                                 uint16_t *depth,
                                  uint32_t depth_len,
                                  uint32_t blockw,
                                  uint32_t blockh,
index 59c914053ada152ef778c307ab1eb09b6e3b33c5..269e596114858bfdf9d1ed381a348c69835f53b0 100644 (file)
@@ -166,9 +166,9 @@ int rbug_send_texture_info_reply(struct rbug_connection *__con,
                                  uint32_t format,
                                  uint32_t *width,
                                  uint32_t width_len,
-                                 uint32_t *height,
+                                 uint16_t *height,
                                  uint32_t height_len,
-                                 uint32_t *depth,
+                                 uint16_t *depth,
                                  uint32_t depth_len,
                                  uint32_t blockw,
                                  uint32_t blockh,
index f6b3cb5e9f9076d75db4644096bea1a7c183ca29..3b97ac81af9fe11f64e4607b8ee54d79dd6b4500 100644 (file)
@@ -248,6 +248,8 @@ vl_video_buffer_template(struct pipe_resource *templ,
                          unsigned depth, unsigned array_size,
                          unsigned usage, unsigned plane)
 {
+   unsigned height = tmpl->height;
+
    memset(templ, 0, sizeof(*templ));
    if (depth > 1)
       templ->target = PIPE_TEXTURE_3D;
@@ -257,14 +259,14 @@ vl_video_buffer_template(struct pipe_resource *templ,
       templ->target = PIPE_TEXTURE_2D;
    templ->format = resource_format;
    templ->width0 = tmpl->width;
-   templ->height0 = tmpl->height;
    templ->depth0 = depth;
    templ->array_size = array_size;
    templ->bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET | tmpl->bind;
    templ->usage = usage;
 
-   vl_video_buffer_adjust_size(&templ->width0, &templ->height0, plane,
+   vl_video_buffer_adjust_size(&templ->width0, &height, plane,
                                tmpl->chroma_format, false);
+   templ->height0 = height;
 }
 
 static void
index 64c2d63a789d15a4be4640eed5452a79aa9ea307..82bcef8d03b2c8fc8f9564d0dd4f1951694a10a4 100644 (file)
@@ -205,7 +205,7 @@ rbug_texture_info(struct rbug_rbug *tr_rbug, struct rbug_header *header, uint32_
    struct rbug_proto_texture_info *gpti = (struct rbug_proto_texture_info *)header;
    struct rbug_list *ptr;
    struct pipe_resource *t;
-   unsigned num_layers;
+   uint16_t num_layers;
 
    mtx_lock(&rb_screen->list_mutex);
    foreach(ptr, &rb_screen->resources) {
index dc2b329f7a2cb45d9916f1e8dd72467d121202a8..79c76484513f085236d87f1fec0d73d01db6a087 100644 (file)
@@ -497,14 +497,14 @@ struct pipe_resource
 {
    struct pipe_reference reference;
    struct pipe_screen *screen; /**< screen that this texture belongs to */
-   enum pipe_texture_target target; /**< PIPE_TEXTURE_x */
-   enum pipe_format format;         /**< PIPE_FORMAT_x */
 
-   unsigned width0;
-   unsigned height0;
-   unsigned depth0;
-   unsigned array_size;
+   unsigned width0; /**< Used by both buffers and textures. */
+   uint16_t height0; /* Textures: The maximum height/depth/array_size is 16k. */
+   uint16_t depth0;
+   uint16_t array_size;
 
+   enum pipe_format format:16;         /**< PIPE_FORMAT_x */
+   enum pipe_texture_target target:8; /**< PIPE_TEXTURE_x */
    unsigned last_level:8;    /**< Index of last mipmap level present/defined */
    unsigned nr_samples:8;    /**< for multisampled surfaces, nr of samples */
    unsigned usage:8;         /**< PIPE_USAGE_x (not a bitmask) */
index 1b486d7c3c84d1a71014cfce01b2a9243000832d..99c59f77a37f1a599731290f4d02d5e4e589540c 100644 (file)
@@ -497,7 +497,8 @@ guess_and_alloc_texture(struct st_context *st,
    const struct gl_texture_image *firstImage;
    GLuint lastLevel, width, height, depth;
    GLuint bindings;
-   GLuint ptWidth, ptHeight, ptDepth, ptLayers;
+   unsigned ptWidth;
+   uint16_t ptHeight, ptDepth, ptLayers;
    enum pipe_format fmt;
    bool guessed_box = false;
 
@@ -649,7 +650,8 @@ st_AllocTextureImageBuffer(struct gl_context *ctx,
       enum pipe_format format =
          st_mesa_format_to_pipe_format(st, texImage->TexFormat);
       GLuint bindings = default_bindings(st, format);
-      GLuint ptWidth, ptHeight, ptDepth, ptLayers;
+      unsigned ptWidth;
+      uint16_t ptHeight, ptDepth, ptLayers;
 
       st_gl_texture_dims_to_pipe_dims(stObj->base.Target,
                                       width, height, depth,
@@ -2443,7 +2445,8 @@ st_finalize_texture(struct gl_context *ctx,
    GLuint face;
    const struct st_texture_image *firstImage;
    enum pipe_format firstImageFormat;
-   GLuint ptWidth, ptHeight, ptDepth, ptLayers, ptNumSamples;
+   unsigned ptWidth;
+   uint16_t ptHeight, ptDepth, ptLayers, ptNumSamples;
 
    if (tObj->Immutable)
       return GL_TRUE;
@@ -2505,7 +2508,8 @@ st_finalize_texture(struct gl_context *ctx,
 
    /* Find size of level=0 Gallium mipmap image, plus number of texture layers */
    {
-      GLuint width, height, depth;
+      unsigned width;
+      uint16_t height, depth;
 
       st_gl_texture_dims_to_pipe_dims(stObj->base.Target,
                                       firstImage->base.Width2,
@@ -2646,7 +2650,8 @@ st_AllocTextureStorage(struct gl_context *ctx,
    struct st_context *st = st_context(ctx);
    struct st_texture_object *stObj = st_texture_object(texObj);
    struct pipe_screen *screen = st->pipe->screen;
-   GLuint ptWidth, ptHeight, ptDepth, ptLayers, bindings;
+   unsigned ptWidth, bindings;
+   uint16_t ptHeight, ptDepth, ptLayers;
    enum pipe_format fmt;
    GLint level;
    GLuint num_samples = texImage->NumSamples;
index 7b72ffd0501ba07ed6ab5b6af315c68b717c1b21..2e9856dcdfdfc33cf5410232a2c4b94881135b00 100644 (file)
@@ -111,13 +111,13 @@ st_texture_create(struct st_context *st,
  */
 void
 st_gl_texture_dims_to_pipe_dims(GLenum texture,
-                                GLuint widthIn,
-                                GLuint heightIn,
-                                GLuint depthIn,
-                                GLuint *widthOut,
-                                GLuint *heightOut,
-                                GLuint *depthOut,
-                                GLuint *layersOut)
+                                unsigned widthIn,
+                                uint16_t heightIn,
+                                uint16_t depthIn,
+                                unsigned *widthOut,
+                                uint16_t *heightOut,
+                                uint16_t *depthOut,
+                                uint16_t *layersOut)
 {
    switch (texture) {
    case GL_TEXTURE_1D:
@@ -202,7 +202,8 @@ st_texture_match_image(struct st_context *st,
                        const struct pipe_resource *pt,
                        const struct gl_texture_image *image)
 {
-   GLuint ptWidth, ptHeight, ptDepth, ptLayers;
+   unsigned ptWidth;
+   uint16_t ptHeight, ptDepth, ptLayers;
 
    /* Images with borders are never pulled into mipmap textures. 
     */
index 00c30f06cf38ac94e76486bb20741471e8bc82b3..44b07da10bcae9df956233b48799fd000c6a4352 100644 (file)
@@ -202,13 +202,13 @@ st_texture_create(struct st_context *st,
 
 extern void
 st_gl_texture_dims_to_pipe_dims(GLenum texture,
-                                GLuint widthIn,
-                                GLuint heightIn,
-                                GLuint depthIn,
-                                GLuint *widthOut,
-                                GLuint *heightOut,
-                                GLuint *depthOut,
-                                GLuint *layersOut);
+                                unsigned widthIn,
+                                uint16_t heightIn,
+                                uint16_t depthIn,
+                                unsigned *widthOut,
+                                uint16_t *heightOut,
+                                uint16_t *depthOut,
+                                uint16_t *layersOut);
 
 /* Check if an image fits into an existing texture object.
  */