projects
/
mesa.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
mesa/get: Add TYPE_UINT for casting through a GLuint.
[mesa.git]
/
src
/
mesa
/
main
/
texstore.c
diff --git
a/src/mesa/main/texstore.c
b/src/mesa/main/texstore.c
index 7039cdf81741a09e1a09c092cf052f3b7b7dacc3..615ba63362efe3012adc9a9fb58fc553652d4c20 100644
(file)
--- a/
src/mesa/main/texstore.c
+++ b/
src/mesa/main/texstore.c
@@
-53,7
+53,6
@@
#include "glheader.h"
#include "bufferobj.h"
#include "glheader.h"
#include "bufferobj.h"
-#include "colormac.h"
#include "format_pack.h"
#include "format_utils.h"
#include "image.h"
#include "format_pack.h"
#include "format_utils.h"
#include "image.h"
@@
-74,8
+73,8
@@
#include "enums.h"
#include "glformats.h"
#include "pixeltransfer.h"
#include "enums.h"
#include "glformats.h"
#include "pixeltransfer.h"
-#include "
../../gallium/auxiliary/util/u_
format_rgb9e5.h"
-#include "
../../gallium/auxiliary/util/u_
format_r11g11b10f.h"
+#include "
util/
format_rgb9e5.h"
+#include "
util/
format_r11g11b10f.h"
enum {
enum {
@@
-88,9
+87,6
@@
enum {
* Texture image storage function.
*/
typedef GLboolean (*StoreTexImageFunc)(TEXSTORE_PARAMS);
* Texture image storage function.
*/
typedef GLboolean (*StoreTexImageFunc)(TEXSTORE_PARAMS);
-static const GLubyte map_identity[6] = { 0, 1, 2, 3, ZERO, ONE };
-static const GLubyte map_3210[6] = { 3, 2, 1, 0, ZERO, ONE };
-static const GLubyte map_1032[6] = { 1, 0, 3, 2, ZERO, ONE };
/**
/**
@@
-98,16
+94,16
@@
static const GLubyte map_1032[6] = { 1, 0, 3, 2, ZERO, ONE };
* No pixel transfer operations or special texel encodings allowed.
* 1D, 2D and 3D images supported.
*/
* No pixel transfer operations or special texel encodings allowed.
* 1D, 2D and 3D images supported.
*/
-
static
void
-memcpy_texture(struct gl_context *ctx,
- GLuint dimensions,
- mesa_format dstFormat,
- GLint dstRowStride,
- GLubyte **dstSlices,
- GLint srcWidth, GLint srcHeight, GLint srcDepth,
- GLenum srcFormat, GLenum srcType,
- const GLvoid *srcAddr,
- const struct gl_pixelstore_attrib *srcPacking)
+void
+
_mesa_
memcpy_texture(struct gl_context *ctx,
+
GLuint dimensions,
+
mesa_format dstFormat,
+
GLint dstRowStride,
+
GLubyte **dstSlices,
+
GLint srcWidth, GLint srcHeight, GLint srcDepth,
+
GLenum srcFormat, GLenum srcType,
+
const GLvoid *srcAddr,
+
const struct gl_pixelstore_attrib *srcPacking)
{
const GLint srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth,
srcFormat, srcType);
{
const GLint srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth,
srcFormat, srcType);
@@
-154,9
+150,9
@@
_mesa_texstore_z32(TEXSTORE_PARAMS)
const GLuint depthScale = 0xffffffff;
GLenum dstType;
(void) dims;
const GLuint depthScale = 0xffffffff;
GLenum dstType;
(void) dims;
-
ASSERT
(dstFormat == MESA_FORMAT_Z_UNORM32 ||
+
assert
(dstFormat == MESA_FORMAT_Z_UNORM32 ||
dstFormat == MESA_FORMAT_Z_FLOAT32);
dstFormat == MESA_FORMAT_Z_FLOAT32);
-
ASSERT
(_mesa_get_format_bytes(dstFormat) == sizeof(GLuint));
+
assert
(_mesa_get_format_bytes(dstFormat) == sizeof(GLuint));
if (dstFormat == MESA_FORMAT_Z_UNORM32)
dstType = GL_UNSIGNED_INT;
if (dstFormat == MESA_FORMAT_Z_UNORM32)
dstType = GL_UNSIGNED_INT;
@@
-191,7
+187,7
@@
_mesa_texstore_x8_z24(TEXSTORE_PARAMS)
const GLuint depthScale = 0xffffff;
(void) dims;
const GLuint depthScale = 0xffffff;
(void) dims;
-
ASSERT
(dstFormat == MESA_FORMAT_Z24_UNORM_X8_UINT);
+
assert
(dstFormat == MESA_FORMAT_Z24_UNORM_X8_UINT);
{
/* general path */
{
/* general path */
@@
-221,7
+217,7
@@
_mesa_texstore_z24_x8(TEXSTORE_PARAMS)
const GLuint depthScale = 0xffffff;
(void) dims;
const GLuint depthScale = 0xffffff;
(void) dims;
-
ASSERT
(dstFormat == MESA_FORMAT_X8_UINT_Z24_UNORM);
+
assert
(dstFormat == MESA_FORMAT_X8_UINT_Z24_UNORM);
{
/* general path */
{
/* general path */
@@
-254,8
+250,8
@@
_mesa_texstore_z16(TEXSTORE_PARAMS)
{
const GLuint depthScale = 0xffff;
(void) dims;
{
const GLuint depthScale = 0xffff;
(void) dims;
-
ASSERT
(dstFormat == MESA_FORMAT_Z_UNORM16);
-
ASSERT
(_mesa_get_format_bytes(dstFormat) == sizeof(GLushort));
+
assert
(dstFormat == MESA_FORMAT_Z_UNORM16);
+
assert
(_mesa_get_format_bytes(dstFormat) == sizeof(GLushort));
{
/* general path */
{
/* general path */
@@
-287,21
+283,21
@@
_mesa_texstore_ycbcr(TEXSTORE_PARAMS)
(void) ctx; (void) dims; (void) baseInternalFormat;
(void) ctx; (void) dims; (void) baseInternalFormat;
-
ASSERT
((dstFormat == MESA_FORMAT_YCBCR) ||
+
assert
((dstFormat == MESA_FORMAT_YCBCR) ||
(dstFormat == MESA_FORMAT_YCBCR_REV));
(dstFormat == MESA_FORMAT_YCBCR_REV));
-
ASSERT
(_mesa_get_format_bytes(dstFormat) == 2);
-
ASSERT
(ctx->Extensions.MESA_ycbcr_texture);
-
ASSERT
(srcFormat == GL_YCBCR_MESA);
-
ASSERT
((srcType == GL_UNSIGNED_SHORT_8_8_MESA) ||
+
assert
(_mesa_get_format_bytes(dstFormat) == 2);
+
assert
(ctx->Extensions.MESA_ycbcr_texture);
+
assert
(srcFormat == GL_YCBCR_MESA);
+
assert
((srcType == GL_UNSIGNED_SHORT_8_8_MESA) ||
(srcType == GL_UNSIGNED_SHORT_8_8_REV_MESA));
(srcType == GL_UNSIGNED_SHORT_8_8_REV_MESA));
-
ASSERT
(baseInternalFormat == GL_YCBCR_MESA);
+
assert
(baseInternalFormat == GL_YCBCR_MESA);
/* always just memcpy since no pixel transfer ops apply */
/* always just memcpy since no pixel transfer ops apply */
- memcpy_texture(ctx, dims,
- dstFormat,
- dstRowStride, dstSlices,
- srcWidth, srcHeight, srcDepth, srcFormat, srcType,
- srcAddr, srcPacking);
+
_mesa_
memcpy_texture(ctx, dims,
+
dstFormat,
+
dstRowStride, dstSlices,
+
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+
srcAddr, srcPacking);
/* Check if we need byte swapping */
/* XXX the logic here _might_ be wrong */
/* Check if we need byte swapping */
/* XXX the logic here _might_ be wrong */
@@
-335,11
+331,11
@@
_mesa_texstore_z24_s8(TEXSTORE_PARAMS)
GLuint *depth = malloc(srcWidth * sizeof(GLuint));
GLubyte *stencil = malloc(srcWidth * sizeof(GLubyte));
GLuint *depth = malloc(srcWidth * sizeof(GLuint));
GLubyte *stencil = malloc(srcWidth * sizeof(GLubyte));
-
ASSERT
(dstFormat == MESA_FORMAT_S8_UINT_Z24_UNORM);
-
ASSERT
(srcFormat == GL_DEPTH_STENCIL_EXT ||
+
assert
(dstFormat == MESA_FORMAT_S8_UINT_Z24_UNORM);
+
assert
(srcFormat == GL_DEPTH_STENCIL_EXT ||
srcFormat == GL_DEPTH_COMPONENT ||
srcFormat == GL_STENCIL_INDEX);
srcFormat == GL_DEPTH_COMPONENT ||
srcFormat == GL_STENCIL_INDEX);
-
ASSERT
(srcFormat != GL_DEPTH_STENCIL_EXT ||
+
assert
(srcFormat != GL_DEPTH_STENCIL_EXT ||
srcType == GL_UNSIGNED_INT_24_8_EXT ||
srcType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
srcType == GL_UNSIGNED_INT_24_8_EXT ||
srcType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
@@
-414,11
+410,11
@@
_mesa_texstore_s8_z24(TEXSTORE_PARAMS)
GLuint *depth;
GLubyte *stencil;
GLuint *depth;
GLubyte *stencil;
-
ASSERT
(dstFormat == MESA_FORMAT_Z24_UNORM_S8_UINT);
-
ASSERT
(srcFormat == GL_DEPTH_STENCIL_EXT ||
+
assert
(dstFormat == MESA_FORMAT_Z24_UNORM_S8_UINT);
+
assert
(srcFormat == GL_DEPTH_STENCIL_EXT ||
srcFormat == GL_DEPTH_COMPONENT ||
srcFormat == GL_STENCIL_INDEX);
srcFormat == GL_DEPTH_COMPONENT ||
srcFormat == GL_STENCIL_INDEX);
-
ASSERT
(srcFormat != GL_DEPTH_STENCIL_EXT ||
+
assert
(srcFormat != GL_DEPTH_STENCIL_EXT ||
srcType == GL_UNSIGNED_INT_24_8_EXT ||
srcType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
srcType == GL_UNSIGNED_INT_24_8_EXT ||
srcType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
@@
-491,8
+487,8
@@
_mesa_texstore_s8_z24(TEXSTORE_PARAMS)
static GLboolean
_mesa_texstore_s8(TEXSTORE_PARAMS)
{
static GLboolean
_mesa_texstore_s8(TEXSTORE_PARAMS)
{
-
ASSERT
(dstFormat == MESA_FORMAT_S_UINT8);
-
ASSERT
(srcFormat == GL_STENCIL_INDEX);
+
assert
(dstFormat == MESA_FORMAT_S_UINT8);
+
assert
(srcFormat == GL_STENCIL_INDEX);
{
const GLint srcRowStride
{
const GLint srcRowStride
@@
-543,11
+539,11
@@
_mesa_texstore_z32f_x24s8(TEXSTORE_PARAMS)
= _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType)
/ sizeof(uint64_t);
= _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType)
/ sizeof(uint64_t);
-
ASSERT
(dstFormat == MESA_FORMAT_Z32_FLOAT_S8X24_UINT);
-
ASSERT
(srcFormat == GL_DEPTH_STENCIL ||
+
assert
(dstFormat == MESA_FORMAT_Z32_FLOAT_S8X24_UINT);
+
assert
(srcFormat == GL_DEPTH_STENCIL ||
srcFormat == GL_DEPTH_COMPONENT ||
srcFormat == GL_STENCIL_INDEX);
srcFormat == GL_DEPTH_COMPONENT ||
srcFormat == GL_STENCIL_INDEX);
-
ASSERT
(srcFormat != GL_DEPTH_STENCIL ||
+
assert
(srcFormat != GL_DEPTH_STENCIL ||
srcType == GL_UNSIGNED_INT_24_8 ||
srcType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
srcType == GL_UNSIGNED_INT_24_8 ||
srcType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
@@
-606,7
+602,7
@@
texstore_depth_stencil(TEXSTORE_PARAMS)
initialized = GL_TRUE;
}
initialized = GL_TRUE;
}
-
ASSERT
(table[dstFormat]);
+
assert
(table[dstFormat]);
return table[dstFormat](ctx, dims, baseInternalFormat,
dstFormat, dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth,
return table[dstFormat](ctx, dims, baseInternalFormat,
dstFormat, dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth,
@@
-666,7
+662,7
@@
texstore_compressed(TEXSTORE_PARAMS)
initialized = GL_TRUE;
}
initialized = GL_TRUE;
}
-
ASSERT
(table[dstFormat]);
+
assert
(table[dstFormat]);
return table[dstFormat](ctx, dims, baseInternalFormat,
dstFormat, dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth,
return table[dstFormat](ctx, dims, baseInternalFormat,
dstFormat, dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth,
@@
-728,19
+724,25
@@
texstore_rgba(TEXSTORE_PARAMS)
*/
GLint swapSize = _mesa_sizeof_packed_type(srcType);
if (swapSize == 2 || swapSize == 4) {
*/
GLint swapSize = _mesa_sizeof_packed_type(srcType);
if (swapSize == 2 || swapSize == 4) {
- int bytesPerPixel = _mesa_bytes_per_pixel(srcFormat, srcType);
- int swapsPerPixel = bytesPerPixel / swapSize;
- int elementCount = srcWidth * srcHeight * srcDepth;
- assert(bytesPerPixel % swapSize == 0);
- tempImage = malloc(elementCount * bytesPerPixel);
+ int imageStride = _mesa_image_image_stride(srcPacking, srcWidth, srcHeight, srcFormat, srcType);
+ int bufferSize = imageStride * srcDepth;
+ int layer;
+ const uint8_t *src;
+ uint8_t *dst;
+
+ tempImage = malloc(bufferSize);
if (!tempImage)
return GL_FALSE;
if (!tempImage)
return GL_FALSE;
- if (swapSize == 2)
- _mesa_swap2_copy(tempImage, (GLushort *) srcAddr,
- elementCount * swapsPerPixel);
- else
- _mesa_swap4_copy(tempImage, (GLuint *) srcAddr,
- elementCount * swapsPerPixel);
+ src = srcAddr;
+ dst = tempImage;
+ for (layer = 0; layer < srcDepth; layer++) {
+ _mesa_swap_bytes_2d_image(srcFormat, srcType,
+ srcPacking,
+ srcWidth, srcHeight,
+ dst, src);
+ src += imageStride;
+ dst += imageStride;
+ }
srcAddr = tempImage;
}
}
srcAddr = tempImage;
}
}
@@
-788,6
+790,7
@@
texstore_rgba(TEXSTORE_PARAMS)
srcType = GL_FLOAT;
srcRowStride = srcWidth * 4 * sizeof(float);
srcMesaFormat = RGBA32_FLOAT;
srcType = GL_FLOAT;
srcRowStride = srcWidth * 4 * sizeof(float);
srcMesaFormat = RGBA32_FLOAT;
+ srcPacking = &ctx->DefaultPacking;
}
src = (GLubyte *)
}
src = (GLubyte *)
@@
-863,7
+866,7
@@
_mesa_texstore_can_use_memcpy(struct gl_context *ctx,
/* The Mesa format must match the input format and type. */
if (!_mesa_format_matches_format_and_type(dstFormat, srcFormat, srcType,
/* The Mesa format must match the input format and type. */
if (!_mesa_format_matches_format_and_type(dstFormat, srcFormat, srcType,
- srcPacking->SwapBytes)) {
+ srcPacking->SwapBytes
, NULL
)) {
return GL_FALSE;
}
return GL_FALSE;
}
@@
-893,13
+896,15
@@
_mesa_texstore_memcpy(TEXSTORE_PARAMS)
return GL_FALSE;
}
return GL_FALSE;
}
- memcpy_texture(ctx, dims,
- dstFormat,
- dstRowStride, dstSlices,
- srcWidth, srcHeight, srcDepth, srcFormat, srcType,
- srcAddr, srcPacking);
+
_mesa_
memcpy_texture(ctx, dims,
+
dstFormat,
+
dstRowStride, dstSlices,
+
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+
srcAddr, srcPacking);
return GL_TRUE;
}
return GL_TRUE;
}
+
+
/**
* Store user data into texture memory.
* Called via glTex[Sub]Image1/2/3D()
/**
* Store user data into texture memory.
* Called via glTex[Sub]Image1/2/3D()
@@
-1004,6
+1009,7
@@
store_texsubimage(struct gl_context *ctx,
/* compute slice info (and do some sanity checks) */
switch (target) {
case GL_TEXTURE_2D:
/* compute slice info (and do some sanity checks) */
switch (target) {
case GL_TEXTURE_2D:
+ case GL_TEXTURE_2D_MULTISAMPLE:
case GL_TEXTURE_RECTANGLE:
case GL_TEXTURE_CUBE_MAP:
case GL_TEXTURE_EXTERNAL_OES:
case GL_TEXTURE_RECTANGLE:
case GL_TEXTURE_CUBE_MAP:
case GL_TEXTURE_EXTERNAL_OES:
@@
-1025,6
+1031,7
@@
store_texsubimage(struct gl_context *ctx,
srcImageStride = _mesa_image_row_stride(packing, width, format, type);
break;
case GL_TEXTURE_2D_ARRAY:
srcImageStride = _mesa_image_row_stride(packing, width, format, type);
break;
case GL_TEXTURE_2D_ARRAY:
+ case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
numSlices = depth;
sliceOffset = zoffset;
depth = 1;
numSlices = depth;
sliceOffset = zoffset;
depth = 1;
@@
-1225,10
+1232,10
@@
_mesa_store_compressed_teximage(struct gl_context *ctx, GLuint dims,
* have to worry about the usual image unpacking or image transfer
* operations.
*/
* have to worry about the usual image unpacking or image transfer
* operations.
*/
-
ASSERT
(texImage);
-
ASSERT
(texImage->Width > 0);
-
ASSERT
(texImage->Height > 0);
-
ASSERT
(texImage->Depth > 0);
+
assert
(texImage);
+
assert
(texImage->Width > 0);
+
assert
(texImage->Height > 0);
+
assert
(texImage->Depth > 0);
/* allocate storage for texture data */
if (!ctx->Driver.AllocTextureImageBuffer(ctx, texImage)) {
/* allocate storage for texture data */
if (!ctx->Driver.AllocTextureImageBuffer(ctx, texImage)) {
@@
-1236,11
+1243,11
@@
_mesa_store_compressed_teximage(struct gl_context *ctx, GLuint dims,
return;
}
return;
}
-
_mesa_store_compressed_texsubi
mage(ctx, dims, texImage,
-
0, 0, 0,
-
texImage->Width, texImage->Height, texImage->Depth,
-
texImage->TexFormat,
-
imageSize, data);
+
ctx->Driver.CompressedTexSubI
mage(ctx, dims, texImage,
+ 0, 0, 0,
+ texImage->Width, texImage->Height, texImage->Depth,
+ texImage->TexFormat,
+ imageSize, data);
}
}
@@
-1260,16
+1267,16
@@
_mesa_compute_compressed_pixelstore(GLuint dims, mesa_format texFormat,
const struct gl_pixelstore_attrib *packing,
struct compressed_pixelstore *store)
{
const struct gl_pixelstore_attrib *packing,
struct compressed_pixelstore *store)
{
- GLuint bw, bh;
+ GLuint bw, bh
, bd
;
- _mesa_get_format_block_size
(texFormat, &bw, &bh
);
+ _mesa_get_format_block_size
_3d(texFormat, &bw, &bh, &bd
);
store->SkipBytes = 0;
store->TotalBytesPerRow = store->CopyBytesPerRow =
_mesa_format_row_stride(texFormat, width);
store->TotalRowsPerSlice = store->CopyRowsPerSlice =
(height + bh - 1) / 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
;
+ store->CopySlices =
(depth + bd - 1) / bd
;
if (packing->CompressedBlockWidth &&
packing->CompressedBlockSize) {
if (packing->CompressedBlockWidth &&
packing->CompressedBlockSize) {