/* Check incoming image format and type */
if (!_mesa_is_legal_format_and_type(ctx, format, type)) {
- /* Yes, generate GL_INVALID_OPERATION, not GL_INVALID_ENUM, if there
- * is a type/format mismatch. See 1.2 spec page 94, sec 3.6.4.
+ /* 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!).
*/
if (!isProxy) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
+ GLenum error = _mesa_is_integer_format(format)
+ ? GL_INVALID_ENUM : GL_INVALID_OPERATION;
+ _mesa_error(ctx, error,
"glTexImage%dD(incompatible format 0x%x, type 0x%x)",
dimensions, format, type);
}
}
}
+ /* additional checks for integer textures */
+ if (ctx->Extensions.EXT_texture_integer &&
+ (_mesa_is_integer_format(format) !=
+ _mesa_is_integer_format(internalFormat))) {
+ if (!isProxy) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTexImage%dD(integer/non-integer format mismatch)",
+ dimensions);
+ }
+ return GL_TRUE;
+ }
+
/* if we get here, the parameters are OK */
return GL_FALSE;
}
}
if (!_mesa_is_legal_format_and_type(ctx, format, type)) {
- _mesa_error(ctx, GL_INVALID_ENUM,
+ /* 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,
"glTexSubImage%dD(incompatible format 0x%x, type 0x%x)",
dimensions, format, type);
return GL_TRUE;
}
}
+ /* If copying into an integer texture, the source buffer must also be
+ * integer-valued.
+ */
+ if (_mesa_is_format_integer(teximage->TexFormat)) {
+ struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer;
+ if (!_mesa_is_format_integer(rb->Format)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glCopyTexSubImage%dD(source buffer is not integer format)",
+ dimensions);
+ return GL_TRUE;
+ }
+ }
+
/* if we get here, the parameters are OK */
return GL_FALSE;
}