gallium: fix out of tex memory crashes
This commit is contained in:
@@ -645,7 +645,8 @@ st_TexImage(GLcontext * ctx,
|
|||||||
if (stImage->pt) {
|
if (stImage->pt) {
|
||||||
texImage->Data = st_texture_image_map(ctx->st, stImage, 0,
|
texImage->Data = st_texture_image_map(ctx->st, stImage, 0,
|
||||||
PIPE_BUFFER_USAGE_CPU_WRITE);
|
PIPE_BUFFER_USAGE_CPU_WRITE);
|
||||||
dstRowStride = stImage->surface->pitch * stImage->surface->cpp;
|
if (stImage->surface)
|
||||||
|
dstRowStride = stImage->surface->pitch * stImage->surface->cpp;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* Allocate regular memory and store the image there temporarily. */
|
/* Allocate regular memory and store the image there temporarily. */
|
||||||
@@ -663,6 +664,11 @@ st_TexImage(GLcontext * ctx,
|
|||||||
texImage->Data = malloc(sizeInBytes);
|
texImage->Data = malloc(sizeInBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!texImage->Data) {
|
||||||
|
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
DBG("Upload image %dx%dx%d row_len %x pitch %x\n",
|
DBG("Upload image %dx%dx%d row_len %x pitch %x\n",
|
||||||
width, height, depth, width * texelBytes, dstRowStride);
|
width, height, depth, width * texelBytes, dstRowStride);
|
||||||
|
|
||||||
@@ -906,7 +912,8 @@ st_TexSubimage(GLcontext * ctx,
|
|||||||
if (stImage->pt) {
|
if (stImage->pt) {
|
||||||
texImage->Data = st_texture_image_map(ctx->st, stImage, zoffset,
|
texImage->Data = st_texture_image_map(ctx->st, stImage, zoffset,
|
||||||
PIPE_BUFFER_USAGE_CPU_WRITE);
|
PIPE_BUFFER_USAGE_CPU_WRITE);
|
||||||
dstRowStride = stImage->surface->pitch * stImage->surface->cpp;
|
if (stImage->surface)
|
||||||
|
dstRowStride = stImage->surface->pitch * stImage->surface->cpp;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!texImage->Data) {
|
if (!texImage->Data) {
|
||||||
|
@@ -197,7 +197,10 @@ st_texture_image_map(struct st_context *st, struct st_texture_image *stImage,
|
|||||||
stImage->level, zoffset,
|
stImage->level, zoffset,
|
||||||
flags);
|
flags);
|
||||||
|
|
||||||
return screen->surface_map(screen, stImage->surface, flags);
|
if (stImage->surface)
|
||||||
|
return screen->surface_map(screen, stImage->surface, flags);
|
||||||
|
else
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user