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: 8d46e35d16 ("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>
This commit is contained in:
Erik Faye-Lund 2021-01-20 10:19:32 +01:00 committed by Marge Bot
parent 7dcb9a0d8c
commit d74b012260
2 changed files with 9 additions and 3 deletions

View file

@ -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,

View file

@ -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);