<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 25, 2015 at 7:42 AM, Emil Velikov <span dir="ltr"><<a href="mailto:emil.l.velikov@gmail.com" target="_blank">emil.l.velikov@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Nanley,<br>
<div><div class="h5"><br>
On 24 August 2015 at 23:49, Nanley Chery <<a href="mailto:nanleychery@gmail.com">nanleychery@gmail.com</a>> wrote:<br>
> On Thu, Aug 20, 2015 at 3:52 PM, Nanley Chery <<a href="mailto:nanleychery@gmail.com">nanleychery@gmail.com</a>> wrote:<br>
>><br>
>> On Thu, Aug 20, 2015 at 11:34 AM, Emil Velikov <<a href="mailto:emil.l.velikov@gmail.com">emil.l.velikov@gmail.com</a>><br>
>> wrote:<br>
>>><br>
>>> 2015-08-12 0:07 GMT+01:00 Nanley Chery <<a href="mailto:nanleychery@gmail.com">nanleychery@gmail.com</a>>:<br>
>>> > From: Nanley Chery <<a href="mailto:nanley.g.chery@intel.com">nanley.g.chery@intel.com</a>><br>
>>> ><br>
>>> > Combine the adjacent cases which have the same GL type in the switch<br>
>>> > statemnt.<br>
>>> ><br>
>>> > Signed-off-by: Nanley Chery <<a href="mailto:nanley.g.chery@intel.com">nanley.g.chery@intel.com</a>><br>
>>> > ---<br>
>>> >  src/mesa/main/formats.c | 152<br>
>>> > ++++++------------------------------------------<br>
>>> >  1 file changed, 17 insertions(+), 135 deletions(-)<br>
>>> ><br>
>>> > diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c<br>
>>> > index cb5ad21..9b9d79b 100644<br>
>>> > --- a/src/mesa/main/formats.c<br>
>>> > +++ b/src/mesa/main/formats.c<br>
>>> > @@ -1005,13 +1005,10 @@<br>
>>> > _mesa_uncompressed_format_to_type_and_comps(mesa_format format,<br>
>>> >     case MESA_FORMAT_R8G8B8X8_UNORM:<br>
>>> >     case MESA_FORMAT_B8G8R8X8_UNORM:<br>
>>> >     case MESA_FORMAT_X8R8G8B8_UNORM:<br>
>>> > -      *datatype = GL_UNSIGNED_BYTE;<br>
>>> > -      *comps = 4;<br>
>>> > -      return;<br>
>>> >     case MESA_FORMAT_BGR_UNORM8:<br>
>>> >     case MESA_FORMAT_RGB_UNORM8:<br>
>>> >        *datatype = GL_UNSIGNED_BYTE;<br>
>>> > -      *comps = 3;<br>
>>> > +      *comps = _mesa_format_num_components(format);<br>
>>> With the datatype aside what is stopping us from using a single<br>
>>> _mesa_format_num_components(format) ?<br>
>>><br>
>> I just checked w/ a gtest and we don't get the same output for the formats<br>
>> listed below. The "Actual" value is the output of<br>
>> _mesa_format_num_components() and the "Expected" value is the output of<br>
>> _mesa_uncompressed_format_to_type_and_comps().<br>
>><br>
>> mesa_formats.cpp:59: Failure<br>
>> Value of: _mesa_format_num_components(f)<br>
>>   Actual: 3<br>
>> Expected: comps<br>
>> Which is: 4<br>
>> MESA_FORMAT_B4G4R4X4_UNORM<br>
>><br>
>> mesa_formats.cpp:59: Failure<br>
>> Value of: _mesa_format_num_components(f)<br>
>>   Actual: 3<br>
>> Expected: comps<br>
>> Which is: 4<br>
>> MESA_FORMAT_B5G5R5X1_UNORM<br>
>><br>
>> mesa_formats.cpp:59: Failure<br>
>> Value of: _mesa_format_num_components(f)<br>
>>   Actual: 3<br>
>> Expected: comps<br>
>> Which is: 4<br>
>> MESA_FORMAT_B10G10R10X2_UNORM<br>
>><br>
>> mesa_formats.cpp:59: Failure<br>
>> Value of: _mesa_format_num_components(f)<br>
>>   Actual: 3<br>
>> Expected: comps<br>
>> Which is: 4<br>
>> MESA_FORMAT_R10G10B10X2_UNORM<br>
>><br>
>> mesa_formats.cpp:59: Failure<br>
>> Value of: _mesa_format_num_components(f)<br>
>>   Actual: 0<br>
>> Expected: comps<br>
>> Which is: 2<br>
>> MESA_FORMAT_YCBCR<br>
>><br>
>> mesa_formats.cpp:59: Failure<br>
>> Value of: _mesa_format_num_components(f)<br>
>>   Actual: 0<br>
>> Expected: comps<br>
>> Which is: 2<br>
>> MESA_FORMAT_YCBCR_REV<br>
>><br>
>> mesa_formats.cpp:59: Failure<br>
>> Value of: _mesa_format_num_components(f)<br>
>>   Actual: 3<br>
>> Expected: comps<br>
>> Which is: 4<br>
>> MESA_FORMAT_RGBX_UNORM16<br>
>><br>
>> mesa_formats.cpp:59: Failure<br>
>> Value of: _mesa_format_num_components(f)<br>
>>   Actual: 3<br>
>> Expected: comps<br>
>> Which is: 4<br>
>> MESA_FORMAT_R8G8B8X8_SNORM<br>
>><br>
>> mesa_formats.cpp:59: Failure<br>
>> Value of: _mesa_format_num_components(f)<br>
>>   Actual: 3<br>
>> Expected: comps<br>
>> Which is: 4<br>
>> MESA_FORMAT_RGBX_SNORM16<br>
>><br>
>> mesa_formats.cpp:59: Failure<br>
>> Value of: _mesa_format_num_components(f)<br>
>>   Actual: 3<br>
>> Expected: comps<br>
>> Which is: 4<br>
>> MESA_FORMAT_B8G8R8X8_SRGB<br>
>><br>
>> mesa_formats.cpp:59: Failure<br>
>> Value of: _mesa_format_num_components(f)<br>
>>   Actual: 3<br>
>> Expected: comps<br>
>> Which is: 4<br>
>> MESA_FORMAT_X8R8G8B8_SRGB<br>
>><br>
>> mesa_formats.cpp:59: Failure<br>
>> Value of: _mesa_format_num_components(f)<br>
>>   Actual: 3<br>
>> Expected: comps<br>
>> Which is: 4<br>
>> MESA_FORMAT_R8G8B8X8_SRGB<br>
>><br>
>> mesa_formats.cpp:59: Failure<br>
>> Value of: _mesa_format_num_components(f)<br>
>>   Actual: 3<br>
>> Expected: comps<br>
>> Which is: 4<br>
>> MESA_FORMAT_X8B8G8R8_SRGB<br>
>><br>
>> mesa_formats.cpp:59: Failure<br>
>> Value of: _mesa_format_num_components(f)<br>
>>   Actual: 2<br>
>> Expected: comps<br>
>> Which is: 1<br>
>> MESA_FORMAT_Z32_FLOAT_S8X24_UINT<br>
>><br>
>> mesa_formats.cpp:59: Failure<br>
>> Value of: _mesa_format_num_components(f)<br>
>>   Actual: 3<br>
>> Expected: comps<br>
>> Which is: 4<br>
>> MESA_FORMAT_RGBX_FLOAT16<br>
>><br>
>> mesa_formats.cpp:59: Failure<br>
>> Value of: _mesa_format_num_components(f)<br>
>>   Actual: 3<br>
>> Expected: comps<br>
>> Which is: 4<br>
>> MESA_FORMAT_RGBX_FLOAT32<br>
>><br>
>> mesa_formats.cpp:59: Failure<br>
>> Value of: _mesa_format_num_components(f)<br>
>>   Actual: 3<br>
>> Expected: comps<br>
>> Which is: 4<br>
>> MESA_FORMAT_RGBX_UINT8<br>
>><br>
>> mesa_formats.cpp:59: Failure<br>
>> Value of: _mesa_format_num_components(f)<br>
>>   Actual: 3<br>
>> Expected: comps<br>
>> Which is: 4<br>
>> MESA_FORMAT_RGBX_UINT16<br>
>><br>
>> mesa_formats.cpp:59: Failure<br>
>> Value of: _mesa_format_num_components(f)<br>
>>   Actual: 3<br>
>> Expected: comps<br>
>> Which is: 4<br>
>> MESA_FORMAT_RGBX_UINT32<br>
>><br>
>> mesa_formats.cpp:59: Failure<br>
>> Value of: _mesa_format_num_components(f)<br>
>>   Actual: 3<br>
>> Expected: comps<br>
>> Which is: 4<br>
>> MESA_FORMAT_RGBX_SINT8<br>
>><br>
>> mesa_formats.cpp:59: Failure<br>
>> Value of: _mesa_format_num_components(f)<br>
>>   Actual: 3<br>
>> Expected: comps<br>
>> Which is: 4<br>
>> MESA_FORMAT_RGBX_SINT16<br>
>><br>
>> mesa_formats.cpp:59: Failure<br>
>> Value of: _mesa_format_num_components(f)<br>
>>   Actual: 3<br>
>> Expected: comps<br>
>> Which is: 4<br>
>> MESA_FORMAT_RGBX_SINT32<br>
>><br>
>> In fact, for this patch, the following behavioral differences exist:<br>
>><br>
>> mesa_formats.cpp:59: Failure<br>
>> Value of: _mesa_format_num_components(f)<br>
>>   Actual: 3<br>
>> Expected: comps<br>
>> Which is: 4<br>
>> MESA_FORMAT_X8B8G8R8_UNORM<br>
>><br>
>> mesa_formats.cpp:59: Failure<br>
>> Value of: _mesa_format_num_components(f)<br>
>>   Actual: 3<br>
>> Expected: comps<br>
>> Which is: 4<br>
>> MESA_FORMAT_R8G8B8X8_UNORM<br>
>><br>
>> mesa_formats.cpp:59: Failure<br>
>> Value of: _mesa_format_num_components(f)<br>
>>   Actual: 3<br>
>> Expected: comps<br>
>> Which is: 4<br>
>> MESA_FORMAT_B8G8R8X8_UNORM<br>
>><br>
>> mesa_formats.cpp:59: Failure<br>
>> Value of: _mesa_format_num_components(f)<br>
>>   Actual: 3<br>
>> Expected: comps<br>
>> Which is: 4<br>
>> MESA_FORMAT_X8R8G8B8_UNORM<br>
>><br>
>> mesa_formats.cpp:59: Failure<br>
>> Value of: _mesa_format_num_components(f)<br>
>>   Actual: 3<br>
>> Expected: comps<br>
>> Which is: 4<br>
>> MESA_FORMAT_X8B8G8R8_SNORM<br>
>><br>
>> I am looking into this issue.<br>
>><br>
> I discussed this issue with Ken and we were able to determine the reason for<br>
> this difference.  _mesa_format_num_components() returns the number of<br>
> components in a format that have useful data. This is equal to the total<br>
> number of components in the format minus the one used for padding (if any).<br>
> These padding components have an X in their name. The proper fix for this is<br>
> to create a second function, _mesa_format_num_components_with_padding. This<br>
> function can then be used instead of hard-coding the number of components<br>
> per format (expect for MESA_FORMAT_YCBCR[_REV]).<br>
><br>
</div></div>I wouldn't bother with this for the time being. That is unless others<br>
insist ;-)<br>
<br></blockquote><div>I was thinking along the same lines. </div><div> </div><div>Regards,</div><div>Nanley</div></div></div></div>