zink: rename zink_batch::state -> zink_batch::bs

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29108>
This commit is contained in:
Mike Blumenkrantz 2024-05-08 10:51:14 -04:00 committed by Marge Bot
parent 107bf9ec7c
commit e27018dc79
16 changed files with 257 additions and 257 deletions

View file

@ -473,7 +473,7 @@ get_batch_state(struct zink_context *ctx, struct zink_batch *batch)
if (bs) {
zink_reset_batch_state(ctx, bs);
} else {
if (!batch->state) {
if (!batch->bs) {
/* this is batch init, so create a few more states for later use */
for (int i = 0; i < 3; i++) {
struct zink_batch_state *state = create_batch_state(ctx);
@ -494,10 +494,10 @@ get_batch_state(struct zink_context *ctx, struct zink_batch *batch)
void
zink_reset_batch(struct zink_context *ctx, struct zink_batch *batch)
{
batch->state = get_batch_state(ctx, batch);
assert(batch->state);
batch->bs = get_batch_state(ctx, batch);
assert(batch->bs);
batch->state->has_work = false;
batch->bs->has_work = false;
}
void
@ -508,8 +508,8 @@ zink_batch_bind_db(struct zink_context *ctx)
unsigned count = 1;
VkDescriptorBufferBindingInfoEXT infos[2] = {0};
infos[0].sType = VK_STRUCTURE_TYPE_DESCRIPTOR_BUFFER_BINDING_INFO_EXT;
infos[0].address = batch->state->dd.db->obj->bda;
infos[0].usage = batch->state->dd.db->obj->vkusage;
infos[0].address = batch->bs->dd.db->obj->bda;
infos[0].usage = batch->bs->dd.db->obj->vkusage;
assert(infos[0].usage);
if (ctx->dd.bindless_init) {
@ -519,9 +519,9 @@ zink_batch_bind_db(struct zink_context *ctx)
assert(infos[1].usage);
count++;
}
VKSCR(CmdBindDescriptorBuffersEXT)(batch->state->cmdbuf, count, infos);
VKSCR(CmdBindDescriptorBuffersEXT)(batch->state->reordered_cmdbuf, count, infos);
batch->state->dd.db_bound = true;
VKSCR(CmdBindDescriptorBuffersEXT)(batch->bs->cmdbuf, count, infos);
VKSCR(CmdBindDescriptorBuffersEXT)(batch->bs->reordered_cmdbuf, count, infos);
batch->bs->dd.db_bound = true;
}
/* called on context creation and after flushing an old batch */
@ -531,7 +531,7 @@ zink_start_batch(struct zink_context *ctx, struct zink_batch *batch)
struct zink_screen *screen = zink_screen(ctx->base.screen);
zink_reset_batch(ctx, batch);
batch->state->usage.unflushed = true;
batch->bs->usage.unflushed = true;
VkCommandBufferBeginInfo cbbi = {0};
cbbi.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
@ -539,22 +539,22 @@ zink_start_batch(struct zink_context *ctx, struct zink_batch *batch)
VkResult result;
VRAM_ALLOC_LOOP(result,
VKCTX(BeginCommandBuffer)(batch->state->cmdbuf, &cbbi),
VKCTX(BeginCommandBuffer)(batch->bs->cmdbuf, &cbbi),
if (result != VK_SUCCESS)
mesa_loge("ZINK: vkBeginCommandBuffer failed (%s)", vk_Result_to_str(result));
);
VRAM_ALLOC_LOOP(result,
VKCTX(BeginCommandBuffer)(batch->state->reordered_cmdbuf, &cbbi),
VKCTX(BeginCommandBuffer)(batch->bs->reordered_cmdbuf, &cbbi),
if (result != VK_SUCCESS)
mesa_loge("ZINK: vkBeginCommandBuffer failed (%s)", vk_Result_to_str(result));
);
VRAM_ALLOC_LOOP(result,
VKCTX(BeginCommandBuffer)(batch->state->unsynchronized_cmdbuf, &cbbi),
VKCTX(BeginCommandBuffer)(batch->bs->unsynchronized_cmdbuf, &cbbi),
if (result != VK_SUCCESS)
mesa_loge("ZINK: vkBeginCommandBuffer failed (%s)", vk_Result_to_str(result));
);
batch->state->fence.completed = false;
batch->bs->fence.completed = false;
#ifdef HAVE_RENDERDOC_APP_H
if (VKCTX(CmdInsertDebugUtilsLabelEXT) && screen->renderdoc_api) {
@ -564,9 +564,9 @@ zink_start_batch(struct zink_context *ctx, struct zink_batch *batch)
capture_label.pNext = NULL;
capture_label.pLabelName = "vr-marker,frame_end,type,application";
memset(capture_label.color, 0, sizeof(capture_label.color));
VKCTX(CmdInsertDebugUtilsLabelEXT)(batch->state->unsynchronized_cmdbuf, &capture_label);
VKCTX(CmdInsertDebugUtilsLabelEXT)(batch->state->reordered_cmdbuf, &capture_label);
VKCTX(CmdInsertDebugUtilsLabelEXT)(batch->state->cmdbuf, &capture_label);
VKCTX(CmdInsertDebugUtilsLabelEXT)(batch->bs->unsynchronized_cmdbuf, &capture_label);
VKCTX(CmdInsertDebugUtilsLabelEXT)(batch->bs->reordered_cmdbuf, &capture_label);
VKCTX(CmdInsertDebugUtilsLabelEXT)(batch->bs->cmdbuf, &capture_label);
}
unsigned renderdoc_frame = p_atomic_read(&screen->renderdoc_frame);
@ -582,9 +582,9 @@ zink_start_batch(struct zink_context *ctx, struct zink_batch *batch)
zink_batch_bind_db(ctx);
/* zero init for unordered blits */
if (screen->info.have_EXT_attachment_feedback_loop_dynamic_state) {
VKCTX(CmdSetAttachmentFeedbackLoopEnableEXT)(ctx->batch.state->cmdbuf, 0);
VKCTX(CmdSetAttachmentFeedbackLoopEnableEXT)(ctx->batch.state->reordered_cmdbuf, 0);
VKCTX(CmdSetAttachmentFeedbackLoopEnableEXT)(ctx->batch.state->unsynchronized_cmdbuf, 0);
VKCTX(CmdSetAttachmentFeedbackLoopEnableEXT)(ctx->batch.bs->cmdbuf, 0);
VKCTX(CmdSetAttachmentFeedbackLoopEnableEXT)(ctx->batch.bs->reordered_cmdbuf, 0);
VKCTX(CmdSetAttachmentFeedbackLoopEnableEXT)(ctx->batch.bs->unsynchronized_cmdbuf, 0);
}
}
@ -811,7 +811,7 @@ zink_end_batch(struct zink_context *ctx, struct zink_batch *batch)
ctx->oom_flush = true;
}
bs = batch->state;
bs = batch->bs;
if (ctx->last_batch_state)
ctx->last_batch_state->next = bs;
else {
@ -825,8 +825,8 @@ zink_end_batch(struct zink_context *ctx, struct zink_batch *batch)
/* this is swapchain presentation semaphore handling */
if (ctx->swapchain) {
if (zink_kopper_acquired(ctx->swapchain->obj->dt, ctx->swapchain->obj->dt_idx) && !ctx->swapchain->obj->present) {
batch->state->present = zink_kopper_present(screen, ctx->swapchain);
batch->state->swapchain = ctx->swapchain;
batch->bs->present = zink_kopper_present(screen, ctx->swapchain);
batch->bs->swapchain = ctx->swapchain;
}
ctx->swapchain = NULL;
}
@ -878,7 +878,7 @@ zink_end_batch(struct zink_context *ctx, struct zink_batch *batch)
for (; res; res = zink_resource(res->base.b.next)) {
VkSemaphore sem = zink_create_exportable_semaphore(screen);
if (sem)
util_dynarray_append(&ctx->batch.state->signal_semaphores, VkSemaphore, sem);
util_dynarray_append(&ctx->batch.bs->signal_semaphores, VkSemaphore, sem);
}
}
@ -938,7 +938,7 @@ void
zink_batch_reference_resource_rw(struct zink_batch *batch, struct zink_resource *res, bool write)
{
/* if the resource already has usage of any sort set for this batch, */
if (!zink_resource_usage_matches(res, batch->state) ||
if (!zink_resource_usage_matches(res, batch->bs) ||
/* or if it's bound somewhere */
!zink_resource_has_binds(res))
/* then it already has a batch ref and doesn't need one here */
@ -949,7 +949,7 @@ zink_batch_reference_resource_rw(struct zink_batch *batch, struct zink_resource
void
zink_batch_add_wait_semaphore(struct zink_batch *batch, VkSemaphore sem)
{
util_dynarray_append(&batch->state->acquires, VkSemaphore, sem);
util_dynarray_append(&batch->bs->acquires, VkSemaphore, sem);
}
static bool
@ -964,7 +964,7 @@ batch_ptr_add_usage(struct zink_batch *batch, struct set *s, void *ptr)
ALWAYS_INLINE static void
check_oom_flush(struct zink_context *ctx, const struct zink_batch *batch)
{
const VkDeviceSize resource_size = batch->state->resource_size;
const VkDeviceSize resource_size = batch->bs->resource_size;
if (resource_size >= zink_screen(ctx->base.screen)->clamp_video_mem) {
ctx->oom_flush = true;
ctx->oom_stall = true;
@ -983,7 +983,7 @@ zink_batch_reference_resource(struct zink_batch *batch, struct zink_resource *re
bool
zink_batch_reference_resource_move(struct zink_batch *batch, struct zink_resource *res)
{
struct zink_batch_state *bs = batch->state;
struct zink_batch_state *bs = batch->bs;
simple_mtx_lock(&bs->ref_lock);
/* swapchains are special */
@ -1056,8 +1056,8 @@ zink_batch_reference_resource_move(struct zink_batch *batch, struct zink_resourc
* performing unbind finishes.
*/
}
check_oom_flush(batch->state->ctx, batch);
batch->state->has_work = true;
check_oom_flush(batch->bs->ctx, batch);
batch->bs->has_work = true;
simple_mtx_unlock(&bs->ref_lock);
return false;
}
@ -1067,12 +1067,12 @@ void
zink_batch_reference_program(struct zink_batch *batch,
struct zink_program *pg)
{
if (zink_batch_usage_matches(pg->batch_uses, batch->state) ||
!batch_ptr_add_usage(batch, &batch->state->programs, pg))
if (zink_batch_usage_matches(pg->batch_uses, batch->bs) ||
!batch_ptr_add_usage(batch, &batch->bs->programs, pg))
return;
pipe_reference(NULL, &pg->reference);
zink_batch_usage_set(&pg->batch_uses, batch->state);
batch->state->has_work = true;
zink_batch_usage_set(&pg->batch_uses, batch->bs);
batch->bs->has_work = true;
}
/* a fast (hopefully) way to check whether a given batch has completed */
@ -1115,7 +1115,7 @@ batch_usage_wait(struct zink_context *ctx, struct zink_batch_usage *u, bool tryw
if (!zink_batch_usage_exists(u))
return;
if (zink_batch_usage_is_unflushed(u)) {
if (likely(u == &ctx->batch.state->usage))
if (likely(u == &ctx->batch.bs->usage))
ctx->base.flush(&ctx->base, NULL, PIPE_FLUSH_HINT_FINISH);
else { //multi-context
mtx_lock(&u->mtx);

View file

@ -73,9 +73,9 @@ blit_resolve(struct zink_context *ctx, const struct pipe_blit_info *info, bool *
struct zink_batch *batch = &ctx->batch;
zink_resource_setup_transfer_layouts(ctx, use_src, dst);
VkCommandBuffer cmdbuf = *needs_present_readback ?
ctx->batch.state->cmdbuf :
ctx->batch.bs->cmdbuf :
zink_get_cmdbuf(ctx, src, dst);
if (cmdbuf == ctx->batch.state->cmdbuf)
if (cmdbuf == ctx->batch.bs->cmdbuf)
zink_flush_dgc_if_enabled(ctx);
zink_batch_reference_resource_rw(batch, use_src, false);
zink_batch_reference_resource_rw(batch, dst, true);
@ -280,9 +280,9 @@ blit_native(struct zink_context *ctx, const struct pipe_blit_info *info, bool *n
struct zink_batch *batch = &ctx->batch;
zink_resource_setup_transfer_layouts(ctx, use_src, dst);
VkCommandBuffer cmdbuf = *needs_present_readback ?
ctx->batch.state->cmdbuf :
ctx->batch.bs->cmdbuf :
zink_get_cmdbuf(ctx, src, dst);
if (cmdbuf == ctx->batch.state->cmdbuf)
if (cmdbuf == ctx->batch.bs->cmdbuf)
zink_flush_dgc_if_enabled(ctx);
zink_batch_reference_resource_rw(batch, use_src, false);
zink_batch_reference_resource_rw(batch, dst, true);
@ -423,8 +423,8 @@ zink_blit(struct pipe_context *pctx,
ctx->unordered_blitting = !(info->render_condition_enable && ctx->render_condition_active) &&
zink_screen(ctx->base.screen)->info.have_KHR_dynamic_rendering &&
!needs_present_readback &&
zink_get_cmdbuf(ctx, src, dst) == ctx->batch.state->reordered_cmdbuf;
VkCommandBuffer cmdbuf = ctx->batch.state->cmdbuf;
zink_get_cmdbuf(ctx, src, dst) == ctx->batch.bs->reordered_cmdbuf;
VkCommandBuffer cmdbuf = ctx->batch.bs->cmdbuf;
VkPipeline pipeline = ctx->gfx_pipeline_state.pipeline;
bool in_rp = ctx->in_rp;
uint64_t tc_data = ctx->dynamic_fb.tc_info.data;
@ -434,11 +434,11 @@ zink_blit(struct pipe_context *pctx,
bool rp_tc_info_updated = ctx->rp_tc_info_updated;
if (ctx->unordered_blitting) {
/* for unordered blit, swap the unordered cmdbuf for the main one for the whole op to avoid conditional hell */
ctx->batch.state->cmdbuf = ctx->batch.state->reordered_cmdbuf;
ctx->batch.bs->cmdbuf = ctx->batch.bs->reordered_cmdbuf;
ctx->in_rp = false;
ctx->rp_changed = true;
ctx->queries_disabled = true;
ctx->batch.state->has_barriers = true;
ctx->batch.bs->has_barriers = true;
ctx->pipeline_changed[0] = true;
zink_reset_ds3_states(ctx);
zink_select_draw_vbo(ctx);
@ -486,7 +486,7 @@ zink_blit(struct pipe_context *pctx,
ctx->rp_tc_info_updated |= rp_tc_info_updated;
ctx->queries_disabled = queries_disabled;
ctx->dynamic_fb.tc_info.data = tc_data;
ctx->batch.state->cmdbuf = cmdbuf;
ctx->batch.bs->cmdbuf = cmdbuf;
ctx->gfx_pipeline_state.pipeline = pipeline;
ctx->pipeline_changed[0] = true;
ctx->ds3_states = ds3_states;

View file

@ -751,7 +751,7 @@ static void
track_freed_sparse_bo(struct zink_context *ctx, struct zink_sparse_backing *backing)
{
pipe_reference(NULL, &backing->bo->base.base.reference);
util_dynarray_append(&ctx->batch.state->freed_sparse_backing_bos, struct zink_bo*, backing->bo);
util_dynarray_append(&ctx->batch.bs->freed_sparse_backing_bos, struct zink_bo*, backing->bo);
}
static VkSemaphore

View file

@ -108,7 +108,7 @@ clear_in_rp(struct pipe_context *pctx,
cr.layerCount = util_framebuffer_get_num_layers(fb);
struct zink_batch *batch = &ctx->batch;
assert(ctx->in_rp);
VKCTX(CmdClearAttachments)(batch->state->cmdbuf, num_attachments, attachments, 1, &cr);
VKCTX(CmdClearAttachments)(batch->bs->cmdbuf, num_attachments, attachments, 1, &cr);
/*
Rendering within a subpass containing a feedback loop creates a data race, except in the following
cases:
@ -474,7 +474,7 @@ zink_clear_texture_dynamic(struct pipe_context *pctx,
zink_blit_barriers(ctx, NULL, res, full_clear);
VkCommandBuffer cmdbuf = zink_get_cmdbuf(ctx, NULL, res);
if (cmdbuf == ctx->batch.state->cmdbuf && ctx->in_rp)
if (cmdbuf == ctx->batch.bs->cmdbuf && ctx->in_rp)
zink_batch_no_rp(ctx);
if (res->aspect & VK_IMAGE_ASPECT_COLOR_BIT) {
@ -701,24 +701,24 @@ fb_clears_apply_internal(struct zink_context *ctx, struct pipe_resource *pres, i
else {
struct zink_resource *res = zink_resource(pres);
bool queries_disabled = ctx->queries_disabled;
VkCommandBuffer cmdbuf = ctx->batch.state->cmdbuf;
VkCommandBuffer cmdbuf = ctx->batch.bs->cmdbuf;
/* slightly different than the u_blitter handling:
* this can be called recursively while unordered_blitting=true
*/
bool can_reorder = zink_screen(ctx->base.screen)->info.have_KHR_dynamic_rendering &&
!ctx->render_condition_active &&
!ctx->unordered_blitting &&
zink_get_cmdbuf(ctx, NULL, res) == ctx->batch.state->reordered_cmdbuf;
zink_get_cmdbuf(ctx, NULL, res) == ctx->batch.bs->reordered_cmdbuf;
if (can_reorder) {
/* set unordered_blitting but NOT blitting:
* let begin_rendering handle layouts
*/
ctx->unordered_blitting = true;
/* for unordered clears, swap the unordered cmdbuf for the main one for the whole op to avoid conditional hell */
ctx->batch.state->cmdbuf = ctx->batch.state->reordered_cmdbuf;
ctx->batch.bs->cmdbuf = ctx->batch.bs->reordered_cmdbuf;
ctx->rp_changed = true;
ctx->queries_disabled = true;
ctx->batch.state->has_barriers = true;
ctx->batch.bs->has_barriers = true;
}
/* this will automatically trigger all the clears */
zink_batch_rp(ctx);
@ -727,7 +727,7 @@ fb_clears_apply_internal(struct zink_context *ctx, struct pipe_resource *pres, i
ctx->unordered_blitting = false;
ctx->rp_changed = true;
ctx->queries_disabled = queries_disabled;
ctx->batch.state->cmdbuf = cmdbuf;
ctx->batch.bs->cmdbuf = cmdbuf;
}
}
zink_fb_clear_reset(ctx, i);

View file

@ -125,7 +125,7 @@ zink_context_destroy(struct pipe_context *pctx)
if (util_queue_is_initialized(&screen->flush_queue))
util_queue_finish(&screen->flush_queue);
if (ctx->batch.state && !screen->device_lost) {
if (ctx->batch.bs && !screen->device_lost) {
simple_mtx_lock(&screen->queue_lock);
VkResult result = VKSCR(QueueWaitIdle)(screen->queue);
simple_mtx_unlock(&screen->queue_lock);
@ -201,12 +201,12 @@ zink_context_destroy(struct pipe_context *pctx)
}
while (screen->last_free_batch_state && screen->last_free_batch_state->next)
screen->last_free_batch_state = screen->last_free_batch_state->next;
if (ctx->batch.state) {
zink_clear_batch_state(ctx, ctx->batch.state);
if (ctx->batch.bs) {
zink_clear_batch_state(ctx, ctx->batch.bs);
if (screen->free_batch_states)
screen->last_free_batch_state->next = ctx->batch.state;
screen->last_free_batch_state->next = ctx->batch.bs;
else {
screen->free_batch_states = ctx->batch.state;
screen->free_batch_states = ctx->batch.bs;
screen->last_free_batch_state = screen->free_batch_states;
}
}
@ -931,11 +931,11 @@ zink_delete_sampler_state(struct pipe_context *pctx,
struct zink_sampler_state *sampler = sampler_state;
struct zink_batch *batch = &zink_context(pctx)->batch;
/* may be called if context_create fails */
if (batch->state) {
util_dynarray_append(&batch->state->zombie_samplers, VkSampler,
if (batch->bs) {
util_dynarray_append(&batch->bs->zombie_samplers, VkSampler,
sampler->sampler);
if (sampler->sampler_clamped)
util_dynarray_append(&batch->state->zombie_samplers, VkSampler,
util_dynarray_append(&batch->bs->zombie_samplers, VkSampler,
sampler->sampler_clamped);
}
if (sampler->custom_border_color)
@ -1991,7 +1991,7 @@ update_feedback_loop_dynamic_state(struct zink_context *ctx)
aspects |= VK_IMAGE_ASPECT_COLOR_BIT;
if (ctx->feedback_loops & BITFIELD_BIT(PIPE_MAX_COLOR_BUFS))
aspects |= VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT;
VKCTX(CmdSetAttachmentFeedbackLoopEnableEXT)(ctx->batch.state->cmdbuf, aspects);
VKCTX(CmdSetAttachmentFeedbackLoopEnableEXT)(ctx->batch.bs->cmdbuf, aspects);
}
static void
@ -2233,7 +2233,7 @@ zink_delete_texture_handle(struct pipe_context *pctx, uint64_t handle)
struct zink_descriptor_surface *ds = &bd->ds;
_mesa_hash_table_remove(&ctx->di.bindless[is_buffer].tex_handles, he);
uint32_t h = handle;
util_dynarray_append(&ctx->batch.state->bindless_releases[0], uint32_t, h);
util_dynarray_append(&ctx->batch.bs->bindless_releases[0], uint32_t, h);
if (ds->is_buffer) {
if (zink_descriptor_mode == ZINK_DESCRIPTOR_MODE_DB) {
@ -2440,7 +2440,7 @@ zink_delete_image_handle(struct pipe_context *pctx, uint64_t handle)
struct zink_descriptor_surface *ds = he->data;
_mesa_hash_table_remove(&ctx->di.bindless[is_buffer].img_handles, he);
uint32_t h = handle;
util_dynarray_append(&ctx->batch.state->bindless_releases[1], uint32_t, h);
util_dynarray_append(&ctx->batch.bs->bindless_releases[1], uint32_t, h);
if (ds->is_buffer) {
if (zink_descriptor_mode == ZINK_DESCRIPTOR_MODE_DB) {
@ -2558,7 +2558,7 @@ zink_set_global_binding(struct pipe_context *pctx,
memcpy(&addr, handles[i], sizeof(addr));
addr += zink_resource_get_address(zink_screen(pctx->screen), res);
memcpy(handles[i], &addr, sizeof(addr));
zink_resource_usage_set(res, ctx->batch.state, true);
zink_resource_usage_set(res, ctx->batch.bs, true);
res->obj->unordered_read = res->obj->unordered_write = false;
zink_screen(ctx->base.screen)->buffer_barrier(ctx, res, VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
} else if (globals[i]) {
@ -2600,7 +2600,7 @@ zink_set_patch_vertices(struct pipe_context *pctx, uint8_t patch_vertices)
if (zink_set_tcs_key_patches(ctx, patch_vertices)) {
ctx->gfx_pipeline_state.dyn_state2.vertices_per_patch = patch_vertices;
if (zink_screen(ctx->base.screen)->info.dynamic_state2_feats.extendedDynamicState2PatchControlPoints)
VKCTX(CmdSetPatchControlPointsEXT)(ctx->batch.state->cmdbuf, patch_vertices);
VKCTX(CmdSetPatchControlPointsEXT)(ctx->batch.bs->cmdbuf, patch_vertices);
else
ctx->gfx_pipeline_state.dirty = true;
zink_flush_dgc_if_enabled(ctx);
@ -2954,7 +2954,7 @@ begin_rendering(struct zink_context *ctx)
if (zink_screen(ctx->base.screen)->info.have_EXT_multisampled_render_to_single_sampled)
ctx->dynamic_fb.info.pNext = ctx->transient_attachments ? &msrtss : NULL;
assert(!ctx->transient_attachments || msrtss.rasterizationSamples != VK_SAMPLE_COUNT_1_BIT);
VKCTX(CmdBeginRendering)(ctx->batch.state->cmdbuf, &ctx->dynamic_fb.info);
VKCTX(CmdBeginRendering)(ctx->batch.bs->cmdbuf, &ctx->dynamic_fb.info);
ctx->in_rp = true;
return clear_buffers;
}
@ -2966,7 +2966,7 @@ update_layered_rendering_state(struct zink_context *ctx)
return;
unsigned framebffer_is_layered = zink_framebuffer_get_num_layers(&ctx->fb_state) > 1;
VKCTX(CmdPushConstants)(
ctx->batch.state->cmdbuf,
ctx->batch.bs->cmdbuf,
zink_screen(ctx->base.screen)->gfx_push_constant_layout,
VK_SHADER_STAGE_ALL_GRAPHICS,
offsetof(struct zink_gfx_push_constant, framebuffer_is_layered), sizeof(unsigned),
@ -3064,7 +3064,7 @@ zink_batch_no_rp_safe(struct zink_context *ctx)
if (ctx->gfx_pipeline_state.render_pass)
zink_end_render_pass(ctx);
else {
VKCTX(CmdEndRendering)(ctx->batch.state->cmdbuf);
VKCTX(CmdEndRendering)(ctx->batch.bs->cmdbuf);
ctx->in_rp = false;
}
assert(!ctx->in_rp);
@ -3370,11 +3370,11 @@ reapply_color_write(struct zink_context *ctx)
const VkBool32 enables[PIPE_MAX_COLOR_BUFS] = {1, 1, 1, 1, 1, 1, 1, 1};
const VkBool32 disables[PIPE_MAX_COLOR_BUFS] = {0};
const unsigned max_att = MIN2(PIPE_MAX_COLOR_BUFS, screen->info.props.limits.maxColorAttachments);
VKCTX(CmdSetColorWriteEnableEXT)(ctx->batch.state->cmdbuf, max_att, ctx->disable_color_writes ? disables : enables);
VKCTX(CmdSetColorWriteEnableEXT)(ctx->batch.state->reordered_cmdbuf, max_att, enables);
VKCTX(CmdSetColorWriteEnableEXT)(ctx->batch.bs->cmdbuf, max_att, ctx->disable_color_writes ? disables : enables);
VKCTX(CmdSetColorWriteEnableEXT)(ctx->batch.bs->reordered_cmdbuf, max_att, enables);
assert(screen->info.have_EXT_extended_dynamic_state);
if (ctx->dsa_state)
VKCTX(CmdSetDepthWriteEnable)(ctx->batch.state->cmdbuf, ctx->disable_color_writes ? VK_FALSE : ctx->dsa_state->hw_state.depth_write);
VKCTX(CmdSetDepthWriteEnable)(ctx->batch.bs->cmdbuf, ctx->disable_color_writes ? VK_FALSE : ctx->dsa_state->hw_state.depth_write);
}
static void
@ -3420,9 +3420,9 @@ flush_batch(struct zink_context *ctx, bool sync)
ctx->deferred_fence = NULL;
if (sync)
sync_flush(ctx, ctx->batch.state);
sync_flush(ctx, ctx->batch.bs);
if (ctx->batch.state->is_device_lost) {
if (ctx->batch.bs->is_device_lost) {
check_device_lost(ctx);
} else {
struct zink_screen *screen = zink_screen(ctx->base.screen);
@ -3443,8 +3443,8 @@ flush_batch(struct zink_context *ctx, bool sync)
ctx->di.bindless_refs_dirty = true;
ctx->sample_locations_changed = ctx->gfx_pipeline_state.sample_locations_enabled;
if (zink_screen(ctx->base.screen)->info.dynamic_state2_feats.extendedDynamicState2PatchControlPoints) {
VKCTX(CmdSetPatchControlPointsEXT)(ctx->batch.state->cmdbuf, ctx->gfx_pipeline_state.dyn_state2.vertices_per_patch);
VKCTX(CmdSetPatchControlPointsEXT)(ctx->batch.state->reordered_cmdbuf, 1);
VKCTX(CmdSetPatchControlPointsEXT)(ctx->batch.bs->cmdbuf, ctx->gfx_pipeline_state.dyn_state2.vertices_per_patch);
VKCTX(CmdSetPatchControlPointsEXT)(ctx->batch.bs->reordered_cmdbuf, 1);
}
update_feedback_loop_dynamic_state(ctx);
if (screen->info.have_EXT_color_write_enable)
@ -3895,9 +3895,9 @@ zink_flush(struct pipe_context *pctx,
};
VkResult result = VKSCR(CreateSemaphore)(screen->dev, &sci, NULL, &export_sem);
if (zink_screen_handle_vkresult(screen, result)) {
assert(!batch->state->signal_semaphore);
batch->state->signal_semaphore = export_sem;
batch->state->has_work = true;
assert(!batch->bs->signal_semaphore);
batch->bs->signal_semaphore = export_sem;
batch->bs->has_work = true;
} else {
mesa_loge("ZINK: vkCreateSemaphore failed (%s)", vk_Result_to_str(result));
@ -3906,7 +3906,7 @@ zink_flush(struct pipe_context *pctx,
}
}
if (!batch->state->has_work) {
if (!batch->bs->has_work) {
if (pfence) {
/* reuse last fence */
bs = ctx->last_batch_state;
@ -3922,7 +3922,7 @@ zink_flush(struct pipe_context *pctx,
if (ctx->tc && !ctx->track_renderpasses)
tc_driver_internal_flush_notify(ctx->tc);
} else {
bs = batch->state;
bs = batch->bs;
if (deferred && !(flags & PIPE_FLUSH_FENCE_FD) && pfence)
deferred_fence = true;
else
@ -3951,7 +3951,7 @@ zink_flush(struct pipe_context *pctx,
}
if (export_sem) {
pipe_reference(NULL, &mfence->reference);
util_dynarray_append(&ctx->batch.state->fences, struct zink_tc_fence*, mfence);
util_dynarray_append(&ctx->batch.bs->fences, struct zink_tc_fence*, mfence);
}
if (deferred_fence) {
@ -3977,7 +3977,7 @@ zink_fence_wait(struct pipe_context *pctx)
{
struct zink_context *ctx = zink_context(pctx);
if (ctx->batch.state->has_work)
if (ctx->batch.bs->has_work)
pctx->flush(pctx, NULL, PIPE_FLUSH_HINT_FINISH);
if (ctx->last_batch_state)
stall(ctx);
@ -4002,7 +4002,7 @@ zink_wait_on_batch(struct zink_context *ctx, uint64_t batch_id)
bool
zink_check_batch_completion(struct zink_context *ctx, uint64_t batch_id)
{
assert(ctx->batch.state);
assert(ctx->batch.bs);
if (!batch_id)
/* not submitted yet */
return false;
@ -4058,14 +4058,14 @@ zink_texture_barrier(struct pipe_context *pctx, unsigned flags)
dmb.dstStageMask |= depth_flags;
}
*/
VKCTX(CmdPipelineBarrier2)(ctx->batch.state->cmdbuf, &dep);
VKCTX(CmdPipelineBarrier2)(ctx->batch.bs->cmdbuf, &dep);
} else {
VkMemoryBarrier bmb = {0};
bmb.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER;
bmb.srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
bmb.dstAccessMask = dst;
VKCTX(CmdPipelineBarrier)(
ctx->batch.state->cmdbuf,
ctx->batch.bs->cmdbuf,
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
0,
@ -4086,7 +4086,7 @@ mem_barrier(struct zink_context *ctx, VkPipelineStageFlags src_stage, VkPipeline
mb.srcAccessMask = src;
mb.dstAccessMask = dst;
zink_batch_no_rp(ctx);
VKCTX(CmdPipelineBarrier)(batch->state->cmdbuf, src_stage, dst_stage, 0, 1, &mb, 0, NULL, 0, NULL);
VKCTX(CmdPipelineBarrier)(batch->bs->cmdbuf, src_stage, dst_stage, 0, 1, &mb, 0, NULL, 0, NULL);
}
void
@ -4523,8 +4523,8 @@ zink_copy_buffer(struct zink_context *ctx, struct zink_resource *dst, struct zin
zink_screen(ctx->base.screen)->buffer_barrier(ctx, src, VK_ACCESS_TRANSFER_READ_BIT, 0);
bool unordered_dst = zink_resource_buffer_transfer_dst_barrier(ctx, dst, dst_offset, size);
bool can_unorder = unordered_dst && unordered_src && !ctx->no_reorder;
VkCommandBuffer cmdbuf = can_unorder ? ctx->batch.state->reordered_cmdbuf : zink_get_cmdbuf(ctx, src, dst);
ctx->batch.state->has_barriers |= can_unorder;
VkCommandBuffer cmdbuf = can_unorder ? ctx->batch.bs->reordered_cmdbuf : zink_get_cmdbuf(ctx, src, dst);
ctx->batch.bs->has_barriers |= can_unorder;
zink_batch_reference_resource_rw(batch, src, false);
zink_batch_reference_resource_rw(batch, dst, true);
if (unlikely(zink_debug & ZINK_DEBUG_SYNC)) {
@ -4621,15 +4621,15 @@ zink_copy_image_buffer(struct zink_context *ctx, struct zink_resource *dst, stru
region.imageExtent.height = src_box->height;
VkCommandBuffer cmdbuf = unsync ?
ctx->batch.state->unsynchronized_cmdbuf :
ctx->batch.bs->unsynchronized_cmdbuf :
/* never promote to unordered if swapchain was acquired */
needs_present_readback ?
ctx->batch.state->cmdbuf :
ctx->batch.bs->cmdbuf :
buf2img ? zink_get_cmdbuf(ctx, buf, use_img) : zink_get_cmdbuf(ctx, use_img, buf);
zink_batch_reference_resource_rw(batch, use_img, buf2img);
zink_batch_reference_resource_rw(batch, buf, !buf2img);
if (unsync) {
ctx->batch.state->has_unsync = true;
ctx->batch.bs->has_unsync = true;
use_img->obj->unsync_access = true;
}
@ -4863,7 +4863,7 @@ zink_resource_commit(struct pipe_context *pctx, struct pipe_resource *pres, unsi
if (sem) {
zink_batch_add_wait_semaphore(&ctx->batch, sem);
zink_batch_reference_resource_rw(&ctx->batch, res, true);
ctx->batch.state->has_work = true;
ctx->batch.bs->has_work = true;
}
} else {
check_device_lost(ctx);
@ -5051,7 +5051,7 @@ zink_emit_string_marker(struct pipe_context *pctx,
string,
{ 0 }
};
screen->vk.CmdInsertDebugUtilsLabelEXT(batch->state->cmdbuf, &label);
screen->vk.CmdInsertDebugUtilsLabelEXT(batch->bs->cmdbuf, &label);
free(temp);
}
@ -5141,7 +5141,7 @@ void
zink_flush_dgc(struct zink_context *ctx)
{
struct zink_screen *screen = zink_screen(ctx->base.screen);
struct zink_batch_state *bs = ctx->batch.state;
struct zink_batch_state *bs = ctx->batch.bs;
if (!ctx->dgc.valid)
return;
@ -5236,7 +5236,7 @@ zink_flush_dgc(struct zink_context *ctx)
VK_NULL_HANDLE,
0
};
VKCTX(CmdExecuteGeneratedCommandsNV)(ctx->batch.state->cmdbuf, VK_FALSE, &gen);
VKCTX(CmdExecuteGeneratedCommandsNV)(ctx->batch.bs->cmdbuf, VK_FALSE, &gen);
pipe_resource_reference(&pres, NULL);
}
@ -5553,7 +5553,7 @@ zink_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
}
zink_start_batch(ctx, &ctx->batch);
if (!ctx->batch.state)
if (!ctx->batch.bs)
goto fail;
if (screen->compact_descriptors)
@ -5570,8 +5570,8 @@ zink_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
* a tess shader later
*/
if (screen->info.dynamic_state2_feats.extendedDynamicState2PatchControlPoints) {
VKCTX(CmdSetPatchControlPointsEXT)(ctx->batch.state->cmdbuf, 1);
VKCTX(CmdSetPatchControlPointsEXT)(ctx->batch.state->reordered_cmdbuf, 1);
VKCTX(CmdSetPatchControlPointsEXT)(ctx->batch.bs->cmdbuf, 1);
VKCTX(CmdSetPatchControlPointsEXT)(ctx->batch.bs->reordered_cmdbuf, 1);
}
}
if (!is_copy_only) {
@ -5796,7 +5796,7 @@ zink_cmd_debug_marker_begin(struct zink_context *ctx, VkCommandBuffer cmdbuf, co
info.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT;
info.pLabelName = name;
VKCTX(CmdBeginDebugUtilsLabelEXT)(cmdbuf ? cmdbuf : ctx->batch.state->cmdbuf, &info);
VKCTX(CmdBeginDebugUtilsLabelEXT)(cmdbuf ? cmdbuf : ctx->batch.bs->cmdbuf, &info);
free(name);
return true;

View file

@ -1070,7 +1070,7 @@ static void
enlarge_db(struct zink_context *ctx)
{
struct zink_screen *screen = zink_screen(ctx->base.screen);
struct zink_batch_state *bs = ctx->batch.state;
struct zink_batch_state *bs = ctx->batch.bs;
/* ensure current db surives */
zink_batch_reference_resource(&ctx->batch, bs->dd.db);
/* rebinding a db mid-batch is extremely costly: if we start with a factor
@ -1085,7 +1085,7 @@ static void
update_separable(struct zink_context *ctx, struct zink_program *pg)
{
struct zink_screen *screen = zink_screen(ctx->base.screen);
struct zink_batch_state *bs = ctx->batch.state;
struct zink_batch_state *bs = ctx->batch.bs;
unsigned use_buffer = 0;
VkDescriptorGetInfoEXT info;
@ -1157,7 +1157,7 @@ static void
zink_descriptors_update_masked_buffer(struct zink_context *ctx, bool is_compute, uint8_t changed_sets, uint8_t bind_sets)
{
struct zink_screen *screen = zink_screen(ctx->base.screen);
struct zink_batch_state *bs = ctx->batch.state;
struct zink_batch_state *bs = ctx->batch.bs;
struct zink_program *pg = is_compute ? &ctx->curr_compute->base : &ctx->curr_program->base;
/* skip if no descriptors are updated */
@ -1233,7 +1233,7 @@ void
zink_descriptors_update_masked(struct zink_context *ctx, bool is_compute, uint8_t changed_sets, uint8_t bind_sets)
{
struct zink_screen *screen = zink_screen(ctx->base.screen);
struct zink_batch_state *bs = ctx->batch.state;
struct zink_batch_state *bs = ctx->batch.bs;
struct zink_program *pg = is_compute ? &ctx->curr_compute->base : &ctx->curr_program->base;
VkDescriptorSet desc_sets[ZINK_DESCRIPTOR_BASE_TYPES];
@ -1247,7 +1247,7 @@ zink_descriptors_update_masked(struct zink_context *ctx, bool is_compute, uint8_
return;
}
/* no flushing allowed: sets are allocated to the batch, so this breaks everything */
assert(ctx->batch.state == bs);
assert(ctx->batch.bs == bs);
u_foreach_bit(type, changed_sets) {
assert(type + 1 < pg->num_dsl);
@ -1285,7 +1285,7 @@ zink_descriptors_update_masked(struct zink_context *ctx, bool is_compute, uint8_
static void
bind_bindless_db(struct zink_context *ctx, struct zink_program *pg)
{
struct zink_batch_state *bs = ctx->batch.state;
struct zink_batch_state *bs = ctx->batch.bs;
struct zink_screen *screen = zink_screen(ctx->base.screen);
unsigned index = 1;
VkDeviceSize offset = 0;
@ -1306,7 +1306,7 @@ bind_bindless_db(struct zink_context *ctx, struct zink_program *pg)
void
zink_descriptors_update(struct zink_context *ctx, bool is_compute)
{
struct zink_batch_state *bs = ctx->batch.state;
struct zink_batch_state *bs = ctx->batch.bs;
struct zink_program *pg = is_compute ? &ctx->curr_compute->base : &ctx->curr_program->base;
struct zink_screen *screen = zink_screen(ctx->base.screen);
bool have_KHR_push_descriptor = screen->info.have_KHR_push_descriptor;
@ -1454,7 +1454,7 @@ zink_descriptors_update(struct zink_context *ctx, bool is_compute)
if (zink_descriptor_mode == ZINK_DESCRIPTOR_MODE_DB) {
bind_bindless_db(ctx, pg);
} else {
VKCTX(CmdBindDescriptorSets)(ctx->batch.state->cmdbuf, is_compute ? VK_PIPELINE_BIND_POINT_COMPUTE : VK_PIPELINE_BIND_POINT_GRAPHICS,
VKCTX(CmdBindDescriptorSets)(ctx->batch.bs->cmdbuf, is_compute ? VK_PIPELINE_BIND_POINT_COMPUTE : VK_PIPELINE_BIND_POINT_GRAPHICS,
pg->layout, screen->desc_set_id[ZINK_DESCRIPTOR_BINDLESS], 1, &ctx->dd.t.bindless_set,
0, NULL);
}

View file

@ -83,7 +83,7 @@ zink_emit_stream_output_targets(struct pipe_context *pctx)
t->base.buffer_offset + t->base.buffer_size);
}
VKCTX(CmdBindTransformFeedbackBuffersEXT)(batch->state->cmdbuf, 0, ctx->num_so_targets,
VKCTX(CmdBindTransformFeedbackBuffersEXT)(batch->bs->cmdbuf, 0, ctx->num_so_targets,
buffers, buffer_offsets,
buffer_sizes);
ctx->dirty_so_targets = false;
@ -168,16 +168,16 @@ zink_bind_vertex_buffers(struct zink_batch *batch, struct zink_context *ctx)
DYNAMIC_STATE != ZINK_DYNAMIC_VERTEX_INPUT2 &&
DYNAMIC_STATE != ZINK_DYNAMIC_VERTEX_INPUT) {
if (elems->hw_state.num_bindings)
VKCTX(CmdBindVertexBuffers2)(batch->state->cmdbuf, 0,
VKCTX(CmdBindVertexBuffers2)(batch->bs->cmdbuf, 0,
elems->hw_state.num_bindings,
buffers, buffer_offsets, NULL, elems->hw_state.b.strides);
} else if (elems->hw_state.num_bindings)
VKSCR(CmdBindVertexBuffers)(batch->state->cmdbuf, 0,
VKSCR(CmdBindVertexBuffers)(batch->bs->cmdbuf, 0,
elems->hw_state.num_bindings,
buffers, buffer_offsets);
if (DYNAMIC_STATE == ZINK_DYNAMIC_VERTEX_INPUT2 || DYNAMIC_STATE == ZINK_DYNAMIC_VERTEX_INPUT)
VKCTX(CmdSetVertexInputEXT)(batch->state->cmdbuf,
VKCTX(CmdSetVertexInputEXT)(batch->bs->cmdbuf,
elems->hw_state.num_bindings, elems->hw_state.dynbindings,
elems->hw_state.num_attribs, elems->hw_state.dynattribs);
@ -187,7 +187,7 @@ zink_bind_vertex_buffers(struct zink_batch *batch, struct zink_context *ctx)
ALWAYS_INLINE static void
update_drawid(struct zink_context *ctx, unsigned draw_id)
{
VKCTX(CmdPushConstants)(ctx->batch.state->cmdbuf, ctx->curr_program->base.layout, VK_SHADER_STAGE_ALL_GRAPHICS,
VKCTX(CmdPushConstants)(ctx->batch.bs->cmdbuf, ctx->curr_program->base.layout, VK_SHADER_STAGE_ALL_GRAPHICS,
offsetof(struct zink_gfx_push_constant, draw_id), sizeof(unsigned),
&draw_id);
}
@ -241,7 +241,7 @@ draw_indexed_need_index_buffer_unref(struct zink_context *ctx,
unsigned draw_id,
bool needs_drawid)
{
VkCommandBuffer cmdbuf = ctx->batch.state->cmdbuf;
VkCommandBuffer cmdbuf = ctx->batch.bs->cmdbuf;
if (dinfo->increment_draw_id && needs_drawid) {
for (unsigned i = 0; i < num_draws; i++) {
update_drawid(ctx, draw_id);
@ -301,7 +301,7 @@ draw_indexed(struct zink_context *ctx,
unsigned draw_id,
bool needs_drawid)
{
VkCommandBuffer cmdbuf = ctx->batch.state->cmdbuf;
VkCommandBuffer cmdbuf = ctx->batch.bs->cmdbuf;
if (dinfo->increment_draw_id && needs_drawid) {
for (unsigned i = 0; i < num_draws; i++) {
update_drawid(ctx, draw_id);
@ -367,7 +367,7 @@ draw(struct zink_context *ctx,
unsigned draw_id,
bool needs_drawid)
{
VkCommandBuffer cmdbuf = ctx->batch.state->cmdbuf;
VkCommandBuffer cmdbuf = ctx->batch.bs->cmdbuf;
if (dinfo->increment_draw_id && needs_drawid) {
for (unsigned i = 0; i < num_draws; i++) {
update_drawid(ctx, draw_id);
@ -598,7 +598,7 @@ zink_draw(struct pipe_context *pctx,
mb.pNext = NULL;
mb.srcAccessMask = VK_ACCESS_MEMORY_WRITE_BIT;
mb.dstAccessMask = VK_ACCESS_MEMORY_READ_BIT;
VKSCR(CmdPipelineBarrier)(ctx->batch.state->cmdbuf,
VKSCR(CmdPipelineBarrier)(ctx->batch.bs->cmdbuf,
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
0, 1, &mb, 0, NULL, 0, NULL);
@ -670,7 +670,7 @@ zink_draw(struct pipe_context *pctx,
ptr->size = res->base.b.width0;
ptr->indexType = index_type[index_size >> 1];
} else {
VKCTX(CmdBindIndexBuffer)(batch->state->cmdbuf, res->obj->buffer, index_offset, index_type[index_size >> 1]);
VKCTX(CmdBindIndexBuffer)(batch->bs->cmdbuf, res->obj->buffer, index_offset, index_type[index_size >> 1]);
}
}
if (DYNAMIC_STATE < ZINK_DYNAMIC_STATE2) {
@ -682,7 +682,7 @@ zink_draw(struct pipe_context *pctx,
if (have_streamout && ctx->dirty_so_targets)
zink_emit_stream_output_targets(pctx);
bool pipeline_changed = update_gfx_pipeline<DYNAMIC_STATE, BATCH_CHANGED>(ctx, batch->state, mode, can_dgc);
bool pipeline_changed = update_gfx_pipeline<DYNAMIC_STATE, BATCH_CHANGED>(ctx, batch->bs, mode, can_dgc);
if (BATCH_CHANGED || ctx->vp_state_changed || (DYNAMIC_STATE == ZINK_NO_DYNAMIC_STATE && pipeline_changed)) {
VkViewport viewports[PIPE_MAX_VIEWPORTS];
@ -711,9 +711,9 @@ zink_draw(struct pipe_context *pctx,
viewports[i] = viewport;
}
if (DYNAMIC_STATE != ZINK_NO_DYNAMIC_STATE)
VKCTX(CmdSetViewportWithCount)(batch->state->cmdbuf, ctx->vp_state.num_viewports, viewports);
VKCTX(CmdSetViewportWithCount)(batch->bs->cmdbuf, ctx->vp_state.num_viewports, viewports);
else
VKCTX(CmdSetViewport)(batch->state->cmdbuf, 0, ctx->vp_state.num_viewports, viewports);
VKCTX(CmdSetViewport)(batch->bs->cmdbuf, 0, ctx->vp_state.num_viewports, viewports);
}
if (BATCH_CHANGED || ctx->scissor_changed || ctx->vp_state_changed || (DYNAMIC_STATE == ZINK_NO_DYNAMIC_STATE && pipeline_changed)) {
VkRect2D scissors[PIPE_MAX_VIEWPORTS];
@ -733,111 +733,111 @@ zink_draw(struct pipe_context *pctx,
}
}
if (DYNAMIC_STATE != ZINK_NO_DYNAMIC_STATE)
VKCTX(CmdSetScissorWithCount)(batch->state->cmdbuf, ctx->vp_state.num_viewports, scissors);
VKCTX(CmdSetScissorWithCount)(batch->bs->cmdbuf, ctx->vp_state.num_viewports, scissors);
else
VKCTX(CmdSetScissor)(batch->state->cmdbuf, 0, ctx->vp_state.num_viewports, scissors);
VKCTX(CmdSetScissor)(batch->bs->cmdbuf, 0, ctx->vp_state.num_viewports, scissors);
}
ctx->vp_state_changed = false;
ctx->scissor_changed = false;
if (BATCH_CHANGED || ctx->stencil_ref_changed) {
VKCTX(CmdSetStencilReference)(batch->state->cmdbuf, VK_STENCIL_FACE_FRONT_BIT,
VKCTX(CmdSetStencilReference)(batch->bs->cmdbuf, VK_STENCIL_FACE_FRONT_BIT,
ctx->stencil_ref.ref_value[0]);
VKCTX(CmdSetStencilReference)(batch->state->cmdbuf, VK_STENCIL_FACE_BACK_BIT,
VKCTX(CmdSetStencilReference)(batch->bs->cmdbuf, VK_STENCIL_FACE_BACK_BIT,
ctx->stencil_ref.ref_value[1]);
ctx->stencil_ref_changed = false;
}
if (DYNAMIC_STATE != ZINK_NO_DYNAMIC_STATE && (BATCH_CHANGED || ctx->dsa_state_changed)) {
VKCTX(CmdSetDepthBoundsTestEnable)(batch->state->cmdbuf, dsa_state->hw_state.depth_bounds_test);
VKCTX(CmdSetDepthBoundsTestEnable)(batch->bs->cmdbuf, dsa_state->hw_state.depth_bounds_test);
if (dsa_state->hw_state.depth_bounds_test)
VKCTX(CmdSetDepthBounds)(batch->state->cmdbuf,
VKCTX(CmdSetDepthBounds)(batch->bs->cmdbuf,
dsa_state->hw_state.min_depth_bounds,
dsa_state->hw_state.max_depth_bounds);
VKCTX(CmdSetDepthTestEnable)(batch->state->cmdbuf, dsa_state->hw_state.depth_test);
VKCTX(CmdSetDepthCompareOp)(batch->state->cmdbuf, dsa_state->hw_state.depth_compare_op);
VKCTX(CmdSetDepthWriteEnable)(batch->state->cmdbuf, dsa_state->hw_state.depth_write);
VKCTX(CmdSetStencilTestEnable)(batch->state->cmdbuf, dsa_state->hw_state.stencil_test);
VKCTX(CmdSetDepthTestEnable)(batch->bs->cmdbuf, dsa_state->hw_state.depth_test);
VKCTX(CmdSetDepthCompareOp)(batch->bs->cmdbuf, dsa_state->hw_state.depth_compare_op);
VKCTX(CmdSetDepthWriteEnable)(batch->bs->cmdbuf, dsa_state->hw_state.depth_write);
VKCTX(CmdSetStencilTestEnable)(batch->bs->cmdbuf, dsa_state->hw_state.stencil_test);
if (dsa_state->hw_state.stencil_test) {
VKCTX(CmdSetStencilOp)(batch->state->cmdbuf, VK_STENCIL_FACE_FRONT_BIT,
VKCTX(CmdSetStencilOp)(batch->bs->cmdbuf, VK_STENCIL_FACE_FRONT_BIT,
dsa_state->hw_state.stencil_front.failOp,
dsa_state->hw_state.stencil_front.passOp,
dsa_state->hw_state.stencil_front.depthFailOp,
dsa_state->hw_state.stencil_front.compareOp);
VKCTX(CmdSetStencilOp)(batch->state->cmdbuf, VK_STENCIL_FACE_BACK_BIT,
VKCTX(CmdSetStencilOp)(batch->bs->cmdbuf, VK_STENCIL_FACE_BACK_BIT,
dsa_state->hw_state.stencil_back.failOp,
dsa_state->hw_state.stencil_back.passOp,
dsa_state->hw_state.stencil_back.depthFailOp,
dsa_state->hw_state.stencil_back.compareOp);
if (dsa_state->base.stencil[1].enabled) {
VKCTX(CmdSetStencilWriteMask)(batch->state->cmdbuf, VK_STENCIL_FACE_FRONT_BIT, dsa_state->hw_state.stencil_front.writeMask);
VKCTX(CmdSetStencilWriteMask)(batch->state->cmdbuf, VK_STENCIL_FACE_BACK_BIT, dsa_state->hw_state.stencil_back.writeMask);
VKCTX(CmdSetStencilCompareMask)(batch->state->cmdbuf, VK_STENCIL_FACE_FRONT_BIT, dsa_state->hw_state.stencil_front.compareMask);
VKCTX(CmdSetStencilCompareMask)(batch->state->cmdbuf, VK_STENCIL_FACE_BACK_BIT, dsa_state->hw_state.stencil_back.compareMask);
VKCTX(CmdSetStencilWriteMask)(batch->bs->cmdbuf, VK_STENCIL_FACE_FRONT_BIT, dsa_state->hw_state.stencil_front.writeMask);
VKCTX(CmdSetStencilWriteMask)(batch->bs->cmdbuf, VK_STENCIL_FACE_BACK_BIT, dsa_state->hw_state.stencil_back.writeMask);
VKCTX(CmdSetStencilCompareMask)(batch->bs->cmdbuf, VK_STENCIL_FACE_FRONT_BIT, dsa_state->hw_state.stencil_front.compareMask);
VKCTX(CmdSetStencilCompareMask)(batch->bs->cmdbuf, VK_STENCIL_FACE_BACK_BIT, dsa_state->hw_state.stencil_back.compareMask);
} else {
VKCTX(CmdSetStencilWriteMask)(batch->state->cmdbuf, VK_STENCIL_FACE_FRONT_AND_BACK, dsa_state->hw_state.stencil_front.writeMask);
VKCTX(CmdSetStencilCompareMask)(batch->state->cmdbuf, VK_STENCIL_FACE_FRONT_AND_BACK, dsa_state->hw_state.stencil_front.compareMask);
VKCTX(CmdSetStencilWriteMask)(batch->bs->cmdbuf, VK_STENCIL_FACE_FRONT_AND_BACK, dsa_state->hw_state.stencil_front.writeMask);
VKCTX(CmdSetStencilCompareMask)(batch->bs->cmdbuf, VK_STENCIL_FACE_FRONT_AND_BACK, dsa_state->hw_state.stencil_front.compareMask);
}
} else {
VKCTX(CmdSetStencilWriteMask)(batch->state->cmdbuf, VK_STENCIL_FACE_FRONT_AND_BACK, dsa_state->hw_state.stencil_front.writeMask);
VKCTX(CmdSetStencilCompareMask)(batch->state->cmdbuf, VK_STENCIL_FACE_FRONT_AND_BACK, dsa_state->hw_state.stencil_front.compareMask);
VKCTX(CmdSetStencilOp)(batch->state->cmdbuf, VK_STENCIL_FACE_FRONT_AND_BACK, VK_STENCIL_OP_KEEP, VK_STENCIL_OP_KEEP, VK_STENCIL_OP_KEEP, VK_COMPARE_OP_ALWAYS);
VKCTX(CmdSetStencilWriteMask)(batch->bs->cmdbuf, VK_STENCIL_FACE_FRONT_AND_BACK, dsa_state->hw_state.stencil_front.writeMask);
VKCTX(CmdSetStencilCompareMask)(batch->bs->cmdbuf, VK_STENCIL_FACE_FRONT_AND_BACK, dsa_state->hw_state.stencil_front.compareMask);
VKCTX(CmdSetStencilOp)(batch->bs->cmdbuf, VK_STENCIL_FACE_FRONT_AND_BACK, VK_STENCIL_OP_KEEP, VK_STENCIL_OP_KEEP, VK_STENCIL_OP_KEEP, VK_COMPARE_OP_ALWAYS);
}
}
ctx->dsa_state_changed = false;
if (BATCH_CHANGED || rast_state_changed) {
if (DYNAMIC_STATE != ZINK_NO_DYNAMIC_STATE) {
VKCTX(CmdSetFrontFace)(batch->state->cmdbuf, (VkFrontFace)ctx->gfx_pipeline_state.dyn_state1.front_face);
VKCTX(CmdSetCullMode)(batch->state->cmdbuf, ctx->gfx_pipeline_state.dyn_state1.cull_mode);
VKCTX(CmdSetFrontFace)(batch->bs->cmdbuf, (VkFrontFace)ctx->gfx_pipeline_state.dyn_state1.front_face);
VKCTX(CmdSetCullMode)(batch->bs->cmdbuf, ctx->gfx_pipeline_state.dyn_state1.cull_mode);
}
if (DYNAMIC_STATE >= ZINK_DYNAMIC_STATE3) {
if (ctx->ds3_states & BITFIELD_BIT(ZINK_DS3_RAST_STIPPLE))
VKCTX(CmdSetLineStippleEXT)(batch->state->cmdbuf, rast_state->base.line_stipple_factor, rast_state->base.line_stipple_pattern);
VKCTX(CmdSetLineStippleEXT)(batch->bs->cmdbuf, rast_state->base.line_stipple_factor, rast_state->base.line_stipple_pattern);
if (ctx->ds3_states & BITFIELD_BIT(ZINK_DS3_RAST_CLIP))
VKCTX(CmdSetDepthClipEnableEXT)(batch->state->cmdbuf, rast_state->hw_state.depth_clip);
VKCTX(CmdSetDepthClipEnableEXT)(batch->bs->cmdbuf, rast_state->hw_state.depth_clip);
if (ctx->ds3_states & BITFIELD_BIT(ZINK_DS3_RAST_CLAMP))
VKCTX(CmdSetDepthClampEnableEXT)(batch->state->cmdbuf, rast_state->hw_state.depth_clamp);
VKCTX(CmdSetDepthClampEnableEXT)(batch->bs->cmdbuf, rast_state->hw_state.depth_clamp);
if (ctx->ds3_states & BITFIELD_BIT(ZINK_DS3_RAST_POLYGON))
VKCTX(CmdSetPolygonModeEXT)(batch->state->cmdbuf, (VkPolygonMode)rast_state->hw_state.polygon_mode);
VKCTX(CmdSetPolygonModeEXT)(batch->bs->cmdbuf, (VkPolygonMode)rast_state->hw_state.polygon_mode);
if (ctx->ds3_states & BITFIELD_BIT(ZINK_DS3_RAST_HALFZ))
VKCTX(CmdSetDepthClipNegativeOneToOneEXT)(batch->state->cmdbuf, !rast_state->hw_state.clip_halfz);
VKCTX(CmdSetDepthClipNegativeOneToOneEXT)(batch->bs->cmdbuf, !rast_state->hw_state.clip_halfz);
if (ctx->ds3_states & BITFIELD_BIT(ZINK_DS3_RAST_PV))
VKCTX(CmdSetProvokingVertexModeEXT)(batch->state->cmdbuf,
VKCTX(CmdSetProvokingVertexModeEXT)(batch->bs->cmdbuf,
rast_state->hw_state.pv_last ?
VK_PROVOKING_VERTEX_MODE_LAST_VERTEX_EXT :
VK_PROVOKING_VERTEX_MODE_FIRST_VERTEX_EXT);
if (ctx->ds3_states & BITFIELD_BIT(ZINK_DS3_RAST_CLIP))
VKCTX(CmdSetLineRasterizationModeEXT)(batch->state->cmdbuf, rast_state->dynamic_line_mode);
VKCTX(CmdSetLineRasterizationModeEXT)(batch->bs->cmdbuf, rast_state->dynamic_line_mode);
if (ctx->ds3_states & BITFIELD_BIT(ZINK_DS3_RAST_STIPPLE_ON))
VKCTX(CmdSetLineStippleEnableEXT)(batch->state->cmdbuf, rast_state->hw_state.line_stipple_enable);
VKCTX(CmdSetLineStippleEnableEXT)(batch->bs->cmdbuf, rast_state->hw_state.line_stipple_enable);
}
}
if ((BATCH_CHANGED || ctx->sample_mask_changed) && screen->have_full_ds3) {
VKCTX(CmdSetRasterizationSamplesEXT)(batch->state->cmdbuf, (VkSampleCountFlagBits)(ctx->gfx_pipeline_state.rast_samples + 1));
VKCTX(CmdSetSampleMaskEXT)(batch->state->cmdbuf, (VkSampleCountFlagBits)(ctx->gfx_pipeline_state.rast_samples + 1), &ctx->gfx_pipeline_state.sample_mask);
VKCTX(CmdSetRasterizationSamplesEXT)(batch->bs->cmdbuf, (VkSampleCountFlagBits)(ctx->gfx_pipeline_state.rast_samples + 1));
VKCTX(CmdSetSampleMaskEXT)(batch->bs->cmdbuf, (VkSampleCountFlagBits)(ctx->gfx_pipeline_state.rast_samples + 1), &ctx->gfx_pipeline_state.sample_mask);
ctx->sample_mask_changed = false;
}
if ((BATCH_CHANGED || ctx->blend_state_changed)) {
if (ctx->gfx_pipeline_state.blend_state) {
if (ctx->ds3_states & BITFIELD_BIT(ZINK_DS3_BLEND_A2C))
VKCTX(CmdSetAlphaToCoverageEnableEXT)(batch->state->cmdbuf, ctx->gfx_pipeline_state.blend_state->alpha_to_coverage &&
VKCTX(CmdSetAlphaToCoverageEnableEXT)(batch->bs->cmdbuf, ctx->gfx_pipeline_state.blend_state->alpha_to_coverage &&
ctx->gfx_stages[MESA_SHADER_FRAGMENT]->info.outputs_written & BITFIELD_BIT(FRAG_RESULT_DATA0));
if (ctx->ds3_states & BITFIELD_BIT(ZINK_DS3_BLEND_A21))
VKCTX(CmdSetAlphaToOneEnableEXT)(batch->state->cmdbuf, ctx->gfx_pipeline_state.blend_state->alpha_to_one);
VKCTX(CmdSetAlphaToOneEnableEXT)(batch->bs->cmdbuf, ctx->gfx_pipeline_state.blend_state->alpha_to_one);
if (ctx->fb_state.nr_cbufs) {
if (ctx->ds3_states & BITFIELD_BIT(ZINK_DS3_BLEND_ON))
VKCTX(CmdSetColorBlendEnableEXT)(batch->state->cmdbuf, 0, ctx->fb_state.nr_cbufs, ctx->gfx_pipeline_state.blend_state->ds3.enables);
VKCTX(CmdSetColorBlendEnableEXT)(batch->bs->cmdbuf, 0, ctx->fb_state.nr_cbufs, ctx->gfx_pipeline_state.blend_state->ds3.enables);
if (ctx->ds3_states & BITFIELD_BIT(ZINK_DS3_BLEND_WRITE))
VKCTX(CmdSetColorWriteMaskEXT)(batch->state->cmdbuf, 0, ctx->fb_state.nr_cbufs, ctx->gfx_pipeline_state.blend_state->ds3.wrmask);
VKCTX(CmdSetColorWriteMaskEXT)(batch->bs->cmdbuf, 0, ctx->fb_state.nr_cbufs, ctx->gfx_pipeline_state.blend_state->ds3.wrmask);
if (ctx->ds3_states & BITFIELD_BIT(ZINK_DS3_BLEND_EQ))
VKCTX(CmdSetColorBlendEquationEXT)(batch->state->cmdbuf, 0, ctx->fb_state.nr_cbufs, ctx->gfx_pipeline_state.blend_state->ds3.eq);
VKCTX(CmdSetColorBlendEquationEXT)(batch->bs->cmdbuf, 0, ctx->fb_state.nr_cbufs, ctx->gfx_pipeline_state.blend_state->ds3.eq);
}
if (ctx->ds3_states & BITFIELD_BIT(ZINK_DS3_BLEND_LOGIC_ON))
VKCTX(CmdSetLogicOpEnableEXT)(batch->state->cmdbuf, ctx->gfx_pipeline_state.blend_state->logicop_enable);
VKCTX(CmdSetLogicOpEnableEXT)(batch->bs->cmdbuf, ctx->gfx_pipeline_state.blend_state->logicop_enable);
if (ctx->ds3_states & BITFIELD_BIT(ZINK_DS3_BLEND_LOGIC))
VKCTX(CmdSetLogicOpEXT)(batch->state->cmdbuf, ctx->gfx_pipeline_state.blend_state->logicop_func);
VKCTX(CmdSetLogicOpEXT)(batch->bs->cmdbuf, ctx->gfx_pipeline_state.blend_state->logicop_func);
}
}
ctx->ds3_states = 0;
@ -845,7 +845,7 @@ zink_draw(struct pipe_context *pctx,
if (BATCH_CHANGED ||
/* only re-emit on non-batch change when actually drawing lines */
((ctx->line_width_changed || rast_prim_changed) && ctx->gfx_pipeline_state.rast_prim == MESA_PRIM_LINES)) {
VKCTX(CmdSetLineWidth)(batch->state->cmdbuf, rast_state->line_width);
VKCTX(CmdSetLineWidth)(batch->bs->cmdbuf, rast_state->line_width);
ctx->line_width_changed = false;
}
@ -858,12 +858,12 @@ zink_draw(struct pipe_context *pctx,
if (depth_bias) {
if (rast_state->base.offset_units_unscaled) {
VKCTX(CmdSetDepthBias)(batch->state->cmdbuf, rast_state->offset_units * ctx->depth_bias_scale_factor, rast_state->offset_clamp, rast_state->offset_scale);
VKCTX(CmdSetDepthBias)(batch->bs->cmdbuf, rast_state->offset_units * ctx->depth_bias_scale_factor, rast_state->offset_clamp, rast_state->offset_scale);
} else {
VKCTX(CmdSetDepthBias)(batch->state->cmdbuf, rast_state->offset_units, rast_state->offset_clamp, rast_state->offset_scale);
VKCTX(CmdSetDepthBias)(batch->bs->cmdbuf, rast_state->offset_units, rast_state->offset_clamp, rast_state->offset_scale);
}
} else {
VKCTX(CmdSetDepthBias)(batch->state->cmdbuf, 0.0f, 0.0f, 0.0f);
VKCTX(CmdSetDepthBias)(batch->bs->cmdbuf, 0.0f, 0.0f, 0.0f);
}
}
ctx->rast_state_changed = false;
@ -872,13 +872,13 @@ zink_draw(struct pipe_context *pctx,
if (ctx->sample_locations_changed) {
VkSampleLocationsInfoEXT loc;
zink_init_vk_sample_locations(ctx, &loc);
VKCTX(CmdSetSampleLocationsEXT)(batch->state->cmdbuf, &loc);
VKCTX(CmdSetSampleLocationsEXT)(batch->bs->cmdbuf, &loc);
}
ctx->sample_locations_changed = false;
}
if (BATCH_CHANGED || ctx->blend_color_changed) {
VKCTX(CmdSetBlendConstants)(batch->state->cmdbuf, ctx->blend_constants);
VKCTX(CmdSetBlendConstants)(batch->bs->cmdbuf, ctx->blend_constants);
}
ctx->blend_state_changed = false;
ctx->blend_color_changed = false;
@ -900,15 +900,15 @@ zink_draw(struct pipe_context *pctx,
}
if (DYNAMIC_STATE != ZINK_NO_DYNAMIC_STATE && (BATCH_CHANGED || mode_changed))
VKCTX(CmdSetPrimitiveTopology)(batch->state->cmdbuf, zink_primitive_topology(mode));
VKCTX(CmdSetPrimitiveTopology)(batch->bs->cmdbuf, zink_primitive_topology(mode));
if (DYNAMIC_STATE >= ZINK_DYNAMIC_STATE2 && (BATCH_CHANGED || ctx->primitive_restart != dinfo->primitive_restart)) {
VKCTX(CmdSetPrimitiveRestartEnable)(batch->state->cmdbuf, dinfo->primitive_restart);
VKCTX(CmdSetPrimitiveRestartEnable)(batch->bs->cmdbuf, dinfo->primitive_restart);
ctx->primitive_restart = dinfo->primitive_restart;
}
if (DYNAMIC_STATE >= ZINK_DYNAMIC_STATE2 && (BATCH_CHANGED || ctx->rasterizer_discard_changed)) {
VKCTX(CmdSetRasterizerDiscardEnable)(batch->state->cmdbuf, ctx->gfx_pipeline_state.dyn_state2.rasterizer_discard);
VKCTX(CmdSetRasterizerDiscardEnable)(batch->bs->cmdbuf, ctx->gfx_pipeline_state.dyn_state2.rasterizer_discard);
ctx->rasterizer_discard_changed = false;
}
@ -930,7 +930,7 @@ zink_draw(struct pipe_context *pctx,
token->pushconstantSize = sizeof(unsigned);
*ptr = draw_mode_is_indexed;
} else {
VKCTX(CmdPushConstants)(batch->state->cmdbuf, ctx->curr_program->base.layout, VK_SHADER_STAGE_ALL_GRAPHICS,
VKCTX(CmdPushConstants)(batch->bs->cmdbuf, ctx->curr_program->base.layout, VK_SHADER_STAGE_ALL_GRAPHICS,
offsetof(struct zink_gfx_push_constant, draw_mode_is_indexed), sizeof(unsigned),
&draw_mode_is_indexed);
}
@ -944,7 +944,7 @@ zink_draw(struct pipe_context *pctx,
token->pushconstantSize = sizeof(float) * 6;
memcpy(ptr, &ctx->tess_levels[0], sizeof(float) * 6);
} else {
VKCTX(CmdPushConstants)(batch->state->cmdbuf, ctx->curr_program->base.layout, VK_SHADER_STAGE_ALL_GRAPHICS,
VKCTX(CmdPushConstants)(batch->bs->cmdbuf, ctx->curr_program->base.layout, VK_SHADER_STAGE_ALL_GRAPHICS,
offsetof(struct zink_gfx_push_constant, default_inner_level), sizeof(float) * 6,
&ctx->tess_levels[0]);
}
@ -965,7 +965,7 @@ zink_draw(struct pipe_context *pctx,
ctx->vp_state.viewport_states[0].scale[0],
ctx->vp_state.viewport_states[0].scale[1]
};
VKCTX(CmdPushConstants)(batch->state->cmdbuf,
VKCTX(CmdPushConstants)(batch->bs->cmdbuf,
ctx->curr_program->base.layout,
VK_SHADER_STAGE_ALL_GRAPHICS,
offsetof(struct zink_gfx_push_constant, viewport_scale),
@ -973,7 +973,7 @@ zink_draw(struct pipe_context *pctx,
uint32_t stipple = ctx->rast_state->base.line_stipple_pattern;
stipple |= ctx->rast_state->base.line_stipple_factor << 16;
VKCTX(CmdPushConstants)(batch->state->cmdbuf,
VKCTX(CmdPushConstants)(batch->bs->cmdbuf,
ctx->curr_program->base.layout,
VK_SHADER_STAGE_ALL_GRAPHICS,
offsetof(struct zink_gfx_push_constant, line_stipple_pattern),
@ -981,7 +981,7 @@ zink_draw(struct pipe_context *pctx,
if (ctx->gfx_pipeline_state.shader_keys.key[MESA_SHADER_FRAGMENT].key.fs.lower_line_smooth) {
float line_width = ctx->rast_state->base.line_width;
VKCTX(CmdPushConstants)(batch->state->cmdbuf,
VKCTX(CmdPushConstants)(batch->bs->cmdbuf,
ctx->curr_program->base.layout,
VK_SHADER_STAGE_ALL_GRAPHICS,
offsetof(struct zink_gfx_push_constant, line_width),
@ -1006,7 +1006,7 @@ zink_draw(struct pipe_context *pctx,
}
}
}
VKCTX(CmdBeginTransformFeedbackEXT)(batch->state->cmdbuf, 0, ctx->num_so_targets, counter_buffers, counter_buffer_offsets);
VKCTX(CmdBeginTransformFeedbackEXT)(batch->bs->cmdbuf, 0, ctx->num_so_targets, counter_buffers, counter_buffer_offsets);
}
bool marker = false;
@ -1049,11 +1049,11 @@ zink_draw(struct pipe_context *pctx,
if (dindirect->indirect_draw_count) {
struct zink_resource *indirect_draw_count = zink_resource(dindirect->indirect_draw_count);
zink_batch_reference_resource_rw(batch, indirect_draw_count, false);
VKCTX(CmdDrawIndexedIndirectCount)(batch->state->cmdbuf, indirect->obj->buffer, dindirect->offset,
VKCTX(CmdDrawIndexedIndirectCount)(batch->bs->cmdbuf, indirect->obj->buffer, dindirect->offset,
indirect_draw_count->obj->buffer, dindirect->indirect_draw_count_offset,
dindirect->draw_count, dindirect->stride);
} else
VKCTX(CmdDrawIndexedIndirect)(batch->state->cmdbuf, indirect->obj->buffer, dindirect->offset, dindirect->draw_count, dindirect->stride);
VKCTX(CmdDrawIndexedIndirect)(batch->bs->cmdbuf, indirect->obj->buffer, dindirect->offset, dindirect->draw_count, dindirect->stride);
} else {
if (unlikely(can_dgc)) {
if (need_index_buffer_unref)
@ -1077,7 +1077,7 @@ zink_draw(struct pipe_context *pctx,
update_drawid(ctx, drawid_offset);
zink_batch_reference_resource_rw(batch, zink_resource(so_target->base.buffer), false);
zink_batch_reference_resource_rw(batch, zink_resource(so_target->counter_buffer), true);
VKCTX(CmdDrawIndirectByteCountEXT)(batch->state->cmdbuf, dinfo->instance_count, dinfo->start_instance,
VKCTX(CmdDrawIndirectByteCountEXT)(batch->bs->cmdbuf, dinfo->instance_count, dinfo->start_instance,
zink_resource(so_target->counter_buffer)->obj->buffer, so_target->counter_buffer_offset, 0,
MIN2(so_target->stride, screen->info.tf_props.maxTransformFeedbackBufferDataStride));
}
@ -1090,11 +1090,11 @@ zink_draw(struct pipe_context *pctx,
if (dindirect->indirect_draw_count) {
struct zink_resource *indirect_draw_count = zink_resource(dindirect->indirect_draw_count);
zink_batch_reference_resource_rw(batch, indirect_draw_count, false);
VKCTX(CmdDrawIndirectCount)(batch->state->cmdbuf, indirect->obj->buffer, dindirect->offset,
VKCTX(CmdDrawIndirectCount)(batch->bs->cmdbuf, indirect->obj->buffer, dindirect->offset,
indirect_draw_count->obj->buffer, dindirect->indirect_draw_count_offset,
dindirect->draw_count, dindirect->stride);
} else
VKCTX(CmdDrawIndirect)(batch->state->cmdbuf, indirect->obj->buffer, dindirect->offset, dindirect->draw_count, dindirect->stride);
VKCTX(CmdDrawIndirect)(batch->bs->cmdbuf, indirect->obj->buffer, dindirect->offset, dindirect->draw_count, dindirect->stride);
} else {
if (unlikely(can_dgc))
draw_dgc(ctx, dinfo, draws, num_draws, drawid_offset, needs_drawid);
@ -1104,7 +1104,7 @@ zink_draw(struct pipe_context *pctx,
}
if (unlikely(zink_tracing))
zink_cmd_debug_marker_end(ctx, batch->state->cmdbuf, marker);
zink_cmd_debug_marker_end(ctx, batch->bs->cmdbuf, marker);
ctx->dgc.valid = can_dgc;
if (have_streamout) {
@ -1116,10 +1116,10 @@ zink_draw(struct pipe_context *pctx,
t->counter_buffer_valid = true;
}
}
VKCTX(CmdEndTransformFeedbackEXT)(batch->state->cmdbuf, 0, ctx->num_so_targets, counter_buffers, counter_buffer_offsets);
VKCTX(CmdEndTransformFeedbackEXT)(batch->bs->cmdbuf, 0, ctx->num_so_targets, counter_buffers, counter_buffer_offsets);
}
batch->state->has_work = true;
batch->bs->has_work = true;
ctx->last_work_was_compute = false;
ctx->work_count = work_count;
/* flush if there's >100k draws */
@ -1144,7 +1144,7 @@ static void
zink_vertex_state_mask(struct zink_context *ctx, struct pipe_vertex_state *vstate, uint32_t partial_velem_mask)
{
struct zink_vertex_state *zstate = (struct zink_vertex_state *)vstate;
VkCommandBuffer cmdbuf = ctx->batch.state->cmdbuf;
VkCommandBuffer cmdbuf = ctx->batch.bs->cmdbuf;
if (partial_velem_mask == vstate->input.full_velem_mask) {
VKCTX(CmdSetVertexInputEXT)(cmdbuf,
@ -1172,7 +1172,7 @@ static void
zink_bind_vertex_state(struct zink_context *ctx, struct pipe_vertex_state *vstate, uint32_t partial_velem_mask)
{
struct zink_vertex_state *zstate = (struct zink_vertex_state *)vstate;
VkCommandBuffer cmdbuf = ctx->batch.state->cmdbuf;
VkCommandBuffer cmdbuf = ctx->batch.bs->cmdbuf;
if (!vstate->input.vbuffer.buffer.resource)
return;
@ -1260,7 +1260,7 @@ zink_launch_grid(struct pipe_context *pctx, const struct pipe_grid_info *info)
mb.pNext = NULL;
mb.srcAccessMask = VK_ACCESS_MEMORY_WRITE_BIT;
mb.dstAccessMask = VK_ACCESS_MEMORY_READ_BIT;
VKSCR(CmdPipelineBarrier)(ctx->batch.state->cmdbuf,
VKSCR(CmdPipelineBarrier)(ctx->batch.bs->cmdbuf,
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
0, 1, &mb, 0, NULL, 0, NULL);
@ -1282,7 +1282,7 @@ zink_launch_grid(struct pipe_context *pctx, const struct pipe_grid_info *info)
&ctx->compute_pipeline_state);
if (prev_pipeline != pipeline || BATCH_CHANGED)
VKCTX(CmdBindPipeline)(batch->state->cmdbuf, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline);
VKCTX(CmdBindPipeline)(batch->bs->cmdbuf, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline);
if (BATCH_CHANGED) {
ctx->pipeline_changed[1] = false;
zink_select_launch_grid(ctx);
@ -1298,11 +1298,11 @@ zink_launch_grid(struct pipe_context *pctx, const struct pipe_grid_info *info)
if (!ctx->queries_disabled)
zink_resume_cs_query(ctx);
if (info->indirect) {
VKCTX(CmdDispatchIndirect)(batch->state->cmdbuf, zink_resource(info->indirect)->obj->buffer, info->indirect_offset);
VKCTX(CmdDispatchIndirect)(batch->bs->cmdbuf, zink_resource(info->indirect)->obj->buffer, info->indirect_offset);
zink_batch_reference_resource_rw(batch, zink_resource(info->indirect), false);
} else
VKCTX(CmdDispatch)(batch->state->cmdbuf, info->grid[0], info->grid[1], info->grid[2]);
batch->state->has_work = true;
VKCTX(CmdDispatch)(batch->bs->cmdbuf, info->grid[0], info->grid[1], info->grid[2]);
batch->bs->has_work = true;
ctx->last_work_was_compute = true;
/* flush if there's >100k computes */
if (!ctx->unordered_blitting && (unlikely(ctx->work_count >= 30000) || ctx->oom_flush))

View file

@ -159,7 +159,7 @@ zink_fence_finish(struct zink_screen *screen, struct pipe_context *pctx, struct
if (pctx && mfence->deferred_ctx == pctx) {
if (mfence->fence == ctx->deferred_fence) {
zink_context(pctx)->batch.state->has_work = true;
zink_context(pctx)->batch.bs->has_work = true;
/* this must be the current batch */
pctx->flush(pctx, NULL, !timeout_ns ? PIPE_FLUSH_ASYNC : 0);
if (!timeout_ns)
@ -236,10 +236,10 @@ zink_fence_server_signal(struct pipe_context *pctx, struct pipe_fence_handle *pf
struct zink_context *ctx = zink_context(pctx);
struct zink_tc_fence *mfence = (struct zink_tc_fence *)pfence;
assert(!ctx->batch.state->signal_semaphore);
ctx->batch.state->signal_semaphore = mfence->sem;
ctx->batch.state->has_work = true;
struct zink_batch_state *bs = ctx->batch.state;
assert(!ctx->batch.bs->signal_semaphore);
ctx->batch.bs->signal_semaphore = mfence->sem;
ctx->batch.bs->has_work = true;
struct zink_batch_state *bs = ctx->batch.bs;
/* this must produce a synchronous flush that completes before the function returns */
pctx->flush(pctx, NULL, 0);
if (zink_screen(ctx->base.screen)->threaded_submit)
@ -258,10 +258,10 @@ zink_fence_server_sync(struct pipe_context *pctx, struct pipe_fence_handle *pfen
mfence->deferred_ctx = pctx;
/* this will be applied on the next submit */
VkPipelineStageFlags flag = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
util_dynarray_append(&ctx->batch.state->wait_semaphores, VkSemaphore, mfence->sem);
util_dynarray_append(&ctx->batch.state->wait_semaphore_stages, VkPipelineStageFlags, flag);
util_dynarray_append(&ctx->batch.bs->wait_semaphores, VkSemaphore, mfence->sem);
util_dynarray_append(&ctx->batch.bs->wait_semaphore_stages, VkPipelineStageFlags, flag);
pipe_reference(NULL, &mfence->reference);
util_dynarray_append(&ctx->batch.state->fences, struct zink_tc_fence*, mfence);
util_dynarray_append(&ctx->batch.bs->fences, struct zink_tc_fence*, mfence);
/* transfer the external wait sempahore ownership to the next submit */
mfence->sem = VK_NULL_HANDLE;

View file

@ -665,7 +665,7 @@ zink_kopper_acquire(struct zink_context *ctx, struct zink_resource *res, uint64_
kill_swapchain(ctx, res);
}
bool is_kill = is_swapchain_kill(ret);
zink_batch_usage_set(&cdt->swapchain->batch_uses, ctx->batch.state);
zink_batch_usage_set(&cdt->swapchain->batch_uses, ctx->batch.bs);
return !is_kill;
}
@ -985,7 +985,7 @@ zink_kopper_acquire_readback(struct zink_context *ctx, struct zink_resource *res
res->base.b.width0 = ctx->swapchain_size.width;
res->base.b.height0 = ctx->swapchain_size.height;
}
zink_batch_usage_set(&cdt->swapchain->batch_uses, ctx->batch.state);
zink_batch_usage_set(&cdt->swapchain->batch_uses, ctx->batch.bs);
*readback = res;
return true;
}

View file

@ -128,7 +128,7 @@ begin_vk_query_indexed(struct zink_context *ctx, struct zink_vk_query *vkq, int
{
struct zink_batch *batch = &ctx->batch;
if (!vkq->started) {
VKCTX(CmdBeginQueryIndexedEXT)(batch->state->cmdbuf,
VKCTX(CmdBeginQueryIndexedEXT)(batch->bs->cmdbuf,
vkq->pool->query_pool,
vkq->query_id,
flags,
@ -142,7 +142,7 @@ end_vk_query_indexed(struct zink_context *ctx, struct zink_vk_query *vkq, int in
{
struct zink_batch *batch = &ctx->batch;
if (vkq->started) {
VKCTX(CmdEndQueryIndexedEXT)(batch->state->cmdbuf,
VKCTX(CmdEndQueryIndexedEXT)(batch->bs->cmdbuf,
vkq->pool->query_pool,
vkq->query_id, index);
vkq->started = false;
@ -154,8 +154,8 @@ reset_vk_query_pool(struct zink_context *ctx, struct zink_vk_query *vkq)
{
struct zink_batch *batch = &ctx->batch;
if (vkq->needs_reset) {
VKCTX(CmdResetQueryPool)(batch->state->reordered_cmdbuf, vkq->pool->query_pool, vkq->query_id, 1);
batch->state->has_barriers = true;
VKCTX(CmdResetQueryPool)(batch->bs->reordered_cmdbuf, vkq->pool->query_pool, vkq->query_id, 1);
batch->bs->has_barriers = true;
}
vkq->needs_reset = false;
}
@ -390,7 +390,7 @@ unref_vk_pool(struct zink_context *ctx, struct zink_query_pool *pool)
{
if (!pool || --pool->refcount)
return;
util_dynarray_append(&ctx->batch.state->dead_querypools, VkQueryPool, pool->query_pool);
util_dynarray_append(&ctx->batch.bs->dead_querypools, VkQueryPool, pool->query_pool);
if (list_is_linked(&pool->list))
list_del(&pool->list);
FREE(pool);
@ -534,7 +534,7 @@ zink_create_query(struct pipe_context *pctx,
if (!qbo_append(pctx->screen, query))
goto fail;
struct zink_batch *batch = &zink_context(pctx)->batch;
batch->state->has_work = true;
batch->bs->has_work = true;
query->needs_reset = true;
query->predicate_dirty = true;
if (query->type == PIPE_QUERY_TIMESTAMP) {
@ -779,9 +779,9 @@ copy_pool_results_to_buffer(struct zink_context *ctx, struct zink_query *query,
util_range_add(&res->base.b, &res->valid_buffer_range, offset, offset + result_size);
assert(query_id < NUM_QUERIES);
res->obj->unordered_read = res->obj->unordered_write = false;
VKCTX(CmdCopyQueryPoolResults)(batch->state->cmdbuf, pool, query_id, num_results, res->obj->buffer,
VKCTX(CmdCopyQueryPoolResults)(batch->bs->cmdbuf, pool, query_id, num_results, res->obj->buffer,
offset, base_result_size, flags);
zink_cmd_debug_marker_end(ctx, batch->state->cmdbuf, marker);
zink_cmd_debug_marker_end(ctx, batch->bs->cmdbuf, marker);
}
static void
@ -902,15 +902,15 @@ begin_query(struct zink_context *ctx, struct zink_batch *batch, struct zink_quer
reset_qbos(ctx, q);
reset_query_range(ctx, q);
q->active = true;
batch->state->has_work = true;
batch->bs->has_work = true;
struct zink_query_start *start = util_dynarray_top_ptr(&q->starts, struct zink_query_start);
if (q->type == PIPE_QUERY_TIME_ELAPSED) {
VKCTX(CmdWriteTimestamp)(batch->state->cmdbuf, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, start->vkq[0]->pool->query_pool, start->vkq[0]->query_id);
VKCTX(CmdWriteTimestamp)(batch->bs->cmdbuf, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, start->vkq[0]->pool->query_pool, start->vkq[0]->query_id);
if (!ctx->in_rp)
update_qbo(ctx, q);
zink_batch_usage_set(&q->batch_uses, batch->state);
_mesa_set_add(&batch->state->active_queries, q);
zink_batch_usage_set(&q->batch_uses, batch->bs);
_mesa_set_add(&batch->bs->active_queries, q);
}
/* ignore the rest of begin_query for timestamps */
if (is_time_query(q))
@ -945,15 +945,15 @@ begin_query(struct zink_context *ctx, struct zink_batch *batch, struct zink_quer
begin_vk_query_indexed(ctx, start->vkq[0], q->index, flags);
}
if (q->vkqtype != VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT && q->vkqtype != VK_QUERY_TYPE_PRIMITIVES_GENERATED_EXT)
VKCTX(CmdBeginQuery)(batch->state->cmdbuf, start->vkq[0]->pool->query_pool, start->vkq[0]->query_id, flags);
VKCTX(CmdBeginQuery)(batch->bs->cmdbuf, start->vkq[0]->pool->query_pool, start->vkq[0]->query_id, flags);
if (q->type == PIPE_QUERY_PIPELINE_STATISTICS_SINGLE && q->index == PIPE_STAT_QUERY_IA_VERTICES) {
assert(!ctx->vertices_query);
ctx->vertices_query = q;
}
if (needs_stats_list(q))
list_addtail(&q->stats_list, &ctx->primitives_generated_queries);
zink_batch_usage_set(&q->batch_uses, batch->state);
_mesa_set_add(&batch->state->active_queries, q);
zink_batch_usage_set(&q->batch_uses, batch->bs);
_mesa_set_add(&batch->bs->active_queries, q);
if (q->needs_rast_discard_workaround) {
ctx->primitives_generated_active = true;
if (zink_set_rasterizer_discard(ctx, true))
@ -999,7 +999,7 @@ static void
update_query_id(struct zink_context *ctx, struct zink_query *q)
{
query_pool_get_range(ctx, q);
ctx->batch.state->has_work = true;
ctx->batch.bs->has_work = true;
q->has_draws = false;
}
@ -1036,7 +1036,7 @@ end_query(struct zink_context *ctx, struct zink_batch *batch, struct zink_query
}
if (q->vkqtype != VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT &&
q->vkqtype != VK_QUERY_TYPE_PRIMITIVES_GENERATED_EXT && !is_time_query(q))
VKCTX(CmdEndQuery)(batch->state->cmdbuf, start->vkq[0]->pool->query_pool, start->vkq[0]->query_id);
VKCTX(CmdEndQuery)(batch->bs->cmdbuf, start->vkq[0]->pool->query_pool, start->vkq[0]->query_id);
if (q->type == PIPE_QUERY_PIPELINE_STATISTICS_SINGLE &&
q->index == PIPE_STAT_QUERY_IA_VERTICES)
@ -1093,10 +1093,10 @@ zink_end_query(struct pipe_context *pctx,
reset_qbos(ctx, query);
reset_query_range(ctx, query);
struct zink_query_start *start = util_dynarray_top_ptr(&query->starts, struct zink_query_start);
VKCTX(CmdWriteTimestamp)(batch->state->cmdbuf, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
VKCTX(CmdWriteTimestamp)(batch->bs->cmdbuf, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
start->vkq[0]->pool->query_pool, start->vkq[0]->query_id);
zink_batch_usage_set(&query->batch_uses, batch->state);
_mesa_set_add(&batch->state->active_queries, query);
zink_batch_usage_set(&query->batch_uses, batch->bs);
_mesa_set_add(&batch->bs->active_queries, query);
query->needs_update = true;
} else if (query->active) {
/* this should be a tc-optimized query end that doesn't split a renderpass */
@ -1168,7 +1168,7 @@ suspend_query(struct zink_context *ctx, struct zink_query *query)
static void
suspend_queries(struct zink_context *ctx, bool rp_only)
{
set_foreach(&ctx->batch.state->active_queries, entry) {
set_foreach(&ctx->batch.bs->active_queries, entry) {
struct zink_query *query = (void*)entry->key;
if (query->suspended || (rp_only && !query->started_in_rp))
continue;
@ -1308,7 +1308,7 @@ zink_start_conditional_render(struct zink_context *ctx)
begin_info.buffer = ctx->render_condition.query->predicate->obj->buffer;
begin_info.flags = begin_flags;
ctx->render_condition.query->predicate->obj->unordered_read = false;
VKCTX(CmdBeginConditionalRenderingEXT)(batch->state->cmdbuf, &begin_info);
VKCTX(CmdBeginConditionalRenderingEXT)(batch->bs->cmdbuf, &begin_info);
zink_batch_reference_resource_rw(batch, ctx->render_condition.query->predicate, false);
ctx->render_condition.active = true;
}
@ -1321,7 +1321,7 @@ zink_stop_conditional_render(struct zink_context *ctx)
zink_clear_apply_conditionals(ctx);
if (unlikely(!zink_screen(ctx->base.screen)->info.have_EXT_conditional_rendering) || !ctx->render_condition.active)
return;
VKCTX(CmdEndConditionalRenderingEXT)(batch->state->cmdbuf);
VKCTX(CmdEndConditionalRenderingEXT)(batch->bs->cmdbuf);
ctx->render_condition.active = false;
}

View file

@ -757,7 +757,7 @@ begin_render_pass(struct zink_context *ctx)
#endif
rpbi.pNext = &infos;
VKCTX(CmdBeginRenderPass)(batch->state->cmdbuf, &rpbi, VK_SUBPASS_CONTENTS_INLINE);
VKCTX(CmdBeginRenderPass)(batch->bs->cmdbuf, &rpbi, VK_SUBPASS_CONTENTS_INLINE);
ctx->in_rp = true;
return clear_buffers;
}
@ -838,7 +838,7 @@ void
zink_end_render_pass(struct zink_context *ctx)
{
if (ctx->in_rp) {
VKCTX(CmdEndRenderPass)(ctx->batch.state->cmdbuf);
VKCTX(CmdEndRenderPass)(ctx->batch.bs->cmdbuf);
for (unsigned i = 0; i < ctx->fb_state.nr_cbufs; i++) {
struct zink_ctx_surface *csurf = (struct zink_ctx_surface*)ctx->fb_state.cbufs[i];

View file

@ -1763,9 +1763,9 @@ add_resource_bind(struct zink_context *ctx, struct zink_resource *res, unsigned
ctx->base.resource_copy_region(&ctx->base, &res->base.b, i, 0, 0, 0, &staging.base.b, i, &box);
}
if (old_obj->exportable) {
simple_mtx_lock(&ctx->batch.state->exportable_lock);
_mesa_set_remove_key(&ctx->batch.state->dmabuf_exports, &staging);
simple_mtx_unlock(&ctx->batch.state->exportable_lock);
simple_mtx_lock(&ctx->batch.bs->exportable_lock);
_mesa_set_remove_key(&ctx->batch.bs->dmabuf_exports, &staging);
simple_mtx_unlock(&ctx->batch.bs->exportable_lock);
}
zink_resource_object_reference(screen, &old_obj, NULL);
return true;

View file

@ -176,19 +176,19 @@ zink_batch_resource_usage_set(struct zink_batch *batch, struct zink_resource *re
{
if (!is_buffer) {
if (res->obj->dt) {
VkSemaphore acquire = zink_kopper_acquire_submit(zink_screen(batch->state->ctx->base.screen), res);
VkSemaphore acquire = zink_kopper_acquire_submit(zink_screen(batch->bs->ctx->base.screen), res);
if (acquire)
util_dynarray_append(&batch->state->acquires, VkSemaphore, acquire);
util_dynarray_append(&batch->bs->acquires, VkSemaphore, acquire);
}
if (write) {
if (!res->valid && res->fb_bind_count)
batch->state->ctx->rp_loadop_changed = true;
batch->bs->ctx->rp_loadop_changed = true;
res->valid = true;
}
}
zink_resource_usage_set(res, batch->state, write);
zink_resource_usage_set(res, batch->bs, write);
batch->state->has_work = true;
batch->bs->has_work = true;
}
void

View file

@ -1844,7 +1844,7 @@ zink_flush_frontbuffer(struct pipe_screen *pscreen,
/* handle any outstanding acquire submits (not just from above) */
if (ctx->swapchain || ctx->needs_present) {
ctx->batch.state->has_work = true;
ctx->batch.bs->has_work = true;
pctx->flush(pctx, NULL, PIPE_FLUSH_END_OF_FRAME);
if (ctx->last_batch_state && screen->threaded_submit) {
struct zink_batch_state *bs = ctx->last_batch_state;

View file

@ -252,10 +252,10 @@ unordered_res_exec(const struct zink_context *ctx, const struct zink_resource *r
if (res->obj->unordered_read && res->obj->unordered_write)
return true;
/* if testing write access but have any ordered read access, cannot promote */
if (is_write && zink_batch_usage_matches(res->obj->bo->reads.u, ctx->batch.state) && !res->obj->unordered_read)
if (is_write && zink_batch_usage_matches(res->obj->bo->reads.u, ctx->batch.bs) && !res->obj->unordered_read)
return false;
/* if write access is unordered or nonexistent, always promote */
return res->obj->unordered_write || !zink_batch_usage_matches(res->obj->bo->writes.u, ctx->batch.state);
return res->obj->unordered_write || !zink_batch_usage_matches(res->obj->bo->writes.u, ctx->batch.bs);
}
static ALWAYS_INLINE bool
@ -289,11 +289,11 @@ zink_get_cmdbuf(struct zink_context *ctx, struct zink_resource *src, struct zink
zink_batch_no_rp(ctx);
if (unordered_exec) {
ctx->batch.state->has_barriers = true;
ctx->batch.state->has_work = true;
return ctx->batch.state->reordered_cmdbuf;
ctx->batch.bs->has_barriers = true;
ctx->batch.bs->has_work = true;
return ctx->batch.bs->reordered_cmdbuf;
}
return ctx->batch.state->cmdbuf;
return ctx->batch.bs->cmdbuf;
}
static void
@ -468,8 +468,8 @@ struct update_unordered_access_and_get_cmdbuf<true> {
assert(!usage_matches);
res->obj->unordered_write = true;
res->obj->unordered_read = true;
ctx->batch.state->has_unsync = true;
return ctx->batch.state->unsynchronized_cmdbuf;
ctx->batch.bs->has_unsync = true;
return ctx->batch.bs->unsynchronized_cmdbuf;
}
};
@ -483,12 +483,12 @@ struct update_unordered_access_and_get_cmdbuf<false> {
if (is_write || zink_resource_usage_check_completion_fast(zink_screen(ctx->base.screen), res, ZINK_RESOURCE_ACCESS_RW))
res->obj->unordered_read = true;
}
if (zink_resource_usage_matches(res, ctx->batch.state) && !ctx->unordered_blitting &&
if (zink_resource_usage_matches(res, ctx->batch.bs) && !ctx->unordered_blitting &&
/* if current batch usage exists with ordered non-transfer access, never promote
* this avoids layout dsync
*/
(!res->obj->unordered_read || !res->obj->unordered_write)) {
cmdbuf = ctx->batch.state->cmdbuf;
cmdbuf = ctx->batch.bs->cmdbuf;
res->obj->unordered_write = false;
res->obj->unordered_read = false;
/* it's impossible to detect this from the caller
@ -498,7 +498,7 @@ struct update_unordered_access_and_get_cmdbuf<false> {
} else {
cmdbuf = is_write ? zink_get_cmdbuf(ctx, NULL, res) : zink_get_cmdbuf(ctx, res, NULL);
/* force subsequent barriers to be ordered to avoid layout desync */
if (cmdbuf != ctx->batch.state->reordered_cmdbuf) {
if (cmdbuf != ctx->batch.bs->reordered_cmdbuf) {
res->obj->unordered_write = false;
res->obj->unordered_read = false;
}
@ -524,7 +524,7 @@ zink_resource_image_barrier(struct zink_context *ctx, struct zink_resource *res,
return;
enum zink_resource_access rw = is_write ? ZINK_RESOURCE_ACCESS_RW : ZINK_RESOURCE_ACCESS_WRITE;
bool completed = zink_resource_usage_check_completion_fast(zink_screen(ctx->base.screen), res, rw);
bool usage_matches = !completed && zink_resource_usage_matches(res, ctx->batch.state);
bool usage_matches = !completed && zink_resource_usage_matches(res, ctx->batch.bs);
VkCommandBuffer cmdbuf = update_unordered_access_and_get_cmdbuf<UNSYNCHRONIZED>::apply(ctx, res, usage_matches, is_write);
assert(new_layout);
@ -547,7 +547,7 @@ zink_resource_image_barrier(struct zink_context *ctx, struct zink_resource *res,
zink_resource_copies_reset(res);
if (res->obj->exportable)
simple_mtx_lock(&ctx->batch.state->exportable_lock);
simple_mtx_lock(&ctx->batch.bs->exportable_lock);
if (res->obj->dt) {
struct kopper_displaytarget *cdt = res->obj->dt;
if (cdt->swapchain->num_acquires && res->obj->dt_idx != UINT32_MAX) {
@ -556,7 +556,7 @@ zink_resource_image_barrier(struct zink_context *ctx, struct zink_resource *res,
} else if (res->obj->exportable) {
struct pipe_resource *pres = NULL;
bool found = false;
_mesa_set_search_or_add(&ctx->batch.state->dmabuf_exports, res, &found);
_mesa_set_search_or_add(&ctx->batch.bs->dmabuf_exports, res, &found);
if (!found) {
pipe_resource_reference(&pres, &res->base.b);
}
@ -565,11 +565,11 @@ zink_resource_image_barrier(struct zink_context *ctx, struct zink_resource *res,
for (struct zink_resource *r = res; r; r = zink_resource(r->base.b.next)) {
VkSemaphore sem = zink_screen_export_dmabuf_semaphore(zink_screen(ctx->base.screen), r);
if (sem)
util_dynarray_append(&ctx->batch.state->fd_wait_semaphores, VkSemaphore, sem);
util_dynarray_append(&ctx->batch.bs->fd_wait_semaphores, VkSemaphore, sem);
}
}
if (res->obj->exportable)
simple_mtx_unlock(&ctx->batch.state->exportable_lock);
simple_mtx_unlock(&ctx->batch.bs->exportable_lock);
}
bool
@ -629,9 +629,9 @@ zink_resource_buffer_transfer_dst_barrier(struct zink_context *ctx, struct zink_
res->obj->last_write = VK_ACCESS_TRANSFER_WRITE_BIT;
res->obj->unordered_access_stage = VK_PIPELINE_STAGE_TRANSFER_BIT;
ctx->batch.state->unordered_write_access |= VK_ACCESS_TRANSFER_WRITE_BIT;
ctx->batch.state->unordered_write_stages |= VK_PIPELINE_STAGE_TRANSFER_BIT;
if (!zink_resource_usage_matches(res, ctx->batch.state)) {
ctx->batch.bs->unordered_write_access |= VK_ACCESS_TRANSFER_WRITE_BIT;
ctx->batch.bs->unordered_write_stages |= VK_PIPELINE_STAGE_TRANSFER_BIT;
if (!zink_resource_usage_matches(res, ctx->batch.bs)) {
res->obj->access = VK_ACCESS_TRANSFER_WRITE_BIT;
res->obj->access_stage = VK_PIPELINE_STAGE_TRANSFER_BIT;
res->obj->ordered_access_is_copied = true;
@ -699,7 +699,7 @@ zink_resource_buffer_barrier(struct zink_context *ctx, struct zink_resource *res
bool is_write = zink_resource_access_is_write(flags);
enum zink_resource_access rw = is_write ? ZINK_RESOURCE_ACCESS_RW : ZINK_RESOURCE_ACCESS_WRITE;
bool completed = zink_resource_usage_check_completion_fast(zink_screen(ctx->base.screen), res, rw);
bool usage_matches = !completed && zink_resource_usage_matches(res, ctx->batch.state);
bool usage_matches = !completed && zink_resource_usage_matches(res, ctx->batch.bs);
if (!usage_matches) {
res->obj->unordered_write = true;
if (is_write || zink_resource_usage_check_completion_fast(zink_screen(ctx->base.screen), res, ZINK_RESOURCE_ACCESS_RW))
@ -766,8 +766,8 @@ zink_resource_buffer_barrier(struct zink_context *ctx, struct zink_resource *res
res->obj->unordered_access = flags;
res->obj->unordered_access_stage = pipeline;
if (is_write) {
ctx->batch.state->unordered_write_access |= flags;
ctx->batch.state->unordered_write_stages |= pipeline;
ctx->batch.bs->unordered_write_access |= flags;
ctx->batch.bs->unordered_write_stages |= pipeline;
}
}
if (!unordered || !usage_matches || res->obj->ordered_access_is_copied) {

View file

@ -676,7 +676,7 @@ zink_batch_state(struct zink_fence *fence)
}
struct zink_batch {
struct zink_batch_state *state;
struct zink_batch_state *bs;
};