#include "pipe/p_context.h"
#include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "pipe/p_shader_tokens.h"
#include "util/u_tile.h"
#include "util/u_blit.h"
_mesa_align_free(texImage->Data);
}
- if (width == 0 || height == 0 || depth == 0) {
- /* stop after freeing old image */
- return;
- }
-
- /* If this is the only mipmap level in the texture, could call
- * bmBufferData with NULL data to free the old block and avoid
- * waiting on any outstanding fences.
+ /*
+ * See if the new image is somehow incompatible with the existing
+ * mipmap. If so, free the old mipmap.
*/
if (stObj->pt) {
if (stObj->teximage_realloc ||
level > (GLint) stObj->pt->last_level ||
- (stObj->pt->last_level == level &&
- stObj->pt->target != PIPE_TEXTURE_CUBE &&
- !st_texture_match_image(stObj->pt, &stImage->base,
- stImage->face, stImage->level))) {
+ !st_texture_match_image(stObj->pt, &stImage->base,
+ stImage->face, stImage->level)) {
DBG("release it\n");
pipe_texture_reference(&stObj->pt, NULL);
assert(!stObj->pt);
}
}
+ if (width == 0 || height == 0 || depth == 0) {
+ /* stop after freeing old image */
+ return;
+ }
+
if (!stObj->pt) {
guess_and_alloc_texture(ctx->st, stObj, stImage);
if (!stObj->pt) {
{
char *dst = texImage->Data;
const char *src = pixels;
- int i;
+ GLuint i, bw, bh, lines;
+ _mesa_get_format_block_size(texImage->TexFormat, &bw, &bh);
+ lines = (height + bh - 1) / bh;
- for(i = 0; i < height; ++i)
+ for(i = 0; i < lines; ++i)
{
memcpy(dst, src, srcImageStride);
dst += dstRowStride;
_mesa_unmap_pbo_dest(ctx, &ctx->Pack);
+ screen->tex_transfer_destroy(tex_xfer);
+
/* destroy the temp / dest surface */
util_destroy_rgba_surface(dst_texture, dst_surface);
}
else {
/* RGBA format */
GLfloat *tempSrc =
- (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat));
+ (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
if (tempSrc && texDest) {
const GLint dims = 2;
}
if (tempSrc)
- _mesa_free(tempSrc);
+ free(tempSrc);
}
st_texture_image_unmap(ctx->st, stImage);
st_texture_image_copy(st->pipe,
stObj->pt, dstLevel, /* dest texture, level */
stImage->pt, /* src texture */
- stImage->face
- );
+ stImage->face);
pipe_texture_reference(&stImage->pt, NULL);
}
else if (stImage->base.Data) {
/* More straightforward upload.
*/
-
st_teximage_flush_before_map(st, stObj->pt, stImage->face, dstLevel,
PIPE_TRANSFER_WRITE);
-
st_texture_image_data(st,
stObj->pt,
stImage->face,