From 850f2aab0390d835d68f9ae4ba1c6d8ed4de992a Mon Sep 17 00:00:00 2001 From: Connor Abbott Date: Thu, 15 Aug 2024 07:42:11 -0400 Subject: [PATCH] ir3, tu: Use a UBO for VS primitive params on a750+ Before we were using direct CP_LOAD_STATE, which is broken with multiple back-to-back draws. This caused regressions in some DX11 traces when enabling early preamble. We still need to use indirect CP_LOAD_STATE for VS params, which are sometimes written by the CP, however for everything else we should use the new UBO path instead. Fixes: 76e417ca593 ("turnip,ir3/a750: Implement consts loading via preamble") Part-of: --- .../ir3/ir3_nir_lower_driver_params_to_ubo.c | 11 ++++++++--- src/freedreno/vulkan/tu_pipeline.cc | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/freedreno/ir3/ir3_nir_lower_driver_params_to_ubo.c b/src/freedreno/ir3/ir3_nir_lower_driver_params_to_ubo.c index 3109c245720..3cceffe6c30 100644 --- a/src/freedreno/ir3/ir3_nir_lower_driver_params_to_ubo.c +++ b/src/freedreno/ir3/ir3_nir_lower_driver_params_to_ubo.c @@ -14,9 +14,6 @@ lower_driver_param_to_ubo(nir_builder *b, nir_intrinsic_instr *intr, void *in) { struct ir3_const_state *const_state = in; - if (b->shader->info.stage == MESA_SHADER_VERTEX) - return false; - unsigned components = nir_intrinsic_dest_components(intr); b->cursor = nir_before_instr(&intr->instr); @@ -52,6 +49,14 @@ lower_driver_param_to_ubo(nir_builder *b, nir_intrinsic_instr *intr, void *in) result = ir3_load_driver_ubo(b, components, &const_state->primitive_param_ubo, 6); break; + /* These are still loaded using CP_LOAD_STATE for compatibility with indirect + * draws where the CP does a CP_LOAD_STATE for us internally: + */ + case nir_intrinsic_load_draw_id: + case nir_intrinsic_load_base_vertex: + case nir_intrinsic_load_first_vertex: + case nir_intrinsic_load_base_instance: + return false; default: { struct driver_param_info param_info; if (!ir3_get_driver_param_info(b->shader, intr, ¶m_info)) diff --git a/src/freedreno/vulkan/tu_pipeline.cc b/src/freedreno/vulkan/tu_pipeline.cc index 264e58267e5..79eeaf777e6 100644 --- a/src/freedreno/vulkan/tu_pipeline.cc +++ b/src/freedreno/vulkan/tu_pipeline.cc @@ -615,7 +615,7 @@ tu6_emit_const(struct tu_cs *cs, uint32_t opcode, enum tu_geom_consts_type type, assert(size % 4 == 0); dwords = (uint32_t *)&((uint8_t *)dwords)[offset]; - if (block == SB6_VS_SHADER || !cs->device->physical_device->info->a7xx.load_shader_consts_via_preamble) { + if (!cs->device->physical_device->info->a7xx.load_shader_consts_via_preamble) { uint32_t base; switch (type) { case TU_CONSTS_PRIMITIVE_MAP: