On Thu, Jul 19, 2012 at 12:54 PM, Brian Paul <brian.e.p...@gmail.com> wrote: > Hi Jordan, > > I'd like to see this patch committed so I can do some follow-on > re-org. Just minor comments below.
Do you mean you would like to see it committed before the rest of the series? I'll fix your other recommendations. Thanks, -Jordan > On Wed, Jul 11, 2012 at 3:58 PM, Jordan Justen > <jordan.l.jus...@intel.com> wrote: >> _mesa_is_integer_format is moved to formats.c and renamed >> as _mesa_is_enum_format_integer. >> >> _mesa_is_format_unsigned, _mesa_is_type_integer, >> _mesa_is_type_unsigned, and _mesa_is_enum_format_or_type_integer >> are added. >> >> Signed-off-by: Jordan Justen <jordan.l.jus...@intel.com> >> --- >> src/mesa/main/drawpix.c | 3 +- >> src/mesa/main/formats.c | 13 ++ >> src/mesa/main/formats.h | 4 +- >> src/mesa/main/glformats.c | 185 >> +++++++++++++++++++++++++++++ >> src/mesa/main/glformats.h | 63 ++++++++++ >> src/mesa/main/image.c | 76 ------------ >> src/mesa/main/image.h | 3 - >> src/mesa/main/pack.c | 9 +- >> src/mesa/main/readpix.c | 7 +- >> src/mesa/main/teximage.c | 11 +- >> src/mesa/sources.mak | 1 + > > You also need to add the new source glformats.c file src/mesa/SConscript. > > >> src/mesa/state_tracker/st_cb_drawpixels.c | 3 +- >> 12 files changed, 284 insertions(+), 94 deletions(-) >> create mode 100644 src/mesa/main/glformats.c >> create mode 100644 src/mesa/main/glformats.h >> >> diff --git a/src/mesa/main/drawpix.c b/src/mesa/main/drawpix.c >> index def55dd..7a5597b 100644 >> --- a/src/mesa/main/drawpix.c >> +++ b/src/mesa/main/drawpix.c >> @@ -35,6 +35,7 @@ >> #include "pbo.h" >> #include "state.h" >> #include "dispatch.h" >> +#include "glformats.h" >> >> >> #if FEATURE_drawpix >> @@ -89,7 +90,7 @@ _mesa_DrawPixels( GLsizei width, GLsizei height, >> * input), NVIDIA's implementation also just returns this error despite >> * exposing GL_EXT_texture_integer, just return an error regardless. >> */ >> - if (_mesa_is_integer_format(format)) { >> + if (_mesa_is_enum_format_integer(format)) { >> _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawPixels(integer >> format)"); >> goto end; >> } >> diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c >> index ccc0b17..ca739cd 100644 >> --- a/src/mesa/main/formats.c >> +++ b/src/mesa/main/formats.c >> @@ -28,6 +28,7 @@ >> #include "formats.h" >> #include "mfeatures.h" >> #include "macros.h" >> +#include "glformats.h" >> >> >> /** >> @@ -1712,6 +1713,17 @@ _mesa_is_format_integer_color(gl_format format) >> >> >> /** >> + * Is the given format an unsigned integer format? >> + */ >> +GLboolean >> +_mesa_is_format_unsigned(gl_format format) >> +{ >> + const struct gl_format_info *info = _mesa_get_format_info(format); >> + return _mesa_is_type_unsigned(info->DataType); >> +} >> + >> + >> +/** >> * Return color encoding for given format. >> * \return GL_LINEAR or GL_SRGB >> */ >> @@ -2935,3 +2947,4 @@ _mesa_format_matches_format_and_type(gl_format >> gl_format, >> >> return GL_FALSE; >> } >> + >> diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h >> index 3a694a8..176e0fd 100644 >> --- a/src/mesa/main/formats.h >> +++ b/src/mesa/main/formats.h >> @@ -311,6 +311,9 @@ _mesa_is_format_packed_depth_stencil(gl_format format); >> extern GLboolean >> _mesa_is_format_integer_color(gl_format format); >> >> +extern GLboolean >> +_mesa_is_format_unsigned(gl_format format); >> + >> extern GLenum >> _mesa_get_format_color_encoding(gl_format format); >> >> @@ -346,7 +349,6 @@ _mesa_format_matches_format_and_type(gl_format gl_format, >> GLenum format, GLenum type, >> GLboolean swapBytes); >> >> - >> #ifdef __cplusplus >> } >> #endif >> diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c >> new file mode 100644 >> index 0000000..b2277c3 >> --- /dev/null >> +++ b/src/mesa/main/glformats.c >> @@ -0,0 +1,185 @@ >> +/* >> + * Mesa 3-D graphics library >> + * Version: 7.7 > > Remove the version line, we don'd do that anymore. > >> + * >> + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. >> + * Copyright (c) 2008-2009 VMware, Inc. > > You can add an Intel copyright line if you want. > > >> + * >> + * Permission is hereby granted, free of charge, to any person obtaining a >> + * copy of this software and associated documentation files (the >> "Software"), >> + * to deal in the Software without restriction, including without limitation >> + * the rights to use, copy, modify, merge, publish, distribute, sublicense, >> + * and/or sell copies of the Software, and to permit persons to whom the >> + * Software is furnished to do so, subject to the following conditions: >> + * >> + * The above copyright notice and this permission notice shall be included >> + * in all copies or substantial portions of the Software. >> + * >> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS >> + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF >> MERCHANTABILITY, >> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL >> + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER >> IN > > s/BRIAN PAUL/THE AUTHORS/ > > >> + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN >> + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE >> SOFTWARE. >> + */ >> + >> + >> +#include "imports.h" >> +#include "glformats.h" >> + >> + >> +/** >> + * Test if the given format is an integer (non-normalized) format. >> + */ >> +GLboolean >> +_mesa_is_enum_format_integer(GLenum format) >> +{ >> + switch (format) { >> + /* generic integer formats */ >> + case GL_RED_INTEGER_EXT: >> + case GL_GREEN_INTEGER_EXT: >> + case GL_BLUE_INTEGER_EXT: >> + case GL_ALPHA_INTEGER_EXT: >> + case GL_RGB_INTEGER_EXT: >> + case GL_RGBA_INTEGER_EXT: >> + case GL_BGR_INTEGER_EXT: >> + case GL_BGRA_INTEGER_EXT: >> + case GL_LUMINANCE_INTEGER_EXT: >> + case GL_LUMINANCE_ALPHA_INTEGER_EXT: >> + case GL_RG_INTEGER: >> + /* specific integer formats */ >> + case GL_RGBA32UI_EXT: >> + case GL_RGB32UI_EXT: >> + case GL_RG32UI: >> + case GL_R32UI: >> + case GL_ALPHA32UI_EXT: >> + case GL_INTENSITY32UI_EXT: >> + case GL_LUMINANCE32UI_EXT: >> + case GL_LUMINANCE_ALPHA32UI_EXT: >> + case GL_RGBA16UI_EXT: >> + case GL_RGB16UI_EXT: >> + case GL_RG16UI: >> + case GL_R16UI: >> + case GL_ALPHA16UI_EXT: >> + case GL_INTENSITY16UI_EXT: >> + case GL_LUMINANCE16UI_EXT: >> + case GL_LUMINANCE_ALPHA16UI_EXT: >> + case GL_RGBA8UI_EXT: >> + case GL_RGB8UI_EXT: >> + case GL_RG8UI: >> + case GL_R8UI: >> + case GL_ALPHA8UI_EXT: >> + case GL_INTENSITY8UI_EXT: >> + case GL_LUMINANCE8UI_EXT: >> + case GL_LUMINANCE_ALPHA8UI_EXT: >> + case GL_RGBA32I_EXT: >> + case GL_RGB32I_EXT: >> + case GL_RG32I: >> + case GL_R32I: >> + case GL_ALPHA32I_EXT: >> + case GL_INTENSITY32I_EXT: >> + case GL_LUMINANCE32I_EXT: >> + case GL_LUMINANCE_ALPHA32I_EXT: >> + case GL_RGBA16I_EXT: >> + case GL_RGB16I_EXT: >> + case GL_RG16I: >> + case GL_R16I: >> + case GL_ALPHA16I_EXT: >> + case GL_INTENSITY16I_EXT: >> + case GL_LUMINANCE16I_EXT: >> + case GL_LUMINANCE_ALPHA16I_EXT: >> + case GL_RGBA8I_EXT: >> + case GL_RGB8I_EXT: >> + case GL_RG8I: >> + case GL_R8I: >> + case GL_ALPHA8I_EXT: >> + case GL_INTENSITY8I_EXT: >> + case GL_LUMINANCE8I_EXT: >> + case GL_LUMINANCE_ALPHA8I_EXT: >> + case GL_RGB10_A2UI: >> + return GL_TRUE; >> + default: >> + return GL_FALSE; >> + } >> +} >> + >> + >> +/** >> + * Test if the given type is an integer (non-normalized) format. >> + */ >> +GLboolean >> +_mesa_is_type_integer(GLenum type) >> +{ >> + switch (type) { >> + case GL_INT: >> + case GL_UNSIGNED_INT: >> + case GL_SHORT: >> + case GL_UNSIGNED_SHORT: >> + case GL_BYTE: >> + case GL_UNSIGNED_BYTE: >> + return GL_TRUE; >> + default: >> + return GL_FALSE; >> + } >> +} >> + >> + >> +/** >> + * Test if the given format or type is an integer (non-normalized) format. >> + */ >> +extern GLboolean >> +_mesa_is_enum_format_or_type_integer(GLenum format, GLenum type) >> +{ >> + return _mesa_is_enum_format_integer(format) || >> _mesa_is_type_integer(type); >> +} >> + >> + >> +GLboolean >> +_mesa_is_type_unsigned(GLenum type) >> +{ >> + switch (type) { >> + case GL_UNSIGNED_INT: >> + case GL_UNSIGNED_INT_8_8_8_8: >> + case GL_UNSIGNED_INT_8_8_8_8_REV: >> + case GL_UNSIGNED_INT_10_10_10_2: >> + case GL_UNSIGNED_INT_2_10_10_10_REV: >> + >> + case GL_UNSIGNED_SHORT: >> + case GL_UNSIGNED_SHORT_4_4_4_4: >> + case GL_UNSIGNED_SHORT_5_5_5_1: >> + case GL_UNSIGNED_SHORT_5_6_5: >> + case GL_UNSIGNED_SHORT_5_6_5_REV: >> + case GL_UNSIGNED_SHORT_4_4_4_4_REV: >> + case GL_UNSIGNED_SHORT_1_5_5_5_REV: >> + case GL_UNSIGNED_SHORT_8_8_MESA: >> + case GL_UNSIGNED_SHORT_8_8_REV_MESA: >> + >> + case GL_UNSIGNED_BYTE: >> + case GL_UNSIGNED_BYTE_3_3_2: >> + case GL_UNSIGNED_BYTE_2_3_3_REV: >> + return GL_TRUE; >> + >> + default: >> + return GL_FALSE; >> + } >> +} >> + >> + >> +/** >> + * Convert various base formats to the cooresponding integer format. >> + */ >> +GLenum >> +_mesa_base_format_to_integer_format(GLenum format) >> +{ >> + switch(format) { >> + case GL_RED: >> + return GL_RED_INTEGER; >> + case GL_RG: >> + return GL_RG_INTEGER; >> + case GL_RGBA: >> + return GL_RGBA_INTEGER; > > what about GL_RGB_INTEGER, GL_LUMINANCE_INTEGER_EXT, etc? > > >> + } >> + >> + return format; >> +} >> + >> diff --git a/src/mesa/main/glformats.h b/src/mesa/main/glformats.h >> new file mode 100644 >> index 0000000..f19aa38 >> --- /dev/null >> +++ b/src/mesa/main/glformats.h >> @@ -0,0 +1,63 @@ >> +/* >> + * Mesa 3-D graphics library >> + * Version: 7.7 > > Same comments here as for glformats.c file. > > With those changes, Reviewed-by: Brian Paul <bri...@vmware.com> > > -Brian > _______________________________________________ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-dev _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev