summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/i965/gen8_draw_upload.c
diff options
context:
space:
mode:
authorKenneth Graunke <kenneth@whitecape.org>2014-09-10 15:41:40 -0700
committerIan Romanick <ian.d.romanick@intel.com>2014-09-12 16:35:35 -0700
commit6b6145204dd4a1112f6e1fe10162636141495b79 (patch)
tree30809a5f9ef2d22f67b7a3677e75c2025b81ee4f /src/mesa/drivers/dri/i965/gen8_draw_upload.c
parente980fe607155c79ccba56ef78854093b7730bef6 (diff)
downloadexternal_mesa3d-6b6145204dd4a1112f6e1fe10162636141495b79.zip
external_mesa3d-6b6145204dd4a1112f6e1fe10162636141495b79.tar.gz
external_mesa3d-6b6145204dd4a1112f6e1fe10162636141495b79.tar.bz2
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 <kenneth@whitecape.org> Cc: "10.3" <mesa-stable@lists.freedesktop.org> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Tested-by: Ian Romanick <ian.d.romanick@intel.com>
Diffstat (limited to 'src/mesa/drivers/dri/i965/gen8_draw_upload.c')
-rw-r--r--src/mesa/drivers/dri/i965/gen8_draw_upload.c22
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 7e4c1eb..8f0e515 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);