aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main/texobj.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-08-16 14:52:47 +0200
committermarha <marha@users.sourceforge.net>2012-08-16 14:52:47 +0200
commite12a88a1a4897365d47e428bceda547a4e02fbd0 (patch)
tree116944397f595fd9b72d8de3b0a3783ccf3937ef /mesalib/src/mesa/main/texobj.c
parentf5a4fa87e844b3ea2658a2355a4c4ac3393a65a1 (diff)
parent4aac32998c2b173b84aec0b020aa086fef4b1423 (diff)
downloadvcxsrv-e12a88a1a4897365d47e428bceda547a4e02fbd0.tar.gz
vcxsrv-e12a88a1a4897365d47e428bceda547a4e02fbd0.tar.bz2
vcxsrv-e12a88a1a4897365d47e428bceda547a4e02fbd0.zip
Merge remote-tracking branch 'origin/released'
Diffstat (limited to 'mesalib/src/mesa/main/texobj.c')
-rw-r--r--mesalib/src/mesa/main/texobj.c213
1 files changed, 211 insertions, 2 deletions
diff --git a/mesalib/src/mesa/main/texobj.c b/mesalib/src/mesa/main/texobj.c
index f70da4fbc..1d905b608 100644
--- a/mesalib/src/mesa/main/texobj.c
+++ b/mesalib/src/mesa/main/texobj.c
@@ -144,7 +144,6 @@ _mesa_initialize_texture_object( struct gl_texture_object *obj,
obj->Sampler.MaxAnisotropy = 1.0;
obj->Sampler.CompareMode = GL_NONE; /* ARB_shadow */
obj->Sampler.CompareFunc = GL_LEQUAL; /* ARB_shadow */
- obj->Sampler.CompareFailValue = 0.0F; /* ARB_shadow_ambient */
obj->DepthMode = GL_LUMINANCE;
obj->Sampler.CubeMapSeamless = GL_FALSE;
obj->Swizzle[0] = GL_RED;
@@ -257,7 +256,6 @@ _mesa_copy_texture_object( struct gl_texture_object *dest,
dest->Sampler.MaxAnisotropy = src->Sampler.MaxAnisotropy;
dest->Sampler.CompareMode = src->Sampler.CompareMode;
dest->Sampler.CompareFunc = src->Sampler.CompareFunc;
- dest->Sampler.CompareFailValue = src->Sampler.CompareFailValue;
dest->Sampler.CubeMapSeamless = src->Sampler.CubeMapSeamless;
dest->DepthMode = src->DepthMode;
dest->Sampler.sRGBDecode = src->Sampler.sRGBDecode;
@@ -879,7 +877,58 @@ _mesa_total_texture_memory(struct gl_context *ctx)
return total;
}
+static struct gl_texture_object *
+invalidate_tex_image_error_check(struct gl_context *ctx, GLuint texture,
+ GLint level, const char *name)
+{
+ /* The GL_ARB_invalidate_subdata spec says:
+ *
+ * "If <texture> is zero or is not the name of a texture, the error
+ * INVALID_VALUE is generated."
+ *
+ * This performs the error check in a different order than listed in the
+ * spec. We have to get the texture object before we can validate the
+ * other parameters against values in the texture object.
+ */
+ struct gl_texture_object *const t = _mesa_lookup_texture(ctx, texture);
+ if (texture == 0 || t == NULL) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "%s(texture)", name);
+ return NULL;
+ }
+ /* The GL_ARB_invalidate_subdata spec says:
+ *
+ * "If <level> is less than zero or greater than the base 2 logarithm
+ * of the maximum texture width, height, or depth, the error
+ * INVALID_VALUE is generated."
+ */
+ if (level < 0 || level > t->MaxLevel) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "%s(level)", name);
+ return NULL;
+ }
+
+ /* The GL_ARB_invalidate_subdata spec says:
+ *
+ * "If the target of <texture> is TEXTURE_RECTANGLE, TEXTURE_BUFFER,
+ * TEXTURE_2D_MULTISAMPLE, or TEXTURE_2D_MULTISAMPLE_ARRAY, and <level>
+ * is not zero, the error INVALID_VALUE is generated."
+ */
+ if (level != 0) {
+ switch (t->Target) {
+ case GL_TEXTURE_RECTANGLE:
+ case GL_TEXTURE_BUFFER:
+ case GL_TEXTURE_2D_MULTISAMPLE:
+ case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
+ _mesa_error(ctx, GL_INVALID_VALUE, "%s(level)", name);
+ return NULL;
+
+ default:
+ break;
+ }
+ }
+
+ return t;
+}
/*@}*/
@@ -1348,4 +1397,164 @@ _mesa_unlock_context_textures( struct gl_context *ctx )
_glthread_UNLOCK_MUTEX(ctx->Shared->TexMutex);
}
+void GLAPIENTRY
+_mesa_InvalidateTexSubImage(GLuint texture, GLint level, GLint xoffset,
+ GLint yoffset, GLint zoffset, GLsizei width,
+ GLsizei height, GLsizei depth)
+{
+ struct gl_texture_object *t;
+ struct gl_texture_image *image;
+ GET_CURRENT_CONTEXT(ctx);
+
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ t = invalidate_tex_image_error_check(ctx, texture, level,
+ "glInvalidateTexSubImage");
+
+ /* The GL_ARB_invalidate_subdata spec says:
+ *
+ * "...the specified subregion must be between -<b> and <dim>+<b> where
+ * <dim> is the size of the dimension of the texture image, and <b> is
+ * the size of the border of that texture image, otherwise
+ * INVALID_VALUE is generated (border is not applied to dimensions that
+ * don't exist in a given texture target)."
+ */
+ image = t->Image[0][level];
+ if (image) {
+ int xBorder;
+ int yBorder;
+ int zBorder;
+ int imageWidth;
+ int imageHeight;
+ int imageDepth;
+
+ /* The GL_ARB_invalidate_subdata spec says:
+ *
+ * "For texture targets that don't have certain dimensions, this
+ * command treats those dimensions as having a size of 1. For
+ * example, to invalidate a portion of a two-dimensional texture,
+ * the application would use <zoffset> equal to zero and <depth>
+ * equal to one."
+ */
+ switch (t->Target) {
+ case GL_TEXTURE_BUFFER:
+ xBorder = 0;
+ yBorder = 0;
+ zBorder = 0;
+ imageWidth = 1;
+ imageHeight = 1;
+ imageDepth = 1;
+ break;
+ case GL_TEXTURE_1D:
+ xBorder = image->Border;
+ yBorder = 0;
+ zBorder = 0;
+ imageWidth = image->Width;
+ imageHeight = 1;
+ imageDepth = 1;
+ break;
+ case GL_TEXTURE_1D_ARRAY:
+ xBorder = image->Border;
+ yBorder = 0;
+ zBorder = 0;
+ imageWidth = image->Width;
+ imageHeight = image->Height;
+ imageDepth = 1;
+ break;
+ case GL_TEXTURE_2D:
+ case GL_TEXTURE_CUBE_MAP:
+ case GL_TEXTURE_RECTANGLE:
+ case GL_TEXTURE_2D_MULTISAMPLE:
+ xBorder = image->Border;
+ yBorder = image->Border;
+ zBorder = 0;
+ imageWidth = image->Width;
+ imageHeight = image->Height;
+ imageDepth = 1;
+ break;
+ case GL_TEXTURE_2D_ARRAY:
+ case GL_TEXTURE_CUBE_MAP_ARRAY:
+ xBorder = image->Border;
+ yBorder = image->Border;
+ zBorder = 0;
+ imageWidth = image->Width;
+ imageHeight = image->Height;
+ imageDepth = image->Depth;
+ break;
+ case GL_TEXTURE_3D:
+ xBorder = image->Border;
+ yBorder = image->Border;
+ zBorder = image->Border;
+ imageWidth = image->Width;
+ imageHeight = image->Height;
+ imageDepth = image->Depth;
+ break;
+ default:
+ assert(!"Should not get here.");
+ xBorder = 0;
+ yBorder = 0;
+ zBorder = 0;
+ imageWidth = 0;
+ imageHeight = 0;
+ imageDepth = 0;
+ break;
+ }
+
+ if (xoffset < -xBorder) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glInvalidateSubTexImage(xoffset)");
+ return;
+ }
+
+ if (xoffset + width > imageWidth + xBorder) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glInvalidateSubTexImage(xoffset+width)");
+ return;
+ }
+
+ if (yoffset < -yBorder) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glInvalidateSubTexImage(yoffset)");
+ return;
+ }
+
+ if (yoffset + height > imageHeight + yBorder) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glInvalidateSubTexImage(yoffset+height)");
+ return;
+ }
+
+ if (zoffset < -zBorder) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glInvalidateSubTexImage(zoffset)");
+ return;
+ }
+
+ if (zoffset + depth > imageDepth + zBorder) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glInvalidateSubTexImage(zoffset+depth)");
+ return;
+ }
+ }
+
+ /* We don't actually do anything for this yet. Just return after
+ * validating the parameters and generating the required errors.
+ */
+ return;
+}
+
+void GLAPIENTRY
+_mesa_InvalidateTexImage(GLuint texture, GLint level)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ invalidate_tex_image_error_check(ctx, texture, level,
+ "glInvalidateTexImage");
+
+ /* We don't actually do anything for this yet. Just return after
+ * validating the parameters and generating the required errors.
+ */
+ return;
+}
+
/*@}*/