and ignored for 1D and 2D images.
Need to pass in image dimensions (1,2,3) to the _mesa_image_address() function.
This change gets propogated to some other routines.
Also added new _mesa_image_address[123]d() convenience functions.
*/
for (row=0; row<height; row++) {
const GLubyte *src = (const GLubyte *)
- _mesa_image_address( unpack, bitmap, width, height,
- GL_COLOR_INDEX, GL_BITMAP, 0, row, 0 );
+ _mesa_image_address2d(unpack, bitmap, width, height,
+ GL_COLOR_INDEX, GL_BITMAP, row, 0 );
if (unpack->LsbFirst) {
/* Lsb first */
if (ctx->_RotateMode) {
for (col=0; col<width; col++) {
const GLubyte *src = (const GLubyte *)
- _mesa_image_address( unpack, bitmap, height, width,
- GL_COLOR_INDEX, GL_BITMAP, 0, col, 0 );
+ _mesa_image_address2d(unpack, bitmap, height, width,
+ GL_COLOR_INDEX, GL_BITMAP, col, 0 );
/* Msb first */
GLubyte mask = 128U >> (unpack->SkipPixels & 0x7);
else {
for (row=0; row<height; row++) {
const GLubyte *src = (const GLubyte *)
- _mesa_image_address( unpack, bitmap, width, height,
- GL_COLOR_INDEX, GL_BITMAP, 0, row, 0 );
+ _mesa_image_address2d(unpack, bitmap, width, height,
+ GL_COLOR_INDEX, GL_BITMAP, row, 0 );
/* Msb first */
GLubyte mask = 128U >> (unpack->SkipPixels & 0x7);
for (row = 0; row < height; row++) {
const GLubyte *src =
- (const GLubyte *) _mesa_image_address(finalUnpack,
- bitmap, width, height,
- GL_COLOR_INDEX,
- GL_BITMAP, 0, row, 0);
+ (const GLubyte *) _mesa_image_address2d(finalUnpack,
+ bitmap, width, height,
+ GL_COLOR_INDEX,
+ GL_BITMAP, row, 0);
if (finalUnpack->LsbFirst) {
/* least significan bit first */
GLubyte mask = 1U << (finalUnpack->SkipPixels & 0x7);
/* compute dest address of bottom-left pixel in bitmap */
for (row = 0; row < height; row++) {
const GLubyte *src =
- (const GLubyte *) _mesa_image_address(finalUnpack,
- bitmap, width, height,
- GL_COLOR_INDEX,
- GL_BITMAP, 0, row, 0);
+ (const GLubyte *) _mesa_image_address2d(finalUnpack,
+ bitmap, width, height,
+ GL_COLOR_INDEX,
+ GL_BITMAP, row, 0);
if (finalUnpack->LsbFirst) {
/* least significan bit first */
GLubyte mask = 1U << (finalUnpack->SkipPixels & 0x7);
GL_FRONT) ? (fxMesa->screen_width) : (info.strideInBytes / 2);
const GLushort *src = (const GLushort *) info.lfbPtr
+ scrY * srcStride + scrX;
- GLubyte *dst = (GLubyte *) _mesa_image_address(packing,
- dstImage, width, height, format, type, 0, 0, 0);
+ GLubyte *dst = (GLubyte *) _mesa_image_address2d(packing,
+ dstImage, width, height, format, type, 0, 0);
const GLint dstStride = _mesa_image_row_stride(packing,
width, format, type);
+ scrY * srcStride + scrX;
const GLint dstStride =
_mesa_image_row_stride(packing, width, format, type);
- GLubyte *dst = (GLubyte *) _mesa_image_address(packing,
- dstImage, width, height, format, type, 0, 0, 0);
+ GLubyte *dst = (GLubyte *) _mesa_image_address2d(packing,
+ dstImage, width, height, format, type, 0, 0);
const GLint widthInBytes = width * 4;
{
+ scrY * dstStride + scrX * 4;
const GLint srcStride =
_mesa_image_row_stride(unpack, width, format, type);
- const GLubyte *src = (GLubyte *) _mesa_image_address(unpack,
- pixels, width, height, format, type, 0, 0, 0);
+ const GLubyte *src = (GLubyte *) _mesa_image_address2d(unpack,
+ pixels, width, height, format, type, 0, 0);
const GLint widthInBytes = width * 4;
if ((format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8) ||
for (row = 0; row < height; row++) {
const GLubyte *src =
- (const GLubyte *) _mesa_image_address(finalUnpack,
- bitmap, width, height,
- GL_COLOR_INDEX, GL_BITMAP,
- 0, row, 0);
+ (const GLubyte *) _mesa_image_address2d(finalUnpack,
+ bitmap, width, height,
+ GL_COLOR_INDEX, GL_BITMAP,
+ row, 0);
if (finalUnpack->LsbFirst) {
/* least significan bit first */
GLubyte mask = 1U << (finalUnpack->SkipPixels & 0x7);
for (row = 0; row < height; row++) {
const GLubyte *src =
- (const GLubyte *) _mesa_image_address(finalUnpack,
- bitmap, width, height,
- GL_COLOR_INDEX, GL_BITMAP,
- 0, row, 0);
+ (const GLubyte *) _mesa_image_address2d(finalUnpack,
+ bitmap, width, height,
+ GL_COLOR_INDEX, GL_BITMAP,
+ row, 0);
if (finalUnpack->LsbFirst) {
/* least significan bit first */
GLubyte mask = 1U << (finalUnpack->SkipPixels & 0x7);
const GLint srcStride = info.strideInBytes / 2; /* stride in GLushorts */
const GLushort *src = (const GLushort *) info.lfbPtr
+ (winY - y) * srcStride + (winX + x);
- GLubyte *dst = (GLubyte *) _mesa_image_address(packing, dstImage,
+ GLubyte *dst = (GLubyte *) _mesa_image_address2d(packing, dstImage,
width, height, format,
- type, 0, 0, 0);
+ type, 0, 0);
GLint dstStride =
_mesa_image_row_stride(packing, width, format, type);
const GLint srcStride = info.strideInBytes / 2; /* stride in GLushorts */
const GLushort *src = (const GLushort *) info.lfbPtr
+ (winY - y) * srcStride + (winX + x);
- GLubyte *dst = (GLubyte *) _mesa_image_address(packing, dstImage,
+ GLubyte *dst = (GLubyte *) _mesa_image_address2d(packing, dstImage,
width, height, format,
- type, 0, 0, 0);
+ type, 0, 0);
GLint dstStride =
_mesa_image_row_stride(packing, width, format, type);
const GLint srcStride = info.strideInBytes / 4; /* stride in GLuints */
const GLuint *src = (const GLuint *) info.lfbPtr
+ (winY - y) * srcStride + (winX + x);
- GLubyte *dst = (GLubyte *) _mesa_image_address(packing, dstImage,
+ GLubyte *dst = (GLubyte *) _mesa_image_address2d(packing, dstImage,
width, height, format,
- type, 0, 0, 0);
+ type, 0, 0);
GLint dstStride =
_mesa_image_row_stride(packing, width, format, type);
if (format == GL_RGBA && type == GL_UNSIGNED_BYTE) {
GLint row;
for (row = 0; row < height; row++) {
- GLubyte *src = (GLubyte *) _mesa_image_address(finalUnpack, pixels,
- width, height, format,
- type, 0, row, 0);
+ GLubyte *src = (GLubyte *) _mesa_image_address2d(finalUnpack,
+ pixels, width, height, format, type, row, 0);
GLint col;
for (col = 0; col < width; col++) {
dst[col] = TDFXPACKCOLOR1555(src[2], src[1], src[0], src[3]);
else if (format == GL_RGB && type == GL_UNSIGNED_BYTE) {
GLint row;
for (row = 0; row < height; row++) {
- GLubyte *src = (GLubyte *) _mesa_image_address(finalUnpack, pixels,
- width, height, format,
- type, 0, row, 0);
+ GLubyte *src = (GLubyte *) _mesa_image_address2d(finalUnpack,
+ pixels, width, height, format, type, row, 0);
GLint col;
for (col = 0; col < width; col++) {
dst[col] = TDFXPACKCOLOR1555(src[2], src[1], src[0], 255);
if (format == GL_RGBA && type == GL_UNSIGNED_BYTE) {
GLint row;
for (row = 0; row < height; row++) {
- GLubyte *src = (GLubyte *) _mesa_image_address(finalUnpack, pixels,
- width, height, format,
- type, 0, row, 0);
+ GLubyte *src = (GLubyte *) _mesa_image_address2d(finalUnpack,
+ pixels, width, height, format, type, row, 0);
GLint col;
for (col = 0; col < width; col++) {
dst[col] = TDFXPACKCOLOR565(src[2], src[1], src[0]);
else if (format == GL_RGB && type == GL_UNSIGNED_BYTE) {
GLint row;
for (row = 0; row < height; row++) {
- GLubyte *src = (GLubyte *) _mesa_image_address(finalUnpack, pixels,
- width, height, format,
- type, 0, row, 0);
+ GLubyte *src = (GLubyte *) _mesa_image_address2d(finalUnpack,
+ pixels, width, height, format, type, row, 0);
GLint col;
for (col = 0; col < width; col++) {
dst[col] = TDFXPACKCOLOR565(src[2], src[1], src[0]);
if (format == GL_RGBA && type == GL_UNSIGNED_BYTE) {
GLint row;
for (row = 0; row < height; row++) {
- GLubyte *src = (GLubyte *) _mesa_image_address(finalUnpack, pixels,
- width, height, format,
- type, 0, row, 0);
+ GLubyte *src = (GLubyte *) _mesa_image_address2d(finalUnpack,
+ pixels, width, height, format, type, row, 0);
GLint col;
for (col = 0; col < width; col++) {
dst[col] = TDFXPACKCOLOR565(src[0], src[1], src[2]);
else if (format == GL_RGB && type == GL_UNSIGNED_BYTE) {
GLint row;
for (row = 0; row < height; row++) {
- GLubyte *src = (GLubyte *) _mesa_image_address(finalUnpack, pixels,
- width, height, format,
- type, 0, row, 0);
+ GLubyte *src = (GLubyte *) _mesa_image_address2d(finalUnpack,
+ pixels, width, height, format, type, row, 0);
GLint col;
for (col = 0; col < width; col++) {
dst[col] = TDFXPACKCOLOR565(src[0], src[1], src[2]);
const GLint widthInBytes = width * 4;
GLint row;
for (row = 0; row < height; row++) {
- GLubyte *src = (GLubyte *) _mesa_image_address(finalUnpack, pixels,
- width, height, format,
- type, 0, row, 0);
+ GLubyte *src = (GLubyte *) _mesa_image_address2d(finalUnpack,
+ pixels, width, height, format, type, row, 0);
MEMCPY(dst, src, widthInBytes);
dst += dstStride;
}
else if (format == GL_RGB && type == GL_UNSIGNED_BYTE) {
GLint row;
for (row = 0; row < height; row++) {
- GLubyte *src = (GLubyte *) _mesa_image_address(finalUnpack, pixels,
- width, height, format,
- type, 0, row, 0);
+ GLubyte *src = (GLubyte *) _mesa_image_address2d(finalUnpack,
+ pixels, width, height, format, type, 0, row, 0);
GLint col;
for (col = 0; col < width; col++) {
dst[col] = TDFXPACKCOLOR8888(src[2], src[1], src[0], 255);
if (unpack->BufferObj->Name) {
/* unpack from PBO */
GLubyte *buf;
- if (!_mesa_validate_pbo_access(unpack, width, height, 1,
+ if (!_mesa_validate_pbo_access(2, unpack, width, height, 1,
format, type, pixels)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glDrawPixels(invalid PBO access)");
if (unpack->BufferObj->Name) {
/* unpack from PBO */
GLubyte *buf;
- if (!_mesa_validate_pbo_access(unpack, width, height, 1,
+ if (!_mesa_validate_pbo_access(2, unpack, width, height, 1,
format, type, pixels)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glDrawPixels(invalid PBO access)");
* go out of bounds.
*/
GLboolean
-_mesa_validate_pbo_access(const struct gl_pixelstore_attrib *pack,
+_mesa_validate_pbo_access(GLuint dimensions,
+ const struct gl_pixelstore_attrib *pack,
GLsizei width, GLsizei height, GLsizei depth,
GLenum format, GLenum type, const GLvoid *ptr)
{
return GL_FALSE;
/* get address of first pixel we'll read */
- start = _mesa_image_address(pack, ptr, width, height,
+ start = _mesa_image_address(dimensions, pack, ptr, width, height,
format, type, 0, 0, 0);
/* get address just past the last pixel we'll read */
- end = _mesa_image_address(pack, ptr, width, height,
+ end = _mesa_image_address(dimensions, pack, ptr, width, height,
format, type, depth-1, height-1, width);
struct gl_buffer_object * bufObj );
extern GLboolean
-_mesa_validate_pbo_access(const struct gl_pixelstore_attrib *pack,
+_mesa_validate_pbo_access(GLuint dimensions,
+ const struct gl_pixelstore_attrib *pack,
GLsizei width, GLsizei height, GLsizei depth,
GLenum format, GLenum type, const GLvoid *ptr);
if (ctx->Unpack.BufferObj->Name) {
/* Get/unpack the color table data from a PBO */
GLubyte *buf;
- if (!_mesa_validate_pbo_access(&ctx->Unpack, count, 1, 1,
+ if (!_mesa_validate_pbo_access(1, &ctx->Unpack, count, 1, 1,
format, type, data)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glColor[Sub]Table(bad PBO access)");
if (ctx->Pack.BufferObj->Name) {
/* pack color table into PBO */
GLubyte *buf;
- if (!_mesa_validate_pbo_access(&ctx->Pack, table->Size, 1, 1,
+ if (!_mesa_validate_pbo_access(1, &ctx->Pack, table->Size, 1, 1,
format, type, data)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glGetColorTable(invalid PBO access)");
if (ctx->Unpack.BufferObj->Name) {
/* unpack filter from PBO */
GLubyte *buf;
- if (!_mesa_validate_pbo_access(&ctx->Unpack, width, 1, 1,
+ if (!_mesa_validate_pbo_access(1, &ctx->Unpack, width, 1, 1,
format, type, image)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glConvolutionFilter1D(invalid PBO access)");
if (ctx->Unpack.BufferObj->Name) {
/* unpack filter from PBO */
GLubyte *buf;
- if (!_mesa_validate_pbo_access(&ctx->Unpack, width, height, 1,
+ if (!_mesa_validate_pbo_access(2, &ctx->Unpack, width, height, 1,
format, type, image)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glConvolutionFilter2D(invalid PBO access)");
/* Unpack filter image. We always store filters in RGBA format. */
for (i = 0; i < height; i++) {
- const GLvoid *src = _mesa_image_address(&ctx->Unpack, image, width,
- height, format, type, 0, i, 0);
+ const GLvoid *src = _mesa_image_address2d(&ctx->Unpack, image, width,
+ height, format, type, i, 0);
GLfloat *dst = ctx->Convolution2D.Filter + i * width * 4;
_mesa_unpack_color_span_float(ctx, width, GL_RGBA, dst,
format, type, src, &ctx->Unpack,
if (ctx->Pack.BufferObj->Name) {
/* Pack the filter into a PBO */
GLubyte *buf;
- if (!_mesa_validate_pbo_access(&ctx->Pack, filter->Width, filter->Height,
+ if (!_mesa_validate_pbo_access(2, &ctx->Pack,
+ filter->Width, filter->Height,
1, format, type, image)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glGetConvolutionFilter(invalid PBO access)");
}
for (row = 0; row < filter->Height; row++) {
- GLvoid *dst = _mesa_image_address( &ctx->Pack, image, filter->Width,
- filter->Height, format, type,
- 0, row, 0);
+ GLvoid *dst = _mesa_image_address2d(&ctx->Pack, image, filter->Width,
+ filter->Height, format, type,
+ row, 0);
const GLfloat *src = filter->Filter + row * filter->Width * 4;
_mesa_pack_rgba_span_float(ctx, filter->Width,
(const GLfloat (*)[4]) src,
if (ctx->Pack.BufferObj->Name) {
/* Pack filter into PBO */
GLubyte *buf;
- if (!_mesa_validate_pbo_access(&ctx->Pack, filter->Width, 1, 1,
+ if (!_mesa_validate_pbo_access(1, &ctx->Pack, filter->Width, 1, 1,
format, type, row)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glGetSeparableFilter(invalid PBO access, width)");
return;
}
- if (!_mesa_validate_pbo_access(&ctx->Pack, filter->Height, 1, 1,
+ if (!_mesa_validate_pbo_access(1, &ctx->Pack, filter->Height, 1, 1,
format, type, column)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glGetSeparableFilter(invalid PBO access, height)");
/* Row filter */
if (row) {
- GLvoid *dst = _mesa_image_address( &ctx->Pack, row, filter->Width,
- filter->Height, format, type,
- 0, 0, 0);
+ GLvoid *dst = _mesa_image_address1d(&ctx->Pack, row, filter->Width,
+ format, type, 0);
_mesa_pack_rgba_span_float(ctx, filter->Width,
(const GLfloat (*)[4]) filter->Filter,
format, type, dst, &ctx->Pack, 0);
/* Column filter */
if (column) {
- GLvoid *dst = _mesa_image_address( &ctx->Pack, column, filter->Width,
- 1, format, type,
- 0, 0, 0);
+ GLvoid *dst = _mesa_image_address1d(&ctx->Pack, column, filter->Height,
+ format, type, 0);
const GLfloat *src = filter->Filter + colStart;
_mesa_pack_rgba_span_float(ctx, filter->Height,
(const GLfloat (*)[4]) src,
if (ctx->Unpack.BufferObj->Name) {
/* unpack filter from PBO */
GLubyte *buf;
- if (!_mesa_validate_pbo_access(&ctx->Unpack, width, 1, 1,
+ if (!_mesa_validate_pbo_access(1, &ctx->Unpack, width, 1, 1,
format, type, row)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glSeparableFilter2D(invalid PBO access, width)");
return;
}
- if (!_mesa_validate_pbo_access(&ctx->Unpack, height, 1, 1,
+ if (!_mesa_validate_pbo_access(1, &ctx->Unpack, height, 1, 1,
format, type, column)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glSeparableFilter2D(invalid PBO access, height)");
* \todo This won't suffice when the PBO is really in VRAM/GPU memory.
*/
static GLvoid *
-unpack_image( GLsizei width, GLsizei height, GLsizei depth,
+unpack_image( GLuint dimensions, GLsizei width, GLsizei height, GLsizei depth,
GLenum format, GLenum type, const GLvoid *pixels,
const struct gl_pixelstore_attrib *unpack )
{
if (unpack->BufferObj->Name == 0) {
/* no PBO */
- return _mesa_unpack_image(width, height, depth, format, type,
+ return _mesa_unpack_image(dimensions, width, height, depth, format, type,
pixels, unpack);
}
- else if (_mesa_validate_pbo_access(unpack, width, height, depth, format,
- type, pixels)) {
+ else if (_mesa_validate_pbo_access(dimensions, unpack, width, height, depth,
+ format, type, pixels)) {
const GLubyte *src = ADD_POINTERS(unpack->BufferObj->Data, pixels);
- return _mesa_unpack_image(width, height, depth, format, type,
+ return _mesa_unpack_image(dimensions, width, height, depth, format, type,
src, unpack);
}
/* bad access! */
format, type, table );
}
else {
- GLvoid *image = unpack_image(width, 1, 1, format, type, table,
+ GLvoid *image = unpack_image(1, width, 1, 1, format, type, table,
&ctx->Unpack);
Node *n;
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
const GLvoid *table)
{
GET_CURRENT_CONTEXT(ctx);
- GLvoid *image = unpack_image(count, 1, 1, format, type, table,
+ GLvoid *image = unpack_image(1, count, 1, 1, format, type, table,
&ctx->Unpack);
Node *n;
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
GLenum format, GLenum type, const GLvoid *filter)
{
GET_CURRENT_CONTEXT(ctx);
- GLvoid *image = unpack_image(width, 1, 1, format, type, filter,
+ GLvoid *image = unpack_image(1, width, 1, 1, format, type, filter,
&ctx->Unpack);
Node *n;
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
GLenum type, const GLvoid *filter)
{
GET_CURRENT_CONTEXT(ctx);
- GLvoid *image = unpack_image(width, height, 1, format, type, filter,
+ GLvoid *image = unpack_image(2, width, height, 1, format, type, filter,
&ctx->Unpack);
Node *n;
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
const GLvoid *pixels )
{
GET_CURRENT_CONTEXT(ctx);
- GLvoid *image = unpack_image(width, height, 1, format, type,
+ GLvoid *image = unpack_image(2, width, height, 1, format, type,
pixels, &ctx->Unpack);
Node *n;
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
border, format, type, pixels );
}
else {
- GLvoid *image = unpack_image(width, 1, 1, format, type,
+ GLvoid *image = unpack_image(1, width, 1, 1, format, type,
pixels, &ctx->Unpack);
Node *n;
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
height, border, format, type, pixels );
}
else {
- GLvoid *image = unpack_image(width, height, 1, format, type,
+ GLvoid *image = unpack_image(2, width, height, 1, format, type,
pixels, &ctx->Unpack);
Node *n;
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
}
else {
Node *n;
- GLvoid *image = unpack_image(width, height, depth, format, type,
+ GLvoid *image = unpack_image(3, width, height, depth, format, type,
pixels, &ctx->Unpack);
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_IMAGE3D, 10 );
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- GLvoid *image = unpack_image(width, 1, 1, format, type,
+ GLvoid *image = unpack_image(1, width, 1, 1, format, type,
pixels, &ctx->Unpack);
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_SUB_IMAGE1D, 7 );
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- GLvoid *image = unpack_image(width, height, 1, format, type,
+ GLvoid *image = unpack_image(2, width, height, 1, format, type,
pixels, &ctx->Unpack);
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_SUB_IMAGE2D, 9 );
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- GLvoid *image = unpack_image(width, height, depth, format, type,
+ GLvoid *image = unpack_image(3, width, height, depth, format, type,
pixels, &ctx->Unpack);
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_SUB_IMAGE3D, 11 );
if (ctx->Pack.BufferObj->Name) {
/* pack min/max values into a PBO */
GLubyte *buf;
- if (!_mesa_validate_pbo_access(&ctx->Pack, 2, 1, 1,
+ if (!_mesa_validate_pbo_access(1, &ctx->Pack, 2, 1, 1,
format, type, values)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glGetMinMax(invalid PBO access)");
if (ctx->Pack.BufferObj->Name) {
/* pack min/max values into a PBO */
GLubyte *buf;
- if (!_mesa_validate_pbo_access(&ctx->Pack, ctx->Histogram.Width, 1, 1,
+ if (!_mesa_validate_pbo_access(1, &ctx->Pack, ctx->Histogram.Width, 1, 1,
format, type, values)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glGetHistogram(invalid PBO access)");
/**
- * Get the address of a pixel in an image (actually a volume).
+ * Return the address of a specific pixel in an image (1D, 2D or 3D).
*
* Pixel unpacking/packing parameters are observed according to \p packing.
*
- * \param image start of image data.
- * \param width image width.
- * \param height image height.
- * \param format pixel format.
- * \param type pixel data type.
- * \param packing the pixelstore attributes
- * \param img which image in the volume (0 for 1D or 2D images)
- * \param row of pixel in the image
- * \param column of pixel in the image
+ * \param dimensions either 1, 2 or 3 to indicate dimensionality of image
+ * \param image starting address of image data
+ * \param width the image width
+ * \param height theimage height
+ * \param format the pixel format
+ * \param type the pixel data type
+ * \param packing the pixelstore attributes
+ * \param img which image in the volume (0 for 1D or 2D images)
+ * \param row row of pixel in the image (0 for 1D images)
+ * \param column column of pixel in the image
*
* \return address of pixel on success, or NULL on error.
*
- * According to the \p packing information calculates the number of pixel/bytes
- * per row/image and refers it.
- *
* \sa gl_pixelstore_attrib.
*/
GLvoid *
-_mesa_image_address( const struct gl_pixelstore_attrib *packing,
- const GLvoid *image, GLsizei width,
- GLsizei height, GLenum format, GLenum type,
+_mesa_image_address( GLuint dimensions,
+ const struct gl_pixelstore_attrib *packing,
+ const GLvoid *image,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
GLint img, GLint row, GLint column )
{
GLint alignment; /* 1, 2 or 4 */
GLint skipimages; /* for 3-D volume images */
GLubyte *pixel_addr;
+ ASSERT(dimensions >= 1 && dimensions <= 3);
+
alignment = packing->Alignment;
if (packing->RowLength > 0) {
pixels_per_row = packing->RowLength;
else {
rows_per_image = height;
}
- skiprows = packing->SkipRows;
+
skippixels = packing->SkipPixels;
- skipimages = packing->SkipImages;
+ /* Note: SKIP_ROWS _is_ used for 1D images */
+ skiprows = packing->SkipRows;
+ /* Note: SKIP_IMAGES is only used for 3D images */
+ skipimages = (dimensions == 3) ? packing->SkipImages : 0;
if (type == GL_BITMAP) {
/* BITMAP data */
}
+GLvoid *
+_mesa_image_address1d( const struct gl_pixelstore_attrib *packing,
+ const GLvoid *image,
+ GLsizei width,
+ GLenum format, GLenum type,
+ GLint column )
+{
+ return _mesa_image_address(1, packing, image, width, 1,
+ format, type, 0, 0, column);
+}
+
+
+GLvoid *
+_mesa_image_address2d( const struct gl_pixelstore_attrib *packing,
+ const GLvoid *image,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ GLint row, GLint column )
+{
+ return _mesa_image_address(2, packing, image, width, height,
+ format, type, 0, row, column);
+}
+
+
+GLvoid *
+_mesa_image_address3d( const struct gl_pixelstore_attrib *packing,
+ const GLvoid *image,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ GLint img, GLint row, GLint column )
+{
+ return _mesa_image_address(3, packing, image, width, height,
+ format, type, img, row, column);
+}
+
+
+
/**
* Compute the stride between image rows.
*
dst = buffer;
for (row = 0; row < height; row++) {
const GLubyte *src = (const GLubyte *)
- _mesa_image_address(packing, pixels, width, height,
- GL_COLOR_INDEX, GL_BITMAP, 0, row, 0);
+ _mesa_image_address2d(packing, pixels, width, height,
+ GL_COLOR_INDEX, GL_BITMAP, row, 0);
if (!src) {
FREE(buffer);
return NULL;
width_in_bytes = CEILING( width, 8 );
src = source;
for (row = 0; row < height; row++) {
- GLubyte *dst = (GLubyte *) _mesa_image_address( packing, dest,
- width, height, GL_COLOR_INDEX, GL_BITMAP, 0, row, 0 );
+ GLubyte *dst = (GLubyte *) _mesa_image_address2d(packing, dest,
+ width, height, GL_COLOR_INDEX, GL_BITMAP, row, 0);
if (!dst)
return;
* need a copy of the data in a standard format.
*/
void *
-_mesa_unpack_image( GLsizei width, GLsizei height, GLsizei depth,
+_mesa_unpack_image( GLuint dimensions,
+ GLsizei width, GLsizei height, GLsizei depth,
GLenum format, GLenum type, const GLvoid *pixels,
const struct gl_pixelstore_attrib *unpack )
{
dst = destBuffer;
for (img = 0; img < depth; img++) {
for (row = 0; row < height; row++) {
- const GLvoid *src = _mesa_image_address(unpack, pixels,
+ const GLvoid *src = _mesa_image_address(dimensions, unpack, pixels,
width, height, format, type, img, row, 0);
MEMCPY(dst, src, bytesPerRow);
/* byte flipping/swapping */
extern GLvoid *
-_mesa_image_address( const struct gl_pixelstore_attrib *packing,
- const GLvoid *image, GLsizei width,
- GLsizei height, GLenum format, GLenum type,
+_mesa_image_address( GLuint dimensions,
+ const struct gl_pixelstore_attrib *packing,
+ const GLvoid *image,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
GLint img, GLint row, GLint column );
+extern GLvoid *
+_mesa_image_address1d( const struct gl_pixelstore_attrib *packing,
+ const GLvoid *image,
+ GLsizei width,
+ GLenum format, GLenum type,
+ GLint column );
+
+extern GLvoid *
+_mesa_image_address2d( const struct gl_pixelstore_attrib *packing,
+ const GLvoid *image,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ GLint row, GLint column );
+
+extern GLvoid *
+_mesa_image_address3d( const struct gl_pixelstore_attrib *packing,
+ const GLvoid *image,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ GLint img, GLint row, GLint column );
+
extern GLint
_mesa_image_row_stride( const struct gl_pixelstore_attrib *packing,
extern void *
-_mesa_unpack_image( GLsizei width, GLsizei height, GLsizei depth,
+_mesa_unpack_image( GLuint dimensions,
+ GLsizei width, GLsizei height, GLsizei depth,
GLenum format, GLenum type, const GLvoid *pixels,
const struct gl_pixelstore_attrib *unpack );
GLubyte *buf;
/* Note, need to use DefaultPacking and Unpack's buffer object */
ctx->DefaultPacking.BufferObj = ctx->Unpack.BufferObj;
- if (!_mesa_validate_pbo_access(&ctx->DefaultPacking, mapsize, 1, 1,
+ if (!_mesa_validate_pbo_access(1, &ctx->DefaultPacking, mapsize, 1, 1,
GL_INTENSITY, GL_FLOAT, values)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glPixelMapfv(invalid PBO access)");
GLubyte *buf;
/* Note, need to use DefaultPacking and Unpack's buffer object */
ctx->DefaultPacking.BufferObj = ctx->Unpack.BufferObj;
- if (!_mesa_validate_pbo_access(&ctx->DefaultPacking, mapsize, 1, 1,
+ if (!_mesa_validate_pbo_access(1, &ctx->DefaultPacking, mapsize, 1, 1,
GL_INTENSITY, GL_UNSIGNED_INT, values)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glPixelMapuiv(invalid PBO access)");
GLubyte *buf;
/* Note, need to use DefaultPacking and Unpack's buffer object */
ctx->DefaultPacking.BufferObj = ctx->Unpack.BufferObj;
- if (!_mesa_validate_pbo_access(&ctx->DefaultPacking, mapsize, 1, 1,
+ if (!_mesa_validate_pbo_access(1, &ctx->DefaultPacking, mapsize, 1, 1,
GL_INTENSITY, GL_UNSIGNED_SHORT,
values)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
GLubyte *buf;
/* Note, need to use DefaultPacking and Pack's buffer object */
ctx->DefaultPacking.BufferObj = ctx->Pack.BufferObj;
- if (!_mesa_validate_pbo_access(&ctx->DefaultPacking, mapsize, 1, 1,
+ if (!_mesa_validate_pbo_access(1, &ctx->DefaultPacking, mapsize, 1, 1,
GL_INTENSITY, GL_FLOAT, values)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glGetPixelMapfv(invalid PBO access)");
GLubyte *buf;
/* Note, need to use DefaultPacking and Pack's buffer object */
ctx->DefaultPacking.BufferObj = ctx->Pack.BufferObj;
- if (!_mesa_validate_pbo_access(&ctx->DefaultPacking, mapsize, 1, 1,
+ if (!_mesa_validate_pbo_access(1, &ctx->DefaultPacking, mapsize, 1, 1,
GL_INTENSITY, GL_UNSIGNED_INT, values)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glGetPixelMapuiv(invalid PBO access)");
GLubyte *buf;
/* Note, need to use DefaultPacking and Pack's buffer object */
ctx->DefaultPacking.BufferObj = ctx->Pack.BufferObj;
- if (!_mesa_validate_pbo_access(&ctx->DefaultPacking, mapsize, 1, 1,
+ if (!_mesa_validate_pbo_access(1, &ctx->DefaultPacking, mapsize, 1, 1,
GL_INTENSITY, GL_UNSIGNED_SHORT,
values)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
if (ctx->Unpack.BufferObj->Name) {
/* Get/unpack the stipple pattern from a PBO */
GLubyte *buf;
- if (!_mesa_validate_pbo_access(&ctx->Unpack, 32, 32, 1,
+ if (!_mesa_validate_pbo_access(2, &ctx->Unpack, 32, 32, 1,
GL_COLOR_INDEX, GL_BITMAP, pattern)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glPolygonStipple(bad PBO access)");
if (ctx->Pack.BufferObj->Name) {
/* Put/pack the stipple pattern into a PBO */
GLubyte *buf;
- if (!_mesa_validate_pbo_access(&ctx->Pack, 32, 32, 1,
+ if (!_mesa_validate_pbo_access(2, &ctx->Pack, 32, 32, 1,
GL_COLOR_INDEX, GL_BITMAP, dest)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glGetPolygonStipple(bad PBO access)");
const struct gl_texture_object *texObj;
const struct gl_texture_image *texImage;
GLint maxLevels = 0;
+ GLuint dimensions;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
return;
}
+ dimensions = (target == GL_TEXTURE_3D) ? 3 : 2;
+
/* XXX - someday the rest of this function should be moved into a
* fallback routine called via ctx->Driver.GetTexImage()
*/
if (ctx->Pack.BufferObj->Name) {
/* pack texture image into a PBO */
GLubyte *buf;
- if (!_mesa_validate_pbo_access(&ctx->Pack, texImage->Width,
+ if (!_mesa_validate_pbo_access(dimensions, &ctx->Pack, texImage->Width,
texImage->Height, texImage->Depth,
format, type, pixels)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
for (img = 0; img < depth; img++) {
for (row = 0; row < height; row++) {
/* compute destination address in client memory */
- GLvoid *dest = _mesa_image_address( &ctx->Pack, pixels,
+ GLvoid *dest = _mesa_image_address( dimensions, &ctx->Pack, pixels,
width, height, format, type,
img, row, 0);
assert(dest);
/* unpack and do transfer ops up to convolution */
for (row = 0; row < srcHeight; row++) {
- const GLvoid *src = _mesa_image_address(srcPacking,
+ const GLvoid *src = _mesa_image_address(dims, srcPacking,
srcAddr, srcWidth, srcHeight,
srcFormat, srcType, img, row, 0);
_mesa_unpack_color_span_float(ctx, srcWidth, GL_RGBA, dst,
dst = tempImage;
for (img = 0; img < srcDepth; img++) {
const GLubyte *src
- = (const GLubyte *) _mesa_image_address(srcPacking, srcAddr,
+ = (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr,
srcWidth, srcHeight,
srcFormat, srcType,
img, 0, 0);
srcWidth, srcFormat,
srcType);
const GLubyte *src
- = (const GLubyte *) _mesa_image_address(srcPacking, srcAddr,
+ = (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr,
srcWidth, srcHeight,
srcFormat, srcType,
img, 0, 0);
* 1D, 2D and 3D images supported.
*/
static void
-memcpy_texture(const struct gl_texture_format *dstFormat,
+memcpy_texture(GLuint dimensions,
+ const struct gl_texture_format *dstFormat,
GLvoid *dstAddr,
GLint dstXoffset, GLint dstYoffset, GLint dstZoffset,
GLint dstRowStride, GLint dstImageStride,
srcFormat, srcType);
const GLint srcImageStride = _mesa_image_image_stride(srcPacking,
srcWidth, srcHeight, srcFormat, srcType);
- const GLubyte *srcImage = (const GLubyte *) _mesa_image_address(srcPacking,
- srcAddr, srcWidth, srcHeight, srcFormat, srcType, 0, 0, 0);
+ const GLubyte *srcImage = (const GLubyte *) _mesa_image_address(dimensions,
+ srcPacking, srcAddr, srcWidth, srcHeight, srcFormat, srcType, 0, 0, 0);
const GLint bytesPerRow = srcWidth * dstFormat->TexelBytes;
const GLint bytesPerImage = srcHeight * bytesPerRow;
const GLint bytesPerTexture = srcDepth * bytesPerImage;
baseInternalFormat == srcFormat &&
srcType == CHAN_TYPE) {
/* simple memcpy path */
- memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ memcpy_texture(dims,
+ dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstImageStride,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
for (img = 0; img < srcDepth; img++) {
const GLint srcRowStride = _mesa_image_row_stride(srcPacking,
srcWidth, srcFormat, srcType);
- GLchan *srcRow = (GLchan *) _mesa_image_address(srcPacking, srcAddr,
- srcWidth, srcHeight, srcFormat, srcType, img, 0, 0);
+ GLchan *srcRow = (GLchan *) _mesa_image_address(dims, srcPacking,
+ srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0);
GLchan *dstRow = dstImage;
for (row = 0; row < srcHeight; row++) {
for (col = 0; col < srcWidth; col++) {
srcFormat == GL_DEPTH_COMPONENT &&
srcType == GL_FLOAT) {
/* simple memcpy path */
- memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ memcpy_texture(dims,
+ dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstImageStride,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
for (img = 0; img < srcDepth; img++) {
GLubyte *dstRow = dstImage;
for (row = 0; row < srcHeight; row++) {
- const GLvoid *src = _mesa_image_address(srcPacking,
+ const GLvoid *src = _mesa_image_address(dims, srcPacking,
srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);
_mesa_unpack_depth_span(ctx, srcWidth, (GLfloat *) dstRow,
srcType, src, srcPacking);
srcFormat == GL_DEPTH_COMPONENT &&
srcType == GL_UNSIGNED_SHORT) {
/* simple memcpy path */
- memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ memcpy_texture(dims,
+ dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstImageStride,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
GLubyte *dstRow = dstImage;
for (row = 0; row < srcHeight; row++) {
GLfloat depthTemp[MAX_WIDTH];
- const GLvoid *src = _mesa_image_address(srcPacking,
+ const GLvoid *src = _mesa_image_address(dims, srcPacking,
srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);
GLushort *dst16 = (GLushort *) dstRow;
_mesa_unpack_depth_span(ctx, srcWidth, depthTemp,
srcFormat == GL_RGB &&
srcType == GL_UNSIGNED_SHORT_5_6_5) {
/* simple memcpy path */
- memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ memcpy_texture(dims,
+ dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstImageStride,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
const GLint srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth,
srcFormat, srcType);
const GLubyte *src = (const GLubyte *)
- _mesa_image_address(srcPacking, srcAddr, srcWidth, srcHeight,
+ _mesa_image_address(dims, srcPacking, srcAddr, srcWidth, srcHeight,
srcFormat, srcType, 0, 0, 0);
GLubyte *dst = (GLubyte *) dstAddr
+ dstZoffset * dstImageStride
((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8) ||
(srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_INT_8_8_8_8_REV))) {
/* simple memcpy path */
- memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ memcpy_texture(dims,
+ dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstImageStride,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
((srcType == GL_UNSIGNED_BYTE && littleEndian) ||
srcType == GL_UNSIGNED_INT_8_8_8_8_REV)) {
/* simple memcpy path (little endian) */
- memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ memcpy_texture(dims,
+ dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstImageStride,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
((srcType == GL_UNSIGNED_BYTE && !littleEndian) ||
srcType == GL_UNSIGNED_INT_8_8_8_8)) {
/* simple memcpy path (big endian) */
- memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ memcpy_texture(dims,
+ dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstImageStride,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
srcType == GL_UNSIGNED_BYTE &&
littleEndian) {
/* simple memcpy path */
- memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ memcpy_texture(dims,
+ dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstImageStride,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
for (img = 0; img < srcDepth; img++) {
const GLint srcRowStride = _mesa_image_row_stride(srcPacking,
srcWidth, srcFormat, srcType);
- GLubyte *srcRow = (GLubyte *) _mesa_image_address(srcPacking, srcAddr,
- srcWidth, srcHeight, srcFormat, srcType, img, 0, 0);
+ GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking,
+ srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0);
GLubyte *dstRow = dstImage;
for (row = 0; row < srcHeight; row++) {
for (col = 0; col < srcWidth; col++) {
srcType == GL_UNSIGNED_BYTE &&
littleEndian) {
/* simple memcpy path */
- memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ memcpy_texture(dims,
+ dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstImageStride,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
for (img = 0; img < srcDepth; img++) {
const GLint srcRowStride = _mesa_image_row_stride(srcPacking,
srcWidth, srcFormat, srcType);
- GLubyte *srcRow = (GLubyte *) _mesa_image_address(srcPacking, srcAddr,
- srcWidth, srcHeight, srcFormat, srcType, img, 0, 0);
+ GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking,
+ srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0);
GLubyte *dstRow = dstImage;
for (row = 0; row < srcHeight; row++) {
for (col = 0; col < srcWidth; col++) {
srcFormat == GL_BGRA &&
srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV) {
/* simple memcpy path */
- memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ memcpy_texture(dims,
+ dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstImageStride,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
srcFormat == GL_BGRA &&
srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV) {
/* simple memcpy path */
- memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ memcpy_texture(dims,
+ dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstImageStride,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
srcType == GL_UNSIGNED_BYTE &&
littleEndian) {
/* simple memcpy path */
- memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ memcpy_texture(dims,
+ dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstImageStride,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
baseInternalFormat == GL_RGB &&
srcFormat == GL_RGB && srcType == GL_UNSIGNED_BYTE_3_3_2) {
/* simple memcpy path */
- memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ memcpy_texture(dims,
+ dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstImageStride,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
baseInternalFormat == srcFormat &&
srcType == GL_UNSIGNED_BYTE) {
/* simple memcpy path */
- memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ memcpy_texture(dims,
+ dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstImageStride,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
srcFormat == GL_COLOR_INDEX &&
srcType == GL_UNSIGNED_BYTE) {
/* simple memcpy path */
- memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ memcpy_texture(dims,
+ dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstImageStride,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
for (img = 0; img < srcDepth; img++) {
GLubyte *dstRow = dstImage;
for (row = 0; row < srcHeight; row++) {
- const GLvoid *src = _mesa_image_address(srcPacking,
+ const GLvoid *src = _mesa_image_address(dims, srcPacking,
srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);
_mesa_unpack_index_span(ctx, srcWidth, GL_UNSIGNED_BYTE, dstRow,
srcType, src, srcPacking,
ASSERT(baseInternalFormat == GL_YCBCR_MESA);
/* always just memcpy since no pixel transfer ops apply */
- memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ memcpy_texture(dims,
+ dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstImageStride,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
baseInternalFormat == srcFormat &&
srcType == GL_FLOAT) {
/* simple memcpy path */
- memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ memcpy_texture(dims,
+ dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstImageStride,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
baseInternalFormat == srcFormat &&
srcType == GL_HALF_FLOAT_ARB) {
/* simple memcpy path */
- memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ memcpy_texture(dims,
+ dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstImageStride,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
* The caller _must_ call unmap_teximage_pbo() too!
*/
static const GLvoid *
-validate_pbo_teximage(GLcontext *ctx,
+validate_pbo_teximage(GLcontext *ctx, GLuint dimensions,
GLsizei width, GLsizei height, GLsizei depth,
GLenum format, GLenum type, const GLvoid *pixels,
const struct gl_pixelstore_attrib *unpack,
/* no PBO */
return pixels;
}
- if (!_mesa_validate_pbo_access(unpack, width, height, depth, format,
- type, pixels)) {
+ if (!_mesa_validate_pbo_access(dimensions, unpack, width, height, depth,
+ format, type, pixels)) {
_mesa_error(ctx, GL_INVALID_OPERATION, funcName, "(invalid PBO access");
return NULL;
}
return;
}
- pixels = validate_pbo_teximage(ctx, width, 1, 1, format, type, pixels,
+ pixels = validate_pbo_teximage(ctx, 1, width, 1, 1, format, type, pixels,
packing, "glTexImage1D");
if (!pixels)
return;
return;
}
- pixels = validate_pbo_teximage(ctx, width, height, 1, format, type, pixels,
- packing, "glTexImage2D");
+ pixels = validate_pbo_teximage(ctx, 2, width, height, 1, format, type,
+ pixels, packing, "glTexImage2D");
if (!pixels)
return;
return;
}
- pixels = validate_pbo_teximage(ctx, width, height, depth, format, type,
+ pixels = validate_pbo_teximage(ctx, 3, width, height, depth, format, type,
pixels, packing, "glTexImage3D");
if (!pixels)
return;
struct gl_texture_object *texObj,
struct gl_texture_image *texImage)
{
- pixels = validate_pbo_teximage(ctx, width, 1, 1, format, type, pixels,
+ pixels = validate_pbo_teximage(ctx, 1, width, 1, 1, format, type, pixels,
packing, "glTexSubImage1D");
if (!pixels)
return;
struct gl_texture_object *texObj,
struct gl_texture_image *texImage)
{
- pixels = validate_pbo_teximage(ctx, width, height, 1, format, type, pixels,
- packing, "glTexSubImage2D");
+ pixels = validate_pbo_teximage(ctx, 2, width, height, 1, format, type,
+ pixels, packing, "glTexSubImage2D");
if (!pixels)
return;
struct gl_texture_object *texObj,
struct gl_texture_image *texImage)
{
- pixels = validate_pbo_teximage(ctx, width, height, depth, format, type,
+ pixels = validate_pbo_teximage(ctx, 3, width, height, depth, format, type,
pixels, packing, "glTexSubImage3D");
if (!pixels)
return;
if (unpack->BufferObj->Name) {
/* unpack from PBO */
GLubyte *buf;
- if (!_mesa_validate_pbo_access(unpack, width, height, 1,
+ if (!_mesa_validate_pbo_access(2, unpack, width, height, 1,
GL_COLOR_INDEX, GL_BITMAP,
(GLvoid *) bitmap)) {
_mesa_error(ctx, GL_INVALID_OPERATION,"glBitmap(invalid PBO access)");
_swrast_span_default_texcoords(ctx, &span);
for (row = 0; row < height; row++, span.y++) {
- const GLubyte *src = (const GLubyte *) _mesa_image_address( unpack,
- bitmap, width, height, GL_COLOR_INDEX, GL_BITMAP, 0, row, 0 );
+ const GLubyte *src = (const GLubyte *) _mesa_image_address2d(unpack,
+ bitmap, width, height, GL_COLOR_INDEX, GL_BITMAP, row, 0);
if (unpack->LsbFirst) {
/* Lsb first */
_swrast_span_default_texcoords(ctx, &span);
for (row=0; row<height; row++, span.y++) {
- const GLubyte *src = (const GLubyte *) _mesa_image_address( unpack,
- bitmap, width, height, GL_COLOR_INDEX, GL_BITMAP, 0, row, 0 );
+ const GLubyte *src = (const GLubyte *) _mesa_image_address2d(unpack,
+ bitmap, width, height, GL_COLOR_INDEX, GL_BITMAP, row, 0);
if (unpack->LsbFirst) {
/* Lsb first */
? MAX_WIDTH : (width - skipPixels);
ASSERT(spanEnd <= MAX_WIDTH);
for (row = 0; row < height; row++, spanY++) {
- const GLvoid *source = _mesa_image_address(unpack, pixels,
- width, height,
- GL_COLOR_INDEX, type,
- 0, row, skipPixels);
+ const GLvoid *source = _mesa_image_address2d(unpack, pixels,
+ width, height,
+ GL_COLOR_INDEX, type,
+ row, skipPixels);
_mesa_unpack_index_span(ctx, spanEnd, GL_UNSIGNED_INT,
span.array->index, type, source, unpack,
ctx->_ImageTransferState);
GLstencil values[MAX_WIDTH];
GLenum destType = (sizeof(GLstencil) == sizeof(GLubyte))
? GL_UNSIGNED_BYTE : GL_UNSIGNED_SHORT;
- const GLvoid *source = _mesa_image_address(unpack, pixels,
- width, height,
- GL_COLOR_INDEX, type,
- 0, row, skipPixels);
+ const GLvoid *source = _mesa_image_address2d(unpack, pixels,
+ width, height,
+ GL_COLOR_INDEX, type,
+ row, skipPixels);
_mesa_unpack_index_span(ctx, spanWidth, destType, values,
type, source, unpack,
ctx->_ImageTransferState);
GLint row, spanY = y;
for (row = 0; row < height; row++, spanY++) {
const GLushort *zSrc = (const GLushort *)
- _mesa_image_address(unpack, pixels, width, height,
- GL_DEPTH_COMPONENT, type, 0, row, 0);
+ _mesa_image_address2d(unpack, pixels, width, height,
+ GL_DEPTH_COMPONENT, type, row, 0);
GLint i;
for (i = 0; i < width; i++)
span.array->z[i] = zSrc[i];
GLint row, spanY = y;
for (row = 0; row < height; row++, spanY++) {
const GLuint *zSrc = (const GLuint *)
- _mesa_image_address(unpack, pixels, width, height,
- GL_DEPTH_COMPONENT, type, 0, row, 0);
+ _mesa_image_address2d(unpack, pixels, width, height,
+ GL_DEPTH_COMPONENT, type, row, 0);
if (shift == 0) {
MEMCPY(span.array->z, zSrc, width * sizeof(GLdepth));
}
ASSERT(span.end <= MAX_WIDTH);
for (row = 0; row < height; row++, spanY++) {
GLfloat floatSpan[MAX_WIDTH];
- const GLvoid *zSrc = _mesa_image_address(unpack,
- pixels, width, height,
- GL_DEPTH_COMPONENT, type,
- 0, row, skipPixels);
+ const GLvoid *zSrc = _mesa_image_address2d(unpack,
+ pixels, width, height,
+ GL_DEPTH_COMPONENT, type,
+ row, skipPixels);
/* Set these for each row since the _swrast_write_* function may
* change them while clipping.
/* Unpack the image and apply transfer ops up to convolution */
dest = tmpImage;
for (row = 0; row < height; row++) {
- const GLvoid *source = _mesa_image_address(unpack,
- pixels, width, height, format, type, 0, row, 0);
+ const GLvoid *source = _mesa_image_address2d(unpack,
+ pixels, width, height, format, type, row, 0);
_mesa_unpack_color_span_float(ctx, width, GL_RGBA, (GLfloat *) dest,
format, type, source, unpack,
transferOps & IMAGE_PRE_CONVOLUTION_BITS);
ASSERT(span.end <= MAX_WIDTH);
for (row = 0; row < height; row++, spanY++) {
- const GLvoid *source = _mesa_image_address(unpack,
- pixels, width, height, format, type, 0, row, skipPixels);
+ const GLvoid *source = _mesa_image_address2d(unpack,
+ pixels, width, height, format, type, row, skipPixels);
/* Set these for each row since the _swrast_write_* function may
* change them while clipping.
if (unpack->BufferObj->Name) {
/* unpack from PBO */
GLubyte *buf;
- if (!_mesa_validate_pbo_access(unpack, width, height, 1,
+ if (!_mesa_validate_pbo_access(2, unpack, width, height, 1,
format, type, pixels)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glDrawPixels(invalid PBO access)");
(*swrast->Driver.ReadCI32Span)(ctx, readWidth, x, y + i, index);
- dest = _mesa_image_address(packing, pixels, width, height,
- GL_COLOR_INDEX, type, 0, i, 0);
+ dest = _mesa_image_address2d(packing, pixels, width, height,
+ GL_COLOR_INDEX, type, i, 0);
_mesa_pack_index_span(ctx, readWidth, type, dest, index,
&ctx->Pack, ctx->_ImageTransferState);
GLint j;
for (j=0;j<height;j++,y++) {
GLdepth depth[MAX_WIDTH];
- GLushort *dst = (GLushort*) _mesa_image_address( packing, pixels,
- width, height, GL_DEPTH_COMPONENT, type, 0, j, 0 );
+ GLushort *dst = (GLushort*) _mesa_image_address2d(packing, pixels,
+ width, height, GL_DEPTH_COMPONENT, type, j, 0);
GLint i;
_swrast_read_depth_span(ctx, width, x, y, depth);
for (i = 0; i < width; i++)
/* Special case: directly read 32-bit unsigned depth values. */
GLint j;
for (j=0;j<height;j++,y++) {
- GLdepth *dst = (GLdepth *) _mesa_image_address( packing, pixels,
- width, height, GL_DEPTH_COMPONENT, type, 0, j, 0 );
+ GLdepth *dst = (GLdepth *) _mesa_image_address2d(packing, pixels,
+ width, height, GL_DEPTH_COMPONENT, type, j, 0);
_swrast_read_depth_span(ctx, width, x, y, dst);
}
}
_swrast_read_depth_span_float(ctx, readWidth, x, y, depth);
- dest = _mesa_image_address(packing, pixels, width, height,
- GL_DEPTH_COMPONENT, type, 0, j, 0);
+ dest = _mesa_image_address2d(packing, pixels, width, height,
+ GL_DEPTH_COMPONENT, type, j, 0);
_mesa_pack_depth_span(ctx, readWidth, (GLdepth *) dest, type,
depth, packing);
_swrast_read_stencil_span(ctx, readWidth, x, y, stencil);
- dest = _mesa_image_address(packing, pixels, width, height,
- GL_STENCIL_INDEX, type, 0, j, 0);
+ dest = _mesa_image_address2d(packing, pixels, width, height,
+ GL_STENCIL_INDEX, type, j, 0);
_mesa_pack_stencil_span(ctx, readWidth, type, dest, stencil, packing);
}
src = convImage;
for (row = 0; row < height; row++) {
GLvoid *dest;
- dest = _mesa_image_address(packing, pixels, readWidth, height,
- format, type, 0, row, 0);
+ dest = _mesa_image_address2d(packing, pixels, readWidth, height,
+ format, type, row, 0);
_mesa_pack_rgba_span_float(ctx, readWidth,
(const GLfloat (*)[4]) src,
format, type, dest, packing,
}
_mesa_map_ci_to_rgba_chan(ctx, readWidth, index, rgba);
}
- dst = _mesa_image_address(packing, pixels, width, height,
- format, type, 0, row, 0);
+ dst = _mesa_image_address2d(packing, pixels, width, height,
+ format, type, row, 0);
if (ctx->Visual.redBits < CHAN_BITS ||
ctx->Visual.greenBits < CHAN_BITS ||
ctx->Visual.blueBits < CHAN_BITS) {
if (clippedPacking.BufferObj->Name) {
/* pack into PBO */
GLubyte *buf;
- if (!_mesa_validate_pbo_access(&clippedPacking, width, height, 1,
+ if (!_mesa_validate_pbo_access(2, &clippedPacking, width, height, 1,
format, type, pixels)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glReadPixels(invalid PBO access)");