vc4: Return GL_OUT_OF_MEMORY when buffer allocation fails.
I was afraid our callers weren't prepared for this, but it looks like at least for resource creation, mesa/st throws an error appropriately. Cc: "11.0" <mesa-stable@lists.freedesktop.org>
This commit is contained in:
@@ -168,8 +168,9 @@ retry:
|
|||||||
vc4_bo_cache_free_all(&screen->bo_cache);
|
vc4_bo_cache_free_all(&screen->bo_cache);
|
||||||
goto retry;
|
goto retry;
|
||||||
}
|
}
|
||||||
fprintf(stderr, "create ioctl failure\n");
|
|
||||||
abort();
|
free(bo);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
screen->bo_count++;
|
screen->bo_count++;
|
||||||
|
@@ -35,11 +35,12 @@
|
|||||||
|
|
||||||
static bool miptree_debug = false;
|
static bool miptree_debug = false;
|
||||||
|
|
||||||
static void
|
static bool
|
||||||
vc4_resource_bo_alloc(struct vc4_resource *rsc)
|
vc4_resource_bo_alloc(struct vc4_resource *rsc)
|
||||||
{
|
{
|
||||||
struct pipe_resource *prsc = &rsc->base.b;
|
struct pipe_resource *prsc = &rsc->base.b;
|
||||||
struct pipe_screen *pscreen = prsc->screen;
|
struct pipe_screen *pscreen = prsc->screen;
|
||||||
|
struct vc4_bo *bo;
|
||||||
|
|
||||||
if (miptree_debug) {
|
if (miptree_debug) {
|
||||||
fprintf(stderr, "alloc %p: size %d + offset %d -> %d\n",
|
fprintf(stderr, "alloc %p: size %d + offset %d -> %d\n",
|
||||||
@@ -51,12 +52,18 @@ vc4_resource_bo_alloc(struct vc4_resource *rsc)
|
|||||||
rsc->cube_map_stride * (prsc->array_size - 1));
|
rsc->cube_map_stride * (prsc->array_size - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
vc4_bo_unreference(&rsc->bo);
|
bo = vc4_bo_alloc(vc4_screen(pscreen),
|
||||||
rsc->bo = vc4_bo_alloc(vc4_screen(pscreen),
|
rsc->slices[0].offset +
|
||||||
rsc->slices[0].offset +
|
rsc->slices[0].size +
|
||||||
rsc->slices[0].size +
|
rsc->cube_map_stride * (prsc->array_size - 1),
|
||||||
rsc->cube_map_stride * (prsc->array_size - 1),
|
"resource");
|
||||||
"resource");
|
if (bo) {
|
||||||
|
vc4_bo_unreference(&rsc->bo);
|
||||||
|
rsc->bo = bo;
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -101,21 +108,27 @@ vc4_resource_transfer_map(struct pipe_context *pctx,
|
|||||||
char *buf;
|
char *buf;
|
||||||
|
|
||||||
if (usage & PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE) {
|
if (usage & PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE) {
|
||||||
vc4_resource_bo_alloc(rsc);
|
if (vc4_resource_bo_alloc(rsc)) {
|
||||||
|
|
||||||
/* If it might be bound as one of our vertex buffers, make
|
/* If it might be bound as one of our vertex buffers,
|
||||||
* sure we re-emit vertex buffer state.
|
* make sure we re-emit vertex buffer state.
|
||||||
*/
|
*/
|
||||||
if (prsc->bind & PIPE_BIND_VERTEX_BUFFER)
|
if (prsc->bind & PIPE_BIND_VERTEX_BUFFER)
|
||||||
vc4->dirty |= VC4_DIRTY_VTXBUF;
|
vc4->dirty |= VC4_DIRTY_VTXBUF;
|
||||||
|
} else {
|
||||||
|
/* If we failed to reallocate, flush everything so
|
||||||
|
* that we don't violate any syncing requirements.
|
||||||
|
*/
|
||||||
|
vc4_flush(pctx);
|
||||||
|
}
|
||||||
} else if (!(usage & PIPE_TRANSFER_UNSYNCHRONIZED)) {
|
} else if (!(usage & PIPE_TRANSFER_UNSYNCHRONIZED)) {
|
||||||
if (vc4_cl_references_bo(pctx, rsc->bo)) {
|
if (vc4_cl_references_bo(pctx, rsc->bo)) {
|
||||||
if ((usage & PIPE_TRANSFER_DISCARD_RANGE) &&
|
if ((usage & PIPE_TRANSFER_DISCARD_RANGE) &&
|
||||||
prsc->last_level == 0 &&
|
prsc->last_level == 0 &&
|
||||||
prsc->width0 == box->width &&
|
prsc->width0 == box->width &&
|
||||||
prsc->height0 == box->height &&
|
prsc->height0 == box->height &&
|
||||||
prsc->depth0 == box->depth) {
|
prsc->depth0 == box->depth &&
|
||||||
vc4_resource_bo_alloc(rsc);
|
vc4_resource_bo_alloc(rsc)) {
|
||||||
if (prsc->bind & PIPE_BIND_VERTEX_BUFFER)
|
if (prsc->bind & PIPE_BIND_VERTEX_BUFFER)
|
||||||
vc4->dirty |= VC4_DIRTY_VTXBUF;
|
vc4->dirty |= VC4_DIRTY_VTXBUF;
|
||||||
} else {
|
} else {
|
||||||
@@ -389,8 +402,7 @@ vc4_resource_create(struct pipe_screen *pscreen,
|
|||||||
rsc->vc4_format = get_resource_texture_format(prsc);
|
rsc->vc4_format = get_resource_texture_format(prsc);
|
||||||
|
|
||||||
vc4_setup_slices(rsc);
|
vc4_setup_slices(rsc);
|
||||||
vc4_resource_bo_alloc(rsc);
|
if (!vc4_resource_bo_alloc(rsc))
|
||||||
if (!rsc->bo)
|
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
return prsc;
|
return prsc;
|
||||||
|
Reference in New Issue
Block a user