mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 13:48:06 +02:00
st/mesa: fix texture memory allocation bug
The following example caused an incorrect GL_OUT_OF_MEMORY error to be raised in glTexSubImage2D: glTexImage2D(level=0, width=32, height=32, pixels=NULL); glTexImage2D(level=0, width=64, height=64, pixels=NULL); glTexSubImage2D(level=0, pixels!=NULL); The second glTexImage2D() call needs to cause the first image to be deallocated then reallocated at the new size. This was not happening because we were testing for pixels==NULL too early.
This commit is contained in:
parent
2921a2555d
commit
cfa1a0a609
1 changed files with 10 additions and 2 deletions
|
|
@ -661,8 +661,10 @@ st_TexImage(GLcontext * ctx,
|
|||
format, type,
|
||||
pixels, unpack, "glTexImage");
|
||||
}
|
||||
if (!pixels)
|
||||
return;
|
||||
|
||||
/* Note: we can't check for pixels==NULL until after we've allocated
|
||||
* memory for the texture.
|
||||
*/
|
||||
|
||||
/* See if we can do texture compression with a blit/render.
|
||||
*/
|
||||
|
|
@ -673,6 +675,9 @@ st_TexImage(GLcontext * ctx,
|
|||
stImage->pt->format,
|
||||
stImage->pt->target,
|
||||
PIPE_TEXTURE_USAGE_RENDER_TARGET, 0)) {
|
||||
if (!pixels)
|
||||
goto done;
|
||||
|
||||
if (compress_with_blit(ctx, target, level, 0, 0, 0, width, height, depth,
|
||||
format, type, pixels, unpack, texImage)) {
|
||||
goto done;
|
||||
|
|
@ -714,6 +719,9 @@ st_TexImage(GLcontext * ctx,
|
|||
return;
|
||||
}
|
||||
|
||||
if (!pixels)
|
||||
goto done;
|
||||
|
||||
DBG("Upload image %dx%dx%d row_len %x pitch %x\n",
|
||||
width, height, depth, width * texelBytes, dstRowStride);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue