From: Kenneth Graunke Date: Wed, 18 Jul 2018 16:23:24 +0000 (-0700) Subject: iris: vertex ID, instance ID X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5520a54bc500fd96a21fa087404eed683d2b89b8;p=mesa.git iris: vertex ID, instance ID --- 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; + } } }