Mesa (main): zink: use dynamic state to apply sample locations during draw
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Jun 9 17:40:58 UTC 2021
Module: Mesa
Branch: main
Commit: 1ea682ed5abcdce5ac5a817e83522206198d6014
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1ea682ed5abcdce5ac5a817e83522206198d6014
Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date: Fri Apr 2 17:40:21 2021 -0400
zink: use dynamic state to apply sample locations during draw
not even going to attempt to figure out how to efficiently hash this
Reviewed-by: Erik Faye-Lund <erik.faye-lund at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11189>
---
src/gallium/drivers/zink/zink_context.c | 1 +
src/gallium/drivers/zink/zink_draw.c | 9 +++++++--
src/gallium/drivers/zink/zink_pipeline.c | 2 ++
src/gallium/drivers/zink/zink_render_pass.c | 2 ++
4 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c
index dbc24c2bec8..19c0ac0d456 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -1812,6 +1812,7 @@ flush_batch(struct zink_context *ctx, bool sync)
ctx->dirty_so_targets = true;
ctx->descriptor_refs_dirty[0] = ctx->descriptor_refs_dirty[1] = true;
ctx->pipeline_changed[0] = ctx->pipeline_changed[1] = true;
+ ctx->sample_locations_changed |= ctx->gfx_pipeline_state.sample_locations_enabled;
ctx->vertex_buffers_dirty = true;
ctx->vp_state_changed = true;
ctx->scissor_changed = true;
diff --git a/src/gallium/drivers/zink/zink_draw.c b/src/gallium/drivers/zink/zink_draw.c
index 3eedaa782a6..989ae837b93 100644
--- a/src/gallium/drivers/zink/zink_draw.c
+++ b/src/gallium/drivers/zink/zink_draw.c
@@ -642,6 +642,13 @@ zink_draw_vbo(struct pipe_context *pctx,
}
}
screen->vk_CmdSetFrontFaceEXT(batch->state->cmdbuf, ctx->gfx_pipeline_state.front_face);
+
+ if (ctx->sample_locations_changed) {
+ VkSampleLocationsInfoEXT loc;
+ zink_init_vk_sample_locations(ctx, &loc);
+ screen->vk_CmdSetSampleLocationsEXT(batch->state->cmdbuf, &loc);
+ }
+ ctx->sample_locations_changed = false;
}
if (depth_bias)
@@ -649,8 +656,6 @@ zink_draw_vbo(struct pipe_context *pctx,
else
vkCmdSetDepthBias(batch->state->cmdbuf, 0.0f, 0.0f, 0.0f);
- ctx->sample_locations_changed = false;
-
if (ctx->gfx_pipeline_state.blend_state->need_blend_constants)
vkCmdSetBlendConstants(batch->state->cmdbuf, ctx->blend_constants);
diff --git a/src/gallium/drivers/zink/zink_pipeline.c b/src/gallium/drivers/zink/zink_pipeline.c
index 6264ccbceb9..27c9cbf917b 100644
--- a/src/gallium/drivers/zink/zink_pipeline.c
+++ b/src/gallium/drivers/zink/zink_pipeline.c
@@ -156,6 +156,8 @@ zink_create_gfx_pipeline(struct zink_screen *screen,
dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT;
dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT;
dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_FRONT_FACE_EXT;
+ if (state->sample_locations_enabled)
+ dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT;
} else {
dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_VIEWPORT;
dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_SCISSOR;
diff --git a/src/gallium/drivers/zink/zink_render_pass.c b/src/gallium/drivers/zink/zink_render_pass.c
index 26c19f74788..95a9f1e452b 100644
--- a/src/gallium/drivers/zink/zink_render_pass.c
+++ b/src/gallium/drivers/zink/zink_render_pass.c
@@ -49,6 +49,7 @@ create_render_pass(VkDevice dev, struct zink_render_pass_state *state)
attachments[i].storeOp = VK_ATTACHMENT_STORE_OP_STORE;
attachments[i].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
attachments[i].stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
+ /* if layout changes are ever handled here, need VkAttachmentSampleLocationsEXT */
attachments[i].initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
attachments[i].finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
color_refs[i].attachment = i;
@@ -71,6 +72,7 @@ create_render_pass(VkDevice dev, struct zink_render_pass_state *state)
attachments[num_attachments].storeOp = VK_ATTACHMENT_STORE_OP_STORE;
attachments[num_attachments].stencilLoadOp = rt->clear_stencil ? VK_ATTACHMENT_LOAD_OP_CLEAR : VK_ATTACHMENT_LOAD_OP_LOAD;
attachments[num_attachments].stencilStoreOp = VK_ATTACHMENT_STORE_OP_STORE;
+ /* if layout changes are ever handled here, need VkAttachmentSampleLocationsEXT */
attachments[num_attachments].initialLayout = layout;
attachments[num_attachments].finalLayout = layout;
More information about the mesa-commit
mailing list