* or all live in user space.
* \param vbuffer returns vertex buffer info
* \param velements returns vertex element info
+ * \return GL_TRUE for success, GL_FALSE otherwise (probably out of memory)
*/
-static void
+static GLboolean
setup_interleaved_attribs(struct gl_context *ctx,
const struct st_vertex_program *vp,
const struct st_vp_variant *vpv,
/* all interleaved arrays in a VBO */
struct st_buffer_object *stobj = st_buffer_object(bufobj);
+ if (!stobj) {
+ /* probably out of memory */
+ return GL_FALSE;
+ }
+
vbuffer->buffer = NULL;
pipe_resource_reference(&vbuffer->buffer, stobj->buffer);
vbuffer->buffer_offset = pointer_to_offset(low_addr);
st->user_attrib[0].stride = stride;
st->num_user_attribs = 1;
}
+
+ return GL_TRUE;
}
* vertex attribute.
* \param vbuffer returns vertex buffer info
* \param velements returns vertex element info
+ * \return GL_TRUE for success, GL_FALSE otherwise (probably out of memory)
*/
-static void
+static GLboolean
setup_non_interleaved_attribs(struct gl_context *ctx,
const struct st_vertex_program *vp,
const struct st_vp_variant *vpv,
* really an offset from the start of the VBO, not a pointer.
*/
struct st_buffer_object *stobj = st_buffer_object(bufobj);
- assert(stobj->buffer);
+
+ if (!stobj || !stobj->buffer) {
+ /* probably ran out of memory */
+ return GL_FALSE;
+ }
vbuffer[attr].buffer = NULL;
pipe_resource_reference(&vbuffer[attr].buffer, stobj->buffer);
st->user_attrib[attr].element_size = element_size;
st->user_attrib[attr].stride = stride;
st->num_user_attribs = MAX2(st->num_user_attribs, attr + 1);
+
+ if (!vbuffer[attr].buffer) {
+ /* probably ran out of memory */
+ return GL_FALSE;
+ }
}
/* common-case setup */
array->Normalized);
assert(velements[attr].src_format);
}
+
+ return GL_TRUE;
}
}
-static void
+/**
+ * Setup vertex arrays and buffers prior to drawing.
+ * \return GL_TRUE for success, GL_FALSE otherwise (probably out of memory)
+ */
+static GLboolean
st_validate_varrays(struct gl_context *ctx,
const struct gl_client_array **arrays,
unsigned max_index,
* Setup the vbuffer[] and velements[] arrays.
*/
if (is_interleaved_arrays(vp, vpv, arrays)) {
- setup_interleaved_attribs(ctx, vp, vpv, arrays, vbuffer, velements,
- max_index, num_instances);
+ if (!setup_interleaved_attribs(ctx, vp, vpv, arrays, vbuffer, velements,
+ max_index, num_instances)) {
+ return GL_FALSE;
+ }
num_vbuffers = 1;
num_velements = vpv->num_inputs;
num_vbuffers = 0;
}
else {
- setup_non_interleaved_attribs(ctx, vp, vpv, arrays,
- vbuffer, velements, max_index,
- num_instances);
+ if (!setup_non_interleaved_attribs(ctx, vp, vpv, arrays,
+ vbuffer, velements, max_index,
+ num_instances)) {
+ return GL_FALSE;
+ }
+
num_vbuffers = vpv->num_inputs;
num_velements = vpv->num_inputs;
}
pipe_resource_reference(&vbuffer[attr].buffer, NULL);
assert(!vbuffer[attr].buffer);
}
+
+ return GL_TRUE;
}
st_validate_state(st);
if (new_array) {
- st_validate_varrays(ctx, arrays, max_index, num_instances);
+ if (!st_validate_varrays(ctx, arrays, max_index, num_instances)) {
+ /* probably out of memory, no-op the draw call */
+ return;
+ }
}
#if 0