}
}
+/**
+ * Depending on the base format involved we may need to apply a rebase
+ * transform (for example: if we download to a Luminance format we want
+ * G=0 and B=0).
+ */
+static bool
+teximage_needs_rebase(mesa_format texFormat, GLenum baseFormat,
+ bool is_compressed, uint8_t *rebaseSwizzle)
+{
+ bool needsRebase = false;
+
+ if (baseFormat == GL_LUMINANCE ||
+ baseFormat == GL_INTENSITY) {
+ needsRebase = true;
+ rebaseSwizzle[0] = MESA_FORMAT_SWIZZLE_X;
+ rebaseSwizzle[1] = MESA_FORMAT_SWIZZLE_ZERO;
+ rebaseSwizzle[2] = MESA_FORMAT_SWIZZLE_ZERO;
+ rebaseSwizzle[3] = MESA_FORMAT_SWIZZLE_ONE;
+ } else if (baseFormat == GL_LUMINANCE_ALPHA) {
+ needsRebase = true;
+ rebaseSwizzle[0] = MESA_FORMAT_SWIZZLE_X;
+ rebaseSwizzle[1] = MESA_FORMAT_SWIZZLE_ZERO;
+ rebaseSwizzle[2] = MESA_FORMAT_SWIZZLE_ZERO;
+ rebaseSwizzle[3] = MESA_FORMAT_SWIZZLE_W;
+ } else if (!is_compressed &&
+ (baseFormat != _mesa_get_format_base_format(texFormat))) {
+ needsRebase =
+ _mesa_compute_rgba2base2rgba_component_mapping(baseFormat,
+ rebaseSwizzle);
+ }
+
+ return needsRebase;
+}
+
/**
* Get a color texture image with decompression.
}
}
- /* Depending on the base format involved we may need to apply a rebase
- * transform (for example: if we download to a Luminance format we want
- * G=0 and B=0).
- */
- if (baseFormat == GL_LUMINANCE ||
- baseFormat == GL_INTENSITY) {
- needsRebase = true;
- rebaseSwizzle[0] = MESA_FORMAT_SWIZZLE_X;
- rebaseSwizzle[1] = MESA_FORMAT_SWIZZLE_ZERO;
- rebaseSwizzle[2] = MESA_FORMAT_SWIZZLE_ZERO;
- rebaseSwizzle[3] = MESA_FORMAT_SWIZZLE_ONE;
- } else if (baseFormat == GL_LUMINANCE_ALPHA) {
- needsRebase = true;
- rebaseSwizzle[0] = MESA_FORMAT_SWIZZLE_X;
- rebaseSwizzle[1] = MESA_FORMAT_SWIZZLE_ZERO;
- rebaseSwizzle[2] = MESA_FORMAT_SWIZZLE_ZERO;
- rebaseSwizzle[3] = MESA_FORMAT_SWIZZLE_W;
- } else {
- needsRebase = false;
- }
+ needsRebase = teximage_needs_rebase(texFormat, baseFormat, true,
+ rebaseSwizzle);
srcStride = 4 * width * sizeof(GLfloat);
dstStride = _mesa_image_row_stride(&ctx->Pack, width, format, type);
bool needsRebase;
void *rgba = NULL;
- /* Depending on the base format involved we may need to apply a rebase
- * transform (for example: if we download to a Luminance format we want
- * G=0 and B=0).
- */
- if (texImage->_BaseFormat == GL_LUMINANCE ||
- texImage->_BaseFormat == GL_INTENSITY) {
- needsRebase = true;
- rebaseSwizzle[0] = MESA_FORMAT_SWIZZLE_X;
- rebaseSwizzle[1] = MESA_FORMAT_SWIZZLE_ZERO;
- rebaseSwizzle[2] = MESA_FORMAT_SWIZZLE_ZERO;
- rebaseSwizzle[3] = MESA_FORMAT_SWIZZLE_ONE;
- } else if (texImage->_BaseFormat == GL_LUMINANCE_ALPHA) {
- needsRebase = true;
- rebaseSwizzle[0] = MESA_FORMAT_SWIZZLE_X;
- rebaseSwizzle[1] = MESA_FORMAT_SWIZZLE_ZERO;
- rebaseSwizzle[2] = MESA_FORMAT_SWIZZLE_ZERO;
- rebaseSwizzle[3] = MESA_FORMAT_SWIZZLE_W;
- } else if (texImage->_BaseFormat !=
- _mesa_get_format_base_format(texFormat)) {
- needsRebase =
- _mesa_compute_rgba2base2rgba_component_mapping(texImage->_BaseFormat,
- rebaseSwizzle);
- } else {
- needsRebase = false;
- }
+ needsRebase = teximage_needs_rebase(texFormat, texImage->_BaseFormat, false,
+ rebaseSwizzle);
/* Describe the dst format */
dst_is_integer = _mesa_is_enum_format_integer(format);
}
done:
- if (rgba)
- free(rgba);
+ free(rgba);
}
* the targets from table 8.19 (for GetTexImage and GetnTexImage *only*),
* or TEXTURE_CUBE_MAP (for GetTextureImage *only*)." (Emphasis added.)
*/
- case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
return dsa ? GL_FALSE : ctx->Extensions.ARB_texture_cube_map;
case GL_TEXTURE_CUBE_MAP:
return dsa ? GL_TRUE : GL_FALSE;
/**
* Wrapper for _mesa_select_tex_image() which can handle target being
- * GL_TEXTURE_CUBE_MAP_ARB in which case we use zoffset to select a cube face.
+ * GL_TEXTURE_CUBE_MAP in which case we use zoffset to select a cube face.
* This can happen for glGetTextureImage and glGetTextureSubImage (DSA
* functions).
*/
/* Extra checks for compressed textures */
{
- GLuint bw, bh;
- _mesa_get_format_block_size(texImage->TexFormat, &bw, &bh);
- if (bw > 1 || bh > 1) {
+ GLuint bw, bh, bd;
+ _mesa_get_format_block_size_3d(texImage->TexFormat, &bw, &bh, &bd);
+ if (bw > 1 || bh > 1 || bd > 1) {
/* offset must be multiple of block size */
if (xoffset % bw != 0) {
_mesa_error(ctx, GL_INVALID_VALUE,
}
}
- /* The size must be a multiple of bw x bh, or we must be using a
+ if (zoffset % bd != 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "%s(zoffset = %d)", caller, zoffset);
+ return true;
+ }
+
+ /* The size must be a multiple of bw x bh x bd, or we must be using a
* offset+size that exactly hits the edge of the image.
*/
if ((width % bw != 0) &&
"%s(height = %d)", caller, height);
return true;
}
+
+ if ((depth % bd != 0) &&
+ (zoffset + depth != (GLint) texImage->Depth)) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "%s(depth = %d)", caller, depth);
+ return true;
+ }
}
}