[Mesa-dev] [PATCH 2/5] i965: Add surface format overrides for Gen6 gather

Kenneth Graunke kenneth at whitecape.org
Wed Feb 5 05:27:22 CET 2014


On 02/03/2014 01:29 AM, Chris Forbes wrote:
> Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
> ---
>  src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 30 ++++++++++++++++++++----
>  1 file changed, 25 insertions(+), 5 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
> index dd96c9b..247b663 100644
> --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
> +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
> @@ -282,15 +282,35 @@ brw_update_texture_surface(struct gl_context *ctx,
>     surf = brw_state_batch(brw, AUB_TRACE_SURFACE_STATE,
>  			  6 * 4, 32, surf_offset);
>  
> -   (void) for_gather;   /* no w/a to apply for this gen */
> +   uint32_t tex_format = translate_tex_format(brw, mt->format,
> +                                              sampler->sRGBDecode);
> +
> +   if (for_gather) {

The cover letter for your patch series has a nice explanation of what's
going on.  It would be great to capture some of that here.  Perhaps by
adding something like:

      /* Sandybridge's gather4 message is broken for integer formats.
       * To work around this, we pretend the surface is UNORM for
       * 8 or 16-bit formats, and emit shader instructions to recover
       * the real INT/UINT value.  For 32-bit formats, we pretend
       * the surface is FLOAT, and simply reinterpret the resulting
       * bits.
       */

> +      switch (tex_format) {
> +      case BRW_SURFACEFORMAT_R8_SINT:
> +      case BRW_SURFACEFORMAT_R8_UINT:
> +         tex_format = BRW_SURFACEFORMAT_R8_UNORM;
> +         break;
> +
> +      case BRW_SURFACEFORMAT_R16_SINT:
> +      case BRW_SURFACEFORMAT_R16_UINT:
> +         tex_format = BRW_SURFACEFORMAT_R16_UNORM;
> +         break;
> +
> +      case BRW_SURFACEFORMAT_R32_SINT:
> +      case BRW_SURFACEFORMAT_R32_UINT:
> +         tex_format = BRW_SURFACEFORMAT_R32_FLOAT;
> +         break;
> +
> +      default:
> +         break;
> +      }
> +   }
>  
>     surf[0] = (translate_tex_target(tObj->Target) << BRW_SURFACE_TYPE_SHIFT |
>  	      BRW_SURFACE_MIPMAPLAYOUT_BELOW << BRW_SURFACE_MIPLAYOUT_SHIFT |
>  	      BRW_SURFACE_CUBEFACE_ENABLES |
> -	      (translate_tex_format(brw,
> -                                    mt->format,
> -				    sampler->sRGBDecode) <<
> -	       BRW_SURFACE_FORMAT_SHIFT));
> +	      tex_format << BRW_SURFACE_FORMAT_SHIFT);
>  
>     surf[1] = intelObj->mt->region->bo->offset64 + intelObj->mt->offset; /* reloc */
>  
> 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140204/6a7b167d/attachment.pgp>


More information about the mesa-dev mailing list