Mesa (master): zink: fix vertex-stride wrangling
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Jan 21 11:19:37 UTC 2021
Module: Mesa
Branch: master
Commit: d74b01226004fe7e245f108f69747c184b3ac044
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d74b01226004fe7e245f108f69747c184b3ac044
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>
---
src/gallium/drivers/zink/zink_context.c | 3 ---
src/gallium/drivers/zink/zink_draw.c | 9 +++++++++
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c
index 8e89d15ecc8..0c057b85451 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 1c3fe3b9b07..b3fcbde4f82 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