[Mesa-dev] [PATCH 03/12] i965: Replace hard-coded indices with const named variables in gen6_queryobj

Chris Wilson chris at chris-wilson.co.uk
Fri Aug 4 20:01:07 UTC 2017


To simplify replacement later, replace repeated use of explicit 0/1 with
local variables of the same value.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Kenneth Graunke <kenneth at whitecape.org>
Cc: Matt Turner <mattst88 at gmail.com>
---
 src/mesa/drivers/dri/i965/gen6_queryobj.c | 30 ++++++++++++++++--------------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/gen6_queryobj.c b/src/mesa/drivers/dri/i965/gen6_queryobj.c
index 8e639cfeef..1ee3974198 100644
--- a/src/mesa/drivers/dri/i965/gen6_queryobj.c
+++ b/src/mesa/drivers/dri/i965/gen6_queryobj.c
@@ -318,6 +318,7 @@ gen6_begin_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;
+   const int idx = 0;
 
    /* Since we're starting a new query, we need to throw away old results. */
    brw_bo_unreference(query->bo);
@@ -347,31 +348,31 @@ gen6_begin_query(struct gl_context *ctx, struct gl_query_object *q)
        * obtain the time elapsed.  Notably, this includes time elapsed while
        * the system was doing other work, such as running other applications.
        */
-      brw_write_timestamp(brw, query->bo, 0);
+      brw_write_timestamp(brw, query->bo, idx);
       break;
 
    case GL_ANY_SAMPLES_PASSED:
    case GL_ANY_SAMPLES_PASSED_CONSERVATIVE:
    case GL_SAMPLES_PASSED_ARB:
-      brw_write_depth_count(brw, query->bo, 0);
+      brw_write_depth_count(brw, query->bo, idx);
       break;
 
    case GL_PRIMITIVES_GENERATED:
-      write_primitives_generated(brw, query->bo, query->Base.Stream, 0);
+      write_primitives_generated(brw, query->bo, query->Base.Stream, idx);
       if (query->Base.Stream == 0)
          ctx->NewDriverState |= BRW_NEW_RASTERIZER_DISCARD;
       break;
 
    case GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN:
-      write_xfb_primitives_written(brw, query->bo, query->Base.Stream, 0);
+      write_xfb_primitives_written(brw, query->bo, query->Base.Stream, idx);
       break;
 
    case GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW_ARB:
-      write_xfb_overflow_streams(ctx, query->bo, query->Base.Stream, 1, 0);
+      write_xfb_overflow_streams(ctx, 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, 0);
+      write_xfb_overflow_streams(ctx, query->bo, 0, MAX_VERTEX_STREAMS, idx);
       break;
 
    case GL_VERTICES_SUBMITTED_ARB:
@@ -385,7 +386,7 @@ gen6_begin_query(struct gl_context *ctx, struct gl_query_object *q)
    case GL_COMPUTE_SHADER_INVOCATIONS_ARB:
    case GL_TESS_CONTROL_SHADER_PATCHES_ARB:
    case GL_TESS_EVALUATION_SHADER_INVOCATIONS_ARB:
-      emit_pipeline_stat(brw, query->bo, query->Base.Stream, query->Base.Target, 0);
+      emit_pipeline_stat(brw, query->bo, query->Base.Stream, query->Base.Target, idx);
       break;
 
    default:
@@ -406,34 +407,35 @@ gen6_end_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;
+   const int idx = 1;
 
    switch (query->Base.Target) {
    case GL_TIME_ELAPSED:
-      brw_write_timestamp(brw, query->bo, 1);
+      brw_write_timestamp(brw, query->bo, idx);
       break;
 
    case GL_ANY_SAMPLES_PASSED:
    case GL_ANY_SAMPLES_PASSED_CONSERVATIVE:
    case GL_SAMPLES_PASSED_ARB:
-      brw_write_depth_count(brw, query->bo, 1);
+      brw_write_depth_count(brw, query->bo, idx);
       break;
 
    case GL_PRIMITIVES_GENERATED:
-      write_primitives_generated(brw, query->bo, query->Base.Stream, 1);
+      write_primitives_generated(brw, query->bo, query->Base.Stream, idx);
       if (query->Base.Stream == 0)
          ctx->NewDriverState |= BRW_NEW_RASTERIZER_DISCARD;
       break;
 
    case GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN:
-      write_xfb_primitives_written(brw, query->bo, query->Base.Stream, 1);
+      write_xfb_primitives_written(brw, query->bo, query->Base.Stream, idx);
       break;
 
    case GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW_ARB:
-      write_xfb_overflow_streams(ctx, query->bo, query->Base.Stream, 1, 1);
+      write_xfb_overflow_streams(ctx, 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, 1);
+      write_xfb_overflow_streams(ctx, query->bo, 0, MAX_VERTEX_STREAMS, idx);
       break;
 
       /* calculate overflow here */
@@ -449,7 +451,7 @@ gen6_end_query(struct gl_context *ctx, struct gl_query_object *q)
    case GL_TESS_CONTROL_SHADER_PATCHES_ARB:
    case GL_TESS_EVALUATION_SHADER_INVOCATIONS_ARB:
       emit_pipeline_stat(brw, query->bo,
-                         query->Base.Stream, query->Base.Target, 1);
+                         query->Base.Stream, query->Base.Target, idx);
       break;
 
    default:
-- 
2.13.3



More information about the mesa-dev mailing list