aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main/texgetimage.c
diff options
context:
space:
mode:
authorErik Faye-Lund <[email protected]>2018-11-22 12:17:32 +0100
committerErik Faye-Lund <[email protected]>2018-11-26 12:29:54 +0100
commit5e0a84f31cac14f1ccc5c74ce2e7cd997f267752 (patch)
treefb9b46f9b0bca0524e15319d623ed5478d1766f0 /src/mesa/main/texgetimage.c
parent38bbb61252aa503571986080afddd98a56bcf2e7 (diff)
mesa/main: factor out tex-image error-checking
This will be useful when we split error-checking for getteximage and gettexsubimage later. Signed-off-by: Erik Faye-Lund <[email protected]> Reviewed-by: Juan A. Suarez <[email protected]>
Diffstat (limited to 'src/mesa/main/texgetimage.c')
-rw-r--r--src/mesa/main/texgetimage.c110
1 files changed, 64 insertions, 46 deletions
diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c
index c30ca703242..8ee5cc0d729 100644
--- a/src/mesa/main/texgetimage.c
+++ b/src/mesa/main/texgetimage.c
@@ -1139,53 +1139,15 @@ pbo_error_check(struct gl_context *ctx, GLenum target,
/**
- * Do error checking for all (non-compressed) get-texture-image functions.
- * \return true if any error, false if no errors.
+ * Do teximage-related error checking for getting uncompressed images.
+ * \return true if there was an error
*/
static bool
-getteximage_error_check(struct gl_context *ctx,
- struct gl_texture_object *texObj,
- GLenum target, GLint level,
- GLint xoffset, GLint yoffset, GLint zoffset,
- GLsizei width, GLsizei height, GLsizei depth,
- GLenum format, GLenum type, GLsizei bufSize,
- GLvoid *pixels, const char *caller)
+teximage_error_check(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
+ GLenum format, const char *caller)
{
- struct gl_texture_image *texImage;
- GLenum baseFormat, err;
- GLint maxLevels;
-
- assert(texObj);
-
- if (texObj->Target == 0) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "%s(invalid texture)", caller);
- return true;
- }
-
- maxLevels = _mesa_max_texture_levels(ctx, target);
- if (level < 0 || level >= maxLevels) {
- _mesa_error(ctx, GL_INVALID_VALUE, "%s(level = %d)", caller, level);
- return true;
- }
-
- err = _mesa_error_check_format_and_type(ctx, format, type);
- if (err != GL_NO_ERROR) {
- _mesa_error(ctx, err, "%s(format/type)", caller);
- return true;
- }
-
- if (dimensions_error_check(ctx, texObj, target, level,
- xoffset, yoffset, zoffset,
- width, height, depth, caller)) {
- return true;
- }
-
- if (pbo_error_check(ctx, target, width, height, depth,
- format, type, bufSize, pixels, caller)) {
- return true;
- }
-
- texImage = select_tex_image(texObj, target, level, zoffset);
+ GLenum baseFormat;
assert(texImage);
/*
@@ -1218,8 +1180,8 @@ getteximage_error_check(struct gl_context *ctx,
return true;
}
else if (_mesa_is_stencil_format(format)
- && !_mesa_is_depthstencil_format(baseFormat)
- && !_mesa_is_stencil_format(baseFormat)) {
+ && !_mesa_is_depthstencil_format(baseFormat)
+ && !_mesa_is_stencil_format(baseFormat)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"%s(format mismatch)", caller);
return true;
@@ -1249,6 +1211,62 @@ getteximage_error_check(struct gl_context *ctx,
/**
+ * Do error checking for all (non-compressed) get-texture-image functions.
+ * \return true if any error, false if no errors.
+ */
+static bool
+getteximage_error_check(struct gl_context *ctx,
+ struct gl_texture_object *texObj,
+ GLenum target, GLint level,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLenum format, GLenum type, GLsizei bufSize,
+ GLvoid *pixels, const char *caller)
+{
+ struct gl_texture_image *texImage;
+ GLenum err;
+ GLint maxLevels;
+
+ assert(texObj);
+
+ if (texObj->Target == 0) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(invalid texture)", caller);
+ return true;
+ }
+
+ maxLevels = _mesa_max_texture_levels(ctx, target);
+ if (level < 0 || level >= maxLevels) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "%s(level = %d)", caller, level);
+ return true;
+ }
+
+ err = _mesa_error_check_format_and_type(ctx, format, type);
+ if (err != GL_NO_ERROR) {
+ _mesa_error(ctx, err, "%s(format/type)", caller);
+ return true;
+ }
+
+ if (dimensions_error_check(ctx, texObj, target, level,
+ xoffset, yoffset, zoffset,
+ width, height, depth, caller)) {
+ return true;
+ }
+
+ if (pbo_error_check(ctx, target, width, height, depth,
+ format, type, bufSize, pixels, caller)) {
+ return true;
+ }
+
+ texImage = select_tex_image(texObj, target, level, zoffset);
+ if (teximage_error_check(ctx, texImage, format, caller)) {
+ return true;
+ }
+
+ return false;
+}
+
+
+/**
* Return the width, height and depth of a texture image.
* This function must be resilient to bad parameter values since
* this is called before full error checking.