[Mesa-dev] [PATCH 2/5] i965: Turn emit_vertex_buffer_state() into a macro.
Matt Turner
mattst88 at gmail.com
Fri Jul 10 11:44:56 PDT 2015
Its uses of OUT_BATCH will need a local variable defined by BEGIN_BATCH.
Increases .text size by 8 bytes.
---
src/mesa/drivers/dri/i965/brw_draw_upload.c | 79 +++++++++++++----------------
1 file changed, 36 insertions(+), 43 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c
index 320e40e..0536ac3 100644
--- a/src/mesa/drivers/dri/i965/brw_draw_upload.c
+++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c
@@ -604,46 +604,40 @@ brw_prepare_shader_draw_parameters(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);
-}
+#define EMIT_VERTEX_BUFFER_STATE(buffer_nr, bo, bo_ending_address, \
+ bo_offset,stride, step_rate) \
+do { \
+ 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); \
+} while (0)
static void brw_emit_vertices(struct brw_context *brw)
{
@@ -704,14 +698,13 @@ static void brw_emit_vertices(struct brw_context *brw)
OUT_BATCH((_3DSTATE_VERTEX_BUFFERS << 16) | (4 * nr_buffers - 1));
for (i = 0; i < brw->vb.nr_buffers; i++) {
struct brw_vertex_buffer *buffer = &brw->vb.buffers[i];
- emit_vertex_buffer_state(brw, i, buffer->bo, buffer->bo->size - 1,
+ EMIT_VERTEX_BUFFER_STATE(i, buffer->bo, buffer->bo->size - 1,
buffer->offset, buffer->stride,
buffer->step_rate);
-
}
if (brw->vs.prog_data->uses_vertexid) {
- emit_vertex_buffer_state(brw, brw->vb.nr_buffers,
+ EMIT_VERTEX_BUFFER_STATE(brw->vb.nr_buffers,
brw->draw.draw_params_bo,
brw->draw.draw_params_bo->size - 1,
brw->draw.draw_params_offset,
--
2.3.6
More information about the mesa-dev
mailing list