diff --git a/src/intel/vulkan/anv_blorp.c b/src/intel/vulkan/anv_blorp.c index 0179cd01add..fd4aafdd589 100644 --- a/src/intel/vulkan/anv_blorp.c +++ b/src/intel/vulkan/anv_blorp.c @@ -159,6 +159,11 @@ anv_blorp_batch_init(struct anv_cmd_buffer *cmd_buffer, assert((flags & BLORP_BATCH_USE_BLITTER) == 0 || (flags & BLORP_BATCH_USE_COMPUTE) == 0); + /* If blorp needs a VS shader, we can't have the component packing of the + * driver interfere with blorp's shader. + */ + flags |= BLORP_BATCH_EMIT_3DSTATE_VF; + blorp_batch_init(&cmd_buffer->device->blorp.context, batch, cmd_buffer, flags); } diff --git a/src/intel/vulkan/anv_cmd_buffer.c b/src/intel/vulkan/anv_cmd_buffer.c index 1cdd2dc6341..7d29dddb44f 100644 --- a/src/intel/vulkan/anv_cmd_buffer.c +++ b/src/intel/vulkan/anv_cmd_buffer.c @@ -551,6 +551,7 @@ anv_cmd_buffer_flush_pipeline_state(struct anv_cmd_buffer *cmd_buffer, diff_fix_state(VF_SGVS, final.vf_sgvs); if (cmd_buffer->device->info->ver >= 11) diff_fix_state(VF_SGVS_2, final.vf_sgvs_2); + diff_fix_state(VF_COMPONENT_PACKING, final.vf_component_packing); if (cmd_buffer->device->info->ver >= 12) diff_fix_state(PRIMITIVE_REPLICATION, final.primitive_replication); diff_fix_state(SBE, final.sbe); diff --git a/src/intel/vulkan/anv_instance.c b/src/intel/vulkan/anv_instance.c index 527a82a35f0..0e1b615538d 100644 --- a/src/intel/vulkan/anv_instance.c +++ b/src/intel/vulkan/anv_instance.c @@ -59,6 +59,7 @@ static const driOptionDescription anv_dri_options[] = { #else DRI_CONF_VK_REQUIRE_ASTC(false) #endif + DRI_CONF_ANV_VF_COMPONENT_PACKING(true) DRI_CONF_SECTION_END DRI_CONF_SECTION_QUALITY @@ -186,6 +187,8 @@ anv_init_dri_options(struct anv_instance *instance) instance->custom_border_colors_without_format = driQueryOptionb(&instance->dri_options, "custom_border_colors_without_format"); + instance->vf_component_packing = + driQueryOptionb(&instance->dri_options, "anv_vf_component_packing"); instance->stack_ids = driQueryOptioni(&instance->dri_options, "intel_stack_id"); switch (instance->stack_ids) { diff --git a/src/intel/vulkan/anv_pipeline.c b/src/intel/vulkan/anv_pipeline.c index 92698f1eeb7..fc5bbc98fb1 100644 --- a/src/intel/vulkan/anv_pipeline.c +++ b/src/intel/vulkan/anv_pipeline.c @@ -332,6 +332,9 @@ populate_vs_prog_key(struct anv_pipeline_stage *stage, memset(&stage->key, 0, sizeof(stage->key)); populate_base_prog_key(stage, device); + + stage->key.vs.vf_component_packing = + device->physical->instance->vf_component_packing; } static void diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index d4825698e97..3237a11cc77 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -1319,6 +1319,7 @@ struct anv_instance { bool anv_fake_nonlocal_memory; bool anv_upper_bound_descriptor_pool_sampler; bool custom_border_colors_without_format; + bool vf_component_packing; /* HW workarounds */ bool no_16bit; @@ -1444,6 +1445,7 @@ enum anv_gfx_state_bits { ANV_GFX_STATE_VF_SGVS_2, ANV_GFX_STATE_VF_SGVS_VI, /* 3DSTATE_VERTEX_ELEMENTS for sgvs elements */ ANV_GFX_STATE_VF_SGVS_INSTANCING, /* 3DSTATE_VF_INSTANCING for sgvs elements */ + ANV_GFX_STATE_VF_COMPONENT_PACKING, ANV_GFX_STATE_PRIMITIVE_REPLICATION, ANV_GFX_STATE_SBE, ANV_GFX_STATE_SBE_SWIZ, @@ -4945,6 +4947,7 @@ struct anv_graphics_pipeline { struct anv_gfx_state_ptr vf_sgvs_2; struct anv_gfx_state_ptr vf_sgvs_instancing; struct anv_gfx_state_ptr vf_instancing; + struct anv_gfx_state_ptr vf_component_packing; struct anv_gfx_state_ptr primitive_replication; struct anv_gfx_state_ptr sbe; struct anv_gfx_state_ptr sbe_swiz; diff --git a/src/intel/vulkan/genX_gfx_state.c b/src/intel/vulkan/genX_gfx_state.c index 864398a740e..85560e45dd2 100644 --- a/src/intel/vulkan/genX_gfx_state.c +++ b/src/intel/vulkan/genX_gfx_state.c @@ -2174,6 +2174,12 @@ cmd_buffer_gfx_state_emission(struct anv_cmd_buffer *cmd_buffer) anv_batch_emit_pipeline_state(&cmd_buffer->batch, pipeline, final.vf_sgvs_2); #endif + if (device->physical->instance->vf_component_packing && + BITSET_TEST(hw_state->dirty, ANV_GFX_STATE_VF_COMPONENT_PACKING)) { + anv_batch_emit_pipeline_state(&cmd_buffer->batch, pipeline, + final.vf_component_packing); + } + if (BITSET_TEST(hw_state->dirty, ANV_GFX_STATE_VS)) { anv_batch_emit_pipeline_state_protected(&cmd_buffer->batch, pipeline, final.vs, protected); @@ -2659,6 +2665,8 @@ cmd_buffer_gfx_state_emission(struct anv_cmd_buffer *cmd_buffer) #if GFX_VERx10 >= 125 vf.GeometryDistributionEnable = true; #endif + vf.ComponentPackingEnable = + device->physical->instance->vf_component_packing; SET(vf, vf, IndexedDrawCutIndexEnable); SET(vf, vf, CutIndex); } diff --git a/src/intel/vulkan/genX_gpu_memcpy.c b/src/intel/vulkan/genX_gpu_memcpy.c index 8395575379e..6e70ccc3a4a 100644 --- a/src/intel/vulkan/genX_gpu_memcpy.c +++ b/src/intel/vulkan/genX_gpu_memcpy.c @@ -78,6 +78,14 @@ emit_common_so_memcpy(struct anv_memcpy_state *state, vfi.VertexElementIndex = 0; } anv_batch_emit(batch, GENX(3DSTATE_VF_STATISTICS), vfs); + anv_batch_emit(batch, GENX(3DSTATE_VF), vf) { +#if GFX_VERx10 >= 125 + /* Memcpy has no requirement that we need to disable geometry + * distribution. + */ + vf.GeometryDistributionEnable = true; +#endif + } anv_batch_emit(batch, GENX(3DSTATE_VF_SGVS), sgvs); #if GFX_VER >= 11 anv_batch_emit(batch, GENX(3DSTATE_VF_SGVS_2), sgvs); diff --git a/src/intel/vulkan/genX_pipeline.c b/src/intel/vulkan/genX_pipeline.c index 2ccb02b5362..e231f62072a 100644 --- a/src/intel/vulkan/genX_pipeline.c +++ b/src/intel/vulkan/genX_pipeline.c @@ -432,6 +432,16 @@ emit_vertex_input(struct anv_graphics_pipeline *pipeline, sgvs.XP2ElementOffset = drawid_slot; } #endif + + if (pipeline->base.base.device->physical->instance->vf_component_packing) { + anv_pipeline_emit(pipeline, final.vf_component_packing, + GENX(3DSTATE_VF_COMPONENT_PACKING), vfc) { + vfc.VertexElementEnablesDW[0] = vs_prog_data->vf_component_packing[0]; + vfc.VertexElementEnablesDW[1] = vs_prog_data->vf_component_packing[1]; + vfc.VertexElementEnablesDW[2] = vs_prog_data->vf_component_packing[2]; + vfc.VertexElementEnablesDW[3] = vs_prog_data->vf_component_packing[3]; + } + } } void @@ -2024,6 +2034,10 @@ genX(graphics_pipeline_emit)(struct anv_graphics_pipeline *pipeline, #if GFX_VER >= 11 anv_pipeline_emit(pipeline, final.vf_sgvs_2, GENX(3DSTATE_VF_SGVS_2), sgvs); #endif + if (pipeline->base.base.device->physical->instance->vf_component_packing) { + anv_pipeline_emit(pipeline, final.vf_component_packing, + GENX(3DSTATE_VF_COMPONENT_PACKING), vfc); + } anv_pipeline_emit(pipeline, final.vs, GENX(3DSTATE_VS), vs); anv_pipeline_emit(pipeline, final.hs, GENX(3DSTATE_HS), hs); anv_pipeline_emit(pipeline, final.ds, GENX(3DSTATE_DS), ds); diff --git a/src/intel/vulkan/genX_simple_shader.c b/src/intel/vulkan/genX_simple_shader.c index 72c39d2aa57..a85ba301a6d 100644 --- a/src/intel/vulkan/genX_simple_shader.c +++ b/src/intel/vulkan/genX_simple_shader.c @@ -77,7 +77,15 @@ genX(emit_simpler_shader_init_fragment)(struct anv_simple_shader *state) .Component3Control = VFCOMP_STORE_1_FP, }); - anv_batch_emit(batch, GENX(3DSTATE_VF_STATISTICS), vf); + anv_batch_emit(batch, GENX(3DSTATE_VF_STATISTICS), vfs); + anv_batch_emit(batch, GENX(3DSTATE_VF), vf) { +#if GFX_VERx10 >= 125 + /* Simple shaders have no requirement that we need to disable geometry + * distribution. + */ + vf.GeometryDistributionEnable = true; +#endif + } anv_batch_emit(batch, GENX(3DSTATE_VF_SGVS), sgvs) { sgvs.InstanceIDEnable = true; sgvs.InstanceIDComponentNumber = COMP_1; diff --git a/src/util/driconf.h b/src/util/driconf.h index bed24268807..c9263074a9a 100644 --- a/src/util/driconf.h +++ b/src/util/driconf.h @@ -857,6 +857,10 @@ DRI_CONF_OPT_B(anv_upper_bound_descriptor_pool_sampler, def, \ "Overallocate samplers in descriptor pools to workaround app bug") +#define DRI_CONF_ANV_VF_COMPONENT_PACKING(def) \ + DRI_CONF_OPT_B(anv_vf_component_packing, def, \ + "Vertex fetching component packing") + /** * \brief HASVK specific configuration options */