[Mesa-dev] [RFC 2/6] i965: add plumbing for ARB_transform_feedback_overflow_query.
Rafael Antognolli
rafael.antognolli at intel.com
Mon Dec 5 18:16:56 UTC 2016
When querying for transform feedback overflow on one or all of the
streams, store information about number of generated and written
primitives. Then check whether generated == written.
Signed-off-by: Rafael Antognolli <rafael.antognolli at intel.com>
---
src/mesa/drivers/dri/i965/brw_queryobj.c | 2 ++
src/mesa/drivers/dri/i965/gen6_queryobj.c | 58 ++++++++++++++++++++++++++++++
src/mesa/drivers/dri/i965/gen7_sol_state.c | 9 +++--
3 files changed, 66 insertions(+), 3 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_queryobj.c b/src/mesa/drivers/dri/i965/brw_queryobj.c
index dda17de..40b86a0 100644
--- a/src/mesa/drivers/dri/i965/brw_queryobj.c
+++ b/src/mesa/drivers/dri/i965/brw_queryobj.c
@@ -530,6 +530,8 @@ brw_is_query_pipelined(struct brw_query_object *query)
case GL_PRIMITIVES_GENERATED:
case GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN:
+ case GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW_ARB:
+ case GL_TRANSFORM_FEEDBACK_OVERFLOW_ARB:
case GL_VERTICES_SUBMITTED_ARB:
case GL_PRIMITIVES_SUBMITTED_ARB:
case GL_VERTEX_SHADER_INVOCATIONS_ARB:
diff --git a/src/mesa/drivers/dri/i965/gen6_queryobj.c b/src/mesa/drivers/dri/i965/gen6_queryobj.c
index bbd3c44..f46a6e6 100644
--- a/src/mesa/drivers/dri/i965/gen6_queryobj.c
+++ b/src/mesa/drivers/dri/i965/gen6_queryobj.c
@@ -98,6 +98,39 @@ write_xfb_primitives_written(struct brw_context *brw,
}
}
+static void
+write_xfb_overflow_streams(struct gl_context *ctx,
+ drm_intel_bo *bo, int stream, int count,
+ int idx)
+{
+ struct brw_context *brw = brw_context(ctx);
+
+ for (int i = 0; i < count; i++) {
+ write_xfb_primitives_written(brw, bo, stream + i, 4 * i + 0 + idx);
+ write_primitives_generated(brw, bo, stream + i, 4 * i + 2 + idx);
+ }
+
+ if (stream == 0)
+ ctx->NewDriverState |= BRW_NEW_RASTERIZER_DISCARD;
+}
+
+static bool
+check_xfb_overflow_streams(uint64_t *results, int count)
+{
+ bool overflow = false;
+
+ for (int i = 0; i < count; i++) {
+ uint64_t *result_i = &results[4 * i];
+
+ if ((result_i[3] - result_i[2]) != (result_i[1] - result_i[0])) {
+ overflow = true;
+ break;
+ }
+ }
+
+ return overflow;
+}
+
static inline int
pipeline_target_to_index(int target)
{
@@ -225,6 +258,14 @@ gen6_queryobj_get_results(struct gl_context *ctx,
query->Base.Result = results[1] - results[0];
break;
+ case GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW_ARB:
+ query->Base.Result = check_xfb_overflow_streams(results, 1);
+ break;
+
+ case GL_TRANSFORM_FEEDBACK_OVERFLOW_ARB:
+ query->Base.Result = check_xfb_overflow_streams(results, MAX_VERTEX_STREAMS);
+ break;
+
case GL_FRAGMENT_SHADER_INVOCATIONS_ARB:
query->Base.Result = (results[1] - results[0]);
/* Implement the "WaDividePSInvocationCountBy4:HSW,BDW" workaround:
@@ -314,6 +355,14 @@ gen6_begin_query(struct gl_context *ctx, struct gl_query_object *q)
write_xfb_primitives_written(brw, query->bo, query->Base.Stream, 0);
break;
+ case GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW_ARB:
+ write_xfb_overflow_streams(ctx, query->bo, query->Base.Stream, 1, 0);
+ break;
+
+ case GL_TRANSFORM_FEEDBACK_OVERFLOW_ARB:
+ write_xfb_overflow_streams(ctx, query->bo, 0, MAX_VERTEX_STREAMS, 0);
+ break;
+
case GL_VERTICES_SUBMITTED_ARB:
case GL_PRIMITIVES_SUBMITTED_ARB:
case GL_VERTEX_SHADER_INVOCATIONS_ARB:
@@ -368,6 +417,15 @@ gen6_end_query(struct gl_context *ctx, struct gl_query_object *q)
write_xfb_primitives_written(brw, query->bo, query->Base.Stream, 1);
break;
+ case GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW_ARB:
+ write_xfb_overflow_streams(ctx, query->bo, query->Base.Stream, 1, 1);
+ break;
+
+ case GL_TRANSFORM_FEEDBACK_OVERFLOW_ARB:
+ write_xfb_overflow_streams(ctx, query->bo, 0, MAX_VERTEX_STREAMS, 1);
+ break;
+
+ /* calculate overflow here */
case GL_VERTICES_SUBMITTED_ARB:
case GL_PRIMITIVES_SUBMITTED_ARB:
case GL_VERTEX_SHADER_INVOCATIONS_ARB:
diff --git a/src/mesa/drivers/dri/i965/gen7_sol_state.c b/src/mesa/drivers/dri/i965/gen7_sol_state.c
index 1775274..f63210b 100644
--- a/src/mesa/drivers/dri/i965/gen7_sol_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_sol_state.c
@@ -243,11 +243,14 @@ upload_3dstate_streamout(struct brw_context *brw, bool active,
/* BRW_NEW_RASTERIZER_DISCARD */
if (ctx->RasterDiscard) {
- if (!query_active(ctx->Query.PrimitivesGenerated[0])) {
+ if (!query_active(ctx->Query.PrimitivesGenerated[0]) &&
+ !query_active(ctx->Query.TransformFeedbackOverflow[0]) &&
+ !query_active(ctx->Query.TransformFeedbackOverflowAny)) {
dw1 |= SO_RENDERING_DISABLE;
} else {
- perf_debug("Rasterizer discard with a GL_PRIMITIVES_GENERATED "
- "query active relies on the clipper.");
+ perf_debug("Rasterizer discard with a GL_PRIMITIVES_GENERATED or "
+ "GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW_ARB query "
+ "active relies on the clipper.");
}
}
--
2.7.4
More information about the mesa-dev
mailing list