| | COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT |
---------------------------------------------------------------------------
*/
+
+#define VIEW_CLASS_GLES(x) (GL_VIEW_CLASS_BPTC_FLOAT + 1 + x)
+#define VIEW_CLASS_EAC_R11 VIEW_CLASS_GLES(0)
+#define VIEW_CLASS_EAC_RG11 VIEW_CLASS_GLES(1)
+#define VIEW_CLASS_ETC2_RGB VIEW_CLASS_GLES(2)
+#define VIEW_CLASS_ETC2_RGBA VIEW_CLASS_GLES(3)
+#define VIEW_CLASS_ETC2_EAC_RGBA VIEW_CLASS_GLES(4)
+#define VIEW_CLASS_ASTC_4x4_RGBA VIEW_CLASS_GLES(5)
+#define VIEW_CLASS_ASTC_5x4_RGBA VIEW_CLASS_GLES(6)
+#define VIEW_CLASS_ASTC_5x5_RGBA VIEW_CLASS_GLES(7)
+#define VIEW_CLASS_ASTC_6x5_RGBA VIEW_CLASS_GLES(8)
+#define VIEW_CLASS_ASTC_6x6_RGBA VIEW_CLASS_GLES(9)
+#define VIEW_CLASS_ASTC_8x5_RGBA VIEW_CLASS_GLES(10)
+#define VIEW_CLASS_ASTC_8x6_RGBA VIEW_CLASS_GLES(11)
+#define VIEW_CLASS_ASTC_8x8_RGBA VIEW_CLASS_GLES(12)
+#define VIEW_CLASS_ASTC_10x5_RGBA VIEW_CLASS_GLES(13)
+#define VIEW_CLASS_ASTC_10x6_RGBA VIEW_CLASS_GLES(14)
+#define VIEW_CLASS_ASTC_10x8_RGBA VIEW_CLASS_GLES(15)
+#define VIEW_CLASS_ASTC_10x10_RGBA VIEW_CLASS_GLES(16)
+#define VIEW_CLASS_ASTC_12x10_RGBA VIEW_CLASS_GLES(17)
+#define VIEW_CLASS_ASTC_12x12_RGBA VIEW_CLASS_GLES(18)
+#define VIEW_CLASS_ASTC_3x3x3_RGBA VIEW_CLASS_GLES(19)
+#define VIEW_CLASS_ASTC_4x3x3_RGBA VIEW_CLASS_GLES(20)
+#define VIEW_CLASS_ASTC_4x4x3_RGBA VIEW_CLASS_GLES(21)
+#define VIEW_CLASS_ASTC_4x4x4_RGBA VIEW_CLASS_GLES(22)
+#define VIEW_CLASS_ASTC_5x4x4_RGBA VIEW_CLASS_GLES(23)
+#define VIEW_CLASS_ASTC_5x5x4_RGBA VIEW_CLASS_GLES(24)
+#define VIEW_CLASS_ASTC_5x5x5_RGBA VIEW_CLASS_GLES(25)
+#define VIEW_CLASS_ASTC_6x5x5_RGBA VIEW_CLASS_GLES(26)
+#define VIEW_CLASS_ASTC_6x6x5_RGBA VIEW_CLASS_GLES(27)
+#define VIEW_CLASS_ASTC_6x6x6_RGBA VIEW_CLASS_GLES(28)
+
+
struct internal_format_class_info {
GLenum view_class;
GLenum internal_format;
{GL_VIEW_CLASS_S3TC_DXT5_RGBA, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT},
};
-/**
- * Lookup format view class based on internalformat
- * \return VIEW_CLASS if internalformat found in table, false otherwise.
- */
-static GLenum
-lookup_view_class(const struct gl_context *ctx, GLenum internalformat)
+static const struct internal_format_class_info gles_etc2_compatible_internal_formats[] = {
+ {VIEW_CLASS_EAC_R11, GL_COMPRESSED_R11_EAC},
+ {VIEW_CLASS_EAC_R11, GL_COMPRESSED_SIGNED_R11_EAC},
+ {VIEW_CLASS_EAC_RG11, GL_COMPRESSED_RG11_EAC},
+ {VIEW_CLASS_EAC_RG11, GL_COMPRESSED_SIGNED_RG11_EAC},
+ {VIEW_CLASS_ETC2_RGB, GL_COMPRESSED_RGB8_ETC2},
+ {VIEW_CLASS_ETC2_RGB, GL_COMPRESSED_SRGB8_ETC2},
+ {VIEW_CLASS_ETC2_RGBA, GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2},
+ {VIEW_CLASS_ETC2_RGBA, GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2},
+ {VIEW_CLASS_ETC2_EAC_RGBA, GL_COMPRESSED_RGBA8_ETC2_EAC},
+ {VIEW_CLASS_ETC2_EAC_RGBA, GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC},
+};
+
+static const struct internal_format_class_info gles_astc_compatible_internal_formats[] = {
+#define ASTC_FMT(size) \
+ {VIEW_CLASS_ASTC_##size##_RGBA, GL_COMPRESSED_RGBA_ASTC_##size##_KHR}, \
+ {VIEW_CLASS_ASTC_##size##_RGBA, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_##size##_KHR}
+
+ ASTC_FMT(4x4),
+ ASTC_FMT(5x4),
+ ASTC_FMT(5x5),
+ ASTC_FMT(6x5),
+ ASTC_FMT(6x6),
+ ASTC_FMT(8x5),
+ ASTC_FMT(8x6),
+ ASTC_FMT(8x8),
+ ASTC_FMT(10x5),
+ ASTC_FMT(10x6),
+ ASTC_FMT(10x8),
+ ASTC_FMT(10x10),
+ ASTC_FMT(12x10),
+ ASTC_FMT(12x12),
+#undef ASTC_FMT
+};
+
+static const struct internal_format_class_info gles_astc_3d_compatible_internal_formats[] = {
+#define ASTC_FMT(size) \
+ {VIEW_CLASS_ASTC_##size##_RGBA, GL_COMPRESSED_RGBA_ASTC_##size##_OES}, \
+ {VIEW_CLASS_ASTC_##size##_RGBA, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_##size##_OES}
+
+ ASTC_FMT(3x3x3),
+ ASTC_FMT(4x3x3),
+ ASTC_FMT(4x4x3),
+ ASTC_FMT(4x4x4),
+ ASTC_FMT(5x4x4),
+ ASTC_FMT(5x5x4),
+ ASTC_FMT(5x5x5),
+ ASTC_FMT(6x5x5),
+ ASTC_FMT(6x6x5),
+ ASTC_FMT(6x6x6),
+#undef ASTC_FMT
+};
+
+GLenum
+_mesa_texture_view_lookup_view_class(const struct gl_context *ctx, GLenum internalformat)
{
GLuint i;
return s3tc_compatible_internal_formats[i].view_class;
}
}
+
+ if (_mesa_is_gles3(ctx)) {
+ for (i = 0; i < ARRAY_SIZE(gles_etc2_compatible_internal_formats); i++) {
+ if (gles_etc2_compatible_internal_formats[i].internal_format
+ == internalformat)
+ return gles_etc2_compatible_internal_formats[i].view_class;
+ }
+
+ if (ctx->Extensions.KHR_texture_compression_astc_ldr) {
+ for (i = 0; i < ARRAY_SIZE(gles_astc_compatible_internal_formats); i++) {
+ if (gles_astc_compatible_internal_formats[i].internal_format
+ == internalformat)
+ return gles_astc_compatible_internal_formats[i].view_class;
+ }
+ }
+
+ if (ctx->Extensions.OES_texture_compression_astc) {
+ for (i = 0; i < ARRAY_SIZE(gles_astc_3d_compatible_internal_formats); i++) {
+ if (gles_astc_3d_compatible_internal_formats[i].internal_format
+ == internalformat)
+ return gles_astc_3d_compatible_internal_formats[i].view_class;
+ }
+ }
+ }
return GL_FALSE;
}
for (level = 0; level < levels; level++) {
for (face = 0; face < numFaces; face++) {
struct gl_texture_image *texImage;
- GLenum faceTarget = target;
-
- if (target == GL_TEXTURE_CUBE_MAP)
- faceTarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X + face;
+ const GLenum faceTarget = _mesa_cube_face_target(target, face);
texImage = _mesa_get_tex_image(ctx, texObj, faceTarget, level);
if (origInternalFormat == newInternalFormat)
return true;
- origViewClass = lookup_view_class(ctx, origInternalFormat);
- newViewClass = lookup_view_class(ctx, newInternalFormat);
+ origViewClass = _mesa_texture_view_lookup_view_class(ctx, origInternalFormat);
+ newViewClass = _mesa_texture_view_lookup_view_class(ctx, newInternalFormat);
if ((origViewClass == newViewClass) && origViewClass != false)
return true;
newViewNumLevels = MIN2(numlevels, origTexObj->NumLevels - minlevel);
newViewNumLayers = MIN2(numlayers, origTexObj->NumLayers - minlayer);
- faceTarget = origTexObj->Target;
- if (faceTarget == GL_TEXTURE_CUBE_MAP)
- faceTarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X + minlayer;
+ faceTarget = _mesa_cube_face_target(origTexObj->Target, minlayer);
/* Get a reference to what will become this View's base level */
origTexImage = _mesa_select_tex_image(origTexObj, faceTarget, minlevel);
case GL_TEXTURE_2D:
case GL_TEXTURE_2D_MULTISAMPLE:
case GL_TEXTURE_RECTANGLE:
+ depth = 1;
+ break;
case GL_TEXTURE_CUBE_MAP:
+ /* If the new texture's target is TEXTURE_CUBE_MAP, the clamped
+ * <numlayers> must be equal to 6.
+ */
+ if (newViewNumLayers != 6) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glTextureView(clamped numlayers %d != 6)",
+ newViewNumLayers);
+ return;
+ }
depth = 1;
break;
case GL_TEXTURE_2D_ARRAY:
- case GL_TEXTURE_CUBE_MAP_ARRAY:
case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
depth = newViewNumLayers;
break;
+ case GL_TEXTURE_CUBE_MAP_ARRAY:
+ /* If the new texture's target is TEXTURE_CUBE_MAP_ARRAY,
+ * then <numlayers> counts layer-faces rather than layers,
+ * and the clamped <numlayers> must be a multiple of 6.
+ * Otherwise, the error INVALID_VALUE is generated.
+ */
+ if ((newViewNumLayers % 6) != 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glTextureView(clamped numlayers %d is not"
+ " a multiple of 6)",
+ newViewNumLayers);
+ return;
+ }
+ depth = newViewNumLayers;
+ break;
}
/* If the dimensions of the original texture are larger than the maximum
return;
}
- sizeOK = ctx->Driver.TestProxyTexImage(ctx, target, 0, texFormat,
- width, height, depth, 0);
+ sizeOK = ctx->Driver.TestProxyTexImage(ctx, target, 1, 0, texFormat,
+ origTexImage->NumSamples,
+ width, height, depth);
if (!sizeOK) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glTextureView(invalid texture size)");
return;
}
break;
-
case GL_TEXTURE_CUBE_MAP:
- /* If the new texture's target is TEXTURE_CUBE_MAP, the clamped
- * <numlayers> must be equal to 6.
- */
- if (newViewNumLayers != 6) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "glTextureView(clamped numlayers %d != 6)",
- newViewNumLayers);
- return;
- }
break;
-
case GL_TEXTURE_CUBE_MAP_ARRAY:
- /* If the new texture's target is TEXTURE_CUBE_MAP_ARRAY,
- * then <numlayers> counts layer-faces rather than layers,
- * and the clamped <numlayers> must be a multiple of 6.
- * Otherwise, the error INVALID_VALUE is generated.
- */
- if ((newViewNumLayers % 6) != 0) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "glTextureView(clamped numlayers %d is not"
- " a multiple of 6)",
- newViewNumLayers);
- return;
- }
break;
}
texObj->Immutable = GL_TRUE;
texObj->ImmutableLevels = origTexObj->ImmutableLevels;
texObj->Target = target;
+ texObj->TargetIndex = _mesa_tex_target_to_index(ctx, target);
+ assert(texObj->TargetIndex < NUM_TEXTURE_TARGETS);
if (ctx->Driver.TextureView != NULL &&
!ctx->Driver.TextureView(ctx, texObj, origTexObj)) {