zink: use dynamic state for feedback loops when available

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23092>
This commit is contained in:
Mike Blumenkrantz
2023-05-04 09:42:22 -04:00
committed by Marge Bot
parent 88d42b6230
commit d17c081b7c
4 changed files with 56 additions and 25 deletions
+4 -1
View File
@@ -450,6 +450,7 @@ zink_batch_bind_db(struct zink_context *ctx)
void void
zink_start_batch(struct zink_context *ctx, struct zink_batch *batch) 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); zink_reset_batch(ctx, batch);
batch->state->usage.unflushed = true; batch->state->usage.unflushed = true;
@@ -473,7 +474,6 @@ zink_start_batch(struct zink_context *ctx, struct zink_batch *batch)
} }
#ifdef HAVE_RENDERDOC_APP_H #ifdef HAVE_RENDERDOC_APP_H
struct zink_screen *screen = zink_screen(ctx->base.screen);
if (VKCTX(CmdInsertDebugUtilsLabelEXT) && screen->renderdoc_api) { if (VKCTX(CmdInsertDebugUtilsLabelEXT) && screen->renderdoc_api) {
VkDebugUtilsLabelEXT capture_label; VkDebugUtilsLabelEXT capture_label;
/* Magic fallback which lets us bridge the Wine barrier over to Linux RenderDoc. */ /* Magic fallback which lets us bridge the Wine barrier over to Linux RenderDoc. */
@@ -496,6 +496,9 @@ zink_start_batch(struct zink_context *ctx, struct zink_batch *batch)
/* descriptor buffers must always be bound at the start of a batch */ /* descriptor buffers must always be bound at the start of a batch */
if (zink_descriptor_mode == ZINK_DESCRIPTOR_MODE_DB && !(ctx->flags & ZINK_CONTEXT_COPY_ONLY)) if (zink_descriptor_mode == ZINK_DESCRIPTOR_MODE_DB && !(ctx->flags & ZINK_CONTEXT_COPY_ONLY))
zink_batch_bind_db(ctx); 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->barrier_cmdbuf, 0);
} }
/* common operations to run post submit; split out for clarity */ /* common operations to run post submit; split out for clarity */
+16
View File
@@ -1900,6 +1900,19 @@ zink_set_shader_images(struct pipe_context *pctx,
zink_context_invalidate_descriptor_state(ctx, shader_type, ZINK_DESCRIPTOR_TYPE_IMAGE, start_slot, count); zink_context_invalidate_descriptor_state(ctx, shader_type, ZINK_DESCRIPTOR_TYPE_IMAGE, start_slot, count);
} }
static void
update_feedback_loop_dynamic_state(struct zink_context *ctx)
{
if (!zink_screen(ctx->base.screen)->info.have_EXT_attachment_feedback_loop_dynamic_state)
return;
VkImageAspectFlags aspects = 0;
if (ctx->feedback_loops & BITFIELD_MASK(PIPE_MAX_COLOR_BUFS))
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);
}
static void static void
update_feedback_loop_state(struct zink_context *ctx, unsigned idx, unsigned feedback_loops) update_feedback_loop_state(struct zink_context *ctx, unsigned idx, unsigned feedback_loops)
{ {
@@ -1913,6 +1926,7 @@ update_feedback_loop_state(struct zink_context *ctx, unsigned idx, unsigned feed
ctx->gfx_pipeline_state.dirty = true; ctx->gfx_pipeline_state.dirty = true;
ctx->gfx_pipeline_state.feedback_loop = false; ctx->gfx_pipeline_state.feedback_loop = false;
} }
update_feedback_loop_dynamic_state(ctx);
} }
ctx->feedback_loops = feedback_loops; ctx->feedback_loops = feedback_loops;
} }
@@ -3194,6 +3208,7 @@ flush_batch(struct zink_context *ctx, bool sync)
VKCTX(CmdSetPatchControlPointsEXT)(ctx->batch.state->cmdbuf, ctx->gfx_pipeline_state.dyn_state2.vertices_per_patch); VKCTX(CmdSetPatchControlPointsEXT)(ctx->batch.state->cmdbuf, ctx->gfx_pipeline_state.dyn_state2.vertices_per_patch);
VKCTX(CmdSetPatchControlPointsEXT)(ctx->batch.state->barrier_cmdbuf, 1); VKCTX(CmdSetPatchControlPointsEXT)(ctx->batch.state->barrier_cmdbuf, 1);
} }
update_feedback_loop_dynamic_state(ctx);
if (conditional_render_active) if (conditional_render_active)
zink_start_conditional_render(ctx); zink_start_conditional_render(ctx);
reapply_color_write(ctx); reapply_color_write(ctx);
@@ -5183,6 +5198,7 @@ add_implicit_feedback_loop(struct zink_context *ctx, struct zink_resource *res)
else else
ctx->dynamic_fb.attachments[idx].imageLayout = VK_IMAGE_LAYOUT_GENERAL; ctx->dynamic_fb.attachments[idx].imageLayout = VK_IMAGE_LAYOUT_GENERAL;
} }
update_feedback_loop_dynamic_state(ctx);
return true; return true;
} }
+32 -24
View File
@@ -332,20 +332,24 @@ zink_create_gfx_pipeline(struct zink_screen *screen,
VkGraphicsPipelineCreateInfo pci = {0}; VkGraphicsPipelineCreateInfo pci = {0};
pci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; pci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
static bool feedback_warn = false;
if (!optimize) if (!optimize)
pci.flags |= VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; pci.flags |= VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT;
if (state->feedback_loop) { if (screen->info.have_EXT_attachment_feedback_loop_dynamic_state) {
if (screen->info.have_EXT_attachment_feedback_loop_layout) dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_ATTACHMENT_FEEDBACK_LOOP_ENABLE_EXT;
pci.flags |= VK_PIPELINE_CREATE_COLOR_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT; } else {
else static bool feedback_warn = false;
warn_missing_feature(feedback_warn, "EXT_attachment_feedback_loop_layout"); if (state->feedback_loop) {
} if (screen->info.have_EXT_attachment_feedback_loop_layout)
if (state->feedback_loop_zs) { pci.flags |= VK_PIPELINE_CREATE_COLOR_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT;
if (screen->info.have_EXT_attachment_feedback_loop_layout) else
pci.flags |= VK_PIPELINE_CREATE_DEPTH_STENCIL_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT; warn_missing_feature(feedback_warn, "EXT_attachment_feedback_loop_layout");
else }
warn_missing_feature(feedback_warn, "EXT_attachment_feedback_loop_layout"); if (state->feedback_loop_zs) {
if (screen->info.have_EXT_attachment_feedback_loop_layout)
pci.flags |= VK_PIPELINE_CREATE_DEPTH_STENCIL_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT;
else
warn_missing_feature(feedback_warn, "EXT_attachment_feedback_loop_layout");
}
} }
if (zink_descriptor_mode == ZINK_DESCRIPTOR_MODE_DB) if (zink_descriptor_mode == ZINK_DESCRIPTOR_MODE_DB)
pci.flags |= VK_PIPELINE_CREATE_DESCRIPTOR_BUFFER_BIT_EXT; pci.flags |= VK_PIPELINE_CREATE_DESCRIPTOR_BUFFER_BIT_EXT;
@@ -540,18 +544,22 @@ zink_create_gfx_pipeline_output(struct zink_screen *screen, struct zink_gfx_pipe
pci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; pci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
pci.pNext = &gplci; pci.pNext = &gplci;
pci.flags = VK_PIPELINE_CREATE_LIBRARY_BIT_KHR | VK_PIPELINE_CREATE_RETAIN_LINK_TIME_OPTIMIZATION_INFO_BIT_EXT; pci.flags = VK_PIPELINE_CREATE_LIBRARY_BIT_KHR | VK_PIPELINE_CREATE_RETAIN_LINK_TIME_OPTIMIZATION_INFO_BIT_EXT;
static bool feedback_warn = false; if (screen->info.have_EXT_attachment_feedback_loop_dynamic_state) {
if (state->feedback_loop) { dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_ATTACHMENT_FEEDBACK_LOOP_ENABLE_EXT;
if (screen->info.have_EXT_attachment_feedback_loop_layout) } else {
pci.flags |= VK_PIPELINE_CREATE_COLOR_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT; static bool feedback_warn = false;
else if (state->feedback_loop) {
warn_missing_feature(feedback_warn, "EXT_attachment_feedback_loop_layout"); if (screen->info.have_EXT_attachment_feedback_loop_layout)
} pci.flags |= VK_PIPELINE_CREATE_COLOR_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT;
if (state->feedback_loop_zs) { else
if (screen->info.have_EXT_attachment_feedback_loop_layout) warn_missing_feature(feedback_warn, "EXT_attachment_feedback_loop_layout");
pci.flags |= VK_PIPELINE_CREATE_DEPTH_STENCIL_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT; }
else if (state->feedback_loop_zs) {
warn_missing_feature(feedback_warn, "EXT_attachment_feedback_loop_layout"); if (screen->info.have_EXT_attachment_feedback_loop_layout)
pci.flags |= VK_PIPELINE_CREATE_DEPTH_STENCIL_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT;
else
warn_missing_feature(feedback_warn, "EXT_attachment_feedback_loop_layout");
}
} }
if (zink_descriptor_mode == ZINK_DESCRIPTOR_MODE_DB) if (zink_descriptor_mode == ZINK_DESCRIPTOR_MODE_DB)
pci.flags |= VK_PIPELINE_CREATE_DESCRIPTOR_BUFFER_BIT_EXT; pci.flags |= VK_PIPELINE_CREATE_DESCRIPTOR_BUFFER_BIT_EXT;
+4
View File
@@ -2536,6 +2536,10 @@ init_driver_workarounds(struct zink_screen *screen)
default: default:
break; break;
} }
/* use same mechanics if dynamic state is supported */
screen->driver_workarounds.always_feedback_loop |= screen->info.have_EXT_attachment_feedback_loop_dynamic_state;
screen->driver_workarounds.always_feedback_loop_zs |= screen->info.have_EXT_attachment_feedback_loop_dynamic_state;
/* these drivers cannot handle OOB gl_Layer values, and therefore need clamping in shader. /* these drivers cannot handle OOB gl_Layer values, and therefore need clamping in shader.
* TODO: Vulkan extension that details whether vulkan driver can handle OOB layer values * TODO: Vulkan extension that details whether vulkan driver can handle OOB layer values
*/ */