summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2014-08-07 20:49:08 -0700
committerKenneth Graunke <[email protected]>2014-09-10 11:05:08 -0700
commit87b10c4a7161905e3a9dc2b2ddc77fbf6908ebd5 (patch)
treeb8f857590bb865410883d727c92eed052143bdc1 /src
parentfdbabf22e183d478cd076215052fa877b125629b (diff)
i965: Refactor Gen4-7 VERTEX_BUFFER_STATE emission into a helper.
We'll need to emit another VERTEX_BUFFER_STATE for gl_BaseVertex; pulling this into a helper function will save us from having to deal with cross-generation differences in that code. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/dri/i965/brw_draw_upload.c77
1 files changed, 47 insertions, 30 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c
index 37a65bcb3c9..7c01d79c5e7 100644
--- a/src/mesa/drivers/dri/i965/brw_draw_upload.c
+++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c
@@ -625,9 +625,52 @@ brw_prepare_shader_draw_parameters(struct brw_context *brw)
}
}
-static void brw_emit_vertices(struct brw_context *brw)
+/**
+ * Emit a VERTEX_BUFFER_STATE entry (part of 3DSTATE_VERTEX_BUFFERS).
+ */
+static void
+emit_vertex_buffer_state(struct brw_context *brw,
+ unsigned buffer_nr,
+ drm_intel_bo *bo,
+ unsigned bo_ending_address,
+ unsigned bo_offset,
+ unsigned stride,
+ unsigned step_rate)
{
struct gl_context *ctx = &brw->ctx;
+ uint32_t dw0;
+
+ if (brw->gen >= 6) {
+ dw0 = (buffer_nr << GEN6_VB0_INDEX_SHIFT) |
+ (step_rate ? GEN6_VB0_ACCESS_INSTANCEDATA
+ : GEN6_VB0_ACCESS_VERTEXDATA);
+ } else {
+ dw0 = (buffer_nr << BRW_VB0_INDEX_SHIFT) |
+ (step_rate ? BRW_VB0_ACCESS_INSTANCEDATA
+ : BRW_VB0_ACCESS_VERTEXDATA);
+ }
+
+ if (brw->gen >= 7)
+ dw0 |= GEN7_VB0_ADDRESS_MODIFYENABLE;
+
+ if (brw->gen == 7)
+ dw0 |= GEN7_MOCS_L3 << 16;
+
+ WARN_ONCE(stride >= (brw->gen >= 5 ? 2048 : 2047),
+ "VBO stride %d too large, bad rendering may occur\n",
+ stride);
+ OUT_BATCH(dw0 | (stride << BRW_VB0_PITCH_SHIFT));
+ OUT_RELOC(bo, I915_GEM_DOMAIN_VERTEX, 0, bo_offset);
+ if (brw->gen >= 5) {
+ OUT_RELOC(bo, I915_GEM_DOMAIN_VERTEX, 0, bo_ending_address);
+ } else {
+ OUT_BATCH(0);
+ }
+ OUT_BATCH(step_rate);
+}
+
+static void brw_emit_vertices(struct brw_context *brw)
+{
GLuint i, nr_elements;
brw_prepare_vertices(brw);
@@ -680,36 +723,10 @@ static void brw_emit_vertices(struct brw_context *brw)
OUT_BATCH((_3DSTATE_VERTEX_BUFFERS << 16) | (4*brw->vb.nr_buffers - 1));
for (i = 0; i < brw->vb.nr_buffers; i++) {
struct brw_vertex_buffer *buffer = &brw->vb.buffers[i];
- uint32_t dw0;
-
- if (brw->gen >= 6) {
- dw0 = buffer->step_rate
- ? GEN6_VB0_ACCESS_INSTANCEDATA
- : GEN6_VB0_ACCESS_VERTEXDATA;
- dw0 |= i << GEN6_VB0_INDEX_SHIFT;
- } else {
- dw0 = buffer->step_rate
- ? BRW_VB0_ACCESS_INSTANCEDATA
- : BRW_VB0_ACCESS_VERTEXDATA;
- dw0 |= i << BRW_VB0_INDEX_SHIFT;
- }
+ emit_vertex_buffer_state(brw, i, buffer->bo, buffer->bo->size - 1,
+ buffer->offset, buffer->stride,
+ buffer->step_rate);
- if (brw->gen >= 7)
- dw0 |= GEN7_VB0_ADDRESS_MODIFYENABLE;
-
- if (brw->gen == 7)
- dw0 |= GEN7_MOCS_L3 << 16;
-
- WARN_ONCE(buffer->stride >= (brw->gen >= 5 ? 2048 : 2047),
- "VBO stride %d too large, bad rendering may occur\n",
- buffer->stride);
- OUT_BATCH(dw0 | (buffer->stride << BRW_VB0_PITCH_SHIFT));
- OUT_RELOC(buffer->bo, I915_GEM_DOMAIN_VERTEX, 0, buffer->offset);
- if (brw->gen >= 5) {
- OUT_RELOC(buffer->bo, I915_GEM_DOMAIN_VERTEX, 0, buffer->bo->size - 1);
- } else
- OUT_BATCH(0);
- OUT_BATCH(buffer->step_rate);
}
ADVANCE_BATCH();
}