On 02/16/2012 11:38 AM, Anuj Phogat wrote:
As suggested by Brian, for a 1D texture array, the border only applies to
the width. For a 2D texture array the border applies to the width and
height but not the depth. This was not handled correctly in
_mesa_init_teximage_fields().
Note: This is a candidate for stable branches
Signed-off-by: Anuj Phogat<anuj.pho...@gmail.com>
---
updated patch as per Brian's comments
src/mesa/main/teximage.c | 14 ++++++++++++--
1 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index e4eb7f6..6a24e9d 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -1083,11 +1083,13 @@ _mesa_init_teximage_fields(struct gl_context *ctx,
GLint border, GLenum internalFormat,
gl_format format)
{
+ GLenum target;
ASSERT(img);
ASSERT(width>= 0);
ASSERT(height>= 0);
ASSERT(depth>= 0);
+ target = img->TexObject->Target;
img->_BaseFormat = _mesa_base_tex_format( ctx, internalFormat );
ASSERT(img->_BaseFormat> 0);
img->InternalFormat = internalFormat;
@@ -1099,19 +1101,27 @@ _mesa_init_teximage_fields(struct gl_context *ctx,
img->Width2 = width - 2 * border; /* == 1<< img->WidthLog2; */
img->WidthLog2 = _mesa_logbase2(img->Width2);
- if (height == 1) { /* 1-D texture */
+ if (target == GL_TEXTURE_1D) {
or target == GL_TEXTURE_BUFFER
img->Height2 = 1;
img->HeightLog2 = 0;
}
+ else if(target == GL_TEXTURE_1D_ARRAY) {
+ img->Height2 = height; /* no border */
+ img->HeightLog2 = 0; /* not used */
+ }
else {
img->Height2 = height - 2 * border; /* == 1<< img->HeightLog2; */
img->HeightLog2 = _mesa_logbase2(img->Height2);
}
- if (depth == 1) { /* 2-D texture */
+ if (target == GL_TEXTURE_2D) {
img->Depth2 = 1;
img->DepthLog2 = 0;
}
+ else if (target == GL_TEXTURE_2D_ARRAY) {
+ img->Depth2 = depth; /* no border */
+ img->DepthLog2 = 0; /* not used */
+ }
else {
img->Depth2 = depth - 2 * border; /* == 1<< img->DepthLog2; */
img->DepthLog2 = _mesa_logbase2(img->Depth2);
This will set Depth2, etc incorrectly if the texture target is 1D,
1D_ARRAY, CUBE, etc.
I think you need to carefully consider all the possible texture
targets and how width/height/depth will be computed for each type.
It might wind up being cleanest to have a switch(target) which sets
both the width and height values for each possible texture type.
Or maybe just leave the "if (height==1)" and "if (depth==1)" tests
as-is. I'd have to take a few minutes to think that through.
-Brian
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev