[Mesa-dev] [PATCH 09/26] glsl: Store ir_variable::depth_layout using 3 bits

Kenneth Graunke kenneth at whitecape.org
Mon Jul 21 17:45:05 PDT 2014


On Monday, July 14, 2014 03:48:41 PM Ian Romanick wrote:
> From: Ian Romanick <ian.d.romanick at intel.com>
> 
> warn_extension_index was moved to improve packing.
> 
> Valgrind massif results for a trimmed apitrace of dota2:
> 
>                   n        time(i)         total(B)   useful-heap(B) extra-heap(B)    stacks(B)
> Before (32-bit): 73 40,580,476,304       68,488,400       62,796,151     5,692,249            0
> After  (32-bit): 73 40,575,751,558       68,116,528       62,618,607     5,497,921            0
> 
> Before (64-bit): 71 37,124,890,613       95,889,584       88,089,008     7,800,576            0
> After  (64-bit): 62 37,123,578,526       95,150,784       87,711,304     7,439,480            0
> 
> A real savings of 173KiB on 32-bit and 368KiB on 64-bit.
> 
> Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
> ---
>  src/glsl/ast_to_hir.cpp |  4 ++--
>  src/glsl/ir.h           | 19 +++++++++----------
>  2 files changed, 11 insertions(+), 12 deletions(-)
> 
> diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
> index 542a869..82ac29e 100644
> --- a/src/glsl/ast_to_hir.cpp
> +++ b/src/glsl/ast_to_hir.cpp
> @@ -2923,8 +2923,8 @@ get_variable_being_redeclared(ir_variable *var, YYLTYPE loc,
>                               "gl_FragDepth: depth layout is declared here "
>                               "as '%s, but it was previously declared as "
>                               "'%s'",
> -                             depth_layout_string(var->data.depth_layout),
> -                             depth_layout_string(earlier->data.depth_layout));
> +                             depth_layout_string(ir_depth_layout(var->data.depth_layout)),
> +                             depth_layout_string(ir_depth_layout(earlier->data.depth_layout)));
>        }
>  
>        earlier->data.depth_layout = var->data.depth_layout;
> diff --git a/src/glsl/ir.h b/src/glsl/ir.h
> index d4010fa..d33d153 100644
> --- a/src/glsl/ir.h
> +++ b/src/glsl/ir.h
> @@ -704,6 +704,13 @@ public:
>         */
>        unsigned index:1;
>  
> +      /**
> +       * \brief Layout qualifier for gl_FragDepth.
> +       *
> +       * This is not equal to \c ir_depth_layout_none if and only if this
> +       * variable is \c gl_FragDepth and a layout qualifier is specified.
> +       */
> +      unsigned depth_layout:3;

Can't you just do:

ir_depth_layout depth_layout:3;

and then drop the casts on use?  It seems to work fine, at least with g++ and clang++.

>  
>        /**
>         * ARB_shader_image_load_store qualifiers.
> @@ -714,9 +721,6 @@ public:
>        unsigned image_volatile:1;
>        unsigned image_restrict:1;
>  
> -      /** Image internal format if specified explicitly, otherwise GL_NONE. */
> -      uint16_t image_format;
> -
>        /**
>         * Emit a warning if this variable is accessed.
>         */
> @@ -724,13 +728,8 @@ public:
>        uint8_t warn_extension_index;
>  
>     public:
> -      /**
> -       * \brief Layout qualifier for gl_FragDepth.
> -       *
> -       * This is not equal to \c ir_depth_layout_none if and only if this
> -       * variable is \c gl_FragDepth and a layout qualifier is specified.
> -       */
> -      ir_depth_layout depth_layout;
> +      /** Image internal format if specified explicitly, otherwise GL_NONE. */
> +      uint16_t image_format;
>  
>        /**
>         * Storage location of the base of this variable
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140721/993575d1/attachment.sig>


More information about the mesa-dev mailing list