[Mesa-dev] [PATCH 11/17] st/mesa: fold error handling into setup_(non_)interleaved_attribs
Marek Olšák
maraeo at gmail.com
Mon May 1 12:53:00 UTC 2017
From: Marek Olšák <marek.olsak at amd.com>
---
src/mesa/state_tracker/st_atom_array.c | 28 ++++++++++------------------
1 file changed, 10 insertions(+), 18 deletions(-)
diff --git a/src/mesa/state_tracker/st_atom_array.c b/src/mesa/state_tracker/st_atom_array.c
index 57f0ec1..cb6e355 100644
--- a/src/mesa/state_tracker/st_atom_array.c
+++ b/src/mesa/state_tracker/st_atom_array.c
@@ -441,21 +441,21 @@ set_vertex_attribs(struct st_context *st,
st->last_num_vbuffers = num_vbuffers;
cso_set_vertex_elements(cso, num_velements, velements);
}
/**
* Set up for drawing interleaved arrays that all live in one VBO
* or all live in user space.
* \param vbuffer returns vertex buffer info
* \param velements returns vertex element info
*/
-static boolean
+static void
setup_interleaved_attribs(struct st_context *st,
const struct st_vertex_program *vp,
const struct st_vp_variant *vpv,
const struct gl_vertex_array **arrays)
{
struct pipe_vertex_buffer vbuffer;
struct pipe_vertex_element velements[PIPE_MAX_ATTRIBS] = {{0}};
GLuint attr;
const GLubyte *low_addr = NULL;
GLboolean usingVBO; /* all arrays in a VBO? */
@@ -530,48 +530,48 @@ setup_interleaved_attribs(struct st_context *st,
vbuffer.buffer.resource = NULL;
vbuffer.is_user_buffer = false;
vbuffer.buffer_offset = 0;
vbuffer.stride = 0;
}
else if (usingVBO) {
/* all interleaved arrays in a VBO */
struct st_buffer_object *stobj = st_buffer_object(bufobj);
if (!stobj || !stobj->buffer) {
- return FALSE; /* out-of-memory error probably */
+ st->vertex_array_out_of_memory = true;
+ return; /* out-of-memory error probably */
}
vbuffer.buffer.resource = stobj->buffer;
vbuffer.is_user_buffer = false;
vbuffer.buffer_offset = pointer_to_offset(low_addr);
vbuffer.stride = stride;
}
else {
/* all interleaved arrays in user memory */
vbuffer.buffer.user = low_addr;
vbuffer.is_user_buffer = !!low_addr; /* if NULL, then unbind */
vbuffer.buffer_offset = 0;
vbuffer.stride = stride;
}
set_vertex_attribs(st, &vbuffer, vpv->num_inputs ? 1 : 0,
velements, vpv->num_inputs);
- return TRUE;
}
/**
* Set up a separate pipe_vertex_buffer and pipe_vertex_element for each
* vertex attribute.
* \param vbuffer returns vertex buffer info
* \param velements returns vertex element info
*/
-static boolean
+static void
setup_non_interleaved_attribs(struct st_context *st,
const struct st_vertex_program *vp,
const struct st_vp_variant *vpv,
const struct gl_vertex_array **arrays)
{
struct gl_context *ctx = st->ctx;
struct pipe_vertex_buffer vbuffer[PIPE_MAX_ATTRIBS];
struct pipe_vertex_element velements[PIPE_MAX_ATTRIBS] = {{0}};
unsigned num_vbuffers = 0;
GLuint attr;
@@ -595,21 +595,22 @@ setup_non_interleaved_attribs(struct st_context *st,
_mesa_bytes_per_vertex_attrib(array->Size, array->Type));
if (_mesa_is_bufferobj(bufobj)) {
/* Attribute data is in a VBO.
* Recall that for VBOs, the gl_vertex_array->Ptr field is
* really an offset from the start of the VBO, not a pointer.
*/
struct st_buffer_object *stobj = st_buffer_object(bufobj);
if (!stobj || !stobj->buffer) {
- return FALSE; /* out-of-memory error probably */
+ st->vertex_array_out_of_memory = true;
+ return; /* out-of-memory error probably */
}
vbuffer[bufidx].buffer.resource = stobj->buffer;
vbuffer[bufidx].is_user_buffer = false;
vbuffer[bufidx].buffer_offset = pointer_to_offset(array->Ptr);
}
else {
/* wrap user data */
void *ptr;
@@ -637,43 +638,34 @@ setup_non_interleaved_attribs(struct st_context *st,
array->Format,
array->Normalized,
array->Integer);
init_velement_lowered(st, vp, velements, 0, src_format,
array->InstanceDivisor, bufidx,
array->Size, array->Doubles, &attr);
}
set_vertex_attribs(st, vbuffer, num_vbuffers, velements, vpv->num_inputs);
- return TRUE;
}
void st_update_array(struct st_context *st)
{
struct gl_context *ctx = st->ctx;
const struct gl_vertex_array **arrays = ctx->Array._DrawArrays;
const struct st_vertex_program *vp;
const struct st_vp_variant *vpv;
st->vertex_array_out_of_memory = FALSE;
/* No drawing has been done yet, so do nothing. */
if (!arrays)
return;
/* vertex program validation must be done before this */
vp = st->vp;
vpv = st->vp_variant;
- if (is_interleaved_arrays(vp, vpv, arrays)) {
- if (!setup_interleaved_attribs(st, vp, vpv, arrays)) {
- st->vertex_array_out_of_memory = TRUE;
- return;
- }
- }
- else {
- if (!setup_non_interleaved_attribs(st, vp, vpv, arrays)) {
- st->vertex_array_out_of_memory = TRUE;
- return;
- }
- }
+ if (is_interleaved_arrays(vp, vpv, arrays))
+ setup_interleaved_attribs(st, vp, vpv, arrays);
+ else
+ setup_non_interleaved_attribs(st, vp, vpv, arrays);
}
--
2.7.4
More information about the mesa-dev
mailing list