Allow glTexImage1/2/3D to specify width/height/depth = 0.
This allows texture state to be resettable to default state. Not allowed according to the spec, but allowed by all other OpenGL libs.
This commit is contained in:
@@ -105,7 +105,7 @@ static void PrintTexture(GLcontext *ctx, const struct gl_texture_image *img)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Compute floor(log_base_2(n)).
|
* Compute floor(log_base_2(n)).
|
||||||
* If n <= 0 return -1.
|
* If n < 0 return -1.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
logbase2( int n )
|
logbase2( int n )
|
||||||
@@ -113,9 +113,11 @@ logbase2( int n )
|
|||||||
GLint i = 1;
|
GLint i = 1;
|
||||||
GLint log2 = 0;
|
GLint log2 = 0;
|
||||||
|
|
||||||
if (n <= 0) {
|
if (n < 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
if (n == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
while ( n > i ) {
|
while ( n > i ) {
|
||||||
i *= 2;
|
i *= 2;
|
||||||
@@ -1094,10 +1096,10 @@ texture_error_check( GLcontext *ctx, GLenum target,
|
|||||||
return GL_TRUE;
|
return GL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (width < 1 || height < 1 || depth < 1) {
|
if (width < 0 || height < 0 || depth < 0) {
|
||||||
if (!isProxy) {
|
if (!isProxy) {
|
||||||
_mesa_error(ctx, GL_INVALID_VALUE,
|
_mesa_error(ctx, GL_INVALID_VALUE,
|
||||||
"glTexImage%dD(width, height or depth < 1)", dimensions);
|
"glTexImage%dD(width, height or depth < 0)", dimensions);
|
||||||
}
|
}
|
||||||
return GL_TRUE;
|
return GL_TRUE;
|
||||||
}
|
}
|
||||||
|
@@ -310,6 +310,15 @@ _mesa_test_texobj_completeness( const GLcontext *ctx,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check width/height/depth for zero */
|
||||||
|
if (t->Image[baseLevel]->Width == 0 ||
|
||||||
|
t->Image[baseLevel]->Height == 0 ||
|
||||||
|
t->Image[baseLevel]->Depth == 0) {
|
||||||
|
incomplete(t, "texture width = 0");
|
||||||
|
t->Complete = GL_FALSE;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Compute _MaxLevel */
|
/* Compute _MaxLevel */
|
||||||
if (t->Target == GL_TEXTURE_1D) {
|
if (t->Target == GL_TEXTURE_1D) {
|
||||||
maxLog2 = t->Image[baseLevel]->WidthLog2;
|
maxLog2 = t->Image[baseLevel]->WidthLog2;
|
||||||
@@ -559,7 +568,6 @@ _mesa_test_texobj_completeness( const GLcontext *ctx,
|
|||||||
}
|
}
|
||||||
else if (t->Target == GL_TEXTURE_RECTANGLE_NV) {
|
else if (t->Target == GL_TEXTURE_RECTANGLE_NV) {
|
||||||
/* XXX special checking? */
|
/* XXX special checking? */
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* Target = ??? */
|
/* Target = ??? */
|
||||||
|
@@ -2716,6 +2716,7 @@ update_texture_state( GLcontext *ctx )
|
|||||||
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
|
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
|
||||||
GLuint enableBits;
|
GLuint enableBits;
|
||||||
|
|
||||||
|
texUnit->_Current = NULL;
|
||||||
texUnit->_ReallyEnabled = 0;
|
texUnit->_ReallyEnabled = 0;
|
||||||
texUnit->_GenFlags = 0;
|
texUnit->_GenFlags = 0;
|
||||||
|
|
||||||
@@ -2789,8 +2790,7 @@ update_texture_state( GLcontext *ctx )
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!texUnit->_ReallyEnabled) {
|
if (!texUnit->_ReallyEnabled) {
|
||||||
texUnit->_Current = NULL;
|
continue;
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (texUnit->_ReallyEnabled)
|
if (texUnit->_ReallyEnabled)
|
||||||
|
@@ -195,9 +195,9 @@ transfer_teximage(GLcontext *ctx, GLuint dimensions,
|
|||||||
texDestFormat == GL_COLOR_INDEX ||
|
texDestFormat == GL_COLOR_INDEX ||
|
||||||
texDestFormat == GL_DEPTH_COMPONENT);
|
texDestFormat == GL_DEPTH_COMPONENT);
|
||||||
ASSERT(texDestAddr);
|
ASSERT(texDestAddr);
|
||||||
ASSERT(srcWidth >= 1);
|
ASSERT(srcWidth >= 0);
|
||||||
ASSERT(srcHeight >= 1);
|
ASSERT(srcHeight >= 0);
|
||||||
ASSERT(srcDepth >= 1);
|
ASSERT(srcDepth >= 0);
|
||||||
ASSERT(dstXoffset >= 0);
|
ASSERT(dstXoffset >= 0);
|
||||||
ASSERT(dstYoffset >= 0);
|
ASSERT(dstYoffset >= 0);
|
||||||
ASSERT(dstZoffset >= 0);
|
ASSERT(dstZoffset >= 0);
|
||||||
|
Reference in New Issue
Block a user