zink: make invalidate_descriptor_state a ctx hook
this will allow for specialization Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23758>
This commit is contained in:
committed by
Marge Bot
parent
ad04bd81b9
commit
53542dd120
@@ -707,7 +707,7 @@ update_descriptor_state_sampler(struct zink_context *ctx, gl_shader_stage shader
|
||||
state->sampler_clamped :
|
||||
state->sampler;
|
||||
if (ctx->di.textures[shader][slot].sampler != sampler) {
|
||||
zink_context_invalidate_descriptor_state(ctx, shader, ZINK_DESCRIPTOR_TYPE_SAMPLER_VIEW, slot, 1);
|
||||
ctx->invalidate_descriptor_state(ctx, shader, ZINK_DESCRIPTOR_TYPE_SAMPLER_VIEW, slot, 1);
|
||||
ctx->di.textures[shader][slot].sampler = sampler;
|
||||
}
|
||||
}
|
||||
@@ -807,7 +807,7 @@ zink_bind_sampler_states(struct pipe_context *pctx,
|
||||
for (unsigned i = 0; i < num_samplers; ++i) {
|
||||
struct zink_sampler_state *state = samplers[i];
|
||||
if (ctx->sampler_states[shader][start_slot + i] != state)
|
||||
zink_context_invalidate_descriptor_state(ctx, shader, ZINK_DESCRIPTOR_TYPE_SAMPLER_VIEW, start_slot, 1);
|
||||
ctx->invalidate_descriptor_state(ctx, shader, ZINK_DESCRIPTOR_TYPE_SAMPLER_VIEW, start_slot, 1);
|
||||
ctx->sampler_states[shader][start_slot + i] = state;
|
||||
if (state) {
|
||||
ctx->di.textures[shader][start_slot + i].sampler = state->sampler;
|
||||
@@ -848,7 +848,7 @@ zink_bind_sampler_states_nonseamless(struct pipe_context *pctx,
|
||||
if (surface && ctx->di.images[shader][start_slot + i].imageView != surface->image_view) {
|
||||
ctx->di.images[shader][start_slot + i].imageView = surface->image_view;
|
||||
update_descriptor_state_sampler(ctx, shader, start_slot + i, zink_resource(surface->base.texture));
|
||||
zink_context_invalidate_descriptor_state(ctx, shader, ZINK_DESCRIPTOR_TYPE_SAMPLER_VIEW, start_slot + i, 1);
|
||||
ctx->invalidate_descriptor_state(ctx, shader, ZINK_DESCRIPTOR_TYPE_SAMPLER_VIEW, start_slot + i, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1513,7 +1513,7 @@ zink_set_constant_buffer(struct pipe_context *pctx,
|
||||
}
|
||||
|
||||
if (update)
|
||||
zink_context_invalidate_descriptor_state(ctx, shader, ZINK_DESCRIPTOR_TYPE_UBO, index, 1);
|
||||
ctx->invalidate_descriptor_state(ctx, shader, ZINK_DESCRIPTOR_TYPE_UBO, index, 1);
|
||||
}
|
||||
|
||||
ALWAYS_INLINE static void
|
||||
@@ -1612,7 +1612,7 @@ zink_set_shader_buffers(struct pipe_context *pctx,
|
||||
if (start_slot + count >= ctx->di.num_ssbos[p_stage])
|
||||
ctx->di.num_ssbos[p_stage] = max_slot + 1;
|
||||
if (update)
|
||||
zink_context_invalidate_descriptor_state(ctx, p_stage, ZINK_DESCRIPTOR_TYPE_SSBO, start_slot, count);
|
||||
ctx->invalidate_descriptor_state(ctx, p_stage, ZINK_DESCRIPTOR_TYPE_SSBO, start_slot, count);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1623,7 +1623,7 @@ update_binds_for_samplerviews(struct zink_context *ctx, struct zink_resource *re
|
||||
u_foreach_bit(slot, res->sampler_binds[MESA_SHADER_COMPUTE]) {
|
||||
if (ctx->di.textures[MESA_SHADER_COMPUTE][slot].imageLayout != layout) {
|
||||
update_descriptor_state_sampler(ctx, MESA_SHADER_COMPUTE, slot, res);
|
||||
zink_context_invalidate_descriptor_state(ctx, MESA_SHADER_COMPUTE, ZINK_DESCRIPTOR_TYPE_SAMPLER_VIEW, slot, 1);
|
||||
ctx->invalidate_descriptor_state(ctx, MESA_SHADER_COMPUTE, ZINK_DESCRIPTOR_TYPE_SAMPLER_VIEW, slot, 1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -1631,7 +1631,7 @@ update_binds_for_samplerviews(struct zink_context *ctx, struct zink_resource *re
|
||||
u_foreach_bit(slot, res->sampler_binds[i]) {
|
||||
if (ctx->di.textures[i][slot].imageLayout != layout) {
|
||||
update_descriptor_state_sampler(ctx, i, slot, res);
|
||||
zink_context_invalidate_descriptor_state(ctx, i, ZINK_DESCRIPTOR_TYPE_SAMPLER_VIEW, slot, 1);
|
||||
ctx->invalidate_descriptor_state(ctx, i, ZINK_DESCRIPTOR_TYPE_SAMPLER_VIEW, slot, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1912,7 +1912,7 @@ zink_set_shader_images(struct pipe_context *pctx,
|
||||
}
|
||||
ctx->di.num_images[shader_type] = start_slot + count;
|
||||
if (update)
|
||||
zink_context_invalidate_descriptor_state(ctx, shader_type, ZINK_DESCRIPTOR_TYPE_IMAGE, start_slot, count);
|
||||
ctx->invalidate_descriptor_state(ctx, shader_type, ZINK_DESCRIPTOR_TYPE_IMAGE, start_slot, count);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -2096,7 +2096,7 @@ zink_set_sampler_views(struct pipe_context *pctx,
|
||||
ctx->di.num_sampler_views[shader_type] = start_slot + num_views;
|
||||
if (update) {
|
||||
struct zink_screen *screen = zink_screen(pctx->screen);
|
||||
zink_context_invalidate_descriptor_state(ctx, shader_type, ZINK_DESCRIPTOR_TYPE_SAMPLER_VIEW, start_slot, num_views);
|
||||
ctx->invalidate_descriptor_state(ctx, shader_type, ZINK_DESCRIPTOR_TYPE_SAMPLER_VIEW, start_slot, num_views);
|
||||
if (!screen->info.have_EXT_non_seamless_cube_map)
|
||||
update_nonseamless_shader_key(ctx, shader_type);
|
||||
shadow_update |= shadow_mask != ctx->di.zs_swizzle[shader_type].mask;
|
||||
@@ -2503,7 +2503,7 @@ zink_update_fbfetch(struct zink_context *ctx)
|
||||
ctx->di.fbfetch.imageView = zink_screen(ctx->base.screen)->info.rb2_feats.nullDescriptor ?
|
||||
VK_NULL_HANDLE :
|
||||
zink_get_dummy_surface(ctx, 0)->image_view;
|
||||
zink_context_invalidate_descriptor_state(ctx, MESA_SHADER_FRAGMENT, ZINK_DESCRIPTOR_TYPE_UBO, 0, 1);
|
||||
ctx->invalidate_descriptor_state(ctx, MESA_SHADER_FRAGMENT, ZINK_DESCRIPTOR_TYPE_UBO, 0, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2522,7 +2522,7 @@ zink_update_fbfetch(struct zink_context *ctx)
|
||||
}
|
||||
ctx->di.fbfetch.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
|
||||
if (changed) {
|
||||
zink_context_invalidate_descriptor_state(ctx, MESA_SHADER_FRAGMENT, ZINK_DESCRIPTOR_TYPE_UBO, 0, 1);
|
||||
ctx->invalidate_descriptor_state(ctx, MESA_SHADER_FRAGMENT, ZINK_DESCRIPTOR_TYPE_UBO, 0, 1);
|
||||
if (!had_fbfetch) {
|
||||
ctx->rp_changed = true;
|
||||
zink_batch_no_rp(ctx);
|
||||
@@ -4048,7 +4048,7 @@ rebind_ubo(struct zink_context *ctx, gl_shader_stage shader, unsigned slot)
|
||||
res->obj->unordered_read = false;
|
||||
res->obj->access |= VK_ACCESS_SHADER_READ_BIT;
|
||||
}
|
||||
zink_context_invalidate_descriptor_state(ctx, shader, ZINK_DESCRIPTOR_TYPE_UBO, slot, 1);
|
||||
ctx->invalidate_descriptor_state(ctx, shader, ZINK_DESCRIPTOR_TYPE_UBO, slot, 1);
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -4070,7 +4070,7 @@ rebind_ssbo(struct zink_context *ctx, gl_shader_stage shader, unsigned slot)
|
||||
res->obj->access |= VK_ACCESS_SHADER_WRITE_BIT;
|
||||
}
|
||||
}
|
||||
zink_context_invalidate_descriptor_state(ctx, shader, ZINK_DESCRIPTOR_TYPE_SSBO, slot, 1);
|
||||
ctx->invalidate_descriptor_state(ctx, shader, ZINK_DESCRIPTOR_TYPE_SSBO, slot, 1);
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -4092,7 +4092,7 @@ rebind_tbo(struct zink_context *ctx, gl_shader_stage shader, unsigned slot)
|
||||
res->obj->unordered_read = false;
|
||||
res->obj->access |= VK_ACCESS_SHADER_READ_BIT;
|
||||
}
|
||||
zink_context_invalidate_descriptor_state(ctx, shader, ZINK_DESCRIPTOR_TYPE_SAMPLER_VIEW, slot, 1);
|
||||
ctx->invalidate_descriptor_state(ctx, shader, ZINK_DESCRIPTOR_TYPE_SAMPLER_VIEW, slot, 1);
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -4128,7 +4128,7 @@ rebind_ibo(struct zink_context *ctx, gl_shader_stage shader, unsigned slot)
|
||||
util_range_add(&res->base.b, &res->valid_buffer_range, image_view->base.u.buf.offset,
|
||||
image_view->base.u.buf.offset + image_view->base.u.buf.size);
|
||||
update_descriptor_state_image(ctx, shader, slot, res);
|
||||
zink_context_invalidate_descriptor_state(ctx, shader, ZINK_DESCRIPTOR_TYPE_IMAGE, slot, 1);
|
||||
ctx->invalidate_descriptor_state(ctx, shader, ZINK_DESCRIPTOR_TYPE_IMAGE, slot, 1);
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -4607,7 +4607,7 @@ rebind_image(struct zink_context *ctx, struct zink_resource *res)
|
||||
struct pipe_surface *psurf = &sv->image_view->base;
|
||||
zink_rebind_surface(ctx, &psurf);
|
||||
sv->image_view = zink_surface(psurf);
|
||||
zink_context_invalidate_descriptor_state(ctx, i, ZINK_DESCRIPTOR_TYPE_SAMPLER_VIEW, j, 1);
|
||||
ctx->invalidate_descriptor_state(ctx, i, ZINK_DESCRIPTOR_TYPE_SAMPLER_VIEW, j, 1);
|
||||
update_descriptor_state_sampler(ctx, i, j, res);
|
||||
}
|
||||
}
|
||||
@@ -4616,7 +4616,7 @@ rebind_image(struct zink_context *ctx, struct zink_resource *res)
|
||||
continue;
|
||||
for (unsigned j = 0; j < ctx->di.num_images[i]; j++) {
|
||||
if (zink_resource(ctx->image_views[i][j].base.resource) == res) {
|
||||
zink_context_invalidate_descriptor_state(ctx, i, ZINK_DESCRIPTOR_TYPE_IMAGE, j, 1);
|
||||
ctx->invalidate_descriptor_state(ctx, i, ZINK_DESCRIPTOR_TYPE_IMAGE, j, 1);
|
||||
update_descriptor_state_image(ctx, i, j, res);
|
||||
_mesa_set_add(ctx->need_barriers[i == MESA_SHADER_COMPUTE], res);
|
||||
}
|
||||
@@ -4684,7 +4684,7 @@ zink_rebind_all_images(struct zink_context *ctx)
|
||||
struct pipe_surface *psurf = &sv->image_view->base;
|
||||
zink_rebind_surface(ctx, &psurf);
|
||||
sv->image_view = zink_surface(psurf);
|
||||
zink_context_invalidate_descriptor_state(ctx, i, ZINK_DESCRIPTOR_TYPE_SAMPLER_VIEW, j, 1);
|
||||
ctx->invalidate_descriptor_state(ctx, i, ZINK_DESCRIPTOR_TYPE_SAMPLER_VIEW, j, 1);
|
||||
update_descriptor_state_sampler(ctx, i, j, res);
|
||||
}
|
||||
}
|
||||
@@ -4696,7 +4696,7 @@ zink_rebind_all_images(struct zink_context *ctx)
|
||||
if (ctx->image_views[i][j].surface->obj != res->obj) {
|
||||
zink_surface_reference(zink_screen(ctx->base.screen), &image_view->surface, NULL);
|
||||
image_view->surface = create_image_surface(ctx, &image_view->base, i == MESA_SHADER_COMPUTE);
|
||||
zink_context_invalidate_descriptor_state(ctx, i, ZINK_DESCRIPTOR_TYPE_IMAGE, j, 1);
|
||||
ctx->invalidate_descriptor_state(ctx, i, ZINK_DESCRIPTOR_TYPE_IMAGE, j, 1);
|
||||
update_descriptor_state_image(ctx, i, j, res);
|
||||
_mesa_set_add(ctx->need_barriers[i == MESA_SHADER_COMPUTE], res);
|
||||
}
|
||||
@@ -5247,6 +5247,7 @@ 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 (!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);
|
||||
|
||||
@@ -1947,6 +1947,7 @@ struct zink_context {
|
||||
};
|
||||
bool bindless_refs_dirty;
|
||||
} di;
|
||||
void (*invalidate_descriptor_state)(struct zink_context *ctx, gl_shader_stage shader, enum zink_descriptor_type type, unsigned, unsigned);
|
||||
struct set *need_barriers[2]; //gfx, compute
|
||||
struct set update_barriers[2][2]; //[gfx, compute][current, next]
|
||||
uint8_t barrier_set_idx[2];
|
||||
|
||||
Reference in New Issue
Block a user