[Mesa-dev] [PATCH] nv50,nvc0: fix Z24 formats

David Heidelberger david.heidelberger at ixit.cz
Thu Sep 11 15:05:07 PDT 2014


I started using PIPE_FORMAT_X8Z24_UNORM and 
PIPE_FORMAT_S8_UINT_Z24_UNORM in Nine state tracker.

As it shows up, it caused problems on NVC0 (PGRAPH errors), which are 
solved by adding PIPE_FORMAT_X8Z24_UNORM in nvc0_miptree.c.

By quick grep I also noticed, there is lot places in nv50, where missing 
case for S8Z24 and X8Z24 which may cause problems.

Also I fixed mask for PIPE_FORMAT_X8Z24_UNORM in 
nv50_blit_eng2d_get_mask from 0x00ffffff to 0xffffff00 (same pattern as 
for PIPE_FORMAT_S8_UINT_Z24_UNORM, which seems to be correct)

David
Dne 2014-09-11 23:01, Ilia Mirkin napsal:
> On Thu, Sep 11, 2014 at 5:45 PM, David Heidelberger
> <david.heidelberger at ixit.cz> wrote:
>> also fixes nv50_blit_eng2d_get_mask for PIPE_FORMAT_X8Z24_UNORM
> 
> Can you explain the problem a little bit and what the end-effect of
> this fix is? If not, that's OK, I can probably work it out...
> 
>> 
>> Tested-by: Tiziano Bacocco <tizbac2 at gmail.com> (on NVC0)
> 
> What was the test that was done? Full piglit run before and after?
> 
>> Signed-off-by: David Heidelberger <david.heidelberger at ixit.cz>
>> ---
>>  src/gallium/drivers/nouveau/nv50/nv50_blit.h    | 26
>> ++++++++++++-------------
>>  src/gallium/drivers/nouveau/nv50/nv50_surface.c |  1 +
>>  src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c |  1 +
>>  3 files changed, 14 insertions(+), 14 deletions(-)
>> 
>> diff --git a/src/gallium/drivers/nouveau/nv50/nv50_blit.h
>> b/src/gallium/drivers/nouveau/nv50/nv50_blit.h
>> index bdd6a63..6b9ddac 100644
>> --- a/src/gallium/drivers/nouveau/nv50/nv50_blit.h
>> +++ b/src/gallium/drivers/nouveau/nv50/nv50_blit.h
>> @@ -111,6 +111,7 @@ nv50_blit_zeta_to_colour_format(enum pipe_format 
>> format)
>>     case PIPE_FORMAT_Z24_UNORM_S8_UINT:
>>     case PIPE_FORMAT_S8_UINT_Z24_UNORM:
>>     case PIPE_FORMAT_Z24X8_UNORM:
>> +   case PIPE_FORMAT_X8Z24_UNORM:
>>        return PIPE_FORMAT_R8G8B8A8_UNORM;
>>     case PIPE_FORMAT_Z32_FLOAT:
>>        return PIPE_FORMAT_R32_FLOAT;
>> @@ -127,23 +128,20 @@ static INLINE uint16_t
>>  nv50_blit_derive_color_mask(const struct pipe_blit_info *info)
>>  {
>>     const unsigned mask = info->mask;
>> -
>>     uint16_t color_mask = 0;
>> 
>>     switch (info->dst.format) {
>>     case PIPE_FORMAT_Z24_UNORM_S8_UINT:
>> -      if (mask & PIPE_MASK_S)
>> -         color_mask |= 0x1000;
>> +      if (mask & PIPE_MASK_S) color_mask |= 0x1000;
>>        /* fall through */
>>     case PIPE_FORMAT_Z24X8_UNORM:
>> -      if (mask & PIPE_MASK_Z)
>> -         color_mask |= 0x0111;
>> +      if (mask & PIPE_MASK_Z) color_mask |= 0x0111;
>>        break;
>>     case PIPE_FORMAT_S8_UINT_Z24_UNORM:
>> -      if (mask & PIPE_MASK_Z)
>> -         color_mask |= 0x1110;
>> -      if (mask & PIPE_MASK_S)
>> -         color_mask |= 0x0001;
>> +      if (mask & PIPE_MASK_S) color_mask |= 0x0001;
>> +      /* fall through */
>> +   case PIPE_FORMAT_X8Z24_UNORM:
>> +      if (mask & PIPE_MASK_Z) color_mask |= 0x1110;
>>        break;
>>     default:
>>        if (mask & (PIPE_MASK_R | PIPE_MASK_Z)) color_mask |= 0x0001;
>> @@ -152,7 +150,6 @@ nv50_blit_derive_color_mask(const struct 
>> pipe_blit_info
>> *info)
>>        if (mask & PIPE_MASK_A) color_mask |= 0x1000;
>>        break;
>>     }
>> -
>>     return color_mask;
>>  }
>> 
>> @@ -163,15 +160,16 @@ nv50_blit_eng2d_get_mask(const struct 
>> pipe_blit_info
>> *info)
>> 
>>     switch (info->dst.format) {
>>     case PIPE_FORMAT_Z24_UNORM_S8_UINT:
>> -      if (info->mask & PIPE_MASK_Z) mask |= 0x00ffffff;
>>        if (info->mask & PIPE_MASK_S) mask |= 0xff000000;
>> +      /* fall through */
>> +   case PIPE_FORMAT_Z24X8_UNORM:
>> +      if (info->mask & PIPE_MASK_Z) mask |= 0x00ffffff;
>>        break;
>>     case PIPE_FORMAT_S8_UINT_Z24_UNORM:
>> -      if (info->mask & PIPE_MASK_Z) mask |= 0xffffff00;
>>        if (info->mask & PIPE_MASK_S) mask |= 0x000000ff;
>> -      break;
>> +      /* fall through */
>>     case PIPE_FORMAT_X8Z24_UNORM:
>> -      if (info->mask & PIPE_MASK_Z) mask = 0x00ffffff;
>> +      if (info->mask & PIPE_MASK_Z) mask |= 0xffffff00;
>>        break;
>>     default:
>>        mask = 0xffffffff;
>> diff --git a/src/gallium/drivers/nouveau/nv50/nv50_surface.c
>> b/src/gallium/drivers/nouveau/nv50/nv50_surface.c
>> index 3f33033..cc683e3 100644
>> --- a/src/gallium/drivers/nouveau/nv50/nv50_surface.c
>> +++ b/src/gallium/drivers/nouveau/nv50/nv50_surface.c
>> @@ -834,6 +834,7 @@ nv50_blit_select_mode(const struct pipe_blit_info 
>> *info)
>>           return NV50_BLIT_MODE_X24S8;
>>        }
>>     case PIPE_FORMAT_S8_UINT_Z24_UNORM:
>> +   case PIPE_FORMAT_X8Z24_UNORM:
>>        switch (mask & PIPE_MASK_ZS) {
>>        case PIPE_MASK_ZS: return NV50_BLIT_MODE_S8Z24;
>>        case PIPE_MASK_Z:  return NV50_BLIT_MODE_X8Z24;
>> diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c
>> b/src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c
>> index 3baa752..4b4d090 100644
>> --- a/src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c
>> +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c
>> @@ -53,6 +53,7 @@ nvc0_mt_choose_storage_type(struct nv50_miptree *mt,
>> boolean compressed)
>>        else
>>           tile_flags = 0x01;
>>        break;
>> +   case PIPE_FORMAT_X8Z24_UNORM:
>>     case PIPE_FORMAT_S8_UINT_Z24_UNORM:
>>        if (compressed)
>>           tile_flags = 0x51 + ms;
>> --
>> 2.1.0
>> 
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list