summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Olšák <marek.olsak@amd.com>2023-01-17 14:37:03 -0500
committerMarek Olšák <marek.olsak@amd.com>2023-01-20 21:34:09 -0500
commite39b90311cadf5efa9016c8521e616087b9f1025 (patch)
treed3521835f09bba0a2f2c8583919d9499fff0bf31
parent777166cc66c7330e66e493ee804d32d1f87d297a (diff)
glthread: set GL_OUT_OF_MEMORY if we fail to upload indices
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20824>
-rw-r--r--src/mesa/main/glthread_draw.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/mesa/main/glthread_draw.c b/src/mesa/main/glthread_draw.c
index b77e0b3cb5d..a89c6b2c2d2 100644
--- a/src/mesa/main/glthread_draw.c
+++ b/src/mesa/main/glthread_draw.c
@@ -71,9 +71,11 @@ upload_indices(struct gl_context *ctx, unsigned count, unsigned index_size,
_mesa_glthread_upload(ctx, *indices, index_size * count,
&upload_offset, &upload_buffer, NULL, 0);
- assert(upload_buffer);
*indices = (const GLvoid*)(intptr_t)upload_offset;
+ if (!upload_buffer)
+ _mesa_marshal_InternalSetError(GL_OUT_OF_MEMORY);
+
return upload_buffer;
}
@@ -91,7 +93,10 @@ upload_multi_indices(struct gl_context *ctx, unsigned total_count,
_mesa_glthread_upload(ctx, NULL, index_size * total_count,
&upload_offset, &upload_buffer, &upload_ptr, 0);
- assert(upload_buffer);
+ if (!upload_buffer) {
+ _mesa_marshal_InternalSetError(GL_OUT_OF_MEMORY);
+ return NULL;
+ }
for (unsigned i = 0, offset = 0; i < draw_count; i++) {
if (count[i] == 0)
@@ -940,15 +945,18 @@ draw_elements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices,
goto sync;
struct glthread_attrib_binding buffers[VERT_ATTRIB_MAX];
- if (user_buffer_mask &&
- !upload_vertices(ctx, user_buffer_mask, start_vertex, num_vertices,
- baseinstance, instance_count, buffers))
- goto sync;
+ if (user_buffer_mask) {
+ upload_vertices(ctx, user_buffer_mask, start_vertex, num_vertices,
+ baseinstance, instance_count, buffers);
+ }
/* Upload indices. */
struct gl_buffer_object *index_buffer = NULL;
- if (has_user_indices)
+ if (has_user_indices) {
index_buffer = upload_indices(ctx, count, index_size, &indices);
+ if (!index_buffer)
+ return; /* the error is set by upload_indices */
+ }
/* Draw asynchronously. */
draw_elements_async_user(ctx, mode, count, type, indices, instance_count,
@@ -1224,6 +1232,9 @@ _mesa_marshal_MultiDrawElementsBaseVertex(GLenum mode, const GLsizei *count,
index_buffer = upload_multi_indices(ctx, total_count, index_size,
draw_count, count, indices,
out_indices);
+ if (!index_buffer)
+ return; /* the error is set by upload_multi_indices */
+
indices = out_indices;
}