iris: Move code to emit binding tables to its own function

This allow us to reduce a bit the size of iris_upload_dirty_render_state() and
in next patches some improvements to this new function will be done.

Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38790>
This commit is contained in:
José Roberto de Souza 2025-11-27 08:34:39 -08:00 committed by Marge Bot
parent 5b039e0996
commit d4658ddb73

View file

@ -6936,6 +6936,54 @@ setup_autostrip_state(struct iris_context *ice,
#endif
}
static void
iris_emit_binding_tables(struct iris_context *ice, struct iris_batch *batch,
uint64_t stage_dirty)
{
struct iris_binder *binder = &ice->state.binder;
for (int stage = 0; stage <= MESA_SHADER_FRAGMENT; stage++) {
/* Gfx9 requires 3DSTATE_BINDING_TABLE_POINTERS_XS to be re-emitted
* in order to commit constants. TODO: Investigate "Disable Gather
* at Set Shader" to go back to legacy mode...
*/
if (stage_dirty & ((IRIS_STAGE_DIRTY_BINDINGS_VS |
(GFX_VER == 9 ? IRIS_STAGE_DIRTY_CONSTANTS_VS : 0))
<< stage)) {
iris_emit_cmd(batch, GENX(3DSTATE_BINDING_TABLE_POINTERS_VS), ptr) {
ptr._3DCommandSubOpcode = 38 + stage;
ptr.PointertoVSBindingTable =
binder->bt_offset[stage] >> IRIS_BT_OFFSET_SHIFT;
}
}
}
for (int stage = 0; stage <= MESA_SHADER_FRAGMENT; stage++) {
if (stage_dirty & (IRIS_STAGE_DIRTY_BINDINGS_VS << stage)) {
iris_populate_binding_table(ice, batch, stage, false);
}
}
for (int stage = 0; stage <= MESA_SHADER_FRAGMENT; stage++) {
if (!(stage_dirty & (IRIS_STAGE_DIRTY_SAMPLER_STATES_VS << stage)) ||
!ice->shaders.prog[stage])
continue;
iris_upload_sampler_states(ice, stage);
struct iris_shader_state *shs = &ice->state.shaders[stage];
struct pipe_resource *res = shs->sampler_table.res;
if (res)
iris_use_pinned_bo(batch, iris_resource_bo(res), false,
IRIS_DOMAIN_NONE);
iris_emit_cmd(batch, GENX(3DSTATE_SAMPLER_STATE_POINTERS_VS), ptr) {
ptr._3DCommandSubOpcode = 43 + stage;
ptr.PointertoVSSamplerState = shs->sampler_table.offset;
}
}
}
static void
iris_upload_dirty_render_state(struct iris_context *ice,
struct iris_batch *batch,
@ -6967,7 +7015,6 @@ iris_upload_dirty_render_state(struct iris_context *ice,
return;
struct iris_genx_state *genx = ice->state.genx;
struct iris_binder *binder = &ice->state.binder;
struct iris_fs_data *fs_data =
iris_fs_data(ice->shaders.prog[MESA_SHADER_FRAGMENT]);
@ -7345,21 +7392,7 @@ iris_upload_dirty_render_state(struct iris_context *ice,
emit_push_constant_packet_all(ice, batch, nobuffer_stages, NULL);
#endif
for (int stage = 0; stage <= MESA_SHADER_FRAGMENT; stage++) {
/* Gfx9 requires 3DSTATE_BINDING_TABLE_POINTERS_XS to be re-emitted
* in order to commit constants. TODO: Investigate "Disable Gather
* at Set Shader" to go back to legacy mode...
*/
if (stage_dirty & ((IRIS_STAGE_DIRTY_BINDINGS_VS |
(GFX_VER == 9 ? IRIS_STAGE_DIRTY_CONSTANTS_VS : 0))
<< stage)) {
iris_emit_cmd(batch, GENX(3DSTATE_BINDING_TABLE_POINTERS_VS), ptr) {
ptr._3DCommandSubOpcode = 38 + stage;
ptr.PointertoVSBindingTable =
binder->bt_offset[stage] >> IRIS_BT_OFFSET_SHIFT;
}
}
}
iris_emit_binding_tables(ice, batch, stage_dirty);
if (GFX_VER >= 11 && (dirty & IRIS_DIRTY_RENDER_BUFFER)) {
// XXX: we may want to flag IRIS_DIRTY_MULTISAMPLE (or SAMPLE_MASK?)
@ -7382,31 +7415,6 @@ iris_upload_dirty_render_state(struct iris_context *ice,
if (dirty & IRIS_DIRTY_RENDER_BUFFER)
trace_framebuffer_state(&batch->trace, NULL, &ice->state.framebuffer);
for (int stage = 0; stage <= MESA_SHADER_FRAGMENT; stage++) {
if (stage_dirty & (IRIS_STAGE_DIRTY_BINDINGS_VS << stage)) {
iris_populate_binding_table(ice, batch, stage, false);
}
}
for (int stage = 0; stage <= MESA_SHADER_FRAGMENT; stage++) {
if (!(stage_dirty & (IRIS_STAGE_DIRTY_SAMPLER_STATES_VS << stage)) ||
!ice->shaders.prog[stage])
continue;
iris_upload_sampler_states(ice, stage);
struct iris_shader_state *shs = &ice->state.shaders[stage];
struct pipe_resource *res = shs->sampler_table.res;
if (res)
iris_use_pinned_bo(batch, iris_resource_bo(res), false,
IRIS_DOMAIN_NONE);
iris_emit_cmd(batch, GENX(3DSTATE_SAMPLER_STATE_POINTERS_VS), ptr) {
ptr._3DCommandSubOpcode = 43 + stage;
ptr.PointertoVSSamplerState = shs->sampler_table.offset;
}
}
if (ice->state.need_border_colors)
iris_use_pinned_bo(batch, border_color_pool->bo, false, IRIS_DOMAIN_NONE);