[Mesa-dev] [PATCH 3/8] i965: Faking the ETC2 compression on Gen < 8 GPUs using two miptrees.

Nanley Chery nanleychery at gmail.com
Tue Jan 22 18:43:28 UTC 2019


On Tue, Jan 22, 2019 at 02:17:16PM +0200, Eleni Maria Stea wrote:
> On 1/19/19 1:32 AM, Nanley Chery wrote:
> >> 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 e214fae140..4d1eafac91 100644
> >> --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
> >> +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
> >> @@ -329,6 +329,17 @@ brw_get_texture_swizzle(const struct gl_context *ctx,
> >>  {
> >>     const struct gl_texture_image *img = t->Image[0][t->BaseLevel];
> >>  
> >> +   struct brw_context *brw = brw_context((struct gl_context *)ctx);
> >> +   const struct gen_device_info *devinfo = &brw->screen->devinfo;
> >> +   bool is_fake_etc = _mesa_is_format_etc2(img->TexFormat) &&
> >> +                      devinfo->gen < 8;
> >> +
> >> +   mesa_format format;
> >> +   if (is_fake_etc)
> >> +      format = intel_lower_compressed_format(brw, img->TexFormat);
> >> +   else
> >> +      format = img->TexFormat;
> >> +
> > 
> > Why is modifying this function necessary?
> 
> Hi,
> 
> I'll try to explain this modification:
> 
> After the changes we made:
> - the image TexFormat remains ETC2 to match the main miptree's format
> - the main miptree stores the compressed data (ETC2) so that the
> GetCompressed* functions work
> - the shadow miptree stores the RGBA data and we map it for the drawing
> 
> This texture swizzle function is called before the drawing and it can't
> access the miptrees. Instead it reads the format of the texture we are
> supposed to have in the memory from the gl_texture_image struct directly
> so in this case it reads the ETC2 format.
> 
> At this time, the texture that we have in the memory and is about to be
> used in the drawing is RGBA (from the shadow miptree).
> 
> As a result, we end up calculating the swizzle of the ETC2 format used
> in the original image (+the main miptree) for the RGBA texture that we
> have in the memory. As a result the texture is not rendered properly.
> 

Oh okay, I was thinking that the swizzles of the ETC2 formats wouldn't
conflict with their decompressed RGBA texture, but I see that the SRGB
ones currently need to have the 1st and 3rd swizzles swapped. 

To avoid having to modify this function, could you try the following?
* setting the bgra argument in the decoding function call to false
* updating the mapping in intel_lower_compressed_format() accordingly

-Nanley

> The solution was to use the corresponding RGBA format when we fake the
> ETC2, but as I couldn't read it from the shadow miptree inside this
> function, I took it by calling intel_lower_compressed_format for the
> original ETC2 format of the gl_texture_image.
> 
> I hope that this change is more clear now, I will add a comment
> explaining this just in case,
> 
> Thank you!
> Eleni
> 
> 


More information about the mesa-dev mailing list