zink: specialize invalidate_descriptor_state hook for compact mode

the constant flag check here has perf implications at high fps,
so avoid it when possible

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23758>
This commit is contained in:
Mike Blumenkrantz 2023-06-08 13:03:48 -04:00 committed by Marge Bot
parent 53542dd120
commit b65efda508
3 changed files with 15 additions and 2 deletions

View file

@ -5247,7 +5247,10 @@ zink_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
if (!ctx->batch.state)
goto fail;
ctx->invalidate_descriptor_state = zink_context_invalidate_descriptor_state;
if (screen->compact_descriptors)
ctx->invalidate_descriptor_state = zink_context_invalidate_descriptor_state_compact;
else
ctx->invalidate_descriptor_state = zink_context_invalidate_descriptor_state;
if (!is_copy_only && !is_compute_only) {
pipe_buffer_write_nooverlap(&ctx->base, ctx->dummy_vertex_buffer, 0, sizeof(data), data);
pipe_buffer_write_nooverlap(&ctx->base, ctx->dummy_xfb_buffer, 0, sizeof(data), data);

View file

@ -1447,11 +1447,19 @@ zink_descriptors_update(struct zink_context *ctx, bool is_compute)
/* called from gallium descriptor change hooks, e.g., set_sampler_views */
void
zink_context_invalidate_descriptor_state(struct zink_context *ctx, gl_shader_stage shader, enum zink_descriptor_type type, unsigned start, unsigned count)
{
if (type == ZINK_DESCRIPTOR_TYPE_UBO && !start)
ctx->dd.push_state_changed[shader == MESA_SHADER_COMPUTE] = true;
else
ctx->dd.state_changed[shader == MESA_SHADER_COMPUTE] |= BITFIELD_BIT(type);
}
void
zink_context_invalidate_descriptor_state_compact(struct zink_context *ctx, gl_shader_stage shader, enum zink_descriptor_type type, unsigned start, unsigned count)
{
if (type == ZINK_DESCRIPTOR_TYPE_UBO && !start)
ctx->dd.push_state_changed[shader == MESA_SHADER_COMPUTE] = true;
else {
if (zink_screen(ctx->base.screen)->compact_descriptors && type > ZINK_DESCRIPTOR_TYPE_SAMPLER_VIEW)
if (type > ZINK_DESCRIPTOR_TYPE_SAMPLER_VIEW)
type -= ZINK_DESCRIPTOR_COMPACT;
ctx->dd.state_changed[shader == MESA_SHADER_COMPUTE] |= BITFIELD_BIT(type);
}

View file

@ -173,6 +173,8 @@ zink_descriptors_update(struct zink_context *ctx, bool is_compute);
void
zink_context_invalidate_descriptor_state(struct zink_context *ctx, gl_shader_stage shader, enum zink_descriptor_type type, unsigned, unsigned);
void
zink_context_invalidate_descriptor_state_compact(struct zink_context *ctx, gl_shader_stage shader, enum zink_descriptor_type type, unsigned, unsigned);
void
zink_batch_descriptor_deinit(struct zink_screen *screen, struct zink_batch_state *bs);