aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main/teximage.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-09-20 10:51:44 +0200
committermarha <marha@users.sourceforge.net>2011-09-20 10:51:44 +0200
commit5921af43b0a9b04c0c6b7d3c1e042e05bd3acbb1 (patch)
treeb7206e85fd135f1cf45c1db3ad85d3dc7c2fa2d3 /mesalib/src/mesa/main/teximage.c
parent97f357506241a5314de9071befcd01be731f1dbb (diff)
parent0470a59df89ab453bdbe0fc2f820278cfffdc61c (diff)
downloadvcxsrv-5921af43b0a9b04c0c6b7d3c1e042e05bd3acbb1.tar.gz
vcxsrv-5921af43b0a9b04c0c6b7d3c1e042e05bd3acbb1.tar.bz2
vcxsrv-5921af43b0a9b04c0c6b7d3c1e042e05bd3acbb1.zip
Merge remote-tracking branch 'origin/released'
Diffstat (limited to 'mesalib/src/mesa/main/teximage.c')
-rw-r--r--mesalib/src/mesa/main/teximage.c100
1 files changed, 89 insertions, 11 deletions
diff --git a/mesalib/src/mesa/main/teximage.c b/mesalib/src/mesa/main/teximage.c
index 6113b2e9e..fa00183ac 100644
--- a/mesalib/src/mesa/main/teximage.c
+++ b/mesalib/src/mesa/main/teximage.c
@@ -511,6 +511,25 @@ _mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat )
}
}
+ if (ctx->API == API_OPENGLES) {
+ switch (internalFormat) {
+ case GL_PALETTE4_RGB8_OES:
+ case GL_PALETTE4_R5_G6_B5_OES:
+ case GL_PALETTE8_RGB8_OES:
+ case GL_PALETTE8_R5_G6_B5_OES:
+ return GL_RGB;
+ case GL_PALETTE4_RGBA8_OES:
+ case GL_PALETTE8_RGB5_A1_OES:
+ case GL_PALETTE4_RGBA4_OES:
+ case GL_PALETTE4_RGB5_A1_OES:
+ case GL_PALETTE8_RGBA8_OES:
+ case GL_PALETTE8_RGBA4_OES:
+ return GL_RGBA;
+ default:
+ ; /* fallthrough */
+ }
+ }
+
return -1; /* error */
}
@@ -3012,15 +3031,12 @@ compressed_texture_error_check(struct gl_context *ctx, GLint dimensions,
const GLenum proxyTarget = get_proxy_target(target);
const GLint maxLevels = _mesa_max_texture_levels(ctx, target);
GLint expectedSize;
+ GLenum choose_format;
+ GLenum choose_type;
+ GLenum proxy_format;
*reason = ""; /* no error */
- /* check level */
- if (level < 0 || level >= maxLevels) {
- *reason = "level";
- return GL_INVALID_VALUE;
- }
-
if (!target_can_be_compressed(ctx, target, internalFormat)) {
*reason = "target";
return GL_INVALID_ENUM;
@@ -3032,6 +3048,68 @@ compressed_texture_error_check(struct gl_context *ctx, GLint dimensions,
return GL_INVALID_ENUM;
}
+ switch (internalFormat) {
+#if FEATURE_ES
+ case GL_PALETTE4_RGB8_OES:
+ case GL_PALETTE4_RGBA8_OES:
+ case GL_PALETTE4_R5_G6_B5_OES:
+ case GL_PALETTE4_RGBA4_OES:
+ case GL_PALETTE4_RGB5_A1_OES:
+ case GL_PALETTE8_RGB8_OES:
+ case GL_PALETTE8_RGBA8_OES:
+ case GL_PALETTE8_R5_G6_B5_OES:
+ case GL_PALETTE8_RGBA4_OES:
+ case GL_PALETTE8_RGB5_A1_OES:
+ _mesa_cpal_compressed_format_type(internalFormat, &choose_format,
+ &choose_type);
+ proxy_format = choose_format;
+
+ /* check level */
+ if (level > 0 || level < -maxLevels) {
+ *reason = "level";
+ return GL_INVALID_VALUE;
+ }
+
+ if (dimensions != 2) {
+ *reason = "compressed paletted textures must be 2D";
+ return GL_INVALID_OPERATION;
+ }
+
+ /* Figure out the expected texture size (in bytes). This will be
+ * checked against the actual size later.
+ */
+ expectedSize = _mesa_cpal_compressed_size(level, internalFormat,
+ width, height);
+
+ /* This is for the benefit of the TestProxyTexImage below. It expects
+ * level to be non-negative. OES_compressed_paletted_texture uses a
+ * weird mechanism where the level specified to glCompressedTexImage2D
+ * is -(n-1) number of levels in the texture, and the data specifies the
+ * complete mipmap stack. This is done to ensure the palette is the
+ * same for all levels.
+ */
+ level = -level;
+ break;
+#endif
+
+ default:
+ choose_format = GL_NONE;
+ choose_type = GL_NONE;
+ proxy_format = internalFormat;
+
+ /* check level */
+ if (level < 0 || level >= maxLevels) {
+ *reason = "level";
+ return GL_INVALID_VALUE;
+ }
+
+ /* Figure out the expected texture size (in bytes). This will be
+ * checked against the actual size later.
+ */
+ expectedSize = compressed_tex_size(width, height, depth, internalFormat);
+ break;
+ }
+
/* This should really never fail */
if (_mesa_base_tex_format(ctx, internalFormat) < 0) {
*reason = "internalFormat";
@@ -3054,8 +3132,8 @@ compressed_texture_error_check(struct gl_context *ctx, GLint dimensions,
/* check image size against compression block size */
{
gl_format texFormat =
- ctx->Driver.ChooseTextureFormat(ctx, internalFormat,
- GL_NONE, GL_NONE);
+ ctx->Driver.ChooseTextureFormat(ctx, proxy_format,
+ choose_format, choose_type);
GLuint bw, bh;
_mesa_get_format_block_size(texFormat, &bw, &bh);
@@ -3073,15 +3151,15 @@ compressed_texture_error_check(struct gl_context *ctx, GLint dimensions,
/* check image sizes */
if (!ctx->Driver.TestProxyTexImage(ctx, proxyTarget, level,
- internalFormat, GL_NONE, GL_NONE,
- width, height, depth, border)) {
+ proxy_format, choose_format,
+ choose_type,
+ width, height, depth, border)) {
/* See error comment above */
*reason = "invalid width, height or format";
return GL_INVALID_OPERATION;
}
/* check image size in bytes */
- expectedSize = compressed_tex_size(width, height, depth, internalFormat);
if (expectedSize != imageSize) {
/* Per GL_ARB_texture_compression: GL_INVALID_VALUE is generated [...]
* if <imageSize> is not consistent with the format, dimensions, and