zink: don't add dynamic vertex pipeline states if no attribs are used
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Mon, 25 Oct 2021 18:11:50 +0000 (14:11 -0400)
committerMarge Bot <eric+marge@anholt.net>
Tue, 26 Oct 2021 18:07:25 +0000 (18:07 +0000)
adding the states requires that vertex attribs be bound, but it's illegal
to bind 0 attribs

cc: mesa-stable

fixes #5558

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13519>

src/gallium/drivers/zink/zink_pipeline.c

index b16b647..6a5b583 100644 (file)
@@ -53,7 +53,7 @@ zink_create_gfx_pipeline(struct zink_screen *screen,
 {
    struct zink_rasterizer_hw_state *hw_rast_state = (void*)state;
    VkPipelineVertexInputStateCreateInfo vertex_input_state;
-   if (!screen->info.have_EXT_vertex_input_dynamic_state) {
+   if (!screen->info.have_EXT_vertex_input_dynamic_state || !state->element_state->num_attribs) {
       memset(&vertex_input_state, 0, sizeof(vertex_input_state));
       vertex_input_state.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
       vertex_input_state.pVertexBindingDescriptions = state->element_state->b.bindings;
@@ -201,10 +201,12 @@ zink_create_gfx_pipeline(struct zink_screen *screen,
       dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_VIEWPORT;
       dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_SCISSOR;
    }
-   if (screen->info.have_EXT_vertex_input_dynamic_state)
-      dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_VERTEX_INPUT_EXT;
-   else if (screen->info.have_EXT_extended_dynamic_state)
-      dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT;
+   if (state->element_state->num_attribs) {
+      if (screen->info.have_EXT_vertex_input_dynamic_state)
+         dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_VERTEX_INPUT_EXT;
+      else if (screen->info.have_EXT_extended_dynamic_state)
+         dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT;
+   }
    if (screen->info.have_EXT_extended_dynamic_state2)
       dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT;
 
@@ -231,7 +233,7 @@ zink_create_gfx_pipeline(struct zink_screen *screen,
    pci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
    pci.layout = prog->base.layout;
    pci.renderPass = state->render_pass->render_pass;
-   if (!screen->info.have_EXT_vertex_input_dynamic_state)
+   if (!screen->info.have_EXT_vertex_input_dynamic_state || !state->element_state->num_attribs)
       pci.pVertexInputState = &vertex_input_state;
    pci.pInputAssemblyState = &primitive_state;
    pci.pRasterizationState = &rast_state;