GLint img, row;
assert(format == GL_DEPTH_STENCIL);
- assert(type == GL_UNSIGNED_INT_24_8 ||
- type == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
for (img = 0; img < depth; img++) {
GLubyte *srcMap;
void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels,
width, height, format, type,
img, row, 0);
- _mesa_unpack_depth_stencil_row(texImage->TexFormat,
- width,
- (const GLuint *) src,
- type, dest);
+ switch (type) {
+ case GL_UNSIGNED_INT_24_8:
+ _mesa_unpack_uint_24_8_depth_stencil_row(texImage->TexFormat,
+ width, src, dest);
+ break;
+ case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
+ _mesa_unpack_float_32_uint_24_8_depth_stencil_row(texImage->TexFormat,
+ width,
+ src, dest);
+ break;
+ default:
+ unreachable("bad type in get_tex_depth_stencil()");
+ }
if (ctx->Pack.SwapBytes) {
_mesa_swap4((GLuint *) dest, width);
}
if (depth > 1) {
/* only a single slice is supported at this time */
- memCopy = FALSE;
+ memCopy = GL_FALSE;
}
if (memCopy) {
_mesa_get_texture_dimensions(texImage->TexObject->Target);
/* map dest buffer, if PBO */
- if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) {
+ if (ctx->Pack.BufferObj) {
/* Packing texture image into a PBO.
* Map the (potentially) VRAM-based buffer into our process space so
* we can write into it with the code below.
width, height, depth, format, type, pixels, texImage);
}
- if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) {
+ if (ctx->Pack.BufferObj) {
ctx->Driver.UnmapBuffer(ctx, ctx->Pack.BufferObj, MAP_INTERNAL);
}
}
width, height, depth,
&ctx->Pack, &store);
- if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) {
+ if (ctx->Pack.BufferObj) {
/* pack texture image into a PBO */
dest = (GLubyte *)
ctx->Driver.MapBufferRange(ctx, 0, ctx->Pack.BufferObj->Size,
}
}
- if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) {
+ if (ctx->Pack.BufferObj) {
ctx->Driver.UnmapBuffer(ctx, ctx->Pack.BufferObj, MAP_INTERNAL);
}
}
"%s(zoffset + depth = %d)", caller, zoffset + depth);
return true;
}
- /* According to OpenGL 4.6 spec, section 8.11.4 ("Texture Image Queries"):
- *
- * "An INVALID_OPERATION error is generated by GetTextureImage if the
- * effective target is TEXTURE_CUBE_MAP or TEXTURE_CUBE_MAP_ARRAY ,
- * and the texture object is not cube complete or cube array complete,
- * respectively."
- *
- * This applies also to GetTextureSubImage, GetCompressedTexImage,
- * GetCompressedTextureImage, and GetnCompressedTexImage.
- */
- if (!_mesa_cube_complete(texObj)) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "%s(cube incomplete)", caller);
- return true;
- }
break;
default:
; /* nothing */
if (!_mesa_validate_pbo_access(dimensions, &ctx->Pack, width, height, depth,
format, type, clientMemSize, pixels)) {
- if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) {
+ if (ctx->Pack.BufferObj) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"%s(out of bounds PBO access)", caller);
} else {
return true;
}
- if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) {
+ if (ctx->Pack.BufferObj) {
/* PBO should not be mapped */
if (_mesa_check_disallowed_mapping(ctx->Pack.BufferObj)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
}
}
- if (!_mesa_is_bufferobj(ctx->Pack.BufferObj) && !pixels) {
+ if (!ctx->Pack.BufferObj && !pixels) {
/* not an error, do nothing */
return true;
}
}
+/**
+ * Do common teximage-related error checking for getting uncompressed images.
+ * \return true if there was an error
+ */
+static bool
+common_error_check(struct gl_context *ctx,
+ struct gl_texture_object *texObj,
+ GLenum target, GLint level,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLenum format, GLenum type, GLsizei bufSize,
+ GLvoid *pixels, const char *caller)
+{
+ GLenum err;
+ GLint maxLevels;
+
+ 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;
+ }
+
+ /* According to OpenGL 4.6 spec, section 8.11.4 ("Texture Image Queries"):
+ *
+ * "An INVALID_OPERATION error is generated by GetTextureImage if the
+ * effective target is TEXTURE_CUBE_MAP or TEXTURE_CUBE_MAP_ARRAY ,
+ * and the texture object is not cube complete or cube array complete,
+ * respectively."
+ *
+ * This applies also to GetTextureSubImage, GetCompressedTexImage,
+ * GetCompressedTextureImage, and GetnCompressedTexImage.
+ */
+ if (target == GL_TEXTURE_CUBE_MAP && !_mesa_cube_complete(texObj)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(cube incomplete)", caller);
+ return true;
+ }
+
+ return false;
+}
+
+
/**
* Do error checking for all (non-compressed) get-texture-image functions.
* \return true if any error, false if no errors.
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);
+ if (common_error_check(ctx, texObj, target, level, width, height, depth,
+ format, type, bufSize, pixels, 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);
+ if (width == 0 || height == 0 || depth == 0) {
+ /* Not an error, but nothing to do. Return 'true' so that the
+ * caller simply returns.
+ */
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);
+ if (pbo_error_check(ctx, target, width, height, depth,
+ format, type, bufSize, pixels, caller)) {
+ return true;
+ }
+
+ texImage = select_tex_image(texObj, target, level, 0);
+ if (teximage_error_check(ctx, texImage, format, caller)) {
+ return true;
+ }
+
+ return false;
+}
+
+
+/**
+ * Do error checking for all (non-compressed) get-texture-image functions.
+ * \return true if any error, false if no errors.
+ */
+static bool
+gettexsubimage_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;
+
+ assert(texObj);
+
+ if (common_error_check(ctx, texObj, target, level, width, height, depth,
+ format, type, bufSize, pixels, caller)) {
return true;
}
_mesa_unlock_texture(ctx, texObj);
}
-
-void GLAPIENTRY
-_mesa_GetnTexImage(GLenum target, GLint level, GLenum format, GLenum type,
- GLsizei bufSize, GLvoid *pixels)
+static void
+_get_texture_image(struct gl_context *ctx,
+ struct gl_texture_object *texObj,
+ GLenum target, GLint level,
+ GLenum format, GLenum type,
+ GLsizei bufSize, GLvoid *pixels,
+ const char *caller)
{
- GET_CURRENT_CONTEXT(ctx);
- static const char *caller = "glGetnTexImage";
GLsizei width, height, depth;
- struct gl_texture_object *texObj;
+ /* EXT/ARB direct_state_access variants don't call _get_texture_image
+ * with a NULL texObj */
+ bool is_dsa = texObj != NULL;
- if (!legal_getteximage_target(ctx, target, false)) {
- _mesa_error(ctx, GL_INVALID_ENUM, "%s", caller);
- return;
+ if (!is_dsa) {
+ texObj = _mesa_get_current_tex_object(ctx, target);
+ assert(texObj);
}
- texObj = _mesa_get_current_tex_object(ctx, target);
- assert(texObj);
get_texture_image_dims(texObj, target, level, &width, &height, &depth);
if (getteximage_error_check(ctx, texObj, target, level,
- 0, 0, 0, width, height, depth,
+ width, height, depth,
format, type, bufSize, pixels, caller)) {
return;
}
void GLAPIENTRY
-_mesa_GetTexImage(GLenum target, GLint level, GLenum format, GLenum type,
- GLvoid *pixels )
+_mesa_GetnTexImageARB(GLenum target, GLint level, GLenum format, GLenum type,
+ GLsizei bufSize, GLvoid *pixels)
{
GET_CURRENT_CONTEXT(ctx);
- static const char *caller = "glGetTexImage";
- GLsizei width, height, depth;
- struct gl_texture_object *texObj;
+ static const char *caller = "glGetnTexImageARB";
if (!legal_getteximage_target(ctx, target, false)) {
_mesa_error(ctx, GL_INVALID_ENUM, "%s", caller);
return;
}
- texObj = _mesa_get_current_tex_object(ctx, target);
- assert(texObj);
+ _get_texture_image(ctx, NULL, target, level, format, type,
+ bufSize, pixels, caller);
+}
- get_texture_image_dims(texObj, target, level, &width, &height, &depth);
- if (getteximage_error_check(ctx, texObj, target, level,
- 0, 0, 0, width, height, depth,
- format, type, INT_MAX, pixels, caller)) {
+void GLAPIENTRY
+_mesa_GetTexImage(GLenum target, GLint level, GLenum format, GLenum type,
+ GLvoid *pixels )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ static const char *caller = "glGetTexImage";
+
+ if (!legal_getteximage_target(ctx, target, false)) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "%s", caller);
return;
}
- get_texture_image(ctx, texObj, target, level,
- 0, 0, 0, width, height, depth,
- format, type, pixels, caller);
+ _get_texture_image(ctx, NULL, target, level, format, type,
+ INT_MAX, pixels, caller);
}
GLsizei bufSize, GLvoid *pixels)
{
GET_CURRENT_CONTEXT(ctx);
- GLsizei width, height, depth;
static const char *caller = "glGetTextureImage";
struct gl_texture_object *texObj =
_mesa_lookup_texture_err(ctx, texture, caller);
return;
}
+ _get_texture_image(ctx, texObj, texObj->Target, level, format, type,
+ bufSize, pixels, caller);
+}
+
+
+void GLAPIENTRY
+_mesa_GetTextureImageEXT(GLuint texture, GLenum target, GLint level,
+ GLenum format, GLenum type, GLvoid *pixels)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ static const char *caller = "glGetTextureImageEXT";
+ struct gl_texture_object *texObj =
+ _mesa_lookup_or_create_texture(ctx, target, texture,
+ false, true, caller);
+
+ if (!texObj) {
+ return;
+ }
+
+ if (!legal_getteximage_target(ctx, target, true)) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "%s", caller);
+ return;
+ }
+
+ _get_texture_image(ctx, texObj, target, level, format, type,
+ INT_MAX, pixels, caller);
+}
+
+
+void GLAPIENTRY
+_mesa_GetMultiTexImageEXT(GLenum texunit, GLenum target, GLint level,
+ GLenum format, GLenum type, GLvoid *pixels)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLsizei width, height, depth;
+ static const char *caller = "glGetMultiTexImageEXT";
+
+ struct gl_texture_object *texObj =
+ _mesa_get_texobj_by_target_and_texunit(ctx, target,
+ texunit - GL_TEXTURE0,
+ false,
+ caller);
+
+ if (!texObj) {
+ return;
+ }
+
+ if (!legal_getteximage_target(ctx, texObj->Target, true)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s", caller);
+ return;
+ }
+
get_texture_image_dims(texObj, texObj->Target, level,
&width, &height, &depth);
if (getteximage_error_check(ctx, texObj, texObj->Target, level,
- 0, 0, 0, width, height, depth,
- format, type, bufSize, pixels, caller)) {
+ width, height, depth,
+ format, type, INT_MAX, pixels, caller)) {
return;
}
return;
}
- if (getteximage_error_check(ctx, texObj, texObj->Target, level,
- xoffset, yoffset, zoffset, width, height, depth,
- format, type, bufSize, pixels, caller)) {
+ if (gettexsubimage_error_check(ctx, texObj, texObj->Target, level,
+ xoffset, yoffset, zoffset,
+ width, height, depth,
+ format, type, bufSize, pixels, caller)) {
return;
}
&ctx->Pack);
/* Do dest buffer bounds checking */
- if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) {
+ if (ctx->Pack.BufferObj) {
/* do bounds checking on PBO write */
if ((GLubyte *) pixels + totalBytes >
(GLubyte *) ctx->Pack.BufferObj->Size) {
}
}
- if (!_mesa_is_bufferobj(ctx->Pack.BufferObj) && !pixels) {
+ if (!ctx->Pack.BufferObj && !pixels) {
/* not an error, but do nothing */
return true;
}
}
+void GLAPIENTRY
+_mesa_GetCompressedTextureImageEXT(GLuint texture, GLenum target, GLint level,
+ GLvoid *pixels)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_texture_object* texObj;
+ GLsizei width, height, depth;
+ static const char *caller = "glGetCompressedTextureImageEXT";
+
+ texObj = _mesa_lookup_or_create_texture(ctx, target, texture,
+ false, true, caller);
+
+ get_texture_image_dims(texObj, texObj->Target, level,
+ &width, &height, &depth);
+
+ if (getcompressedteximage_error_check(ctx, texObj, texObj->Target, level,
+ 0, 0, 0, width, height, depth,
+ INT_MAX, pixels, caller)) {
+ return;
+ }
+
+ get_compressed_texture_image(ctx, texObj, texObj->Target, level,
+ 0, 0, 0, width, height, depth,
+ pixels, caller);
+}
+
+
+void GLAPIENTRY
+_mesa_GetCompressedMultiTexImageEXT(GLenum texunit, GLenum target, GLint level,
+ GLvoid *pixels)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_texture_object* texObj;
+ GLsizei width, height, depth;
+ static const char *caller = "glGetCompressedMultiTexImageEXT";
+
+ texObj = _mesa_get_texobj_by_target_and_texunit(ctx, target,
+ texunit - GL_TEXTURE0,
+ false,
+ caller);
+
+ get_texture_image_dims(texObj, texObj->Target, level,
+ &width, &height, &depth);
+
+ if (getcompressedteximage_error_check(ctx, texObj, texObj->Target, level,
+ 0, 0, 0, width, height, depth,
+ INT_MAX, pixels, caller)) {
+ return;
+ }
+
+ get_compressed_texture_image(ctx, texObj, texObj->Target, level,
+ 0, 0, 0, width, height, depth,
+ pixels, caller);
+}
+
+
void GLAPIENTRY
_mesa_GetCompressedTextureImage(GLuint texture, GLint level,
GLsizei bufSize, GLvoid *pixels)
}
-void APIENTRY
+void GLAPIENTRY
_mesa_GetCompressedTextureSubImage(GLuint texture, GLint level,
GLint xoffset, GLint yoffset,
GLint zoffset, GLsizei width,