aboutsummaryrefslogtreecommitdiff
path: root/mesalib
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-02-08 16:41:27 +0100
committermarha <marha@users.sourceforge.net>2012-02-08 16:41:27 +0100
commit03346747e21e4cd1db30c6a5d8af6705575e3755 (patch)
tree120604af21bdac64007a0a3005dcce420cb76714 /mesalib
parentada3d2c30b5a7a1a79e128b7326d50c3bab77a8a (diff)
downloadvcxsrv-03346747e21e4cd1db30c6a5d8af6705575e3755.tar.gz
vcxsrv-03346747e21e4cd1db30c6a5d8af6705575e3755.tar.bz2
vcxsrv-03346747e21e4cd1db30c6a5d8af6705575e3755.zip
mesa git update 8 feb 2012
Diffstat (limited to 'mesalib')
-rw-r--r--mesalib/configure.ac10
-rw-r--r--mesalib/scons/custom.py5
-rw-r--r--mesalib/scons/gallium.py12
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_debug.h2
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_video.h1
-rw-r--r--mesalib/src/mesa/drivers/dri/Makefile.am6
-rw-r--r--mesalib/src/mesa/main/debug.c29
-rw-r--r--mesalib/src/mesa/main/drawpix.c38
-rw-r--r--mesalib/src/mesa/main/image.c216
-rw-r--r--mesalib/src/mesa/main/image.h6
-rw-r--r--mesalib/src/mesa/main/readpix.c160
-rw-r--r--mesalib/src/mesa/main/readpix.h4
-rw-r--r--mesalib/src/mesa/main/texgetimage.c44
-rw-r--r--mesalib/src/mesa/main/teximage.c25
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom_sampler.c2
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom_texture.c3
16 files changed, 269 insertions, 294 deletions
diff --git a/mesalib/configure.ac b/mesalib/configure.ac
index e859d4cc6..b2b1ab8f4 100644
--- a/mesalib/configure.ac
+++ b/mesalib/configure.ac
@@ -36,7 +36,7 @@ USER_CXXFLAGS="$CXXFLAGS"
dnl Versions for external dependencies
LIBDRM_REQUIRED=2.4.24
-LIBDRM_RADEON_REQUIRED=2.4.24
+LIBDRM_RADEON_REQUIRED=2.4.31
LIBDRM_INTEL_REQUIRED=2.4.30
LIBDRM_NOUVEAU_REQUIRED=0.6
DRI2PROTO_REQUIRED=2.6
@@ -1240,11 +1240,14 @@ if test "x$enable_dri" = xyes; then
LIBS="$save_LIBS"
fi
- # libdrm is required for all except swrast
+ # if we are building any dri driver other than swrast ...
if test -n "$DRI_DIRS" -a x"$DRI_DIRS" != xswrast; then
+ # ... libdrm is required
if test "x$have_libdrm" != xyes; then
AC_MSG_ERROR([DRI drivers requires libdrm >= $LIBDRM_REQUIRED])
fi
+ # ... and build dricommon
+ HAVE_COMMON_DRI=yes
fi
# put all the necessary libs together
@@ -1309,6 +1312,7 @@ AM_CONDITIONAL(HAVE_NOUVEAU_DRI, test x$HAVE_NOUVEAU_DRI = xyes)
AM_CONDITIONAL(HAVE_R200_DRI, test x$HAVE_R200_DRI = xyes)
AM_CONDITIONAL(HAVE_RADEON_DRI, test x$HAVE_RADEON_DRI = xyes)
AM_CONDITIONAL(HAVE_SWRAST_DRI, test x$HAVE_SWRAST_DRI = xyes)
+AM_CONDITIONAL(HAVE_COMMON_DRI, test x$HAVE_COMMON_DRI = xyes)
dnl
dnl OSMesa configuration
@@ -1860,11 +1864,13 @@ if test "x$with_gallium_drivers" != x; then
gallium_check_st "i915/drm" "dri-i915" "xorg-i915"
;;
xr300)
+ PKG_CHECK_MODULES([RADEON], [libdrm_radeon >= $LIBDRM_RADEON_REQUIRED])
gallium_require_llvm "Gallium R300"
GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r300"
gallium_check_st "radeon/drm" "dri-r300" "xorg-r300" "" "xvmc-r300" "vdpau-r300" "va-r300"
;;
xr600)
+ PKG_CHECK_MODULES([RADEON], [libdrm_radeon >= $LIBDRM_RADEON_REQUIRED])
GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r600"
gallium_check_st "radeon/drm" "dri-r600" "xorg-r600" "" "xvmc-r600" "vdpau-r600" "va-r600"
;;
diff --git a/mesalib/scons/custom.py b/mesalib/scons/custom.py
index 08073162e..cc953bd99 100644
--- a/mesalib/scons/custom.py
+++ b/mesalib/scons/custom.py
@@ -174,6 +174,9 @@ def _pkg_check_modules(env, name, modules):
if subprocess.call(["pkg-config", "--exists", ' '.join(modules)]) != 0:
return
+ # Strip version expressions from modules
+ modules = [module.split(' ', 1)[0] for module in modules]
+
# Other flags may affect the compilation of unrelated targets, so store
# them with a prefix, (e.g., XXX_CFLAGS, XXX_LIBS, etc)
try:
@@ -189,7 +192,7 @@ def _pkg_check_modules(env, name, modules):
def pkg_check_modules(env, name, modules):
- sys.stdout.write('Checking for %s...' % name)
+ sys.stdout.write('Checking for %s (%s)...' % (name, ' '.join(modules)))
_pkg_check_modules(env, name, modules)
result = env['HAVE_' + name]
sys.stdout.write(' %s\n' % ['no', 'yes'][int(bool(result))])
diff --git a/mesalib/scons/gallium.py b/mesalib/scons/gallium.py
index eed89cf71..2fa80db88 100644
--- a/mesalib/scons/gallium.py
+++ b/mesalib/scons/gallium.py
@@ -507,12 +507,12 @@ def generate(env):
env.PkgCheckModules('X11', ['x11', 'xext', 'xdamage', 'xfixes'])
env.PkgCheckModules('XCB', ['x11-xcb', 'xcb-glx'])
env.PkgCheckModules('XF86VIDMODE', ['xxf86vm'])
- env.PkgCheckModules('DRM', ['libdrm'])
- env.PkgCheckModules('DRM_INTEL', ['libdrm_intel'])
- env.PkgCheckModules('DRM_RADEON', ['libdrm_radeon'])
- env.PkgCheckModules('XORG', ['xorg-server'])
- env.PkgCheckModules('KMS', ['libkms'])
- env.PkgCheckModules('UDEV', ['libudev'])
+ env.PkgCheckModules('DRM', ['libdrm >= 2.4.24'])
+ env.PkgCheckModules('DRM_INTEL', ['libdrm_intel >= 2.4.30'])
+ env.PkgCheckModules('DRM_RADEON', ['libdrm_radeon >= 2.4.31'])
+ env.PkgCheckModules('XORG', ['xorg-server >= 1.6.0'])
+ env.PkgCheckModules('KMS', ['libkms >= 2.4.24'])
+ env.PkgCheckModules('UDEV', ['libudev > 150'])
env['dri'] = env['x11'] and env['drm']
diff --git a/mesalib/src/gallium/auxiliary/util/u_debug.h b/mesalib/src/gallium/auxiliary/util/u_debug.h
index ed19cda05..06470f66a 100644
--- a/mesalib/src/gallium/auxiliary/util/u_debug.h
+++ b/mesalib/src/gallium/auxiliary/util/u_debug.h
@@ -101,7 +101,7 @@ debug_printf(const char *format, ...)
* ... isn't portable so we need to pass arguments in parentheses.
*
* usage:
- * debug_printf_once(("awnser: %i\n", 42));
+ * debug_printf_once(("answer: %i\n", 42));
*/
#define debug_printf_once(args) \
do { \
diff --git a/mesalib/src/gallium/auxiliary/util/u_video.h b/mesalib/src/gallium/auxiliary/util/u_video.h
index be3fac2d0..e575947d4 100644
--- a/mesalib/src/gallium/auxiliary/util/u_video.h
+++ b/mesalib/src/gallium/auxiliary/util/u_video.h
@@ -64,7 +64,6 @@ u_reduce_video_profile(enum pipe_video_profile profile)
return PIPE_VIDEO_CODEC_MPEG4_AVC;
default:
- assert(0);
return PIPE_VIDEO_CODEC_UNKNOWN;
}
}
diff --git a/mesalib/src/mesa/drivers/dri/Makefile.am b/mesalib/src/mesa/drivers/dri/Makefile.am
index 8b9358221..48d36858b 100644
--- a/mesalib/src/mesa/drivers/dri/Makefile.am
+++ b/mesalib/src/mesa/drivers/dri/Makefile.am
@@ -1,4 +1,8 @@
-SUBDIRS = common
+SUBDIRS =
+
+if HAVE_COMMON_DRI
+SUBDIRS+=common
+endif
if HAVE_I915_DRI
SUBDIRS+=i915
diff --git a/mesalib/src/mesa/main/debug.c b/mesalib/src/mesa/main/debug.c
index 72aa8cb4f..71d7f1ac6 100644
--- a/mesalib/src/mesa/main/debug.c
+++ b/mesalib/src/mesa/main/debug.c
@@ -554,8 +554,35 @@ _mesa_dump_image(const char *filename, const void *image, GLuint w, GLuint h,
else if (format == GL_LUMINANCE_ALPHA && type == GL_UNSIGNED_BYTE) {
write_ppm(filename, image, w, h, 2, 1, 0, 0, invert);
}
+ else if (format == GL_RED && type == GL_UNSIGNED_BYTE) {
+ write_ppm(filename, image, w, h, 1, 0, 0, 0, invert);
+ }
+ else if (format == GL_RGBA && type == GL_FLOAT) {
+ /* convert floats to ubyte */
+ GLubyte *buf = (GLubyte *) malloc(w * h * 4 * sizeof(GLubyte));
+ const GLfloat *f = (const GLfloat *) image;
+ GLuint i;
+ for (i = 0; i < w * h * 4; i++) {
+ UNCLAMPED_FLOAT_TO_UBYTE(buf[i], f[i]);
+ }
+ write_ppm(filename, buf, w, h, 4, 0, 1, 2, invert);
+ free(buf);
+ }
+ else if (format == GL_RED && type == GL_FLOAT) {
+ /* convert floats to ubyte */
+ GLubyte *buf = (GLubyte *) malloc(w * h * sizeof(GLubyte));
+ const GLfloat *f = (const GLfloat *) image;
+ GLuint i;
+ for (i = 0; i < w * h; i++) {
+ UNCLAMPED_FLOAT_TO_UBYTE(buf[i], f[i]);
+ }
+ write_ppm(filename, buf, w, h, 1, 0, 0, 0, invert);
+ free(buf);
+ }
else {
- _mesa_problem(NULL, "Unsupported format/type in _mesa_dump_image()");
+ _mesa_problem(NULL,
+ "Unsupported format 0x%x / type 0x%x in _mesa_dump_image()",
+ format, type);
}
}
diff --git a/mesalib/src/mesa/main/drawpix.c b/mesalib/src/mesa/main/drawpix.c
index 01983d945..c2f7db2e8 100644
--- a/mesalib/src/mesa/main/drawpix.c
+++ b/mesalib/src/mesa/main/drawpix.c
@@ -33,7 +33,6 @@
#include "image.h"
#include "mfeatures.h"
#include "pbo.h"
-#include "readpix.h"
#include "state.h"
#include "dispatch.h"
@@ -48,6 +47,7 @@ static void GLAPIENTRY
_mesa_DrawPixels( GLsizei width, GLsizei height,
GLenum format, GLenum type, const GLvoid *pixels )
{
+ GLenum err;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
@@ -94,8 +94,40 @@ _mesa_DrawPixels( GLsizei width, GLsizei height,
goto end;
}
- if (_mesa_error_check_format_type(ctx, format, type, GL_TRUE)) {
- goto end; /* the error code was recorded */
+ err = _mesa_error_check_format_and_type(ctx, format, type);
+ if (err != GL_NO_ERROR) {
+ _mesa_error(ctx, err, "glDrawPixels(invalid format %s and/or type %s)",
+ _mesa_lookup_enum_by_nr(format),
+ _mesa_lookup_enum_by_nr(type));
+ goto end;
+ }
+
+ /* do special format-related checks */
+ switch (format) {
+ case GL_STENCIL_INDEX:
+ case GL_DEPTH_COMPONENT:
+ case GL_DEPTH_STENCIL_EXT:
+ /* these buffers must exist */
+ if (!_mesa_dest_buffer_exists(ctx, format)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glDrawPixels(missing deest buffer)");
+ goto end;
+ }
+ break;
+ case GL_COLOR_INDEX:
+ if (ctx->PixelMaps.ItoR.Size == 0 ||
+ ctx->PixelMaps.ItoG.Size == 0 ||
+ ctx->PixelMaps.ItoB.Size == 0) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glDrawPixels(drawing color index pixels into RGB buffer)");
+ goto end;
+ }
+ break;
+ default:
+ /* for color formats it's not an error if the destination color
+ * buffer doesn't exist.
+ */
+ break;
}
if (ctx->RasterDiscard) {
diff --git a/mesalib/src/mesa/main/image.c b/mesalib/src/mesa/main/image.c
index 3491704f8..750db9444 100644
--- a/mesalib/src/mesa/main/image.c
+++ b/mesalib/src/mesa/main/image.c
@@ -356,18 +356,83 @@ _mesa_bytes_per_pixel( GLenum format, GLenum type )
/**
- * Test for a legal pixel format and type.
+ * Do error checking of format/type combinations for glReadPixels,
+ * glDrawPixels and glTex[Sub]Image. Note that depending on the format
+ * and type values, we may either generate GL_INVALID_OPERATION or
+ * GL_INVALID_ENUM.
*
* \param format pixel format.
* \param type pixel type.
*
- * \return GL_TRUE if the given pixel format and type are legal, or GL_FALSE
- * otherwise.
+ * \return GL_INVALID_ENUM, GL_INVALID_OPERATION or GL_NO_ERROR
*/
-GLboolean
-_mesa_is_legal_format_and_type(const struct gl_context *ctx,
- GLenum format, GLenum type)
+GLenum
+_mesa_error_check_format_and_type(const struct gl_context *ctx,
+ GLenum format, GLenum type)
{
+ /* special type-based checks (see glReadPixels, glDrawPixels error lists) */
+ switch (type) {
+ case GL_BITMAP:
+ if (format != GL_COLOR_INDEX && format != GL_STENCIL_INDEX) {
+ return GL_INVALID_ENUM;
+ }
+ break;
+
+ case GL_UNSIGNED_BYTE_3_3_2:
+ case GL_UNSIGNED_BYTE_2_3_3_REV:
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ if (format == GL_RGB) {
+ break; /* OK */
+ }
+ if (format == GL_RGB_INTEGER_EXT &&
+ ctx->Extensions.ARB_texture_rgb10_a2ui) {
+ break; /* OK */
+ }
+ return GL_INVALID_OPERATION;
+
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ 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:
+ if (format == GL_RGBA ||
+ format == GL_BGRA ||
+ format == GL_ABGR_EXT) {
+ break; /* OK */
+ }
+ if ((format == GL_RGBA_INTEGER_EXT || format == GL_BGRA_INTEGER_EXT) &&
+ ctx->Extensions.ARB_texture_rgb10_a2ui) {
+ break; /* OK */
+ }
+ return GL_INVALID_OPERATION;
+
+ case GL_UNSIGNED_INT_24_8:
+ if (!ctx->Extensions.EXT_packed_depth_stencil) {
+ return GL_INVALID_ENUM;
+ }
+ if (format != GL_DEPTH_STENCIL) {
+ return GL_INVALID_OPERATION;
+ }
+ return GL_NO_ERROR;
+
+ case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
+ if (!ctx->Extensions.ARB_depth_buffer_float) {
+ return GL_INVALID_ENUM;
+ }
+ if (format != GL_DEPTH_STENCIL) {
+ return GL_INVALID_OPERATION;
+ }
+ return GL_NO_ERROR;
+
+ default:
+ ; /* fall-through */
+ }
+
+ /* now, for each format, check the type for compatibility */
switch (format) {
case GL_COLOR_INDEX:
case GL_STENCIL_INDEX:
@@ -380,12 +445,14 @@ _mesa_is_legal_format_and_type(const struct gl_context *ctx,
case GL_INT:
case GL_UNSIGNED_INT:
case GL_FLOAT:
- return GL_TRUE;
- case GL_HALF_FLOAT_ARB:
- return ctx->Extensions.ARB_half_float_pixel;
+ return GL_NO_ERROR;
+ case GL_HALF_FLOAT:
+ return ctx->Extensions.ARB_half_float_pixel
+ ? GL_NO_ERROR : GL_INVALID_ENUM;
default:
- return GL_FALSE;
+ return GL_INVALID_ENUM;
}
+
case GL_RED:
case GL_GREEN:
case GL_BLUE:
@@ -404,16 +471,17 @@ _mesa_is_legal_format_and_type(const struct gl_context *ctx,
case GL_INT:
case GL_UNSIGNED_INT:
case GL_FLOAT:
- return GL_TRUE;
- case GL_HALF_FLOAT_ARB:
- return ctx->Extensions.ARB_half_float_pixel;
+ return GL_NO_ERROR;
+ case GL_HALF_FLOAT:
+ return ctx->Extensions.ARB_half_float_pixel
+ ? GL_NO_ERROR : GL_INVALID_ENUM;
default:
- return GL_FALSE;
+ return GL_INVALID_ENUM;
}
+
case GL_RG:
if (!ctx->Extensions.ARB_texture_rg)
- return GL_FALSE;
-
+ return GL_INVALID_ENUM;
switch (type) {
case GL_BYTE:
case GL_UNSIGNED_BYTE:
@@ -422,12 +490,14 @@ _mesa_is_legal_format_and_type(const struct gl_context *ctx,
case GL_INT:
case GL_UNSIGNED_INT:
case GL_FLOAT:
- return GL_TRUE;
- case GL_HALF_FLOAT_ARB:
- return ctx->Extensions.ARB_half_float_pixel;
+ return GL_NO_ERROR;
+ case GL_HALF_FLOAT:
+ return ctx->Extensions.ARB_half_float_pixel
+ ? GL_NO_ERROR : GL_INVALID_ENUM;
default:
- return GL_FALSE;
+ return GL_INVALID_ENUM;
}
+
case GL_RGB:
switch (type) {
case GL_BYTE:
@@ -441,16 +511,20 @@ _mesa_is_legal_format_and_type(const struct gl_context *ctx,
case GL_UNSIGNED_BYTE_2_3_3_REV:
case GL_UNSIGNED_SHORT_5_6_5:
case GL_UNSIGNED_SHORT_5_6_5_REV:
- return GL_TRUE;
- case GL_HALF_FLOAT_ARB:
- return ctx->Extensions.ARB_half_float_pixel;
+ return GL_NO_ERROR;
+ case GL_HALF_FLOAT:
+ return ctx->Extensions.ARB_half_float_pixel
+ ? GL_NO_ERROR : GL_INVALID_ENUM;
case GL_UNSIGNED_INT_5_9_9_9_REV:
- return ctx->Extensions.EXT_texture_shared_exponent;
+ return ctx->Extensions.EXT_texture_shared_exponent
+ ? GL_NO_ERROR : GL_INVALID_ENUM;
case GL_UNSIGNED_INT_10F_11F_11F_REV:
- return ctx->Extensions.EXT_packed_float;
+ return ctx->Extensions.EXT_packed_float
+ ? GL_NO_ERROR : GL_INVALID_ENUM;
default:
- return GL_FALSE;
+ return GL_INVALID_ENUM;
}
+
case GL_BGR:
switch (type) {
/* NOTE: no packed types are supported with BGR. That's
@@ -463,12 +537,14 @@ _mesa_is_legal_format_and_type(const struct gl_context *ctx,
case GL_INT:
case GL_UNSIGNED_INT:
case GL_FLOAT:
- return GL_TRUE;
- case GL_HALF_FLOAT_ARB:
- return ctx->Extensions.ARB_half_float_pixel;
+ return GL_NO_ERROR;
+ case GL_HALF_FLOAT:
+ return ctx->Extensions.ARB_half_float_pixel
+ ? GL_NO_ERROR : GL_INVALID_ENUM;
default:
- return GL_FALSE;
+ return GL_INVALID_ENUM;
}
+
case GL_RGBA:
case GL_BGRA:
case GL_ABGR_EXT:
@@ -488,28 +564,37 @@ _mesa_is_legal_format_and_type(const struct gl_context *ctx,
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:
- return GL_TRUE;
- case GL_HALF_FLOAT_ARB:
- return ctx->Extensions.ARB_half_float_pixel;
+ return GL_NO_ERROR;
+ case GL_HALF_FLOAT:
+ return ctx->Extensions.ARB_half_float_pixel
+ ? GL_NO_ERROR : GL_INVALID_ENUM;
default:
- return GL_FALSE;
+ return GL_INVALID_ENUM;
}
+
case GL_YCBCR_MESA:
+ if (!ctx->Extensions.MESA_ycbcr_texture)
+ return GL_INVALID_ENUM;
if (type == GL_UNSIGNED_SHORT_8_8_MESA ||
type == GL_UNSIGNED_SHORT_8_8_REV_MESA)
- return GL_TRUE;
+ return GL_NO_ERROR;
else
- return GL_FALSE;
+ return GL_INVALID_OPERATION;
+
case GL_DEPTH_STENCIL_EXT:
- if ((ctx->Extensions.EXT_packed_depth_stencil &&
- type == GL_UNSIGNED_INT_24_8_EXT) ||
- (ctx->Extensions.ARB_depth_buffer_float &&
- type == GL_FLOAT_32_UNSIGNED_INT_24_8_REV))
- return GL_TRUE;
+ if (ctx->Extensions.EXT_packed_depth_stencil &&
+ type == GL_UNSIGNED_INT_24_8)
+ return GL_NO_ERROR;
+ else if (ctx->Extensions.ARB_depth_buffer_float &&
+ type == GL_FLOAT_32_UNSIGNED_INT_24_8_REV)
+ return GL_NO_ERROR;
else
- return GL_FALSE;
+ return GL_INVALID_ENUM;
+
case GL_DUDV_ATI:
case GL_DU8DV8_ATI:
+ if (!ctx->Extensions.ATI_envmap_bumpmap)
+ return GL_INVALID_ENUM;
switch (type) {
case GL_BYTE:
case GL_UNSIGNED_BYTE:
@@ -518,9 +603,9 @@ _mesa_is_legal_format_and_type(const struct gl_context *ctx,
case GL_INT:
case GL_UNSIGNED_INT:
case GL_FLOAT:
- return GL_TRUE;
+ return GL_NO_ERROR;
default:
- return GL_FALSE;
+ return GL_INVALID_ENUM;
}
/* integer-valued formats */
@@ -536,10 +621,11 @@ _mesa_is_legal_format_and_type(const struct gl_context *ctx,
case GL_UNSIGNED_SHORT:
case GL_INT:
case GL_UNSIGNED_INT:
- return ctx->VersionMajor >= 3 ||
- ctx->Extensions.EXT_texture_integer;
+ return (ctx->VersionMajor >= 3 ||
+ ctx->Extensions.EXT_texture_integer)
+ ? GL_NO_ERROR : GL_INVALID_ENUM;
default:
- return GL_FALSE;
+ return GL_INVALID_ENUM;
}
case GL_RGB_INTEGER_EXT:
@@ -550,15 +636,17 @@ _mesa_is_legal_format_and_type(const struct gl_context *ctx,
case GL_UNSIGNED_SHORT:
case GL_INT:
case GL_UNSIGNED_INT:
- return ctx->VersionMajor >= 3 ||
- ctx->Extensions.EXT_texture_integer;
+ return (ctx->VersionMajor >= 3 ||
+ ctx->Extensions.EXT_texture_integer)
+ ? GL_NO_ERROR : GL_INVALID_ENUM;
case GL_UNSIGNED_BYTE_3_3_2:
case GL_UNSIGNED_BYTE_2_3_3_REV:
case GL_UNSIGNED_SHORT_5_6_5:
case GL_UNSIGNED_SHORT_5_6_5_REV:
- return ctx->Extensions.ARB_texture_rgb10_a2ui;
+ return ctx->Extensions.ARB_texture_rgb10_a2ui
+ ? GL_NO_ERROR : GL_INVALID_ENUM;
default:
- return GL_FALSE;
+ return GL_INVALID_ENUM;
}
case GL_BGR_INTEGER_EXT:
@@ -570,10 +658,11 @@ _mesa_is_legal_format_and_type(const struct gl_context *ctx,
case GL_INT:
case GL_UNSIGNED_INT:
/* NOTE: no packed formats w/ BGR format */
- return ctx->VersionMajor >= 3 ||
- ctx->Extensions.EXT_texture_integer;
+ return (ctx->VersionMajor >= 3 ||
+ ctx->Extensions.EXT_texture_integer)
+ ? GL_NO_ERROR : GL_INVALID_ENUM;
default:
- return GL_FALSE;
+ return GL_INVALID_ENUM;
}
case GL_RGBA_INTEGER_EXT:
@@ -585,8 +674,9 @@ _mesa_is_legal_format_and_type(const struct gl_context *ctx,
case GL_UNSIGNED_SHORT:
case GL_INT:
case GL_UNSIGNED_INT:
- return ctx->VersionMajor >= 3 ||
- ctx->Extensions.EXT_texture_integer;
+ return (ctx->VersionMajor >= 3 ||
+ ctx->Extensions.EXT_texture_integer)
+ ? GL_NO_ERROR : GL_INVALID_ENUM;
case GL_UNSIGNED_SHORT_4_4_4_4:
case GL_UNSIGNED_SHORT_4_4_4_4_REV:
case GL_UNSIGNED_SHORT_5_5_5_1:
@@ -595,9 +685,10 @@ _mesa_is_legal_format_and_type(const struct gl_context *ctx,
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:
- return ctx->Extensions.ARB_texture_rgb10_a2ui;
+ return ctx->Extensions.ARB_texture_rgb10_a2ui
+ ? GL_NO_ERROR : GL_INVALID_ENUM;
default:
- return GL_FALSE;
+ return GL_INVALID_ENUM;
}
case GL_LUMINANCE_INTEGER_EXT:
@@ -609,15 +700,16 @@ _mesa_is_legal_format_and_type(const struct gl_context *ctx,
case GL_UNSIGNED_SHORT:
case GL_INT:
case GL_UNSIGNED_INT:
- return ctx->Extensions.EXT_texture_integer;
+ return ctx->Extensions.EXT_texture_integer
+ ? GL_NO_ERROR : GL_INVALID_ENUM;
default:
- return GL_FALSE;
+ return GL_INVALID_ENUM;
}
default:
- ; /* fall-through */
+ return GL_INVALID_ENUM;
}
- return GL_FALSE;
+ return GL_NO_ERROR;
}
diff --git a/mesalib/src/mesa/main/image.h b/mesalib/src/mesa/main/image.h
index e4961ed3d..f1ed88379 100644
--- a/mesalib/src/mesa/main/image.h
+++ b/mesalib/src/mesa/main/image.h
@@ -53,9 +53,9 @@ _mesa_components_in_format( GLenum format );
extern GLint
_mesa_bytes_per_pixel( GLenum format, GLenum type );
-extern GLboolean
-_mesa_is_legal_format_and_type(const struct gl_context *ctx,
- GLenum format, GLenum type);
+extern GLenum
+_mesa_error_check_format_and_type(const struct gl_context *ctx,
+ GLenum format, GLenum type);
extern GLboolean
_mesa_is_color_format(GLenum format);
diff --git a/mesalib/src/mesa/main/readpix.c b/mesalib/src/mesa/main/readpix.c
index 908a55e70..48708a6eb 100644
--- a/mesalib/src/mesa/main/readpix.c
+++ b/mesalib/src/mesa/main/readpix.c
@@ -575,162 +575,13 @@ _mesa_readpixels(struct gl_context *ctx,
}
-/**
- * Do error checking of the format/type parameters to glReadPixels and
- * glDrawPixels.
- * \param drawing if GL_TRUE do checking for DrawPixels, else do checking
- * for ReadPixels.
- * \return GL_TRUE if error detected, GL_FALSE if no errors
- */
-GLboolean
-_mesa_error_check_format_type(struct gl_context *ctx, GLenum format,
- GLenum type, GLboolean drawing)
-{
- const char *readDraw = drawing ? "Draw" : "Read";
- const GLboolean reading = !drawing;
-
- /* state validation should have already been done */
- ASSERT(ctx->NewState == 0x0);
-
- if (ctx->Extensions.EXT_packed_depth_stencil
- && type == GL_UNSIGNED_INT_24_8_EXT
- && format != GL_DEPTH_STENCIL_EXT) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "gl%sPixels(format is not GL_DEPTH_STENCIL_EXT)", readDraw);
- return GL_TRUE;
- }
-
- if (ctx->Extensions.ARB_depth_buffer_float
- && type == GL_FLOAT_32_UNSIGNED_INT_24_8_REV
- && format != GL_DEPTH_STENCIL_EXT) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "gl%sPixels(format is not GL_DEPTH_STENCIL_EXT)", readDraw);
- return GL_TRUE;
- }
-
- /* basic combinations test */
- if (!_mesa_is_legal_format_and_type(ctx, format, type)) {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "gl%sPixels(format or type)", readDraw);
- return GL_TRUE;
- }
-
- /* additional checks */
- switch (format) {
- case GL_RG:
- case GL_RED:
- case GL_GREEN:
- case GL_BLUE:
- case GL_ALPHA:
- case GL_LUMINANCE:
- case GL_LUMINANCE_ALPHA:
- case GL_RGB:
- case GL_BGR:
- case GL_RGBA:
- case GL_BGRA:
- case GL_ABGR_EXT:
- 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:
- if (!drawing) {
- /* reading */
- if (!_mesa_source_buffer_exists(ctx, GL_COLOR)) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glReadPixels(no color buffer)");
- return GL_TRUE;
- }
- }
- break;
- case GL_COLOR_INDEX:
- if (drawing) {
- if (ctx->PixelMaps.ItoR.Size == 0 ||
- ctx->PixelMaps.ItoG.Size == 0 ||
- ctx->PixelMaps.ItoB.Size == 0) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glDrawPixels(drawing color index pixels into RGB buffer)");
- return GL_TRUE;
- }
- }
- else {
- /* reading */
- if (!_mesa_source_buffer_exists(ctx, GL_COLOR)) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glReadPixels(no color buffer)");
- return GL_TRUE;
- }
- /* We no longer support CI-mode color buffers so trying to read
- * GL_COLOR_INDEX pixels is always an error.
- */
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glReadPixels(color buffer is RGB)");
- return GL_TRUE;
- }
- break;
- case GL_STENCIL_INDEX:
- if ((drawing && !_mesa_dest_buffer_exists(ctx, format)) ||
- (reading && !_mesa_source_buffer_exists(ctx, format))) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "gl%sPixels(no stencil buffer)", readDraw);
- return GL_TRUE;
- }
- break;
- case GL_DEPTH_COMPONENT:
- if ((drawing && !_mesa_dest_buffer_exists(ctx, format))) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "gl%sPixels(no depth buffer)", readDraw);
- return GL_TRUE;
- }
- break;
- case GL_DEPTH_STENCIL_EXT:
- /* Check validity of the type first. */
- switch (type) {
- case GL_UNSIGNED_INT_24_8_EXT:
- if (!ctx->Extensions.EXT_packed_depth_stencil) {
- _mesa_error(ctx, GL_INVALID_ENUM, "gl%sPixels(type)", readDraw);
- return GL_TRUE;
- }
- break;
- case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
- if (!ctx->Extensions.ARB_depth_buffer_float) {
- _mesa_error(ctx, GL_INVALID_ENUM, "gl%sPixels(type)", readDraw);
- return GL_TRUE;
- }
- break;
- default:
- _mesa_error(ctx, GL_INVALID_ENUM, "gl%sPixels(type)", readDraw);
- return GL_TRUE;
- }
- if ((drawing && !_mesa_dest_buffer_exists(ctx, format)) ||
- (reading && !_mesa_source_buffer_exists(ctx, format))) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "gl%sPixels(no depth or stencil buffer)", readDraw);
- return GL_TRUE;
- }
- break;
- default:
- /* this should have been caught in _mesa_is_legal_format_type() */
- _mesa_problem(ctx, "unexpected format in _mesa_%sPixels", readDraw);
- return GL_TRUE;
- }
-
- /* no errors */
- return GL_FALSE;
-}
-
-
-
void GLAPIENTRY
_mesa_ReadnPixelsARB( GLint x, GLint y, GLsizei width, GLsizei height,
GLenum format, GLenum type, GLsizei bufSize,
GLvoid *pixels )
{
+ GLenum err;
+
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
@@ -752,8 +603,11 @@ _mesa_ReadnPixelsARB( GLint x, GLint y, GLsizei width, GLsizei height,
if (ctx->NewState)
_mesa_update_state(ctx);
- if (_mesa_error_check_format_type(ctx, format, type, GL_FALSE)) {
- /* found an error */
+ err = _mesa_error_check_format_and_type(ctx, format, type);
+ if (err != GL_NO_ERROR) {
+ _mesa_error(ctx, err, "glReadPixels(invalid format %s and/or type %s)",
+ _mesa_lookup_enum_by_nr(format),
+ _mesa_lookup_enum_by_nr(type));
return;
}
diff --git a/mesalib/src/mesa/main/readpix.h b/mesalib/src/mesa/main/readpix.h
index 6caaf3adc..5a5f73f52 100644
--- a/mesalib/src/mesa/main/readpix.h
+++ b/mesalib/src/mesa/main/readpix.h
@@ -33,10 +33,6 @@ struct gl_context;
struct gl_pixelstore_attrib;
-extern GLboolean
-_mesa_error_check_format_type(struct gl_context *ctx, GLenum format, GLenum type,
- GLboolean drawing);
-
extern void
_mesa_readpixels(struct gl_context *ctx,
GLint x, GLint y, GLsizei width, GLsizei height,
diff --git a/mesalib/src/mesa/main/texgetimage.c b/mesalib/src/mesa/main/texgetimage.c
index 42495c8c7..bff003d24 100644
--- a/mesalib/src/mesa/main/texgetimage.c
+++ b/mesalib/src/mesa/main/texgetimage.c
@@ -734,7 +734,7 @@ getteximage_error_check(struct gl_context *ctx, GLenum target, GLint level,
struct gl_texture_image *texImage;
const GLint maxLevels = _mesa_max_texture_levels(ctx, target);
const GLuint dimensions = (target == GL_TEXTURE_3D) ? 3 : 2;
- GLenum baseFormat;
+ GLenum baseFormat, err;
if (maxLevels == 0) {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(target=0x%x)", target);
@@ -746,37 +746,9 @@ getteximage_error_check(struct gl_context *ctx, GLenum target, GLint level,
return GL_TRUE;
}
- if (_mesa_sizeof_packed_type(type) <= 0) {
- _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexImage(type)" );
- return GL_TRUE;
- }
-
- if (_mesa_components_in_format(format) <= 0 ||
- format == GL_STENCIL_INDEX ||
- format == GL_COLOR_INDEX) {
- _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexImage(format)" );
- return GL_TRUE;
- }
-
- if (!ctx->Extensions.ARB_depth_texture && _mesa_is_depth_format(format)) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(format)");
- return GL_TRUE;
- }
-
- if (!ctx->Extensions.MESA_ycbcr_texture && _mesa_is_ycbcr_format(format)) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(format)");
- return GL_TRUE;
- }
-
- if (!ctx->Extensions.EXT_packed_depth_stencil
- && _mesa_is_depthstencil_format(format)) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(format)");
- return GL_TRUE;
- }
-
- if (!ctx->Extensions.ATI_envmap_bumpmap
- && _mesa_is_dudv_format(format)) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(format)");
+ err = _mesa_error_check_format_and_type(ctx, format, type);
+ if (err != GL_NO_ERROR) {
+ _mesa_error(ctx, err, "glGetTexImage(format/type)");
return GL_TRUE;
}
@@ -787,14 +759,6 @@ getteximage_error_check(struct gl_context *ctx, GLenum target, GLint level,
return GL_TRUE;
}
- if (!_mesa_is_legal_format_and_type(ctx, format, type)) {
- /* GL_INVALID_OPERATION is generated by a format/type
- * mismatch (see the 1.2 spec page 94, sec 3.6.4.)
- */
- _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(target)");
- return GL_TRUE;
- }
-
texImage = _mesa_select_tex_image(ctx, texObj, target, level);
if (!texImage) {
/* non-existant texture image */
diff --git a/mesalib/src/mesa/main/teximage.c b/mesalib/src/mesa/main/teximage.c
index 018aca063..25da75369 100644
--- a/mesalib/src/mesa/main/teximage.c
+++ b/mesalib/src/mesa/main/teximage.c
@@ -1511,6 +1511,7 @@ texture_error_check( struct gl_context *ctx,
const GLboolean isProxy = target == proxyTarget;
GLboolean sizeOK = GL_TRUE;
GLboolean colorFormat;
+ GLenum err;
/* Even though there are no color-index textures, we still have to support
* uploading color-index data and remapping it to RGB via the
@@ -1579,16 +1580,10 @@ texture_error_check( struct gl_context *ctx,
}
/* Check incoming image format and type */
- if (!_mesa_is_legal_format_and_type(ctx, format, type)) {
- /* Normally, GL_INVALID_OPERATION is generated by a format/type
- * mismatch (see the 1.2 spec page 94, sec 3.6.4.). But with the
- * GL_EXT_texture_integer extension, some combinations should generate
- * GL_INVALID_ENUM instead (grr!).
- */
+ err = _mesa_error_check_format_and_type(ctx, format, type);
+ if (err != GL_NO_ERROR) {
if (!isProxy) {
- GLenum error = _mesa_is_integer_format(format)
- ? GL_INVALID_ENUM : GL_INVALID_OPERATION;
- _mesa_error(ctx, error,
+ _mesa_error(ctx, err,
"glTexImage%dD(incompatible format 0x%x, type 0x%x)",
dimensions, format, type);
}
@@ -1737,6 +1732,8 @@ subtexture_error_check( struct gl_context *ctx, GLuint dimensions,
GLint width, GLint height, GLint depth,
GLenum format, GLenum type )
{
+ GLenum err;
+
/* Basic level check */
if (level < 0 || level >= MAX_TEXTURE_LEVELS) {
_mesa_error(ctx, GL_INVALID_ENUM, "glTexSubImage2D(level=%d)", level);
@@ -1760,13 +1757,9 @@ subtexture_error_check( struct gl_context *ctx, GLuint dimensions,
return GL_TRUE;
}
- if (!_mesa_is_legal_format_and_type(ctx, format, type)) {
- /* As with the glTexImage2D check above, the error code here
- * depends on texture integer.
- */
- GLenum error = _mesa_is_integer_format(format)
- ? GL_INVALID_OPERATION : GL_INVALID_ENUM;
- _mesa_error(ctx, error,
+ err = _mesa_error_check_format_and_type(ctx, format, type);
+ if (err != GL_NO_ERROR) {
+ _mesa_error(ctx, err,
"glTexSubImage%dD(incompatible format 0x%x, type 0x%x)",
dimensions, format, type);
return GL_TRUE;
diff --git a/mesalib/src/mesa/state_tracker/st_atom_sampler.c b/mesalib/src/mesa/state_tracker/st_atom_sampler.c
index ad159c64d..8845fed51 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_sampler.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_sampler.c
@@ -201,6 +201,8 @@ update_vertex_samplers(struct st_context *st)
struct gl_vertex_program *vprog = ctx->VertexProgram._Current;
GLuint su;
+ if (st->state.num_vertex_samplers == 0 && vprog->Base.SamplersUsed == 0)
+ return;
st->state.num_vertex_samplers = 0;
/* loop over sampler units (aka tex image units) */
diff --git a/mesalib/src/mesa/state_tracker/st_atom_texture.c b/mesalib/src/mesa/state_tracker/st_atom_texture.c
index 88e6128c8..d241527cc 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_texture.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_texture.c
@@ -260,6 +260,9 @@ update_vertex_textures(struct st_context *st)
struct gl_vertex_program *vprog = ctx->VertexProgram._Current;
GLuint su;
+ if (!vprog->Base.SamplersUsed && st->state.num_vertex_textures == 0)
+ return;
+
st->state.num_vertex_textures = 0;
/* loop over sampler units (aka tex image units) */