From 61e3f549c53d89436c12e3904b7db1cb6d9153e8 Mon Sep 17 00:00:00 2001 From: Charles Baker Date: Fri, 10 Dec 2021 09:22:28 +1300 Subject: [PATCH] zink: Set vertex binding stride without dynamic state extensions EXT_vertex_input_dynamic_state When both EXT_vertex_input_dynamic_state and EXT_extended_dynamic_state are not available stride is never set and nothing is rasterized as all triangles are degenerate. This fix copies stride into the VkVertexInputBindingDescription array when the graphics pipeline is created when those extensions aren't available. Reviewed-By: Mike Blumenkrantz Part-of: --- src/gallium/drivers/zink/zink_pipeline.c | 8 ++++++++ src/gallium/drivers/zink/zink_pipeline.h | 1 + src/gallium/drivers/zink/zink_program.c | 12 +++++++----- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/zink/zink_pipeline.c b/src/gallium/drivers/zink/zink_pipeline.c index 6a5b583cac7..b4f5d3a4383 100644 --- a/src/gallium/drivers/zink/zink_pipeline.c +++ b/src/gallium/drivers/zink/zink_pipeline.c @@ -49,6 +49,7 @@ VkPipeline zink_create_gfx_pipeline(struct zink_screen *screen, struct zink_gfx_program *prog, struct zink_gfx_pipeline_state *state, + const uint8_t *binding_map, VkPrimitiveTopology primitive_topology) { struct zink_rasterizer_hw_state *hw_rast_state = (void*)state; @@ -60,6 +61,13 @@ zink_create_gfx_pipeline(struct zink_screen *screen, vertex_input_state.vertexBindingDescriptionCount = state->element_state->num_bindings; vertex_input_state.pVertexAttributeDescriptions = state->element_state->attribs; vertex_input_state.vertexAttributeDescriptionCount = state->element_state->num_attribs; + if (!screen->info.have_EXT_extended_dynamic_state) { + for (int i = 0; i < state->element_state->num_bindings; ++i) { + const unsigned buffer_id = binding_map[i]; + VkVertexInputBindingDescription *binding = &state->element_state->b.bindings[i]; + binding->stride = state->vertex_strides[buffer_id]; + } + } } VkPipelineVertexInputDivisorStateCreateInfoEXT vdiv_state; diff --git a/src/gallium/drivers/zink/zink_pipeline.h b/src/gallium/drivers/zink/zink_pipeline.h index 04c6a05d25e..b3acb614947 100644 --- a/src/gallium/drivers/zink/zink_pipeline.h +++ b/src/gallium/drivers/zink/zink_pipeline.h @@ -110,6 +110,7 @@ VkPipeline zink_create_gfx_pipeline(struct zink_screen *screen, struct zink_gfx_program *prog, struct zink_gfx_pipeline_state *state, + const uint8_t *binding_map, VkPrimitiveTopology primitive_topology); VkPipeline diff --git a/src/gallium/drivers/zink/zink_program.c b/src/gallium/drivers/zink/zink_program.c index b39f3d55a84..c06a1e3bea8 100644 --- a/src/gallium/drivers/zink/zink_program.c +++ b/src/gallium/drivers/zink/zink_program.c @@ -771,9 +771,10 @@ zink_get_gfx_pipeline(struct zink_context *ctx, hash = XXH32(&vertex_buffers_enabled_mask, sizeof(uint32_t), hash); for (unsigned i = 0; i < state->element_state->num_bindings; i++) { - struct pipe_vertex_buffer *vb = ctx->vertex_buffers + ctx->element_state->binding_map[i]; - state->vertex_strides[i] = vb->buffer.resource ? vb->stride : 0; - hash = XXH32(&state->vertex_strides[i], sizeof(uint32_t), hash); + const unsigned buffer_id = ctx->element_state->binding_map[i]; + struct pipe_vertex_buffer *vb = ctx->vertex_buffers + buffer_id; + state->vertex_strides[buffer_id] = vb->buffer.resource ? vb->stride : 0; + hash = XXH32(&state->vertex_strides[buffer_id], sizeof(uint32_t), hash); } state->vertex_hash = hash ^ state->element_state->hash; } else @@ -787,8 +788,9 @@ zink_get_gfx_pipeline(struct zink_context *ctx, if (!entry) { util_queue_fence_wait(&prog->base.cache_fence); - VkPipeline pipeline = zink_create_gfx_pipeline(screen, prog, - state, vkmode); + VkPipeline pipeline = zink_create_gfx_pipeline(screen, prog, state, + ctx->element_state->binding_map, + vkmode); if (pipeline == VK_NULL_HANDLE) return VK_NULL_HANDLE;