mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-03 02:50:16 +01:00
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:
parent
88d42b6230
commit
d17c081b7c
4 changed files with 56 additions and 25 deletions
|
|
@ -450,6 +450,7 @@ zink_batch_bind_db(struct zink_context *ctx)
|
|||
void
|
||||
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;
|
||||
|
|
@ -473,7 +474,6 @@ zink_start_batch(struct zink_context *ctx, struct zink_batch *batch)
|
|||
}
|
||||
|
||||
#ifdef HAVE_RENDERDOC_APP_H
|
||||
struct zink_screen *screen = zink_screen(ctx->base.screen);
|
||||
if (VKCTX(CmdInsertDebugUtilsLabelEXT) && screen->renderdoc_api) {
|
||||
VkDebugUtilsLabelEXT capture_label;
|
||||
/* 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 */
|
||||
if (zink_descriptor_mode == ZINK_DESCRIPTOR_MODE_DB && !(ctx->flags & ZINK_CONTEXT_COPY_ONLY))
|
||||
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 */
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
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
|
||||
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.feedback_loop = false;
|
||||
}
|
||||
update_feedback_loop_dynamic_state(ctx);
|
||||
}
|
||||
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->barrier_cmdbuf, 1);
|
||||
}
|
||||
update_feedback_loop_dynamic_state(ctx);
|
||||
if (conditional_render_active)
|
||||
zink_start_conditional_render(ctx);
|
||||
reapply_color_write(ctx);
|
||||
|
|
@ -5183,6 +5198,7 @@ add_implicit_feedback_loop(struct zink_context *ctx, struct zink_resource *res)
|
|||
else
|
||||
ctx->dynamic_fb.attachments[idx].imageLayout = VK_IMAGE_LAYOUT_GENERAL;
|
||||
}
|
||||
update_feedback_loop_dynamic_state(ctx);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -332,20 +332,24 @@ zink_create_gfx_pipeline(struct zink_screen *screen,
|
|||
|
||||
VkGraphicsPipelineCreateInfo pci = {0};
|
||||
pci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
|
||||
static bool feedback_warn = false;
|
||||
if (!optimize)
|
||||
pci.flags |= VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT;
|
||||
if (state->feedback_loop) {
|
||||
if (screen->info.have_EXT_attachment_feedback_loop_layout)
|
||||
pci.flags |= VK_PIPELINE_CREATE_COLOR_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT;
|
||||
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 (screen->info.have_EXT_attachment_feedback_loop_dynamic_state) {
|
||||
dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_ATTACHMENT_FEEDBACK_LOOP_ENABLE_EXT;
|
||||
} else {
|
||||
static bool feedback_warn = false;
|
||||
if (state->feedback_loop) {
|
||||
if (screen->info.have_EXT_attachment_feedback_loop_layout)
|
||||
pci.flags |= VK_PIPELINE_CREATE_COLOR_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT;
|
||||
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)
|
||||
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.pNext = &gplci;
|
||||
pci.flags = VK_PIPELINE_CREATE_LIBRARY_BIT_KHR | VK_PIPELINE_CREATE_RETAIN_LINK_TIME_OPTIMIZATION_INFO_BIT_EXT;
|
||||
static bool feedback_warn = false;
|
||||
if (state->feedback_loop) {
|
||||
if (screen->info.have_EXT_attachment_feedback_loop_layout)
|
||||
pci.flags |= VK_PIPELINE_CREATE_COLOR_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT;
|
||||
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 (screen->info.have_EXT_attachment_feedback_loop_dynamic_state) {
|
||||
dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_ATTACHMENT_FEEDBACK_LOOP_ENABLE_EXT;
|
||||
} else {
|
||||
static bool feedback_warn = false;
|
||||
if (state->feedback_loop) {
|
||||
if (screen->info.have_EXT_attachment_feedback_loop_layout)
|
||||
pci.flags |= VK_PIPELINE_CREATE_COLOR_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT;
|
||||
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)
|
||||
pci.flags |= VK_PIPELINE_CREATE_DESCRIPTOR_BUFFER_BIT_EXT;
|
||||
|
|
|
|||
|
|
@ -2536,6 +2536,10 @@ init_driver_workarounds(struct zink_screen *screen)
|
|||
default:
|
||||
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.
|
||||
* TODO: Vulkan extension that details whether vulkan driver can handle OOB layer values
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue