diff options
author | Kenneth Graunke <[email protected]> | 2014-09-10 15:41:40 -0700 |
---|---|---|
committer | Ian Romanick <[email protected]> | 2014-09-12 16:35:35 -0700 |
commit | 6b6145204dd4a1112f6e1fe10162636141495b79 (patch) | |
tree | 30809a5f9ef2d22f67b7a3677e75c2025b81ee4f /src/mesa/drivers/dri/i965/gen8_draw_upload.c | |
parent | e980fe607155c79ccba56ef78854093b7730bef6 (diff) |
i965: Separate gl_InstanceID and gl_VertexID uploading.
We always uploaded them together, mostly out of laziness - both required
an additional vertex element. However, gl_VertexID now also requires an
additional vertex buffer for storing gl_BaseVertex; for non-indirect
draws this also means uploading (a small amount of) data. This is extra
overhead we don't need if the shader only uses gl_InstanceID.
In particular, our clear shaders currently use gl_InstanceID for doing
layered clears, but don't need gl_VertexID.
Signed-off-by: Kenneth Graunke <[email protected]>
Cc: "10.3" <[email protected]>
Reviewed-by: Ian Romanick <[email protected]>
Tested-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/mesa/drivers/dri/i965/gen8_draw_upload.c')
-rw-r--r-- | src/mesa/drivers/dri/i965/gen8_draw_upload.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/mesa/drivers/dri/i965/gen8_draw_upload.c b/src/mesa/drivers/dri/i965/gen8_draw_upload.c index 7e4c1eb3b63..8f0e5155556 100644 --- a/src/mesa/drivers/dri/i965/gen8_draw_upload.c +++ b/src/mesa/drivers/dri/i965/gen8_draw_upload.c @@ -43,7 +43,7 @@ gen8_emit_vertices(struct brw_context *brw) brw_prepare_vertices(brw); brw_prepare_shader_draw_parameters(brw); - if (brw->vs.prog_data->uses_vertexid) { + if (brw->vs.prog_data->uses_vertexid || brw->vs.prog_data->uses_instanceid) { unsigned vue = brw->vb.nr_enabled; WARN_ONCE(brw->vs.prog_data->inputs_read & VERT_BIT_EDGEFLAG, @@ -53,14 +53,22 @@ gen8_emit_vertices(struct brw_context *brw) "Trying to insert VID/IID past 33rd vertex element, " "need to reorder the vertex attrbutes."); + unsigned dw1 = 0; + if (brw->vs.prog_data->uses_vertexid) { + dw1 |= GEN8_SGVS_ENABLE_VERTEX_ID | + (2 << GEN8_SGVS_VERTEX_ID_COMPONENT_SHIFT) | /* .z channel */ + (vue << GEN8_SGVS_VERTEX_ID_ELEMENT_OFFSET_SHIFT); + } + + if (brw->vs.prog_data->uses_instanceid) { + dw1 |= GEN8_SGVS_ENABLE_INSTANCE_ID | + (3 << GEN8_SGVS_INSTANCE_ID_COMPONENT_SHIFT) | /* .w channel */ + (vue << GEN8_SGVS_INSTANCE_ID_ELEMENT_OFFSET_SHIFT); + } + BEGIN_BATCH(2); OUT_BATCH(_3DSTATE_VF_SGVS << 16 | (2 - 2)); - OUT_BATCH(GEN8_SGVS_ENABLE_VERTEX_ID | - (2 << GEN8_SGVS_VERTEX_ID_COMPONENT_SHIFT) | /* .z channel */ - (vue << GEN8_SGVS_VERTEX_ID_ELEMENT_OFFSET_SHIFT) | - GEN8_SGVS_ENABLE_INSTANCE_ID | - (3 << GEN8_SGVS_INSTANCE_ID_COMPONENT_SHIFT) | /* .w channel */ - (vue << GEN8_SGVS_INSTANCE_ID_ELEMENT_OFFSET_SHIFT)); + OUT_BATCH(dw1); ADVANCE_BATCH(); BEGIN_BATCH(3); |