ilo: simplify ilo_render_get_query_len()
authorChia-I Wu <olvaffe@gmail.com>
Thu, 25 Sep 2014 04:32:21 +0000 (12:32 +0800)
committerChia-I Wu <olvaffe@gmail.com>
Fri, 26 Sep 2014 13:15:55 +0000 (21:15 +0800)
For all supported query types, we always emit a PIPE_CONTROL.  Call
ilo_render_get_flush_len() for simplicity and clarity.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
src/gallium/drivers/ilo/ilo_render.c

index 3dea7c6a0fa20cceb4bbf8e68479d05fd95d0520..2995ee8346f9413860e8487837463cf386d566b1 100644 (file)
@@ -238,41 +238,28 @@ ilo_render_get_query_len(const struct ilo_render *render,
 
    ILO_DEV_ASSERT(render->dev, 6, 7.5);
 
+   /* always a flush or a variant of flush */
+   len = ilo_render_get_flush_len(render);
+
    switch (query_type) {
    case PIPE_QUERY_OCCLUSION_COUNTER:
-      len = GEN6_PIPE_CONTROL__SIZE;
-      if (ilo_dev_gen(render->dev) == ILO_GEN(6))
-         len *= 3;
-      break;
    case PIPE_QUERY_TIMESTAMP:
    case PIPE_QUERY_TIME_ELAPSED:
-      len = GEN6_PIPE_CONTROL__SIZE;
-      if (ilo_dev_gen(render->dev) == ILO_GEN(6))
-         len *= 2;
+      /* no reg */
       break;
    case PIPE_QUERY_PRIMITIVES_GENERATED:
    case PIPE_QUERY_PRIMITIVES_EMITTED:
-      len = GEN6_PIPE_CONTROL__SIZE;
-      if (ilo_dev_gen(render->dev) == ILO_GEN(6))
-         len *= 3;
-
       len += GEN6_MI_STORE_REGISTER_MEM__SIZE * 2;
       break;
    case PIPE_QUERY_PIPELINE_STATISTICS:
-      if (ilo_dev_gen(render->dev) >= ILO_GEN(7)) {
-         const int num_regs = 10;
-         const int num_pads = 1;
-
-         len = GEN6_PIPE_CONTROL__SIZE +
-            GEN6_MI_STORE_REGISTER_MEM__SIZE * 2 * num_regs +
-            GEN6_MI_STORE_DATA_IMM__SIZE * num_pads;
-      } else {
-         const int num_regs = 8;
-         const int num_pads = 3;
-
-         len = GEN6_PIPE_CONTROL__SIZE * 3 +
-            GEN6_MI_STORE_REGISTER_MEM__SIZE * 2 * num_regs +
-            GEN6_MI_STORE_DATA_IMM__SIZE * num_pads;
+      {
+         const int num_regs =
+            (ilo_dev_gen(render->dev) >= ILO_GEN(7)) ? 10 : 8;
+         const int num_pads =
+            (ilo_dev_gen(render->dev) >= ILO_GEN(7)) ? 1 : 3;
+
+         len += GEN6_MI_STORE_REGISTER_MEM__SIZE * 2 * num_regs +
+                GEN6_MI_STORE_DATA_IMM__SIZE * num_pads;
       }
       break;
    default: