<div dir="ltr">Thanks for pointing out these errors. I'll fix them in the next version.<br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Aug 21, 2015 at 2:34 PM, Chad Versace <span dir="ltr"><<a href="mailto:chad.versace@intel.com" target="_blank">chad.versace@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Wed 19 Aug 2015, Nanley Chery wrote:<br>
> From: Nanley Chery <<a href="mailto:nanley.g.chery@intel.com">nanley.g.chery@intel.com</a>><br>
><br>
> All compressed formats return GL_FALSE and there isn't any evidence to<br>
> support that this behaviour would change. Remove all switch cases for<br>
> compressed formats.<br>
><br>
> v2. Since the exhaustive switch is removed, add a gtest to ensure<br>
> all formats are handled.<br>
> v3. Ensure that GL_NO_ERROR is set before returning.<br>
><br>
> Cc: Brian Paul <<a href="mailto:brianp@vmware.com">brianp@vmware.com</a>><br>
> Cc: Chad Versace <<a href="mailto:chad.versace@intel.com">chad.versace@intel.com</a>><br>
> Signed-off-by: Nanley Chery <<a href="mailto:nanley.g.chery@intel.com">nanley.g.chery@intel.com</a>><br>
> ---<br>
> src/mesa/drivers/dri/i915/intel_pixel_read.c | 2 +-<br>
> src/mesa/drivers/dri/i915/intel_tex_image.c | 2 +-<br>
> src/mesa/main/formats.c | 58 ++++++----------------------<br>
> src/mesa/main/formats.h | 2 +-<br>
> src/mesa/main/readpix.c | 2 +-<br>
> src/mesa/main/tests/mesa_formats.cpp | 7 +++-<br>
> src/mesa/main/texgetimage.c | 2 +-<br>
> src/mesa/main/texstore.c | 2 +-<br>
> src/mesa/state_tracker/st_cb_readpixels.c | 2 +-<br>
> src/mesa/state_tracker/st_cb_texture.c | 6 +--<br>
> src/mesa/state_tracker/st_format.c | 2 +-<br>
> src/mesa/swrast/s_drawpix.c | 2 +-<br>
> 12 files changed, 29 insertions(+), 60 deletions(-)<br>
><br>
</div></div><span class="">> diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c<br>
> index e58b917..1f221f1 100644<br>
> --- a/src/mesa/main/formats.c<br>
> +++ b/src/mesa/main/formats.c<br>
> @@ -1432,15 +1432,19 @@ _mesa_uncompressed_format_to_type_and_comps(mesa_format format,<br>
> GLboolean<br>
> _mesa_format_matches_format_and_type(mesa_format mesa_format,<br>
> GLenum format, GLenum type,<br>
> - GLboolean swapBytes)<br>
> + GLboolean swapBytes, GLenum *error)<br>
<br>
</span>The parameter alignment looks wrong here. Maybe it's just my email app,<br>
though.<br>
<br>
Please document the function's error behavior: what errors does it and<br>
emit and when.<br>
<span class=""><br>
> {<br>
> const GLboolean littleEndian = _mesa_little_endian();<br>
> + if (error)<br>
> + *error = GL_NO_ERROR;<br>
><br>
> /* Note: When reading a GL format/type combination, the format lists channel<br>
> * assignments from most significant channel in the type to least<br>
> * significant. A type with _REV indicates that the assignments are<br>
> * swapped, so they are listed from least significant to most significant.<br>
> *<br>
> + * Compressed formats will fall through and return GL_FALSE.<br>
> + *<br>
> * For sanity, please keep this switch statement ordered the same as the<br>
> * enums in formats.h.<br>
> */<br>
<br>
<br>
<br>
</span><span class="">> @@ -2024,8 +1983,13 @@ _mesa_format_matches_format_and_type(mesa_format mesa_format,<br>
> case MESA_FORMAT_B8G8R8X8_SRGB:<br>
> case MESA_FORMAT_X8R8G8B8_SRGB:<br>
> return GL_FALSE;<br>
> + default:<br>
> + if (!_mesa_is_format_compressed(format)) {<br>
> + assert(0);<br>
> + if (error)<br>
> + *error = GL_INVALID_ENUM;<br>
> + }<br>
> }<br>
<br>
</span>The pattern in the default case...<br>
<br>
if (!stuff) {<br>
assert(0);<br>
if (error)<br>
*error = GL_INVALID_ENUM;<br>
}<br>
<br>
would be better phrased as this equivalent code:<br>
<br>
assert(stuff);<br>
if (error)<br>
*error = GL_INVALID_ENUM;<br>
<span class=""><br>
> -<br>
> return GL_FALSE;<br>
> }<br>
><br>
> diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h<br>
> index e08247e..0634b78 100644<br>
> --- a/src/mesa/main/formats.h<br>
> +++ b/src/mesa/main/formats.h<br>
> @@ -675,7 +675,7 @@ _mesa_format_has_color_component(mesa_format format, int component);<br>
> GLboolean<br>
> _mesa_format_matches_format_and_type(mesa_format mesa_format,<br>
> GLenum format, GLenum type,<br>
> - GLboolean swapBytes);<br>
> + GLboolean swapBytes, GLenum *error);<br>
><br>
> #ifdef __cplusplus<br>
> }<br>
<br>
<br>
<br>
</span><span class="">> diff --git a/src/mesa/main/tests/mesa_formats.cpp b/src/mesa/main/tests/mesa_formats.cpp<br>
> index 7bf9147..dfc7d0e 100644<br>
> --- a/src/mesa/main/tests/mesa_formats.cpp<br>
> +++ b/src/mesa/main/tests/mesa_formats.cpp<br>
> @@ -49,11 +49,16 @@ TEST(MesaFormatsTest, FormatTypeAndComps)<br>
> */<br>
> if (!_mesa_is_format_compressed(f)) {<br>
> GLenum datatype = 0;<br>
> + GLenum error = 0;<br>
> GLuint comps = 0;<br>
> - _mesa_uncompressed_format_to_type_and_comps(f, &datatype, &comps);<br>
><br>
> /* If the datatype is zero, the format was not handled */<br>
> + _mesa_uncompressed_format_to_type_and_comps(f, &datatype, &comps);<br>
> ASSERT_NE(datatype, (GLenum)0);<br>
> +<br>
> + /* If the error is INVALID_ENUM, the format was not handled */<br>
> + _mesa_format_matches_format_and_type(f, f, datatype, GL_FALSE, &error);<br>
> + ASSERT_NE(error, (GLenum)GL_INVALID_ENUM);<br>
<br>
</span>Two comments on the new check:<br>
<br>
- It is more robust to check that no error was returned<br>
rather than checking that a specific error was not returned. That<br>
is, this is more robust:<br>
<br>
ASSERT_EQ(error, (GLenum)GL_NO_ERROR)<br>
<br>
- One of the first two arguments to<br>
_mesa_uncompressed_format_to_type_and_comps() is wrong. The patch<br>
passes the same value for each argument, but parameters have<br>
different types.<br>
<br>
<br>
> 2.5.0<br>
<br>
Git 2.5.0? Are you building Git from source? Fedora 22 is still shipping<br>
git-2.4.3.<br>
</blockquote></div>I'm running Arch Linux.</div></div>