radeonsi: reflect blitter VS in si_context::num_vertex_elements

Set it to 0 if the VS doesn't use VBOs. This fixes an assertion failure.

Fixes: 7bf5d2ce75 - radeonsi: add assertion requiring binding vertex elements before vertex_buffers
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/12698
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33482>
This commit is contained in:
Marek Olšák 2025-02-26 23:16:23 -05:00 committed by Marge Bot
parent c662fcfa94
commit bafab3324e
4 changed files with 18 additions and 10 deletions

View file

@ -2042,12 +2042,7 @@ void si_shader_pointers_mark_dirty(struct si_context *sctx)
{
sctx->shader_pointers_dirty =
u_bit_consecutive(SI_DESCS_FIRST_SHADER, SI_NUM_DESCS - SI_DESCS_FIRST_SHADER);
sctx->vertex_buffers_dirty = sctx->num_vertex_elements > 0 &&
/* si_draw_rectangle doesn't bind vertex elements, so we shouldn't
* mark vertex buffers as dirty. We can get here due to
* si_need_gfx_cs_space. */
(!sctx->shader.vs.cso ||
!sctx->shader.vs.cso->info.base.vs.blit_sgprs_amd);
sctx->vertex_buffers_dirty = sctx->num_vertex_elements > 0;
si_mark_atom_dirty(sctx, &sctx->atoms.s.gfx_shader_pointers);
sctx->graphics_internal_bindings_pointer_dirty = sctx->descriptors[SI_DESCS_INTERNAL].buffer != NULL;
sctx->compute_internal_bindings_pointer_dirty = sctx->descriptors[SI_DESCS_INTERNAL].buffer != NULL;

View file

@ -1084,7 +1084,7 @@ struct si_context {
/* shader information */
uint64_t ps_inputs_read_or_disabled;
struct si_vertex_elements *vertex_elements;
unsigned num_vertex_elements;
unsigned num_vertex_elements; /* 0 if the VS uses blit SGPRs to compute VS inputs */
unsigned cs_max_waves_per_sh;
uint32_t compute_tmpring_size;
bool vertex_elements_but_no_buffers;
@ -2224,6 +2224,11 @@ static inline bool si_is_buffer_idle(struct si_context *sctx, struct si_resource
sctx->ws->buffer_wait(sctx->ws, buf->buf, 0, usage | RADEON_USAGE_DISALLOW_SLOW_REPLY);
}
static inline bool si_vs_uses_vbos(struct si_shader_selector *sel)
{
return !sel || !sel->info.base.vs.blit_sgprs_amd;
}
#define PRINT_ERR(fmt, args...) \
fprintf(stderr, "EE %s:%d %s - " fmt, __FILE__, __LINE__, __func__, ##args)

View file

@ -4617,7 +4617,7 @@ static void si_bind_vertex_elements(struct pipe_context *ctx, void *state)
v = sctx->no_velems_state;
sctx->vertex_elements = v;
sctx->num_vertex_elements = v->count;
sctx->num_vertex_elements = si_vs_uses_vbos(sctx->shader.vs.cso) ? v->count : 0;
sctx->vertex_buffers_dirty = sctx->num_vertex_elements > 0;
sctx->vertex_buffer_unaligned = 0;
#ifndef NDEBUG

View file

@ -3820,18 +3820,26 @@ static void si_update_last_vgt_stage_state(struct si_context *sctx,
static void si_bind_vs_shader(struct pipe_context *ctx, void *state)
{
struct si_context *sctx = (struct si_context *)ctx;
struct si_shader_selector *old_hw_vs = si_get_vs(sctx)->cso;
struct si_shader *old_hw_vs_variant = si_get_vs(sctx)->current;
struct si_shader_selector *sel = (struct si_shader_selector*)state;
if (sctx->shader.vs.cso == sel)
return;
struct si_shader_selector *old_hw_vs = si_get_vs(sctx)->cso;
struct si_shader *old_hw_vs_variant = si_get_vs(sctx)->current;
bool old_uses_vbos = si_vs_uses_vbos(sctx->shader.vs.cso);
bool new_uses_vbos = si_vs_uses_vbos(sel);
sctx->shader.vs.cso = sel;
sctx->shader.vs.current = (sel && sel->variants_count) ? sel->variants[0] : NULL;
sctx->num_vs_blit_sgprs = sel ? sel->info.base.vs.blit_sgprs_amd : 0;
sctx->vs_uses_draw_id = sel ? sel->info.uses_drawid : false;
if (old_uses_vbos != new_uses_vbos) {
sctx->num_vertex_elements = new_uses_vbos ? sctx->vertex_elements->count : 0;
sctx->vertex_buffers_dirty = new_uses_vbos;
}
if (si_update_ngg(sctx))
si_shader_change_notify(sctx);