diff options
author | Iago Toral Quiroga <[email protected]> | 2019-08-01 12:30:34 +0200 |
---|---|---|
committer | Iago Toral Quiroga <[email protected]> | 2019-08-08 08:36:52 +0200 |
commit | 0f2d1dfe65bfe1ee8f02ce45f100a5508debdfd4 (patch) | |
tree | 3bc9ea893083eb7b1dcad28381145206688b73f8 /src/gallium/drivers/v3d/v3dx_state.c | |
parent | cf8986bce058e2724e01c68fcc64e34e59869a06 (diff) |
v3d: use the GPU to record primitives written to transform feedback
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
Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/gallium/drivers/v3d/v3dx_state.c')
-rw-r--r-- | src/gallium/drivers/v3d/v3dx_state.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/gallium/drivers/v3d/v3dx_state.c b/src/gallium/drivers/v3d/v3dx_state.c index b6a57249044..c709b476f99 100644 --- a/src/gallium/drivers/v3d/v3dx_state.c +++ b/src/gallium/drivers/v3d/v3dx_state.c @@ -1222,6 +1222,14 @@ v3d_set_stream_output_targets(struct pipe_context *pctx, assert(num_targets <= ARRAY_SIZE(so->targets)); + /* Update recorded vertex counts when we are ending the recording of + * transform feedback. We do this when we switch primitive types + * at draw time, but if we haven't switched primitives in our last + * draw we need to do it here as well. + */ + if (num_targets == 0 && so->num_targets > 0) + v3d_tf_update_counters(ctx); + for (i = 0; i < num_targets; i++) { if (offsets[i] != -1) so->offsets[i] = offsets[i]; @@ -1234,6 +1242,15 @@ v3d_set_stream_output_targets(struct pipe_context *pctx, so->num_targets = num_targets; + /* Create primitive counters BO if needed */ + if (num_targets > 0 && !ctx->prim_counts) { + uint32_t zeroes[7] = { 0 }; /* Init all 7 counters to 0 */ + u_upload_data(ctx->uploader, + 0, sizeof(zeroes), 32, zeroes, + &ctx->prim_counts_offset, + &ctx->prim_counts); + } + ctx->dirty |= VC5_DIRTY_STREAMOUT; } |