return format;
}
+/**
+ * Returns a corresponding base format for a given internal floating point
+ * format as specifed by OES_texture_float.
+ */
+static GLenum
+oes_float_internal_format(const struct gl_context *ctx,
+ GLenum format, GLenum type)
+{
+ switch (type) {
+ case GL_FLOAT:
+ if (ctx->Extensions.OES_texture_float) {
+ switch (format) {
+ case GL_RGBA32F:
+ return GL_RGBA;
+ case GL_RGB32F:
+ return GL_RGB;
+ case GL_ALPHA32F_ARB:
+ return GL_ALPHA;
+ case GL_LUMINANCE32F_ARB:
+ return GL_LUMINANCE;
+ case GL_LUMINANCE_ALPHA32F_ARB:
+ return GL_LUMINANCE_ALPHA;
+ default:
+ break;
+ }
+ }
+ break;
+
+ case GL_HALF_FLOAT_OES:
+ if (ctx->Extensions.OES_texture_half_float) {
+ switch (format) {
+ case GL_RGBA16F:
+ return GL_RGBA;
+ case GL_RGB16F:
+ return GL_RGB;
+ case GL_ALPHA16F_ARB:
+ return GL_ALPHA;
+ case GL_LUMINANCE16F_ARB:
+ return GL_LUMINANCE;
+ case GL_LUMINANCE_ALPHA16F_ARB:
+ return GL_LUMINANCE_ALPHA;
+ default:
+ break;
+ }
+ }
+ break;
+ }
+ return format;
+}
+
/**
* Install gl_texture_image in a gl_texture_object according to the target
*
* This should also be applicable for glTexStorage3D(). Other available
* targets for these functions are: TEXTURE_3D and TEXTURE_CUBE_MAP_ARRAY.
+ *
+ * Section 8.7, page 179 of OpenGL ES 3.2 adds:
+ *
+ * An INVALID_OPERATION error is generated by CompressedTexImage3D
+ * if internalformat is one of the the formats in table 8.17 and target is
+ * not TEXTURE_2D_ARRAY, TEXTURE_CUBE_MAP_ARRAY or TEXTURE_3D.
+ *
+ * An INVALID_OPERATION error is generated by CompressedTexImage3D
+ * if internalformat is TEXTURE_CUBE_MAP_ARRAY and the “Cube Map
+ * Array” column of table 8.17 is not checked, or if internalformat
+ * is TEXTURE_- 3D and the “3D Tex.” column of table 8.17 is not
+ * checked.
+ *
+ * The instances of <internalformat> above should say <target>.
+ *
+ * Such table 8.17 has checked "Cube Map Array" column for all the
+ * cases. So in practice, TEXTURE_CUBE_MAP_ARRAY is now valid for OpenGL ES 3.2
*/
- if (layout == MESA_FORMAT_LAYOUT_ETC2 && _mesa_is_gles3(ctx))
+ if (layout == MESA_FORMAT_LAYOUT_ETC2 && _mesa_is_gles3(ctx) &&
+ !_mesa_is_gles32(ctx))
return write_error(error, GL_INVALID_OPERATION);
target_can_be_compresed = _mesa_has_texture_cube_map_array(ctx);
break;
* \param format pixel data format given by the user.
* \param type pixel data type given by the user.
* \param internalFormat internal format given by the user.
- * \param dimensions texture image dimensions (must be 1, 2 or 3).
* \param callerName name of the caller function to print in the error message
*
* \return true if a error is found, false otherwise
*/
static bool
texture_format_error_check_gles(struct gl_context *ctx, GLenum format,
- GLenum type, GLenum internalFormat,
- GLuint dimensions, const char *callerName)
+ GLenum type, GLenum internalFormat, const char *callerName)
{
- GLenum err;
-
- if (_mesa_is_gles3(ctx)) {
- err = _mesa_es3_error_check_format_and_type(ctx, format, type,
- internalFormat);
- if (err != GL_NO_ERROR) {
- _mesa_error(ctx, err,
- "%s(format = %s, type = %s, internalformat = %s)",
- callerName, _mesa_enum_to_string(format),
- _mesa_enum_to_string(type),
- _mesa_enum_to_string(internalFormat));
- return true;
- }
- }
- else {
- err = _mesa_es_error_check_format_and_type(ctx, format, type, dimensions);
- if (err != GL_NO_ERROR) {
- _mesa_error(ctx, err, "%s(format = %s, type = %s)",
- callerName, _mesa_enum_to_string(format),
- _mesa_enum_to_string(type));
- return true;
- }
+ GLenum err = _mesa_es3_error_check_format_and_type(ctx, format, type,
+ internalFormat);
+ if (err != GL_NO_ERROR) {
+ _mesa_error(ctx, err,
+ "%s(format = %s, type = %s, internalformat = %s)",
+ callerName, _mesa_enum_to_string(format),
+ _mesa_enum_to_string(type),
+ _mesa_enum_to_string(internalFormat));
+ return true;
}
return false;
* Formats and types that require additional extensions (e.g., GL_FLOAT
* requires GL_OES_texture_float) are filtered elsewhere.
*/
+ char bufCallerName[20];
+ snprintf(bufCallerName, 20, "glTexImage%dD", dimensions);
if (_mesa_is_gles(ctx) &&
- texture_format_error_check_gles(ctx, format, type, internalFormat,
- dimensions, "glTexImage%dD")) {
+ texture_format_error_check_gles(ctx, format, type,
+ internalFormat, bufCallerName)) {
return GL_TRUE;
}
return GL_TRUE;
}
+ GLenum internalFormat = _mesa_is_gles(ctx) ?
+ oes_float_internal_format(ctx, texImage->InternalFormat, type) :
+ texImage->InternalFormat;
+
/* OpenGL ES 1.x and OpenGL ES 2.0 impose additional restrictions on the
* combinations of format, internalFormat, and type that can be used.
* Formats and types that require additional extensions (e.g., GL_FLOAT
*/
if (_mesa_is_gles(ctx) &&
texture_format_error_check_gles(ctx, format, type,
- texImage->InternalFormat,
- dimensions, callerName)) {
+ internalFormat, callerName)) {
return GL_TRUE;
}
}
}
- /* If the application requested compression to an S3TC format but we don't
- * have the DXTn library, force a generic compressed format instead.
- */
- if (internalFormat != format && format != GL_NONE) {
- const GLenum before = internalFormat;
-
- switch (internalFormat) {
- case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
- if (!ctx->Mesa_DXTn)
- internalFormat = GL_COMPRESSED_RGB;
- break;
- case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
- if (!ctx->Mesa_DXTn)
- internalFormat = GL_COMPRESSED_RGBA;
- break;
- default:
- break;
- }
-
- if (before != internalFormat) {
- _mesa_warning(ctx,
- "DXT compression requested (%s), "
- "but libtxc_dxtn library not installed. Using %s "
- "instead.",
- _mesa_enum_to_string(before),
- _mesa_enum_to_string(internalFormat));
- }
- }
-
- /* choose format from scratch */
f = ctx->Driver.ChooseTextureFormat(ctx, target, internalFormat,
format, type);
assert(f != MESA_FORMAT_NONE);
*/
static GLboolean
compressed_subtexture_target_check(struct gl_context *ctx, GLenum target,
- GLint dims, GLenum format, bool dsa,
+ GLint dims, GLenum intFormat, bool dsa,
const char *caller)
{
GLboolean targetOK;
+ mesa_format format;
+ enum mesa_format_layout layout;
if (dsa && target == GL_TEXTURE_RECTANGLE) {
_mesa_error(ctx, GL_INVALID_OPERATION, "%s(invalid target %s)", caller,
* which is (at this time) only bptc. Otherwise we'd say s3tc (and
* more) are valid here, which they are not, but of course not
* mentioned by core spec.
+ *
+ * Also, from GL_KHR_texture_compression_astc_{hdr,ldr}:
+ *
+ * "Add a second new column "3D Tex." which is empty for all non-ASTC
+ * formats. If only the LDR profile is supported by the implementation,
+ * this column is also empty for all ASTC formats. If both the LDR and HDR
+ * profiles are supported, this column is checked for all ASTC formats."
+ *
+ * "An INVALID_OPERATION error is generated by CompressedTexSubImage3D if
+ * <format> is one of the formats in table 8.19 and <target> is not
+ * TEXTURE_2D_ARRAY, TEXTURE_CUBE_MAP_ARRAY, or TEXTURE_3D.
+ *
+ * An INVALID_OPERATION error is generated by CompressedTexSubImage3D if
+ * <format> is TEXTURE_CUBE_MAP_ARRAY and the "Cube Map Array" column of
+ * table 8.19 is *not* checked, or if <format> is TEXTURE_3D and the "3D
+ * Tex." column of table 8.19 is *not* checked"
+ *
+ * And from GL_KHR_texture_compression_astc_sliced_3d:
+ *
+ * "Modify the "3D Tex." column to be checked for all ASTC formats."
*/
- switch (format) {
- /* These are the only 3D compression formats supported at this time */
- case GL_COMPRESSED_RGBA_BPTC_UNORM:
- case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM:
- case GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT:
- case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT:
+ format = _mesa_glenum_to_compressed_format(intFormat);
+ layout = _mesa_get_format_layout(format);
+ switch (layout) {
+ case MESA_FORMAT_LAYOUT_BPTC:
/* valid format */
break;
+ case MESA_FORMAT_LAYOUT_ASTC:
+ targetOK =
+ ctx->Extensions.KHR_texture_compression_astc_hdr ||
+ ctx->Extensions.KHR_texture_compression_astc_sliced_3d;
+ break;
default:
/* invalid format */
_mesa_error(ctx, GL_INVALID_OPERATION,
"%s(invalid target %s for format %s)", caller,
_mesa_enum_to_string(target),
- _mesa_enum_to_string(format));
+ _mesa_enum_to_string(intFormat));
return GL_TRUE;
}
break;
const GLvoid *data, bool dsa, bool no_error,
const char *caller)
{
- struct gl_texture_object *texObj;
+ struct gl_texture_object *texObj = NULL;
struct gl_texture_image *texImage;
GET_CURRENT_CONTEXT(ctx);
}
GLboolean
-_mesa_is_renderable_texture_format(struct gl_context *ctx, GLenum internalformat)
+_mesa_is_renderable_texture_format(const struct gl_context *ctx,
+ GLenum internalformat)
{
/* Everything that is allowed for renderbuffers,
* except for a base format of GL_STENCIL_INDEX, unless supported.
}
if (!check_multisample_target(dims, target, dsa)) {
- if (dsa) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "%s(target)", func);
- return;
- }
- else {
- _mesa_error(ctx, GL_INVALID_ENUM, "%s(target)", func);
- return;
- }
+ GLenum err = dsa ? GL_INVALID_OPERATION : GL_INVALID_ENUM;
+ _mesa_error(ctx, err, "%s(target=%s)", func,
+ _mesa_enum_to_string(target));
+ return;
}
/* check that the specified internalformat is color/depth/stencil-renderable;
* However, if samples is not supported, then no error is generated.
*/
if (!samplesOK && !_mesa_is_proxy_texture(target)) {
- _mesa_error(ctx, sample_count_error, "%s(samples)", func);
+ _mesa_error(ctx, sample_count_error, "%s(samples=%d)", func, samples);
return;
}