return ctx->Extensions.ARB_texture_cube_map_array
? ctx->Const.MaxCubeTextureLevels : 0;
case GL_TEXTURE_BUFFER:
- return ctx->API == API_OPENGL_CORE &&
- ctx->Extensions.ARB_texture_buffer_object ? 1 : 0;
+ return (_mesa_has_ARB_texture_buffer_object(ctx) ||
+ _mesa_has_OES_texture_buffer(ctx)) ? 1 : 0;
case GL_TEXTURE_2D_MULTISAMPLE:
case GL_PROXY_TEXTURE_2D_MULTISAMPLE:
case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
GLsizei subDepth, const char *func)
{
const GLenum target = destImage->TexObject->Target;
- GLuint bw, bh;
+ GLuint bw, bh, bd;
/* Check size */
if (subWidth < 0) {
* compressed formats supported by Mesa allow sub-textures to be updated
* along compressed block boundaries.
*/
- _mesa_get_format_block_size(destImage->TexFormat, &bw, &bh);
+ _mesa_get_format_block_size_3d(destImage->TexFormat, &bw, &bh, &bd);
- if (bw != 1 || bh != 1) {
+ if (bw != 1 || bh != 1 || bd != 1) {
/* offset must be multiple of block size */
- if ((xoffset % bw != 0) || (yoffset % bh != 0)) {
+ if ((xoffset % bw != 0) || (yoffset % bh != 0) || (zoffset % bd != 0)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "%s(xoffset = %d, yoffset = %d)",
- func, xoffset, yoffset);
+ "%s(xoffset = %d, yoffset = %d, zoffset = %d)",
+ func, xoffset, yoffset, zoffset);
return GL_TRUE;
}
"%s(height = %d)", func, subHeight);
return GL_TRUE;
}
+
+ if ((subDepth % bd != 0) &&
+ (zoffset + subDepth != (GLint) destImage->Depth)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(depth = %d)", func, subDepth);
+ return GL_TRUE;
+ }
}
return GL_FALSE;
}
}
+ /* In the ES 3.2 specification's Table 8.13 (Valid CopyTexImage source
+ * framebuffer/destination texture base internal format combinations),
+ * all the entries for stencil are left blank (unsupported).
+ */
+ if (_mesa_is_gles(ctx) && _mesa_is_stencil_format(texImage->_BaseFormat)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(stencil disallowed)", caller);
+ return GL_TRUE;
+ }
+
/* if we get here, the parameters are OK */
return GL_FALSE;
}
if (_mesa_get_format_bits(texFormat, GL_DEPTH_BITS) > 0) {
/* reading from depth/stencil buffer */
return ctx->ReadBuffer->Attachment[BUFFER_DEPTH].Renderbuffer;
- }
- else {
+ } else if (_mesa_get_format_bits(texFormat, GL_STENCIL_BITS) > 0) {
+ return ctx->ReadBuffer->Attachment[BUFFER_STENCIL].Renderbuffer;
+ } else {
/* copying from color buffer */
return ctx->ReadBuffer->_ColorReadBuffer;
}
return GL_FALSE;
}
+static bool
+can_avoid_reallocation(struct gl_texture_image *texImage, GLenum internalFormat,
+ mesa_format texFormat, GLint x, GLint y, GLsizei width,
+ GLsizei height, GLint border)
+{
+ if (texImage->InternalFormat != internalFormat)
+ return false;
+ if (texImage->TexFormat != texFormat)
+ return false;
+ if (texImage->Border != border)
+ return false;
+ if (texImage->Width2 != width)
+ return false;
+ if (texImage->Height2 != height)
+ return false;
+ return true;
+}
+
/**
* Implement the glCopyTexImage1/2D() functions.
*/
texFormat = _mesa_choose_texture_format(ctx, texObj, target, level,
internalFormat, GL_NONE, GL_NONE);
+ /* First check if reallocating the texture buffer can be avoided.
+ * Without the realloc the copy can be 20x faster.
+ */
+ _mesa_lock_texture(ctx, texObj);
+ {
+ texImage = _mesa_select_tex_image(texObj, target, level);
+ if (texImage && can_avoid_reallocation(texImage, internalFormat, texFormat,
+ x, y, width, height, border)) {
+ _mesa_unlock_texture(ctx, texObj);
+ return _mesa_copy_texture_sub_image(ctx, dims, texObj, target, level,
+ 0, 0, 0, x, y, width, height,
+ "CopyTexImage");
+ }
+ }
+ _mesa_unlock_texture(ctx, texObj);
+ _mesa_perf_debug(ctx, MESA_DEBUG_SEVERITY_LOW, "glCopyTexImage "
+ "can't avoid reallocating texture storage\n");
+
rb = _mesa_get_read_renderbuffer_for_format(ctx, internalFormat);
if (_mesa_is_gles3(ctx)) {
static mesa_format
get_texbuffer_format(const struct gl_context *ctx, GLenum internalFormat)
{
- if (ctx->API != API_OPENGL_CORE) {
+ if (ctx->API == API_OPENGL_COMPAT) {
switch (internalFormat) {
case GL_ALPHA8:
return MESA_FORMAT_A_UNORM8;
}
}
- if (ctx->API == API_OPENGL_CORE &&
- ctx->Extensions.ARB_texture_buffer_object_rgb32) {
+ if (_mesa_has_ARB_texture_buffer_object_rgb32(ctx) ||
+ _mesa_has_OES_texture_buffer(ctx)) {
switch (internalFormat) {
case GL_RGB32F:
return MESA_FORMAT_RGB_FLOAT32;
case GL_RGBA8:
return MESA_FORMAT_R8G8B8A8_UNORM;
case GL_RGBA16:
+ if (_mesa_is_gles(ctx))
+ return MESA_FORMAT_NONE;
return MESA_FORMAT_RGBA_UNORM16;
case GL_RGBA16F_ARB:
return MESA_FORMAT_RGBA_FLOAT16;
case GL_RG8:
return MESA_FORMAT_R8G8_UNORM;
case GL_RG16:
+ if (_mesa_is_gles(ctx))
+ return MESA_FORMAT_NONE;
return MESA_FORMAT_R16G16_UNORM;
case GL_RG16F:
return MESA_FORMAT_RG_FLOAT16;
case GL_R8:
return MESA_FORMAT_R_UNORM8;
case GL_R16:
+ if (_mesa_is_gles(ctx))
+ return MESA_FORMAT_NONE;
return MESA_FORMAT_R_UNORM16;
case GL_R16F:
return MESA_FORMAT_R_FLOAT16;
/* NOTE: ARB_texture_buffer_object has interactions with
* the compatibility profile that are not implemented.
*/
- if (!(ctx->API == API_OPENGL_CORE &&
- ctx->Extensions.ARB_texture_buffer_object)) {
+ if (!_mesa_has_ARB_texture_buffer_object(ctx) &&
+ !_mesa_has_OES_texture_buffer(ctx)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"%s(ARB_texture_buffer_object is not"
" implemented for the compatibility profile)", caller);