From: Jonathan Marek Date: Mon, 6 Jan 2020 02:40:18 +0000 (-0500) Subject: etnaviv: implement gl_VertexID/gl_InstanceID X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=76d93b437b74c4980009dcea837cb701da2304b0;p=mesa.git etnaviv: implement gl_VertexID/gl_InstanceID Fixes: dEQP-GLES3.functional.instanced.* Signed-off-by: Jonathan Marek Reviewed-by: Christian Gmeiner --- diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c b/src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c index 7934eb0490e..3aa2b00c822 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c +++ b/src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c @@ -120,6 +120,11 @@ etna_lower_io(nir_shader *shader, struct etna_shader_variant *v) nir_ssa_def *ssa = nir_imul(&b, intr->src[0].ssa, nir_imm_int(&b, 16)); nir_instr_rewrite_src(instr, &intr->src[0], nir_src_for_ssa(ssa)); } break; + case nir_intrinsic_load_vertex_id: + case nir_intrinsic_load_instance_id: + /* detect use of vertex_id/instance_id */ + v->vs_id_in_reg = v->infile.num_reg; + break; default: break; } diff --git a/src/gallium/drivers/etnaviv/etnaviv_emit.c b/src/gallium/drivers/etnaviv/etnaviv_emit.c index 977f156958a..e60437d8ec9 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_emit.c +++ b/src/gallium/drivers/etnaviv/etnaviv_emit.c @@ -132,6 +132,7 @@ emit_halti5_only_state(struct etna_context *ctx, int vs_output_count) etna_coalesce_start(stream, &coalesce); if (unlikely(dirty & (ETNA_DIRTY_SHADER))) { /* Magic states (load balancing, inter-unit sync, buffers) */ + /*007C4*/ EMIT_STATE(FE_HALTI5_ID_CONFIG, ctx->shader_state.FE_HALTI5_ID_CONFIG); /*00870*/ EMIT_STATE(VS_HALTI5_OUTPUT_COUNT, vs_output_count | ((vs_output_count * 0x10) << 8)); /*008A0*/ EMIT_STATE(VS_HALTI5_UNK008A0, 0x0001000e | ((0x110/vs_output_count) << 20)); for (int x = 0; x < 4; ++x) { diff --git a/src/gallium/drivers/etnaviv/etnaviv_internal.h b/src/gallium/drivers/etnaviv/etnaviv_internal.h index b226526410d..c868cafab8d 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_internal.h +++ b/src/gallium/drivers/etnaviv/etnaviv_internal.h @@ -265,6 +265,7 @@ struct compiled_shader_state { uint32_t GL_VARYING_NUM_COMPONENTS; uint32_t GL_VARYING_COMPONENT_USE[2]; uint32_t GL_HALTI5_SH_SPECIALS; + uint32_t FE_HALTI5_ID_CONFIG; unsigned vs_inst_mem_size; unsigned ps_inst_mem_size; uint32_t *VS_INST_MEM; diff --git a/src/gallium/drivers/etnaviv/etnaviv_shader.c b/src/gallium/drivers/etnaviv/etnaviv_shader.c index 937a83c8979..6f6f8d2b9f4 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_shader.c +++ b/src/gallium/drivers/etnaviv/etnaviv_shader.c @@ -284,6 +284,20 @@ etna_shader_update_vs_inputs(struct compiled_shader_state *cs, etna_bitarray_set(vs_input, 8, idx, cur_temp++); } + if (vs->vs_id_in_reg >= 0) { + cs->VS_INPUT_COUNT = VIVS_VS_INPUT_COUNT_COUNT(num_vs_inputs + 1) | + VIVS_VS_INPUT_COUNT_UNK8(vs->input_count_unk8) | + VIVS_VS_INPUT_COUNT_ID_ENABLE; + + etna_bitarray_set(vs_input, 8, num_vs_inputs, vs->vs_id_in_reg); + + cs->FE_HALTI5_ID_CONFIG = + VIVS_FE_HALTI5_ID_CONFIG_VERTEX_ID_ENABLE | + VIVS_FE_HALTI5_ID_CONFIG_INSTANCE_ID_ENABLE | + VIVS_FE_HALTI5_ID_CONFIG_VERTEX_ID_REG(vs->vs_id_in_reg * 4) | + VIVS_FE_HALTI5_ID_CONFIG_INSTANCE_ID_REG(vs->vs_id_in_reg * 4 + 1); + } + for (int idx = 0; idx < ARRAY_SIZE(cs->VS_INPUT); ++idx) cs->VS_INPUT[idx] = vs_input[idx];