mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 04:48:08 +02:00
mesa: get rid of imageOffsets arrays in texstore code
These were used to find the start of a 3D image slice (or 2D array texture slice) given a base address. Instead, use a simple array of address of image slices instead. This is a step toward getting rid of the gl_texture_image::ImageOffsets field. Reviewed-by: Eric Anholt <eric@anholt.net>
This commit is contained in:
parent
c3ef232315
commit
5253cf9805
10 changed files with 232 additions and 380 deletions
|
|
@ -57,6 +57,7 @@ intel_blit_texsubimage(struct gl_context * ctx,
|
|||
unsigned int blit_x = 0, blit_y = 0;
|
||||
unsigned long pitch;
|
||||
uint32_t tiling_mode = I915_TILING_NONE;
|
||||
GLubyte *dstMap;
|
||||
|
||||
/* Try to do a blit upload of the subimage if the texture is
|
||||
* currently busy.
|
||||
|
|
@ -108,8 +109,7 @@ intel_blit_texsubimage(struct gl_context * ctx,
|
|||
return false;
|
||||
}
|
||||
|
||||
texImage->Data = temp_bo->virtual;
|
||||
texImage->ImageOffsets[0] = 0;
|
||||
dstMap = temp_bo->virtual;
|
||||
dstRowStride = pitch;
|
||||
|
||||
intel_miptree_get_image_offset(intelImage->mt, level,
|
||||
|
|
@ -122,10 +122,9 @@ intel_blit_texsubimage(struct gl_context * ctx,
|
|||
|
||||
if (!_mesa_texstore(ctx, 2, texImage->_BaseFormat,
|
||||
texImage->TexFormat,
|
||||
texImage->Data,
|
||||
xoffset, yoffset, 0,
|
||||
dstRowStride,
|
||||
texImage->ImageOffsets,
|
||||
&dstMap,
|
||||
width, height, 1,
|
||||
format, type, pixels, packing)) {
|
||||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "intelTexSubImage");
|
||||
|
|
@ -136,7 +135,6 @@ intel_blit_texsubimage(struct gl_context * ctx,
|
|||
intelImage->mt->cpp;
|
||||
|
||||
drm_intel_gem_bo_unmap_gtt(temp_bo);
|
||||
texImage->Data = NULL;
|
||||
|
||||
ret = intelEmitCopyBlit(intel,
|
||||
intelImage->mt->cpp,
|
||||
|
|
|
|||
|
|
@ -477,9 +477,9 @@ nouveau_teximage(struct gl_context *ctx, GLint dims, GLenum target, GLint level,
|
|||
0, 0, width, height);
|
||||
|
||||
ret = _mesa_texstore(ctx, dims, ti->_BaseFormat,
|
||||
ti->TexFormat, ti->Data,
|
||||
ti->TexFormat,
|
||||
0, 0, 0, s->pitch,
|
||||
ti->ImageOffsets,
|
||||
(GLubyte **) &ti->Data,
|
||||
width, height, depth,
|
||||
format, type, pixels, packing);
|
||||
assert(ret);
|
||||
|
|
@ -565,8 +565,9 @@ nouveau_texsubimage(struct gl_context *ctx, GLint dims, GLenum target, GLint lev
|
|||
xoffset, yoffset, width, height);
|
||||
|
||||
ret = _mesa_texstore(ctx, 3, ti->_BaseFormat, ti->TexFormat,
|
||||
ti->Data, 0, 0, 0, s->pitch,
|
||||
ti->ImageOffsets, width, height, depth,
|
||||
0, 0, 0, s->pitch,
|
||||
(GLubyte **) &ti->Data,
|
||||
width, height, depth,
|
||||
format, type, pixels, packing);
|
||||
assert(ret);
|
||||
|
||||
|
|
|
|||
|
|
@ -785,11 +785,19 @@ static void radeon_store_teximage(struct gl_context* ctx, int dims,
|
|||
copy_rows(img_start, dstRowStride, pixels, srcRowStride, rows, bytesPerRow);
|
||||
}
|
||||
else {
|
||||
GLubyte *slices[512];
|
||||
GLuint texelBytes = _mesa_get_format_bytes(texImage->TexFormat);
|
||||
GLuint i;
|
||||
assert(depth <= 512);
|
||||
for (i = 0; i < depth; i++) {
|
||||
slices[i] = (GLubyte *) texImage->Data
|
||||
+ dstImageOffsets[i] * texelBytes;
|
||||
}
|
||||
if (!_mesa_texstore(ctx, dims, texImage->_BaseFormat,
|
||||
texImage->TexFormat, texImage->Data,
|
||||
texImage->TexFormat,
|
||||
xoffset, yoffset, zoffset,
|
||||
dstRowStride,
|
||||
dstImageOffsets,
|
||||
slices,
|
||||
width, height, depth,
|
||||
format, type, pixels, packing)) {
|
||||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage");
|
||||
|
|
|
|||
|
|
@ -72,7 +72,6 @@ _mesa_texstore_rgb_fxt1(TEXSTORE_PARAMS)
|
|||
ASSERT(dstYoffset % 4 == 0);
|
||||
ASSERT(dstZoffset == 0);
|
||||
(void) dstZoffset;
|
||||
(void) dstImageOffsets;
|
||||
|
||||
if (srcFormat != GL_RGB ||
|
||||
srcType != GL_UNSIGNED_BYTE ||
|
||||
|
|
@ -99,7 +98,7 @@ _mesa_texstore_rgb_fxt1(TEXSTORE_PARAMS)
|
|||
|
||||
dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
|
||||
dstFormat,
|
||||
texWidth, (GLubyte *) dstAddr);
|
||||
texWidth, dstSlices[0]);
|
||||
|
||||
fxt1_encode(srcWidth, srcHeight, 3, pixels, srcRowStride,
|
||||
dst, dstRowStride);
|
||||
|
|
@ -128,7 +127,6 @@ _mesa_texstore_rgba_fxt1(TEXSTORE_PARAMS)
|
|||
ASSERT(dstYoffset % 4 == 0);
|
||||
ASSERT(dstZoffset == 0);
|
||||
(void) dstZoffset;
|
||||
(void) dstImageOffsets;
|
||||
|
||||
if (srcFormat != GL_RGBA ||
|
||||
srcType != GL_UNSIGNED_BYTE ||
|
||||
|
|
@ -155,7 +153,7 @@ _mesa_texstore_rgba_fxt1(TEXSTORE_PARAMS)
|
|||
|
||||
dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
|
||||
dstFormat,
|
||||
texWidth, (GLubyte *) dstAddr);
|
||||
texWidth, dstSlices[0]);
|
||||
|
||||
fxt1_encode(srcWidth, srcHeight, 4, pixels, srcRowStride,
|
||||
dst, dstRowStride);
|
||||
|
|
|
|||
|
|
@ -106,7 +106,6 @@ _mesa_texstore_red_rgtc1(TEXSTORE_PARAMS)
|
|||
ASSERT(dstYoffset % 4 == 0);
|
||||
ASSERT(dstZoffset % 4 == 0);
|
||||
(void) dstZoffset;
|
||||
(void) dstImageOffsets;
|
||||
|
||||
|
||||
tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
|
||||
|
|
@ -120,7 +119,7 @@ _mesa_texstore_red_rgtc1(TEXSTORE_PARAMS)
|
|||
|
||||
dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
|
||||
dstFormat,
|
||||
texWidth, (GLubyte *) dstAddr);
|
||||
texWidth, dstSlices[0]);
|
||||
|
||||
blkaddr = dst;
|
||||
dstRowDiff = dstRowStride >= (srcWidth * 2) ? dstRowStride - (((srcWidth + 3) & ~3) * 2) : 0;
|
||||
|
|
@ -162,7 +161,6 @@ _mesa_texstore_signed_red_rgtc1(TEXSTORE_PARAMS)
|
|||
ASSERT(dstYoffset % 4 == 0);
|
||||
ASSERT(dstZoffset % 4 == 0);
|
||||
(void) dstZoffset;
|
||||
(void) dstImageOffsets;
|
||||
|
||||
tempImage = _mesa_make_temp_float_image(ctx, dims,
|
||||
baseInternalFormat,
|
||||
|
|
@ -175,7 +173,7 @@ _mesa_texstore_signed_red_rgtc1(TEXSTORE_PARAMS)
|
|||
|
||||
dst = (GLbyte *)_mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
|
||||
dstFormat,
|
||||
texWidth, (GLubyte *) dstAddr);
|
||||
texWidth, dstSlices[0]);
|
||||
|
||||
blkaddr = dst;
|
||||
dstRowDiff = dstRowStride >= (srcWidth * 2) ? dstRowStride - (((srcWidth + 3) & ~3) * 2) : 0;
|
||||
|
|
@ -218,7 +216,6 @@ _mesa_texstore_rg_rgtc2(TEXSTORE_PARAMS)
|
|||
ASSERT(dstYoffset % 4 == 0);
|
||||
ASSERT(dstZoffset % 4 == 0);
|
||||
(void) dstZoffset;
|
||||
(void) dstImageOffsets;
|
||||
|
||||
tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
|
||||
baseInternalFormat,
|
||||
|
|
@ -231,7 +228,7 @@ _mesa_texstore_rg_rgtc2(TEXSTORE_PARAMS)
|
|||
|
||||
dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
|
||||
dstFormat,
|
||||
texWidth, (GLubyte *) dstAddr);
|
||||
texWidth, dstSlices[0]);
|
||||
|
||||
blkaddr = dst;
|
||||
dstRowDiff = dstRowStride >= (srcWidth * 4) ? dstRowStride - (((srcWidth + 3) & ~3) * 4) : 0;
|
||||
|
|
@ -280,7 +277,6 @@ _mesa_texstore_signed_rg_rgtc2(TEXSTORE_PARAMS)
|
|||
ASSERT(dstYoffset % 4 == 0);
|
||||
ASSERT(dstZoffset % 4 == 0);
|
||||
(void) dstZoffset;
|
||||
(void) dstImageOffsets;
|
||||
|
||||
tempImage = _mesa_make_temp_float_image(ctx, dims,
|
||||
baseInternalFormat,
|
||||
|
|
@ -293,7 +289,7 @@ _mesa_texstore_signed_rg_rgtc2(TEXSTORE_PARAMS)
|
|||
|
||||
dst = (GLbyte *)_mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
|
||||
dstFormat,
|
||||
texWidth, (GLubyte *) dstAddr);
|
||||
texWidth, dstSlices[0]);
|
||||
|
||||
blkaddr = dst;
|
||||
dstRowDiff = dstRowStride >= (srcWidth * 4) ? dstRowStride - (((srcWidth + 3) & ~3) * 4) : 0;
|
||||
|
|
|
|||
|
|
@ -174,7 +174,6 @@ _mesa_texstore_rgb_dxt1(TEXSTORE_PARAMS)
|
|||
ASSERT(dstYoffset % 4 == 0);
|
||||
ASSERT(dstZoffset % 4 == 0);
|
||||
(void) dstZoffset;
|
||||
(void) dstImageOffsets;
|
||||
|
||||
if (srcFormat != GL_RGB ||
|
||||
srcType != GL_UNSIGNED_BYTE ||
|
||||
|
|
@ -198,7 +197,7 @@ _mesa_texstore_rgb_dxt1(TEXSTORE_PARAMS)
|
|||
|
||||
dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
|
||||
dstFormat,
|
||||
texWidth, (GLubyte *) dstAddr);
|
||||
texWidth, dstSlices[0]);
|
||||
|
||||
if (ext_tx_compress_dxtn) {
|
||||
(*ext_tx_compress_dxtn)(3, srcWidth, srcHeight, pixels,
|
||||
|
|
@ -233,7 +232,6 @@ _mesa_texstore_rgba_dxt1(TEXSTORE_PARAMS)
|
|||
ASSERT(dstYoffset % 4 == 0);
|
||||
ASSERT(dstZoffset % 4 == 0);
|
||||
(void) dstZoffset;
|
||||
(void) dstImageOffsets;
|
||||
|
||||
if (srcFormat != GL_RGBA ||
|
||||
srcType != GL_UNSIGNED_BYTE ||
|
||||
|
|
@ -257,7 +255,7 @@ _mesa_texstore_rgba_dxt1(TEXSTORE_PARAMS)
|
|||
|
||||
dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
|
||||
dstFormat,
|
||||
texWidth, (GLubyte *) dstAddr);
|
||||
texWidth, dstSlices[0]);
|
||||
if (ext_tx_compress_dxtn) {
|
||||
(*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels,
|
||||
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
|
||||
|
|
@ -291,7 +289,6 @@ _mesa_texstore_rgba_dxt3(TEXSTORE_PARAMS)
|
|||
ASSERT(dstYoffset % 4 == 0);
|
||||
ASSERT(dstZoffset % 4 == 0);
|
||||
(void) dstZoffset;
|
||||
(void) dstImageOffsets;
|
||||
|
||||
if (srcFormat != GL_RGBA ||
|
||||
srcType != GL_UNSIGNED_BYTE ||
|
||||
|
|
@ -314,7 +311,7 @@ _mesa_texstore_rgba_dxt3(TEXSTORE_PARAMS)
|
|||
|
||||
dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
|
||||
dstFormat,
|
||||
texWidth, (GLubyte *) dstAddr);
|
||||
texWidth, dstSlices[0]);
|
||||
if (ext_tx_compress_dxtn) {
|
||||
(*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels,
|
||||
GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
|
||||
|
|
@ -348,7 +345,6 @@ _mesa_texstore_rgba_dxt5(TEXSTORE_PARAMS)
|
|||
ASSERT(dstYoffset % 4 == 0);
|
||||
ASSERT(dstZoffset % 4 == 0);
|
||||
(void) dstZoffset;
|
||||
(void) dstImageOffsets;
|
||||
|
||||
if (srcFormat != GL_RGBA ||
|
||||
srcType != GL_UNSIGNED_BYTE ||
|
||||
|
|
@ -371,7 +367,7 @@ _mesa_texstore_rgba_dxt5(TEXSTORE_PARAMS)
|
|||
|
||||
dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
|
||||
dstFormat,
|
||||
texWidth, (GLubyte *) dstAddr);
|
||||
texWidth, dstSlices[0]);
|
||||
if (ext_tx_compress_dxtn) {
|
||||
(*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels,
|
||||
GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -45,10 +45,9 @@
|
|||
* \param dims either 1 or 2 or 3
|
||||
* \param baseInternalFormat user-specified base internal format
|
||||
* \param dstFormat destination Mesa texture format
|
||||
* \param dstAddr destination image address
|
||||
* \param dstX/Y/Zoffset destination x/y/z offset (ala TexSubImage), in texels
|
||||
* \param dstRowStride destination image row stride, in bytes
|
||||
* \param dstImageOffsets offset of each 2D slice within 3D texture, in texels
|
||||
* \param dstSlices array of addresses of image slices (for 3D, array texture)
|
||||
* \param srcWidth/Height/Depth source image size, in pixels
|
||||
* \param srcFormat incoming image format
|
||||
* \param srcType incoming image data type
|
||||
|
|
@ -59,9 +58,9 @@
|
|||
struct gl_context *ctx, GLuint dims, \
|
||||
GLenum baseInternalFormat, \
|
||||
gl_format dstFormat, \
|
||||
GLvoid *dstAddr, \
|
||||
GLint dstXoffset, GLint dstYoffset, GLint dstZoffset, \
|
||||
GLint dstRowStride, const GLuint *dstImageOffsets, \
|
||||
GLint dstRowStride, \
|
||||
GLubyte **dstSlices, \
|
||||
GLint srcWidth, GLint srcHeight, GLint srcDepth, \
|
||||
GLenum srcFormat, GLenum srcType, \
|
||||
const GLvoid *srcAddr, \
|
||||
|
|
|
|||
|
|
@ -494,7 +494,6 @@ make_texture(struct st_context *st,
|
|||
|
||||
{
|
||||
struct pipe_transfer *transfer;
|
||||
static const GLuint dstImageOffsets = 0;
|
||||
GLboolean success;
|
||||
GLubyte *dest;
|
||||
const GLbitfield imageTransferStateSave = ctx->_ImageTransferState;
|
||||
|
|
@ -517,10 +516,9 @@ make_texture(struct st_context *st,
|
|||
success = _mesa_texstore(ctx, 2, /* dims */
|
||||
baseInternalFormat, /* baseInternalFormat */
|
||||
mformat, /* gl_format */
|
||||
dest, /* dest */
|
||||
0, 0, 0, /* dstX/Y/Zoffset */
|
||||
transfer->stride, /* dstRowStride, bytes */
|
||||
&dstImageOffsets, /* dstImageOffsets */
|
||||
&dest, /* destSlices */
|
||||
width, height, 1, /* size */
|
||||
format, type, /* src format/type */
|
||||
pixels, /* data source */
|
||||
|
|
|
|||
|
|
@ -803,10 +803,9 @@ st_TexImage(struct gl_context * ctx,
|
|||
if (!_mesa_texstore(ctx, dims,
|
||||
texImage->_BaseFormat,
|
||||
texImage->TexFormat,
|
||||
texImage->Data,
|
||||
0, 0, 0, /* dstX/Y/Zoffset */
|
||||
dstRowStride,
|
||||
texImage->ImageOffsets,
|
||||
(GLubyte **) &texImage->Data, /* dstSlice */
|
||||
width, height, 1,
|
||||
format, type, src, unpack)) {
|
||||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage");
|
||||
|
|
@ -1091,10 +1090,9 @@ st_TexSubimage(struct gl_context *ctx, GLint dims, GLenum target, GLint level,
|
|||
for (i = 0; i < depth; i++) {
|
||||
if (!_mesa_texstore(ctx, dims, texImage->_BaseFormat,
|
||||
texImage->TexFormat,
|
||||
texImage->Data,
|
||||
0, 0, 0,
|
||||
dstRowStride,
|
||||
texImage->ImageOffsets,
|
||||
(GLubyte **) &texImage->Data,
|
||||
width, height, 1,
|
||||
format, type, src, packing)) {
|
||||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage");
|
||||
|
|
@ -1356,10 +1354,9 @@ fallback_copy_texsubimage(struct gl_context *ctx, GLenum target, GLint level,
|
|||
_mesa_texstore(ctx, dims,
|
||||
texImage->_BaseFormat,
|
||||
texImage->TexFormat,
|
||||
texDest,
|
||||
0, 0, 0,
|
||||
dstRowStride,
|
||||
texImage->ImageOffsets,
|
||||
(GLubyte **) &texDest,
|
||||
width, height, 1,
|
||||
GL_RGBA, GL_FLOAT, tempSrc, /* src */
|
||||
&unpack);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue