[Mesa-dev] [PATCH 2/8] [v3] i965: Add all surface types to the batch decode

Kenneth Graunke kenneth at whitecape.org
Mon May 18 01:40:32 PDT 2015


On Friday, May 15, 2015 10:06:18 PM Ben Widawsky wrote:
> It's true that not all surfaces apply for every gen, but for the most part this
> is what we want. (The unfortunate case is when we use an valid surface, but not
> for the specific GEN).
> 
> This was automated with a vim macro.
> 
> v2: Shortened common forms such as R8G8B8A8->RGBA8. Note that this makes some of
> the sample output in subsequent commits slightly incorrect.
> 
> v3: Use the name from the table (Ken). This requires declaring the surface
> format array as extern, and declaring the struct in the .h file.
> 
> Signed-off-by: Ben Widawsky <ben at bwidawsk.net>
> ---
>  src/mesa/drivers/dri/i965/brw_context.h         | 14 ++++++++++++++
>  src/mesa/drivers/dri/i965/brw_state_dump.c      |  9 +--------
>  src/mesa/drivers/dri/i965/brw_surface_formats.c | 14 --------------
>  3 files changed, 15 insertions(+), 22 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
> index 2dcc23c..49f5269 100644
> --- a/src/mesa/drivers/dri/i965/brw_context.h
> +++ b/src/mesa/drivers/dri/i965/brw_context.h
> @@ -1738,6 +1738,20 @@ void brw_upload_abo_surfaces(struct brw_context *brw,
>                               struct brw_stage_prog_data *prog_data);
>  
>  /* brw_surface_formats.c */
> +struct surface_format_info {
> +   bool exists;
> +   int sampling;
> +   int filtering;
> +   int shadow_compare;
> +   int chroma_key;
> +   int render_target;
> +   int alpha_blend;
> +   int input_vb;
> +   int streamed_output_vb;
> +   int color_processing;
> +   const char *name;
> +};
> +extern const struct surface_format_info surface_formats[];
>  bool brw_render_target_supported(struct brw_context *brw,
>                                   struct gl_renderbuffer *rb);
>  uint32_t brw_depth_format(struct brw_context *brw, mesa_format format);
> diff --git a/src/mesa/drivers/dri/i965/brw_state_dump.c b/src/mesa/drivers/dri/i965/brw_state_dump.c
> index 530f5a8..aa63c15 100644
> --- a/src/mesa/drivers/dri/i965/brw_state_dump.c
> +++ b/src/mesa/drivers/dri/i965/brw_state_dump.c
> @@ -67,14 +67,7 @@ get_965_surfacetype(unsigned int surfacetype)
>  static const char *
>  get_965_surface_format(unsigned int surface_format)
>  {
> -    switch (surface_format) {
> -    case 0x000: return "r32g32b32a32_float";
> -    case 0x0c1: return "b8g8r8a8_unorm";
> -    case 0x100: return "b5g6r5_unorm";
> -    case 0x102: return "b5g5r5a1_unorm";
> -    case 0x104: return "b4g4r4a4_unorm";
> -    default: return "unknown";
> -    }
> +   return surface_formats[surface_format].name;
>  }
>  
>  static void dump_vs_state(struct brw_context *brw, uint32_t offset)
> diff --git a/src/mesa/drivers/dri/i965/brw_surface_formats.c b/src/mesa/drivers/dri/i965/brw_surface_formats.c
> index 97136d0..dce3091 100644
> --- a/src/mesa/drivers/dri/i965/brw_surface_formats.c
> +++ b/src/mesa/drivers/dri/i965/brw_surface_formats.c
> @@ -28,20 +28,6 @@
>  #include "brw_defines.h"
>  #include "brw_wm.h"
>  
> -struct surface_format_info {
> -   bool exists;
> -   int sampling;
> -   int filtering;
> -   int shadow_compare;
> -   int chroma_key;
> -   int render_target;
> -   int alpha_blend;
> -   int input_vb;
> -   int streamed_output_vb;
> -   int color_processing;
> -   const char *name;
> -};
> -
>  /* This macro allows us to write the table almost as it appears in the PRM,
>   * while restructuring it to turn it into the C code we want.
>   */
> 

Perhaps make a 'const char *brw_surface_format_name(unsigned format)'
function instead?  I'd prefer to keep the struct definition for the
table in brw_surface_formats.c (near the table itself), unless you
have need of it beyond the name.
-------------- 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/20150518/84b53180/attachment-0001.sig>


More information about the mesa-dev mailing list