[Mesa-dev] [PATCH 09/12] i965: Pass consistent args along gen6_queryobj.c
Chris Wilson
chris at chris-wilson.co.uk
Fri Aug 4 20:01:13 UTC 2017
Be consistent in passing along brw_context rather than switching between
that and gl_context.
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
src/mesa/drivers/dri/i965/gen6_queryobj.c | 32 ++++++++++++++-----------------
1 file changed, 14 insertions(+), 18 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/gen6_queryobj.c b/src/mesa/drivers/dri/i965/gen6_queryobj.c
index 25ea51503e..0ba6919374 100644
--- a/src/mesa/drivers/dri/i965/gen6_queryobj.c
+++ b/src/mesa/drivers/dri/i965/gen6_queryobj.c
@@ -99,12 +99,10 @@ write_xfb_primitives_written(struct brw_context *brw,
}
static void
-write_xfb_overflow_streams(struct gl_context *ctx,
+write_xfb_overflow_streams(struct brw_context *brw,
struct brw_bo *bo, int stream, int count,
int idx)
{
- struct brw_context *brw = brw_context(ctx);
-
brw_emit_mi_flush(brw);
for (int i = 0; i < count; i++) {
@@ -204,15 +202,10 @@ emit_pipeline_stat(struct brw_context *brw, struct brw_bo *bo,
* Wait on the query object's BO and calculate the final result.
*/
static void
-gen6_queryobj_get_results(struct gl_context *ctx,
+gen6_queryobj_get_results(struct brw_context *brw,
struct brw_query_object *query,
uint64_t *results)
{
- struct brw_context *brw = brw_context(ctx);
-
- if (query->bo == NULL)
- return;
-
if (unlikely(!query->bo->cache_coherent))
gen_invalidate_range(results, query->bo->size);
@@ -232,7 +225,7 @@ gen6_queryobj_get_results(struct gl_context *ctx,
/* Ensure the scaled timestamp overflows according to
* GL_QUERY_COUNTER_BITS
*/
- query->Base.Result &= (1ull << ctx->Const.QueryCounterBits.Timestamp) - 1;
+ query->Base.Result &= (1ull << brw->ctx.Const.QueryCounterBits.Timestamp) - 1;
break;
case GL_SAMPLES_PASSED_ARB:
@@ -396,7 +389,7 @@ gen6_begin_query(struct gl_context *ctx, struct gl_query_object *q)
case GL_PRIMITIVES_GENERATED:
write_primitives_generated(brw, query->bo, query->Base.Stream, idx);
if (query->Base.Stream == 0)
- ctx->NewDriverState |= BRW_NEW_RASTERIZER_DISCARD;
+ brw->ctx.NewDriverState |= BRW_NEW_RASTERIZER_DISCARD;
break;
case GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN:
@@ -404,11 +397,11 @@ gen6_begin_query(struct gl_context *ctx, struct gl_query_object *q)
break;
case GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW_ARB:
- write_xfb_overflow_streams(ctx, query->bo, query->Base.Stream, 1, idx);
+ write_xfb_overflow_streams(brw, query->bo, query->Base.Stream, 1, idx);
break;
case GL_TRANSFORM_FEEDBACK_OVERFLOW_ARB:
- write_xfb_overflow_streams(ctx, query->bo, 0, MAX_VERTEX_STREAMS, idx);
+ write_xfb_overflow_streams(brw, query->bo, 0, MAX_VERTEX_STREAMS, idx);
break;
case GL_VERTICES_SUBMITTED_ARB:
@@ -459,7 +452,7 @@ gen6_end_query(struct gl_context *ctx, struct gl_query_object *q)
case GL_PRIMITIVES_GENERATED:
write_primitives_generated(brw, query->bo, query->Base.Stream, idx);
if (query->Base.Stream == 0)
- ctx->NewDriverState |= BRW_NEW_RASTERIZER_DISCARD;
+ brw->ctx.NewDriverState |= BRW_NEW_RASTERIZER_DISCARD;
break;
case GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN:
@@ -467,11 +460,11 @@ gen6_end_query(struct gl_context *ctx, struct gl_query_object *q)
break;
case GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW_ARB:
- write_xfb_overflow_streams(ctx, query->bo, query->Base.Stream, 1, idx);
+ write_xfb_overflow_streams(brw, query->bo, query->Base.Stream, 1, idx);
break;
case GL_TRANSFORM_FEEDBACK_OVERFLOW_ARB:
- write_xfb_overflow_streams(ctx, query->bo, 0, MAX_VERTEX_STREAMS, idx);
+ write_xfb_overflow_streams(brw, query->bo, 0, MAX_VERTEX_STREAMS, idx);
break;
/* calculate overflow here */
@@ -530,6 +523,9 @@ static void gen6_wait_query(struct gl_context *ctx, struct gl_query_object *q)
struct brw_context *brw = brw_context(ctx);
struct brw_query_object *query = (struct brw_query_object *)q;
+ if (query->bo == NULL)
+ return;
+
/* If the application has requested the query result, but this batch is
* still contributing to it, flush it now to finish that work so the
* result will become available (eventually).
@@ -540,7 +536,7 @@ static void gen6_wait_query(struct gl_context *ctx, struct gl_query_object *q)
if (!results[GEN6_QUERY_PREDICATE]) /* not yet available, must wait */
brw_bo_wait_rendering(query->bo);
- gen6_queryobj_get_results(ctx, query, results + GEN6_QUERY_RESULTS);
+ gen6_queryobj_get_results(brw, query, results + GEN6_QUERY_RESULTS);
}
/**
@@ -572,7 +568,7 @@ static void gen6_check_query(struct gl_context *ctx, struct gl_query_object *q)
uint64_t *results = query->results;
if (results[GEN6_QUERY_PREDICATE] || /* already available, can read async */
!brw_bo_map_busy(query->bo, MAP_READ)) /* GPU hang, results lost? */
- gen6_queryobj_get_results(ctx, query, results + GEN6_QUERY_RESULTS);
+ gen6_queryobj_get_results(brw, query, results + GEN6_QUERY_RESULTS);
}
static void
--
2.13.3
More information about the mesa-dev
mailing list