v3d: use the GPU to record primitives written to transform feedback

Graphics / Mesa 3D Graphics Library / Mesa - Iago Toral Quiroga [igalia.com] - 8 August 2019 06:36 EDT

We can use the PRIMITIVE_COUNTS_FEEDBACK packet to write various primitive counts to a buffer, including the number of primives written to transform feedback buffers, which will handle buffer overflow correctly.

There are a couple of caveats with this:

Primitive counters are reset when we emit a 'Tile Binning Mode Configuration' packet, which can happen in the middle of a primitives query, so we need to read the buffer when we submit a job and accumulate the counts in the context so we don't lose them.

We also need to do the same when we switch primitive type during transform feedback so we can compute the correct number of recorded vertices from the number of primitives. This is necessary so we can provide an accurate
vertex count for draw from transform feedback.

v2:- When computing the number of vertices for a primitive, pass in the base primitive, since that is what the hardware will count.- No need to update primitive counts when switching primitive types if the base primitives are the same.
- Log perf warning when mapping the primitive counts BO for readback (Eric).
- Only emit the primitive counts packet once at job end (Eric).
- Use u_upload mechanism for the primitive counts buffer (Eric).
- Use the XML to generate indices into the primitive counters buffer (Eric).

Fixes piglit tests: spec/ext_transform_feedback/overflow-edge-cases spec/ext_transform_feedback/query-primitives_written-bufferrange spec/ext_transform_feedback/query-primitives_written-bufferrange-discard spec/ext_transform_feedback/change-size base-shrink spec/ext_transform_feedback/change-size base-grow spec/ext_transform_feedback/change-size offset-shrink spec/ext_transform_feedback/change-size offset-grow spec/ext_transform_feedback/change-size range-shrink spec/ext_transform_feedback/change-size range-grow spec/ext_transform_feedback/intervening-read prims-written

0f2d1dfe65b v3d: use the GPU to record primitives written to transform feedback
src/broadcom/cle/v3d_packet_v33.xml | 10 ++++++++++
src/gallium/drivers/v3d/v3d_context.c | 37 +++++++++++++++++++++++++++++++++++
src/gallium/drivers/v3d/v3d_context.h | 4 ++++
src/gallium/drivers/v3d/v3d_job.c | 21 ++++++++++++++++++++
src/gallium/drivers/v3d/v3d_query.c | 11 +++++++++++
src/gallium/drivers/v3d/v3dx_draw.c | 34 +++++++++++++++++---------------
src/gallium/drivers/v3d/v3dx_job.c | 14 +++++++++++++
src/gallium/drivers/v3d/v3dx_state.c | 17 ++++++++++++++++
8 files changed, 132 insertions(+), 16 deletions(-)

Upstream: cgit.freedesktop.org


  • Share