-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I'm trying to get the patches attached to bug #2996 update. As part of
that, I'm generating some smaller, more trivial patchs to commit to the
tree /before/ RC1. I committed one really trivial one last night (the
EvalComputeK stuff). This one is a little bit bigger, so I'd appreciate
some review before I commit it.
Basically, this refactors __glXImageSize and __glXImage3DSize into a
single function. It replaces all calls to the old functions with calls
to __glXImageSize with the new parameter list.
I have also added 'target' as a parameter. This is a stepping stone to
the code in patch #2410. Basically, if the texture target is one of
GL_PROXY_*, the image size is always zero. This gathers all the checks
for that into a single place. I have *not* modified the existing
callers to take this into account. They still do their own checks for
GL_PROXY_*. However, when the generated versions of those functions are
added to the tree, they *will* rely on that.
The code growth is mainly due to the new 40 line comment before
__glXImageSize.
I have tested this with a few of the texture using demos and tests from
Mesa, including tunnel and texdown.
88be9d7346fffb7dbbb80fb6208ca6be glXImageSize-01.patch
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
iD8DBQFDOx2BX1gOwKyEAw8RAr4PAJ9R30UsO9+exxLqycJ6IEXjv1hokACfYaHt
f3EK8/O3EA+DXFBKyhlhOg0=
=3P/L
-----END PGP SIGNATURE-----
Index: glxserver.h
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/GL/glx/glxserver.h,v
retrieving revision 1.4
diff -u -d -r1.4 glxserver.h
--- glxserver.h 3 Jul 2005 07:01:02 -0000 1.4
+++ glxserver.h 28 Sep 2005 20:07:17 -0000
@@ -225,13 +225,10 @@
*/
extern int __glXTypeSize(GLenum enm);
-extern int __glXImageSize(GLenum format, GLenum type, GLsizei w, GLsizei h,
- GLint rowLength, GLint skipRows, GLint alignment);
-extern int __glXImage3DSize(GLenum format, GLenum type,
- GLsizei w, GLsizei h, GLsizei d,
- GLint imageHeight, GLint rowLength,
- GLint skipImages, GLint skipRows,
- GLint alignment);
+extern int __glXImageSize(GLenum format, GLenum type,
+ GLenum target, GLsizei w, GLsizei h, GLsizei d,
+ GLint imageHeight, GLint rowLength, GLint skipImages, GLint skipRows,
+ GLint alignment);
extern int __glXCallListsReqSize(GLbyte *pc, Bool swap);
extern int __glXBitmapReqSize(GLbyte *pc, Bool swap);
Index: renderpix.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/GL/glx/renderpix.c,v
retrieving revision 1.3
diff -u -d -r1.3 renderpix.c
--- renderpix.c 3 Jul 2005 07:01:02 -0000 1.3
+++ renderpix.c 28 Sep 2005 20:07:17 -0000
@@ -301,8 +301,9 @@
/* XXX check this usage - internal code called
** a version without the packing parameters
*/
- image1len = __glXImageSize(hdr->format, hdr->type, hdr->width, 1,
- hdr->rowLength, hdr->skipRows, hdr->alignment);
+ image1len = __glXImageSize(hdr->format, hdr->type, 0, hdr->width, 1, 1,
+ 0, hdr->rowLength, 0, hdr->skipRows,
+ hdr->alignment);
image1len = __GLX_PAD(image1len);
glSeparableFilter2D(hdr->target, hdr->internalformat,
Index: renderpixswap.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/GL/glx/renderpixswap.c,v
retrieving revision 1.3
diff -u -d -r1.3 renderpixswap.c
--- renderpixswap.c 3 Jul 2005 07:01:02 -0000 1.3
+++ renderpixswap.c 28 Sep 2005 20:07:17 -0000
@@ -543,8 +543,9 @@
/* XXX check this usage - internal code called
** a version without the packing parameters
*/
- image1len = __glXImageSize(hdr->format, hdr->type, hdr->width, 1,
- hdr->rowLength, hdr->skipRows, hdr->alignment);
+ image1len = __glXImageSize(hdr->format, hdr->type, 0, hdr->width, 1, 1,
+ 0, hdr->rowLength, 0, hdr->skipRows,
+ hdr->alignment);
image1len = __GLX_PAD(image1len);
Index: rensize.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/GL/glx/rensize.c,v
retrieving revision 1.7
diff -u -d -r1.7 rensize.c
--- rensize.c 28 Sep 2005 03:37:22 -0000 1.7
+++ rensize.c 28 Sep 2005 20:07:17 -0000
@@ -268,19 +268,49 @@
return 2 * mapsize;
}
-int __glXImageSize( GLenum format, GLenum type, GLsizei w, GLsizei h,
- GLint rowLength, GLint skipRows, GLint alignment )
-{
- return __glXImage3DSize( format, type, w, h, 1, 0, rowLength,
- 0, skipRows, alignment );
-}
-
-/* XXX
- * This should be folded into __glXImageSize().
+/**
+ * Calculate the size of an image.
+ *
+ * The size of an image sent to the server from the client or sent from the
+ * server to the client is calculated. The size is based on the dimensions
+ * of the image, the type of pixel data, padding in the image, and the
+ * alignment requirements of the image.
+ *
+ * \param format Format of the pixels. Same as the \c format parameter
+ * to \c glTexImage1D
+ * \param type Type of the pixel data. Same as the \c type parameter
+ * to \c glTexImage1D
+ * \param target Typically the texture target of the image. If the
+ * target is one of \c GL_PROXY_*, the size returned is
+ * always zero. For uses that do not have a texture target
+ * (e.g, glDrawPixels), zero should be specified.
+ * \param w Width of the image data. Must be >= 1.
+ * \param h Height of the image data. Must be >= 1, even for 1D
+ * images.
+ * \param d Depth of the image data. Must be >= 1, even for 1D or
+ * 2D images.
+ * \param imageHeight If non-zero, defines the true height of a volumetric
+ * image. This value will be used instead of \c h for
+ * calculating the size of the image.
+ * \param rowLength If non-zero, defines the true width of an image. This
+ * value will be used instead of \c w for calculating the
+ * size of the image.
+ * \param skipImages Number of extra layers of image data in a volumtric
+ * image that are to be skipped before the real data.
+ * \param skipRows Number of extra rows of image data in an image that are
+ * to be skipped before the real data.
+ * \param alignment Specifies the alignment for the start of each pixel row
+ * in memory. This value must be one of 1, 2, 4, or 8.
+ *
+ * \returns
+ * The size of the image is returned. If the specified \c format and \c type
+ * are invalid, -1 is returned. If \c target is one of \c GL_PROXY_*, zero
+ * is returned.
*/
-int __glXImage3DSize( GLenum format, GLenum type, GLsizei w, GLsizei h,
- GLsizei d, GLint imageHeight, GLint rowLength,
- GLint skipImages, GLint skipRows, GLint alignment )
+int __glXImageSize( GLenum format, GLenum type, GLenum target,
+ GLsizei w, GLsizei h, GLsizei d,
+ GLint imageHeight, GLint rowLength,
+ GLint skipImages, GLint skipRows, GLint alignment )
{
GLint bytesPerElement, elementsPerGroup, groupsPerRow;
GLint groupSize, rowSize, padding, imageSize;
@@ -292,6 +322,22 @@
}
if (w==0 || h==0 || d == 0) return 0;
+ switch( target ) {
+ case GL_PROXY_TEXTURE_1D:
+ case GL_PROXY_TEXTURE_2D:
+ case GL_PROXY_TEXTURE_3D:
+ case GL_PROXY_TEXTURE_4D_SGIS:
+ case GL_PROXY_TEXTURE_CUBE_MAP:
+ case GL_PROXY_TEXTURE_RECTANGLE_ARB:
+ case GL_PROXY_HISTOGRAM:
+ case GL_PROXY_COLOR_TABLE:
+ case GL_PROXY_TEXTURE_COLOR_TABLE_SGI:
+ case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE:
+ case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE:
+ case GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP:
+ return 0;
+ }
+
if (type == GL_BITMAP) {
if (rowLength > 0) {
groupsPerRow = rowLength;
@@ -425,7 +471,8 @@
skipRows = SWAPL( skipRows );
alignment = SWAPL( alignment );
}
- return __glXImageSize( format, type, w, h, rowLength, skipRows, alignment );
+ return __glXImageSize( format, type, 0, w, h, 1,
+ 0, rowLength, 0, skipRows, alignment );
}
int __glXBitmapReqSize(GLbyte *pc, Bool swap )
@@ -444,8 +491,8 @@
skipRows = SWAPL( skipRows );
alignment = SWAPL( alignment );
}
- return __glXImageSize( GL_COLOR_INDEX, GL_BITMAP, w, h,
- rowLength, skipRows, alignment );
+ return __glXImageSize( GL_COLOR_INDEX, GL_BITMAP, 0, w, h, 1,
+ 0, rowLength, 0, skipRows, alignment );
}
int __glXTexImage1DReqSize(GLbyte *pc, Bool swap )
@@ -473,7 +520,8 @@
} else if (format == GL_STENCIL_INDEX || format == GL_DEPTH_COMPONENT) {
return -1;
}
- return __glXImageSize( format, type, w, 1, rowLength, skipRows, alignment );
+ return __glXImageSize( format, type, 0, w, 1, 1,
+ 0, rowLength, 0, skipRows, alignment );
}
int __glXTexImage2DReqSize(GLbyte *pc, Bool swap )
@@ -503,7 +551,8 @@
} else if (format == GL_STENCIL_INDEX || format == GL_DEPTH_COMPONENT) {
return -1;
}
- return __glXImageSize( format, type, w, h, rowLength, skipRows, alignment );
+ return __glXImageSize( format, type, 0, w, h, 1,
+ 0, rowLength, 0, skipRows, alignment );
}
/* XXX this is used elsewhere - should it be exported from glxserver.h? */
@@ -614,7 +663,8 @@
skipRows = SWAPL( skipRows );
alignment = SWAPL( alignment );
}
- return __glXImageSize( format, type, w, 1, rowLength, skipRows, alignment );
+ return __glXImageSize( format, type, 0, w, 1, 1,
+ 0, rowLength, 0, skipRows, alignment );
}
int __glXTexSubImage2DReqSize(GLbyte *pc, Bool swap )
@@ -637,7 +687,8 @@
skipRows = SWAPL( skipRows );
alignment = SWAPL( alignment );
}
- return __glXImageSize( format, type, w, h, rowLength, skipRows, alignment );
+ return __glXImageSize( format, type, 0, w, h, 1,
+ 0, rowLength, 0, skipRows, alignment );
}
int __glXTexImage3DReqSize(GLbyte *pc, Bool swap )
@@ -672,9 +723,8 @@
if (target == GL_PROXY_TEXTURE_3D || nullImage) {
return 0;
} else {
- return __glXImage3DSize( format, type, w, h, d, imageHeight,
- rowLength, skipImages, skipRows,
- alignment);
+ return __glXImageSize( format, type, target, w, h, d, imageHeight,
+ rowLength, skipImages, skipRows, alignment );
}
}
@@ -710,9 +760,8 @@
if (target == GL_PROXY_TEXTURE_3D) {
return 0;
} else {
- return __glXImage3DSize( format, type, w, h, d, imageHeight,
- rowLength, skipImages, skipRows,
- alignment);
+ return __glXImageSize( format, type, target, w, h, d, imageHeight,
+ rowLength, skipImages, skipRows, alignment );
}
}
@@ -735,7 +784,8 @@
alignment = SWAPL( alignment );
}
- return __glXImageSize ( format, type, w, 1, rowLength, 0, alignment );
+ return __glXImageSize( format, type, 0, w, 1, 1,
+ 0, rowLength, 0, 0, alignment );
}
int __glXConvolutionFilter2DReqSize(GLbyte *pc, Bool swap )
@@ -761,7 +811,8 @@
alignment = SWAPL( alignment );
}
- return __glXImageSize ( format, type, w, h, rowLength, skipRows, alignment );
+ return __glXImageSize( format, type, 0, w, h, 1,
+ 0, rowLength, 0, skipRows, alignment );
}
int __glXConvolutionParameterivSize(GLenum pname)
@@ -820,9 +871,11 @@
}
/* XXX Should rowLength be used for either or both image? */
- image1size = __glXImageSize ( format, type, w, 1, rowLength, 0, alignment );
+ image1size = __glXImageSize( format, type, 0, w, 1, 1,
+ 0, rowLength, 0, 0, alignment );
image1size = __GLX_PAD(image1size);
- image2size = __glXImageSize ( format, type, h, 1, rowLength, 0, alignment );
+ image2size = __glXImageSize( format, type, 0, h, 1, 1,
+ 0, rowLength, 0, 0, alignment );
return image1size + image2size;
}
@@ -876,7 +929,8 @@
alignment = SWAPL( alignment );
}
- return __glXImageSize ( format, type, w, 1, rowLength, 0, alignment );
+ return __glXImageSize( format, type, 0, w, 1, 1,
+ 0, rowLength, 0, 0, alignment );
}
int __glXColorSubTableReqSize(GLbyte *pc, Bool swap )
@@ -898,7 +952,8 @@
alignment = SWAPL( alignment );
}
- return __glXImageSize ( format, type, count, 1, rowLength, 0, alignment );
+ return __glXImageSize( format, type, 0, count, 1, 1,
+ 0, rowLength, 0, 0, alignment );
}
int __glXColorTableParameterfvReqSize(GLbyte *pc, Bool swap )
Index: singlesize.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/GL/glx/singlesize.c,v
retrieving revision 1.6
diff -u -d -r1.6 singlesize.c
--- singlesize.c 28 Sep 2005 03:37:22 -0000 1.6
+++ singlesize.c 28 Sep 2005 20:07:18 -0000
@@ -51,7 +51,7 @@
GLint __glReadPixels_size(GLenum format, GLenum type, GLint w, GLint h)
{
- return __glXImage3DSize( format, type, w, h, 1, 0, 0, 0, 0, 4 );
+ return __glXImageSize( format, type, 0, w, h, 1, 0, 0, 0, 0, 4 );
}
/**
@@ -1127,8 +1127,8 @@
GLint __glGetTexImage_size(GLenum target, GLint level, GLenum format,
GLenum type, GLint width, GLint height, GLint depth)
{
- return __glXImage3DSize( format, type, width, height, depth,
- 0, 0, 0, 0, 4 );
+ return __glXImageSize( format, type, target, width, height, depth,
+ 0, 0, 0, 0, 4 );
}
GLint __glGetConvolutionParameteriv_size(GLenum pname)