diff options
author | Marek Olšák <[email protected]> | 2020-03-27 05:07:02 -0400 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-04-30 22:01:55 +0000 |
commit | 42842306d3c7ba71f89022a1ebb09a4454a1b6e0 (patch) | |
tree | 0ff9d8e04ebd26d7e699c13cb6481750af006486 /src/mesa/state_tracker | |
parent | 2e3a9d78289ace1928e2dc093fc743cad81c911c (diff) |
mesa,st/mesa: add a fast path for non-static VAOs
Skip most of _mesa_update_vao_derived_arrays if the VAO is not static.
Drivers need a separate codepath for this.
This increases performance by 7% with glthread and the game "torcs".
The reason is that glthread uploads vertices and sets vertex buffers
every draw call, so the overhead is very noticable. glthread doesn't
hide the overhead, because the driver thread is the busiest thread.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4314>
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r-- | src/mesa/state_tracker/st_atom_array.c | 32 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_extensions.c | 2 |
2 files changed, 34 insertions, 0 deletions
diff --git a/src/mesa/state_tracker/st_atom_array.c b/src/mesa/state_tracker/st_atom_array.c index 0b5909ba11a..1faf72b0db5 100644 --- a/src/mesa/state_tracker/st_atom_array.c +++ b/src/mesa/state_tracker/st_atom_array.c @@ -149,6 +149,38 @@ st_setup_arrays(struct st_context *st, st->draw_needs_minmax_index = (userbuf_attribs & ~_mesa_draw_nonzero_divisor_bits(ctx)) != 0; + if (vao->IsDynamic) { + while (mask) { + const gl_vert_attrib attr = u_bit_scan(&mask); + const struct gl_array_attributes *const attrib = + _mesa_draw_array_attrib(vao, attr); + const struct gl_vertex_buffer_binding *const binding = + &vao->BufferBinding[attrib->BufferBindingIndex]; + const unsigned bufidx = (*num_vbuffers)++; + + /* Set the vertex buffer. */ + if (binding->BufferObj) { + struct st_buffer_object *stobj = st_buffer_object(binding->BufferObj); + + vbuffer[bufidx].buffer.resource = stobj ? stobj->buffer : NULL; + vbuffer[bufidx].is_user_buffer = false; + vbuffer[bufidx].buffer_offset = binding->Offset + + attrib->RelativeOffset; + } else { + vbuffer[bufidx].buffer.user = attrib->Ptr; + vbuffer[bufidx].is_user_buffer = true; + vbuffer[bufidx].buffer_offset = 0; + } + vbuffer[bufidx].stride = binding->Stride; /* in bytes */ + + /* Set the vertex element. */ + init_velement(vp, velements->velems, &attrib->Format, 0, + binding->InstanceDivisor, bufidx, + input_to_index[attr]); + } + return; + } + while (mask) { /* The attribute index to start pulling a binding */ const gl_vert_attrib i = ffs(mask) - 1; diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index 386b035a052..5ddb55f053d 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -583,6 +583,8 @@ void st_init_limits(struct pipe_screen *screen, c->MultiDrawWithUserIndices = screen->get_param(screen, PIPE_CAP_DRAW_INFO_START_WITH_USER_INDICES); + c->AllowDynamicVAOFastPath = true; + c->glBeginEndBufferSize = screen->get_param(screen, PIPE_CAP_GL_BEGIN_END_BUFFER_SIZE); } |