[Mesa-dev] [PATCH 3/3] i965/blorp: Use core vertex buffer state setup

Topi Pohjolainen topi.pohjolainen at intel.com
Fri May 20 03:47:31 UTC 2016


Also split the setup from the setup of vertex elements.

Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
---
 src/mesa/drivers/dri/i965/gen6_blorp.c | 102 ++++++++++++---------------------
 1 file changed, 36 insertions(+), 66 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/gen6_blorp.c b/src/mesa/drivers/dri/i965/gen6_blorp.c
index 5f84ab0..4d73d04 100644
--- a/src/mesa/drivers/dri/i965/gen6_blorp.c
+++ b/src/mesa/drivers/dri/i965/gen6_blorp.c
@@ -30,56 +30,12 @@
 #include "brw_state.h"
 
 #include "brw_blorp.h"
+#include "vbo/vbo.h"
+#include "brw_draw.h"
 
 static void
-gen6_blorp_emit_vertex_buffer_state(struct brw_context *brw,
-                                    unsigned num_elems,
-                                    unsigned vbo_size,
-                                    uint32_t vertex_offset)
-{
-   /* 3DSTATE_VERTEX_BUFFERS */
-   const int num_buffers = 1;
-   const int batch_length = 1 + 4 * num_buffers;
-
-   uint32_t dw0 = GEN6_VB0_ACCESS_VERTEXDATA |
-                  (num_elems * sizeof(float)) << BRW_VB0_PITCH_SHIFT;
-
-   if (brw->gen >= 7)
-      dw0 |= GEN7_VB0_ADDRESS_MODIFYENABLE;
-
-   switch (brw->gen) {
-   case 7:
-      dw0 |= GEN7_MOCS_L3 << 16;
-      break;
-   case 8:
-      dw0 |= BDW_MOCS_WB << 16;
-      break;
-   case 9:
-      dw0 |= SKL_MOCS_WB << 16;
-      break;
-   }
-
-   BEGIN_BATCH(batch_length);
-   OUT_BATCH((_3DSTATE_VERTEX_BUFFERS << 16) | (batch_length - 2));
-   OUT_BATCH(dw0);
-   if (brw->gen >= 8) {
-      OUT_RELOC64(brw->batch.bo, I915_GEM_DOMAIN_VERTEX, 0, vertex_offset);
-      OUT_BATCH(vbo_size);
-   } else {
-      /* start address */
-      OUT_RELOC(brw->batch.bo, I915_GEM_DOMAIN_VERTEX, 0,
-                vertex_offset);
-      /* end address */
-      OUT_RELOC(brw->batch.bo, I915_GEM_DOMAIN_VERTEX, 0,
-                vertex_offset + vbo_size - 1);
-      OUT_BATCH(0);
-   }
-   ADVANCE_BATCH();
-}
-
-void
-gen6_blorp_emit_vertices(struct brw_context *brw,
-                         const struct brw_blorp_params *params)
+gen6_blorp_emit_vertex_data(struct brw_context *brw,
+                            const struct brw_blorp_params *params)
 {
    uint32_t vertex_offset;
 
@@ -119,24 +75,38 @@ gen6_blorp_emit_vertices(struct brw_context *brw,
     * instead of reading them from the buffer. See the vertex element setup
     * below.
     */
-   {
-      float *vertex_data;
-
-      const float vertices[] = {
-         /* v0 */ (float)params->x0, (float)params->y1,
-         /* v1 */ (float)params->x1, (float)params->y1,
-         /* v2 */ (float)params->x0, (float)params->y0,
-      };
-
-      vertex_data = (float *) brw_state_batch(brw, AUB_TRACE_VERTEX_BUFFER,
-                                              sizeof(vertices), 32,
-                                              &vertex_offset);
-      memcpy(vertex_data, vertices, sizeof(vertices));
-
-      const unsigned blorp_num_vue_elems = 2;
-      gen6_blorp_emit_vertex_buffer_state(brw, blorp_num_vue_elems,
-                                          sizeof(vertices), vertex_offset);
-   }
+   const float vertices[] = {
+      /* v0 */ (float)params->x0, (float)params->y1,
+      /* v1 */ (float)params->x1, (float)params->y1,
+      /* v2 */ (float)params->x0, (float)params->y0,
+   };
+
+   float *const vertex_data = (float *)brw_state_batch(
+                                          brw, AUB_TRACE_VERTEX_BUFFER,
+                                          sizeof(vertices), 32,
+                                          &vertex_offset);
+   memcpy(vertex_data, vertices, sizeof(vertices));
+
+   /* 3DSTATE_VERTEX_BUFFERS */
+   const int num_buffers = 1;
+   const int batch_length = 1 + 4 * num_buffers;
+
+   BEGIN_BATCH(batch_length);
+   OUT_BATCH((_3DSTATE_VERTEX_BUFFERS << 16) | (batch_length - 2));
+
+   const unsigned blorp_num_vue_elems = 2;
+   const unsigned stride = blorp_num_vue_elems * sizeof(float);
+   EMIT_VERTEX_BUFFER_STATE(brw, 0 /* buffer_nr */, brw->batch.bo,
+                            vertex_offset, vertex_offset + sizeof(vertices),
+                            stride, 0 /* steprate */);
+   ADVANCE_BATCH();
+}
+
+void
+gen6_blorp_emit_vertices(struct brw_context *brw,
+                         const struct brw_blorp_params *params)
+{
+   gen6_blorp_emit_vertex_data(brw, params);
 
    /* 3DSTATE_VERTEX_ELEMENTS
     *
-- 
2.5.5



More information about the mesa-dev mailing list