Mesa (staging/21.0): zink: fix vertex-stride wrangling
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Jan 21 22:55:16 UTC 2021
Module: Mesa
Branch: staging/21.0
Commit: 7f76e0d4b22b3a276d1cc6fd2f5bf7a1d0e9cbda
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7f76e0d4b22b3a276d1cc6fd2f5bf7a1d0e9cbda
Author: Erik Faye-Lund <erik.faye-lund at collabora.com>
Date: Wed Jan 20 10:19:32 2021 +0100
zink: fix vertex-stride wrangling
Because Gallium and Vulkan disagree on what kind of state strides is, we
need to wrangle this state a bit, and up until now, we've been simply
fixing this up while binding the vertex-buffers.
But this isn't robust, because the vertex element state might be bound
after the vertex-buffer state was bound. We also need to take
binding-map into account, which we're currently missing as well.
Instead, w need to deal with this at a place where we know what's being
used for both of these. So let's do this during draw instead.
Ideally, we'd also do some dirty-tracking to know if this is needed or
not, but I believe Mike has some patches in this areas lined up, so it
might be easier to wait for those.
Fixes: 8d46e35d16e ("zink: introduce opengl over vulkan")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3661
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4125
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8588>
(cherry picked from commit d74b01226004fe7e245f108f69747c184b3ac044)
---
.pick_status.json | 2 +-
src/gallium/drivers/zink/zink_context.c | 3 ---
src/gallium/drivers/zink/zink_draw.c | 9 +++++++++
3 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/.pick_status.json b/.pick_status.json
index edfc80d5dfc..4869fb7a562 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -130,7 +130,7 @@
"description": "zink: fix vertex-stride wrangling",
"nominated": true,
"nomination_type": 1,
- "resolution": 0,
+ "resolution": 1,
"master_sha": null,
"because_sha": "8d46e35d16e3936968958bcab86d61967a673305"
},
diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c
index 32821a5da30..fe5d4460755 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -481,8 +481,6 @@ zink_set_vertex_buffers(struct pipe_context *pctx,
for (int i = 0; i < num_buffers; ++i) {
const struct pipe_vertex_buffer *vb = buffers + i;
struct zink_resource *res = zink_resource(vb->buffer.resource);
-
- ctx->gfx_pipeline_state.bindings[start_slot + i].stride = vb->stride;
if (res && res->needs_xfb_barrier) {
/* if we're binding a previously-used xfb buffer, we need cmd buffer synchronization to ensure
* that we use the right buffer data
@@ -491,7 +489,6 @@ zink_set_vertex_buffers(struct pipe_context *pctx,
res->needs_xfb_barrier = false;
}
}
- ctx->gfx_pipeline_state.dirty = true;
}
util_set_vertex_buffers_mask(ctx->buffers, &ctx->buffers_enabled_mask,
diff --git a/src/gallium/drivers/zink/zink_draw.c b/src/gallium/drivers/zink/zink_draw.c
index 9e0768d0082..d5e949bfae2 100644
--- a/src/gallium/drivers/zink/zink_draw.c
+++ b/src/gallium/drivers/zink/zink_draw.c
@@ -266,6 +266,15 @@ zink_draw_vbo(struct pipe_context *pctx,
ctx->gfx_pipeline_state.dirty = true;
ctx->gfx_pipeline_state.primitive_restart = !!dinfo->primitive_restart;
+ for (unsigned i = 0; i < ctx->element_state->hw_state.num_bindings; i++) {
+ unsigned binding = ctx->element_state->binding_map[i];
+ const struct pipe_vertex_buffer *vb = ctx->buffers + binding;
+ if (ctx->gfx_pipeline_state.bindings[i].stride != vb->stride) {
+ ctx->gfx_pipeline_state.bindings[i].stride = vb->stride;
+ ctx->gfx_pipeline_state.dirty = true;
+ }
+ }
+
VkPipeline pipeline = zink_get_gfx_pipeline(screen, gfx_program,
&ctx->gfx_pipeline_state,
dinfo->mode);
More information about the mesa-commit
mailing list