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];
|
VkBuffer buffers[PIPE_MAX_ATTRIBS];
|
||||||
VkDeviceSize buffer_offsets[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;
|
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)
|
if (!elems->hw_state.num_bindings)
|
||||||
return;
|
return;
|
||||||
@@ -171,13 +173,20 @@ zink_bind_vertex_buffers(struct zink_batch *batch, struct zink_context *ctx)
|
|||||||
struct zink_resource *res = zink_resource(vb->buffer.resource);
|
struct zink_resource *res = zink_resource(vb->buffer.resource);
|
||||||
buffers[i] = res->buffer;
|
buffers[i] = res->buffer;
|
||||||
buffer_offsets[i] = vb->buffer_offset;
|
buffer_offsets[i] = vb->buffer_offset;
|
||||||
|
buffer_strides[i] = vb->stride;
|
||||||
zink_batch_reference_resource_rw(batch, res, false);
|
zink_batch_reference_resource_rw(batch, res, false);
|
||||||
} else {
|
} else {
|
||||||
buffers[i] = zink_resource(ctx->dummy_vertex_buffer)->buffer;
|
buffers[i] = zink_resource(ctx->dummy_vertex_buffer)->buffer;
|
||||||
buffer_offsets[i] = 0;
|
buffer_offsets[i] = 0;
|
||||||
|
buffer_strides[i] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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,
|
vkCmdBindVertexBuffers(batch->cmdbuf, 0,
|
||||||
elems->hw_state.num_bindings,
|
elems->hw_state.num_bindings,
|
||||||
buffers, buffer_offsets);
|
buffers, buffer_offsets);
|
||||||
@@ -699,6 +708,7 @@ zink_draw_vbo(struct pipe_context *pctx,
|
|||||||
ctx->gfx_pipeline_state.dirty = true;
|
ctx->gfx_pipeline_state.dirty = true;
|
||||||
ctx->gfx_pipeline_state.primitive_restart = !!dinfo->primitive_restart;
|
ctx->gfx_pipeline_state.primitive_restart = !!dinfo->primitive_restart;
|
||||||
|
|
||||||
|
if (!zink_screen(pctx->screen)->info.have_EXT_extended_dynamic_state) {
|
||||||
for (unsigned i = 0; i < ctx->element_state->hw_state.num_bindings; i++) {
|
for (unsigned i = 0; i < ctx->element_state->hw_state.num_bindings; i++) {
|
||||||
unsigned binding = ctx->element_state->binding_map[i];
|
unsigned binding = ctx->element_state->binding_map[i];
|
||||||
const struct pipe_vertex_buffer *vb = ctx->buffers + binding;
|
const struct pipe_vertex_buffer *vb = ctx->buffers + binding;
|
||||||
@@ -707,6 +717,7 @@ zink_draw_vbo(struct pipe_context *pctx,
|
|||||||
ctx->gfx_pipeline_state.dirty = true;
|
ctx->gfx_pipeline_state.dirty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
enum pipe_prim_type reduced_prim = u_reduced_prim(dinfo->mode);
|
enum pipe_prim_type reduced_prim = u_reduced_prim(dinfo->mode);
|
||||||
|
|
||||||
|
@@ -136,6 +136,7 @@ zink_create_gfx_pipeline(struct zink_screen *screen,
|
|||||||
if (screen->info.have_EXT_extended_dynamic_state) {
|
if (screen->info.have_EXT_extended_dynamic_state) {
|
||||||
dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT;
|
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_SCISSOR_WITH_COUNT_EXT;
|
||||||
|
dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT;
|
||||||
} else {
|
} else {
|
||||||
dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_VIEWPORT;
|
dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_VIEWPORT;
|
||||||
dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_SCISSOR;
|
dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_SCISSOR;
|
||||||
|
Reference in New Issue
Block a user