summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2018-07-18 09:23:24 -0700
committerKenneth Graunke <[email protected]>2019-02-21 10:26:07 -0800
commit5520a54bc500fd96a21fa087404eed683d2b89b8 (patch)
tree4566f0c0ccbc6fa12844a74a4fc82a8b2ca7de1e /src
parenta9083bdb71117a84a81909a201657b192c37a027 (diff)
iris: vertex ID, instance ID
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/iris/iris_context.h1
-rw-r--r--src/gallium/drivers/iris/iris_program_cache.c4
-rw-r--r--src/gallium/drivers/iris/iris_state.c27
3 files changed, 29 insertions, 3 deletions
diff --git a/src/gallium/drivers/iris/iris_context.h b/src/gallium/drivers/iris/iris_context.h
index 6bcfd1ca99a..c0420ef397a 100644
--- a/src/gallium/drivers/iris/iris_context.h
+++ b/src/gallium/drivers/iris/iris_context.h
@@ -96,6 +96,7 @@ struct blorp_params;
#define IRIS_DIRTY_SO_BUFFERS (1ull << 48)
#define IRIS_DIRTY_SO_DECL_LIST (1ull << 49)
#define IRIS_DIRTY_STREAMOUT (1ull << 50)
+#define IRIS_DIRTY_VF_SGVS (1ull << 51)
/**
* Non-orthogonal state (NOS) dependency flags.
diff --git a/src/gallium/drivers/iris/iris_program_cache.c b/src/gallium/drivers/iris/iris_program_cache.c
index 0bf01205ffb..6f88062f269 100644
--- a/src/gallium/drivers/iris/iris_program_cache.c
+++ b/src/gallium/drivers/iris/iris_program_cache.c
@@ -99,9 +99,13 @@ dirty_flag_for_cache(enum iris_program_cache_id cache_id)
assert(cache_id <= MESA_SHADER_STAGES);
// XXX: ugly...
+ // XXX: move this flagging out to a higher level, allow comparison of
+ // XXX: new and old programs to decide what bits to twiddle
// XXX: CLIP: toggle if barycentric modes has any NONPERSPECTIVE or not
if (cache_id == IRIS_CACHE_FS)
return IRIS_DIRTY_WM | IRIS_DIRTY_FS | IRIS_DIRTY_CLIP;
+ if (cache_id == IRIS_CACHE_VS)
+ return IRIS_DIRTY_VS | IRIS_DIRTY_VF_SGVS;
return IRIS_DIRTY_VS << cache_id;
}
diff --git a/src/gallium/drivers/iris/iris_state.c b/src/gallium/drivers/iris/iris_state.c
index 0cecb307a88..f62c0f377df 100644
--- a/src/gallium/drivers/iris/iris_state.c
+++ b/src/gallium/drivers/iris/iris_state.c
@@ -1652,6 +1652,11 @@ static void
iris_bind_vertex_elements_state(struct pipe_context *ctx, void *state)
{
struct iris_context *ice = (struct iris_context *) ctx;
+ struct iris_vertex_element_state *old_cso = ice->state.cso_vertex_elements;
+ struct iris_vertex_element_state *new_cso = state;
+
+ if (new_cso && cso_changed(count))
+ ice->state.dirty |= IRIS_DIRTY_VF_SGVS;
ice->state.cso_vertex_elements = state;
ice->state.dirty |= IRIS_DIRTY_VERTEX_ELEMENTS;
@@ -3147,9 +3152,25 @@ iris_upload_render_state(struct iris_context *ice,
(1 + cso->count * GENX(VERTEX_ELEMENT_STATE_length)));
iris_batch_emit(batch, cso->vf_instancing, sizeof(uint32_t) *
cso->count * GENX(3DSTATE_VF_INSTANCING_length));
- for (int i = 0; i < cso->count; i++) {
- /* TODO: vertexid, instanceid support */
- iris_emit_cmd(batch, GENX(3DSTATE_VF_SGVS), sgvs);
+ }
+
+ if (dirty & IRIS_DIRTY_VF_SGVS) {
+ const struct brw_vs_prog_data *vs_prog_data = (void *)
+ ice->shaders.prog[MESA_SHADER_VERTEX]->prog_data;
+ struct iris_vertex_element_state *cso = ice->state.cso_vertex_elements;
+
+ iris_emit_cmd(batch, GENX(3DSTATE_VF_SGVS), sgv) {
+ if (vs_prog_data->uses_vertexid) {
+ sgv.VertexIDEnable = true;
+ sgv.VertexIDComponentNumber = 2;
+ sgv.VertexIDElementOffset = cso->count;
+ }
+
+ if (vs_prog_data->uses_instanceid) {
+ sgv.InstanceIDEnable = true;
+ sgv.InstanceIDComponentNumber = 3;
+ sgv.InstanceIDElementOffset = cso->count;
+ }
}
}