anv: emit DrawID if needed

v2: use define for buffer ID (Jason)

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
This commit is contained in:
Lionel Landwerlin
2017-01-29 03:15:03 +00:00
parent 543d5db4e2
commit 9413e11869
3 changed files with 63 additions and 7 deletions

View File

@@ -102,7 +102,8 @@ emit_vertex_input(struct anv_pipeline *pipeline,
uint32_t elem_count = __builtin_popcount(elements) -
__builtin_popcount(elements_double) / 2;
uint32_t total_elems = elem_count + needs_svgs_elem;
const uint32_t total_elems =
elem_count + needs_svgs_elem + vs_prog_data->uses_drawid;
if (total_elems == 0)
return;
@@ -201,6 +202,28 @@ emit_vertex_input(struct anv_pipeline *pipeline,
sgvs.InstanceIDElementOffset = id_slot;
}
#endif
const uint32_t drawid_slot = elem_count + needs_svgs_elem;
if (vs_prog_data->uses_drawid) {
struct GENX(VERTEX_ELEMENT_STATE) element = {
.VertexBufferIndex = ANV_DRAWID_VB_INDEX,
.Valid = true,
.SourceElementFormat = ISL_FORMAT_R32_UINT,
.Component0Control = VFCOMP_STORE_SRC,
.Component1Control = VFCOMP_STORE_0,
.Component2Control = VFCOMP_STORE_0,
.Component3Control = VFCOMP_STORE_0,
};
GENX(VERTEX_ELEMENT_STATE_pack)(NULL,
&p[1 + drawid_slot * 2],
&element);
#if GEN_GEN >= 8
anv_batch_emit(&pipeline->batch, GENX(3DSTATE_VF_INSTANCING), vfi) {
vfi.VertexElementIndex = drawid_slot;
}
#endif
}
}
void