zink: use dynamic vertex buffer strides
this removes another case of needing to rehash/create a new pipeline Reviewed-by: Dave Airlie <airlied@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9272>
This commit is contained in:
@@ -159,7 +159,9 @@ zink_bind_vertex_buffers(struct zink_batch *batch, struct zink_context *ctx)
|
||||
{
|
||||
VkBuffer buffers[PIPE_MAX_ATTRIBS];
|
||||
VkDeviceSize buffer_offsets[PIPE_MAX_ATTRIBS];
|
||||
VkDeviceSize buffer_strides[PIPE_MAX_ATTRIBS];
|
||||
const struct zink_vertex_elements_state *elems = ctx->element_state;
|
||||
struct zink_screen *screen = zink_screen(ctx->base.screen);
|
||||
|
||||
if (!elems->hw_state.num_bindings)
|
||||
return;
|
||||
@@ -171,16 +173,23 @@ zink_bind_vertex_buffers(struct zink_batch *batch, struct zink_context *ctx)
|
||||
struct zink_resource *res = zink_resource(vb->buffer.resource);
|
||||
buffers[i] = res->buffer;
|
||||
buffer_offsets[i] = vb->buffer_offset;
|
||||
buffer_strides[i] = vb->stride;
|
||||
zink_batch_reference_resource_rw(batch, res, false);
|
||||
} else {
|
||||
buffers[i] = zink_resource(ctx->dummy_vertex_buffer)->buffer;
|
||||
buffer_offsets[i] = 0;
|
||||
buffer_strides[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
vkCmdBindVertexBuffers(batch->cmdbuf, 0,
|
||||
elems->hw_state.num_bindings,
|
||||
buffers, buffer_offsets);
|
||||
if (screen->info.have_EXT_extended_dynamic_state)
|
||||
screen->vk_CmdBindVertexBuffers2EXT(batch->cmdbuf, 0,
|
||||
elems->hw_state.num_bindings,
|
||||
buffers, buffer_offsets, NULL, buffer_strides);
|
||||
else
|
||||
vkCmdBindVertexBuffers(batch->cmdbuf, 0,
|
||||
elems->hw_state.num_bindings,
|
||||
buffers, buffer_offsets);
|
||||
}
|
||||
|
||||
static struct zink_compute_program *
|
||||
@@ -699,12 +708,14 @@ 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;
|
||||
if (!zink_screen(pctx->screen)->info.have_EXT_extended_dynamic_state) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -136,6 +136,7 @@ zink_create_gfx_pipeline(struct zink_screen *screen,
|
||||
if (screen->info.have_EXT_extended_dynamic_state) {
|
||||
dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT;
|
||||
dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT;
|
||||
dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT;
|
||||
} else {
|
||||
dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_VIEWPORT;
|
||||
dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_SCISSOR;
|
||||
|
Reference in New Issue
Block a user