mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-03 13:40:11 +01:00
mesa: Remove unnecessary parameters from AllocTextureImageBuffer
Size and format information is always stored in gl_texture_image structure. That makes it preferable to remove duplicate information from parameters to make interface easier to understand. Signed-off-by: Pauli Nieminen <pauli.nieminen@linux.intel.com> Reviewed-by: Brian Paul <brianp@vmware.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
parent
c5af889180
commit
c9a7dfcf92
9 changed files with 29 additions and 56 deletions
|
|
@ -51,9 +51,7 @@ intelDeleteTextureObject(struct gl_context *ctx,
|
|||
|
||||
static GLboolean
|
||||
intel_alloc_texture_image_buffer(struct gl_context *ctx,
|
||||
struct gl_texture_image *image,
|
||||
gl_format format, GLsizei width,
|
||||
GLsizei height, GLsizei depth)
|
||||
struct gl_texture_image *image)
|
||||
{
|
||||
struct intel_context *intel = intel_context(ctx);
|
||||
struct intel_texture_image *intel_image = intel_texture_image(image);
|
||||
|
|
@ -84,14 +82,14 @@ intel_alloc_texture_image_buffer(struct gl_context *ctx,
|
|||
assert(!intel_image->base.ImageOffsets);
|
||||
intel_image->base.ImageOffsets = malloc(slices * sizeof(GLuint));
|
||||
|
||||
_swrast_init_texture_image(image, width, height, depth);
|
||||
_swrast_init_texture_image(image);
|
||||
|
||||
if (intel_texobj->mt &&
|
||||
intel_miptree_match_image(intel_texobj->mt, image)) {
|
||||
intel_miptree_reference(&intel_image->mt, intel_texobj->mt);
|
||||
DBG("%s: alloc obj %p level %d %dx%dx%d using object's miptree %p\n",
|
||||
__FUNCTION__, texobj, image->Level,
|
||||
width, height, depth, intel_texobj->mt);
|
||||
image->Width, image->Height, image->Depth, intel_texobj->mt);
|
||||
} else {
|
||||
intel_image->mt = intel_miptree_create_for_teximage(intel, intel_texobj,
|
||||
intel_image,
|
||||
|
|
@ -106,7 +104,7 @@ intel_alloc_texture_image_buffer(struct gl_context *ctx,
|
|||
|
||||
DBG("%s: alloc obj %p level %d %dx%dx%d using new miptree %p\n",
|
||||
__FUNCTION__, texobj, image->Level,
|
||||
width, height, depth, intel_image->mt);
|
||||
image->Width, image->Height, image->Depth, intel_image->mt);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -160,8 +160,7 @@ try_pbo_upload(struct gl_context *ctx,
|
|||
return false;
|
||||
}
|
||||
|
||||
ctx->Driver.AllocTextureImageBuffer(ctx, image, image->TexFormat,
|
||||
image->Width, image->Height, 1);
|
||||
ctx->Driver.AllocTextureImageBuffer(ctx, image);
|
||||
|
||||
if (!intelImage->mt) {
|
||||
DBG("%s: no miptree\n", __FUNCTION__);
|
||||
|
|
|
|||
|
|
@ -103,9 +103,7 @@ radeonDeleteTextureImage(struct gl_context *ctx, struct gl_texture_image *img)
|
|||
|
||||
static GLboolean
|
||||
radeonAllocTextureImageBuffer(struct gl_context *ctx,
|
||||
struct gl_texture_image *timage,
|
||||
gl_format format, GLsizei width,
|
||||
GLsizei height, GLsizei depth)
|
||||
struct gl_texture_image *timage)
|
||||
{
|
||||
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
|
||||
radeon_texture_image *image = get_radeon_texture_image(timage);
|
||||
|
|
|
|||
|
|
@ -327,9 +327,7 @@ struct dd_function_table {
|
|||
|
||||
/** Called to allocate memory for a single texture image */
|
||||
GLboolean (*AllocTextureImageBuffer)(struct gl_context *ctx,
|
||||
struct gl_texture_image *texImage,
|
||||
gl_format format, GLsizei width,
|
||||
GLsizei height, GLsizei depth);
|
||||
struct gl_texture_image *texImage);
|
||||
|
||||
/** Free the memory for a single texture image */
|
||||
void (*FreeTextureImageBuffer)(struct gl_context *ctx,
|
||||
|
|
|
|||
|
|
@ -1865,8 +1865,7 @@ _mesa_prepare_mipmap_level(struct gl_context *ctx,
|
|||
width, height, depth,
|
||||
border, intFormat, format);
|
||||
|
||||
ctx->Driver.AllocTextureImageBuffer(ctx, dstImage,
|
||||
format, width, height, depth);
|
||||
ctx->Driver.AllocTextureImageBuffer(ctx, dstImage);
|
||||
|
||||
/* in case the mipmap level is part of an FBO: */
|
||||
_mesa_update_fbo_texture(ctx, texObj, face, level);
|
||||
|
|
|
|||
|
|
@ -4345,9 +4345,7 @@ _mesa_store_teximage(struct gl_context *ctx,
|
|||
return;
|
||||
|
||||
/* allocate storage for texture data */
|
||||
if (!ctx->Driver.AllocTextureImageBuffer(ctx, texImage, texImage->TexFormat,
|
||||
texImage->Width, texImage->Height,
|
||||
texImage->Depth)) {
|
||||
if (!ctx->Driver.AllocTextureImageBuffer(ctx, texImage)) {
|
||||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage%uD", dims);
|
||||
return;
|
||||
}
|
||||
|
|
@ -4402,8 +4400,7 @@ _mesa_store_compressed_teximage(struct gl_context *ctx, GLuint dims,
|
|||
ASSERT(texImage->Depth == 1);
|
||||
|
||||
/* allocate storage for texture data */
|
||||
if (!ctx->Driver.AllocTextureImageBuffer(ctx, texImage, texImage->TexFormat,
|
||||
width, height, 1)) {
|
||||
if (!ctx->Driver.AllocTextureImageBuffer(ctx, texImage)) {
|
||||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D");
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -415,20 +415,18 @@ guess_and_alloc_texture(struct st_context *st,
|
|||
*/
|
||||
static GLboolean
|
||||
st_AllocTextureImageBuffer(struct gl_context *ctx,
|
||||
struct gl_texture_image *texImage,
|
||||
gl_format format, GLsizei width,
|
||||
GLsizei height, GLsizei depth)
|
||||
struct gl_texture_image *texImage)
|
||||
{
|
||||
struct st_context *st = st_context(ctx);
|
||||
struct st_texture_image *stImage = st_texture_image(texImage);
|
||||
struct st_texture_object *stObj = st_texture_object(texImage->TexObject);
|
||||
const GLuint level = texImage->Level;
|
||||
GLuint width = texImage->Width;
|
||||
GLuint height = texImage->Height;
|
||||
GLuint depth = texImage->Depth;
|
||||
|
||||
DBG("%s\n", __FUNCTION__);
|
||||
|
||||
assert(width > 0);
|
||||
assert(height > 0);
|
||||
assert(depth > 0);
|
||||
assert(!stImage->TexData);
|
||||
assert(!stImage->pt); /* xxx this might be wrong */
|
||||
|
||||
|
|
|
|||
|
|
@ -63,40 +63,34 @@ _swrast_delete_texture_image(struct gl_context *ctx,
|
|||
*/
|
||||
GLboolean
|
||||
_swrast_alloc_texture_image_buffer(struct gl_context *ctx,
|
||||
struct gl_texture_image *texImage,
|
||||
gl_format format, GLsizei width,
|
||||
GLsizei height, GLsizei depth)
|
||||
struct gl_texture_image *texImage)
|
||||
{
|
||||
struct swrast_texture_image *swImg = swrast_texture_image(texImage);
|
||||
GLuint bytes = _mesa_format_image_size(format, width, height, depth);
|
||||
GLuint bytes = _mesa_format_image_size(texImage->TexFormat, texImage->Width,
|
||||
texImage->Height, texImage->Depth);
|
||||
GLuint i;
|
||||
|
||||
/* This _should_ be true (revisit if these ever fail) */
|
||||
assert(texImage->Width == width);
|
||||
assert(texImage->Height == height);
|
||||
assert(texImage->Depth == depth);
|
||||
|
||||
assert(!swImg->Buffer);
|
||||
swImg->Buffer = _mesa_align_malloc(bytes, 512);
|
||||
if (!swImg->Buffer)
|
||||
return GL_FALSE;
|
||||
|
||||
/* RowStride and ImageOffsets[] describe how to address texels in 'Data' */
|
||||
swImg->RowStride = width;
|
||||
swImg->RowStride = texImage->Width;
|
||||
|
||||
/* Allocate the ImageOffsets array and initialize to typical values.
|
||||
* We allocate the array for 1D/2D textures too in order to avoid special-
|
||||
* case code in the texstore routines.
|
||||
*/
|
||||
swImg->ImageOffsets = (GLuint *) malloc(depth * sizeof(GLuint));
|
||||
swImg->ImageOffsets = (GLuint *) malloc(texImage->Depth * sizeof(GLuint));
|
||||
if (!swImg->ImageOffsets)
|
||||
return GL_FALSE;
|
||||
|
||||
for (i = 0; i < depth; i++) {
|
||||
swImg->ImageOffsets[i] = i * width * height;
|
||||
for (i = 0; i < texImage->Depth; i++) {
|
||||
swImg->ImageOffsets[i] = i * texImage->Width * texImage->Height;
|
||||
}
|
||||
|
||||
_swrast_init_texture_image(texImage, width, height, depth);
|
||||
_swrast_init_texture_image(texImage);
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
|
@ -110,14 +104,13 @@ _swrast_alloc_texture_image_buffer(struct gl_context *ctx,
|
|||
* Returns GL_TRUE on success, GL_FALSE on memory allocation failure.
|
||||
*/
|
||||
void
|
||||
_swrast_init_texture_image(struct gl_texture_image *texImage, GLsizei width,
|
||||
GLsizei height, GLsizei depth)
|
||||
_swrast_init_texture_image(struct gl_texture_image *texImage)
|
||||
{
|
||||
struct swrast_texture_image *swImg = swrast_texture_image(texImage);
|
||||
|
||||
if ((width == 1 || _mesa_is_pow_two(texImage->Width2)) &&
|
||||
(height == 1 || _mesa_is_pow_two(texImage->Height2)) &&
|
||||
(depth == 1 || _mesa_is_pow_two(texImage->Depth2)))
|
||||
if ((texImage->Width == 1 || _mesa_is_pow_two(texImage->Width2)) &&
|
||||
(texImage->Height == 1 || _mesa_is_pow_two(texImage->Height2)) &&
|
||||
(texImage->Depth == 1 || _mesa_is_pow_two(texImage->Depth2)))
|
||||
swImg->_IsPowerOfTwo = GL_TRUE;
|
||||
else
|
||||
swImg->_IsPowerOfTwo = GL_FALSE;
|
||||
|
|
@ -348,11 +341,7 @@ _swrast_AllocTextureStorage(struct gl_context *ctx,
|
|||
for (face = 0; face < numFaces; face++) {
|
||||
for (level = 0; level < levels; level++) {
|
||||
struct gl_texture_image *texImage = texObj->Image[face][level];
|
||||
if (!_swrast_alloc_texture_image_buffer(ctx, texImage,
|
||||
texImage->TexFormat,
|
||||
texImage->Width,
|
||||
texImage->Height,
|
||||
texImage->Depth)) {
|
||||
if (!_swrast_alloc_texture_image_buffer(ctx, texImage)) {
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -215,13 +215,10 @@ _swrast_delete_texture_image(struct gl_context *ctx,
|
|||
|
||||
extern GLboolean
|
||||
_swrast_alloc_texture_image_buffer(struct gl_context *ctx,
|
||||
struct gl_texture_image *texImage,
|
||||
gl_format format, GLsizei width,
|
||||
GLsizei height, GLsizei depth);
|
||||
struct gl_texture_image *texImage);
|
||||
|
||||
extern void
|
||||
_swrast_init_texture_image(struct gl_texture_image *texImage, GLsizei width,
|
||||
GLsizei height, GLsizei depth);
|
||||
_swrast_init_texture_image(struct gl_texture_image *texImage);
|
||||
|
||||
extern void
|
||||
_swrast_free_texture_image_buffer(struct gl_context *ctx,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue