So it's near the other pixel-store functions. --- src/mesa/main/pixelstore.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++ src/mesa/main/pixelstore.h | 22 ++++++++++++++++ src/mesa/main/texstore.c | 65 +-------------------------------------------- src/mesa/main/texstore.h | 19 ------------- 4 files changed, 89 insertions(+), 83 deletions(-)
diff --git a/src/mesa/main/pixelstore.c b/src/mesa/main/pixelstore.c index fc81533..a453f17 100644 --- a/src/mesa/main/pixelstore.c +++ b/src/mesa/main/pixelstore.c @@ -30,6 +30,7 @@ #include "glheader.h" #include "bufferobj.h" +#include "formats.h" #include "context.h" #include "pixelstore.h" #include "mtypes.h" @@ -326,3 +327,68 @@ _mesa_compressed_pixel_storage_error_check( return true; } + + +/** + * Compute compressed_pixelstore parameters for copying compressed + * texture data. + * \param dims number of texture image dimensions: 1, 2 or 3 + * \param texFormat the compressed texture format + * \param width, height, depth size of image to copy + * \param packing pixelstore parameters describing user-space image packing + * \param store returns the compressed_pixelstore parameters + */ +void +_mesa_compute_compressed_pixelstore(GLuint dims, mesa_format texFormat, + GLsizei width, GLsizei height, + GLsizei depth, + const struct gl_pixelstore_attrib *packing, + struct compressed_pixelstore *store) +{ + GLuint bw, bh; + + _mesa_get_format_block_size(texFormat, &bw, &bh); + + store->SkipBytes = 0; + store->TotalBytesPerRow = store->CopyBytesPerRow = + _mesa_format_row_stride(texFormat, width); + store->TotalRowsPerSlice = store->CopyRowsPerSlice = + (height + bh - 1) / bh; + store->CopySlices = depth; + + if (packing->CompressedBlockWidth && + packing->CompressedBlockSize) { + + bw = packing->CompressedBlockWidth; + + if (packing->RowLength) { + store->TotalBytesPerRow = packing->CompressedBlockSize * + ((packing->RowLength + bw - 1) / bw); + } + + store->SkipBytes += + packing->SkipPixels * packing->CompressedBlockSize / bw; + } + + if (dims > 1 && packing->CompressedBlockHeight && + packing->CompressedBlockSize) { + + bh = packing->CompressedBlockHeight; + + store->SkipBytes += packing->SkipRows * store->TotalBytesPerRow / bh; + store->CopyRowsPerSlice = (height + bh - 1) / bh; /* rows in blocks */ + + if (packing->ImageHeight) { + store->TotalRowsPerSlice = (packing->ImageHeight + bh - 1) / bh; + } + } + + if (dims > 2 && packing->CompressedBlockDepth && + packing->CompressedBlockSize) { + + int bd = packing->CompressedBlockDepth; + + store->SkipBytes += packing->SkipImages * store->TotalBytesPerRow * + store->TotalRowsPerSlice / bd; + } +} diff --git a/src/mesa/main/pixelstore.h b/src/mesa/main/pixelstore.h index 6838454..e3f7cf9 100644 --- a/src/mesa/main/pixelstore.h +++ b/src/mesa/main/pixelstore.h @@ -57,4 +57,26 @@ _mesa_compressed_pixel_storage_error_check( const char *caller); + +/** + * Information used when copying compressed image data. + */ +struct compressed_pixelstore +{ + int SkipBytes; + int CopyBytesPerRow; + int CopyRowsPerSlice; + int TotalBytesPerRow; + int TotalRowsPerSlice; + int CopySlices; +}; + + +extern void +_mesa_compute_compressed_pixelstore(GLuint dims, mesa_format texFormat, + GLsizei width, GLsizei height, + GLsizei depth, + const struct gl_pixelstore_attrib *packing, + struct compressed_pixelstore *store); + #endif diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index 50aa1fd..4208ae0 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -62,6 +62,7 @@ #include "mtypes.h" #include "pack.h" #include "pbo.h" +#include "pixelstore.h" #include "imports.h" #include "texcompress.h" #include "texcompress_fxt1.h" @@ -2198,70 +2199,6 @@ _mesa_store_compressed_teximage(struct gl_context *ctx, GLuint dims, /** - * Compute compressed_pixelstore parameters for copying compressed - * texture data. - * \param dims number of texture image dimensions: 1, 2 or 3 - * \param texFormat the compressed texture format - * \param width, height, depth size of image to copy - * \param packing pixelstore parameters describing user-space image packing - * \param store returns the compressed_pixelstore parameters - */ -void -_mesa_compute_compressed_pixelstore(GLuint dims, mesa_format texFormat, - GLsizei width, GLsizei height, - GLsizei depth, - const struct gl_pixelstore_attrib *packing, - struct compressed_pixelstore *store) -{ - GLuint bw, bh; - - _mesa_get_format_block_size(texFormat, &bw, &bh); - - store->SkipBytes = 0; - store->TotalBytesPerRow = store->CopyBytesPerRow = - _mesa_format_row_stride(texFormat, width); - store->TotalRowsPerSlice = store->CopyRowsPerSlice = - (height + bh - 1) / bh; - store->CopySlices = depth; - - if (packing->CompressedBlockWidth && - packing->CompressedBlockSize) { - - bw = packing->CompressedBlockWidth; - - if (packing->RowLength) { - store->TotalBytesPerRow = packing->CompressedBlockSize * - ((packing->RowLength + bw - 1) / bw); - } - - store->SkipBytes += packing->SkipPixels * packing->CompressedBlockSize / bw; - } - - if (dims > 1 && packing->CompressedBlockHeight && - packing->CompressedBlockSize) { - - bh = packing->CompressedBlockHeight; - - store->SkipBytes += packing->SkipRows * store->TotalBytesPerRow / bh; - store->CopyRowsPerSlice = (height + bh - 1) / bh; /* rows in blocks */ - - if (packing->ImageHeight) { - store->TotalRowsPerSlice = (packing->ImageHeight + bh - 1) / bh; - } - } - - if (dims > 2 && packing->CompressedBlockDepth && - packing->CompressedBlockSize) { - - int bd = packing->CompressedBlockDepth; - - store->SkipBytes += packing->SkipImages * store->TotalBytesPerRow * - store->TotalRowsPerSlice / bd; - } -} - - -/** * Fallback for Driver.CompressedTexSubImage() */ void diff --git a/src/mesa/main/texstore.h b/src/mesa/main/texstore.h index 4c41d1f..2e5a266 100644 --- a/src/mesa/main/texstore.h +++ b/src/mesa/main/texstore.h @@ -138,23 +138,4 @@ _mesa_store_compressed_texsubimage(struct gl_context *ctx, GLuint dims, GLenum format, GLsizei imageSize, const GLvoid *data); - -struct compressed_pixelstore { - int SkipBytes; - int CopyBytesPerRow; - int CopyRowsPerSlice; - int TotalBytesPerRow; - int TotalRowsPerSlice; - int CopySlices; -}; - - -extern void -_mesa_compute_compressed_pixelstore(GLuint dims, mesa_format texFormat, - GLsizei width, GLsizei height, - GLsizei depth, - const struct gl_pixelstore_attrib *packing, - struct compressed_pixelstore *store); - - #endif -- 1.9.1 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev