summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Faye-Lund <erik.faye-lund@collabora.com>2021-01-20 10:19:32 +0100
committerDylan Baker <dylan.c.baker@intel.com>2021-01-21 13:26:36 -0800
commit7f76e0d4b22b3a276d1cc6fd2f5bf7a1d0e9cbda (patch)
tree4181473d186675079fc2f2b1195d17ad10a82cba
parenteaefaa9610a291a0c06a5c31d90aa84cce437f2d (diff)
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@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8588> (cherry picked from commit d74b01226004fe7e245f108f69747c184b3ac044)
-rw-r--r--.pick_status.json2
-rw-r--r--src/gallium/drivers/zink/zink_context.c3
-rw-r--r--src/gallium/drivers/zink/zink_draw.c9
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);