zink: no-op descriptor updating for draws without descriptors
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Thu, 17 Sep 2020 11:32:13 +0000 (07:32 -0400)
committerMarge Bot <eric+marge@anholt.net>
Wed, 24 Feb 2021 22:44:50 +0000 (22:44 +0000)
this is a valid case that we can trivially shortcut to cut down on calls

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9155>

src/gallium/drivers/zink/zink_draw.c
src/gallium/drivers/zink/zink_program.c

index cf22962..70d1fd6 100644 (file)
@@ -731,7 +731,8 @@ zink_draw_vbo(struct pipe_context *pctx,
    barrier_vertex_buffers(ctx);
    barrier_draw_buffers(ctx, dinfo, dindirect, index_buffer);
 
-   update_descriptors(ctx, screen, false);
+   if (gfx_program->num_descriptors)
+      update_descriptors(ctx, screen, false);
 
    struct zink_batch *batch = zink_batch_rp(ctx);
    VkViewport viewports[PIPE_MAX_VIEWPORTS] = {};
@@ -932,7 +933,8 @@ zink_launch_grid(struct pipe_context *pctx, const struct pipe_grid_info *info)
    VkPipeline pipeline = zink_get_compute_pipeline(screen, comp_program,
                                                &ctx->compute_pipeline_state);
 
-   update_descriptors(ctx, screen, true);
+   if (comp_program->num_descriptors)
+      update_descriptors(ctx, screen, true);
 
 
    vkCmdBindPipeline(batch->cmdbuf, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline);
index 7b5cbf9..31d522d 100644 (file)
@@ -134,6 +134,10 @@ create_desc_set_layout(VkDevice dev,
       }
    }
 
+   *num_descriptors = num_bindings;
+   if (!num_bindings)
+      return VK_NULL_HANDLE;
+
    VkDescriptorSetLayoutCreateInfo dcslci = {};
    dcslci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
    dcslci.pNext = NULL;
@@ -147,20 +151,17 @@ create_desc_set_layout(VkDevice dev,
       return VK_NULL_HANDLE;
    }
 
-   *num_descriptors = num_bindings;
    return dsl;
 }
 
 static VkPipelineLayout
 create_gfx_pipeline_layout(VkDevice dev, VkDescriptorSetLayout dsl)
 {
-   assert(dsl != VK_NULL_HANDLE);
-
    VkPipelineLayoutCreateInfo plci = {};
    plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
 
    plci.pSetLayouts = &dsl;
-   plci.setLayoutCount = 1;
+   plci.setLayoutCount = !!dsl;
 
 
    VkPushConstantRange pcr[2] = {};
@@ -185,13 +186,11 @@ create_gfx_pipeline_layout(VkDevice dev, VkDescriptorSetLayout dsl)
 static VkPipelineLayout
 create_compute_pipeline_layout(VkDevice dev, VkDescriptorSetLayout dsl)
 {
-   assert(dsl != VK_NULL_HANDLE);
-
    VkPipelineLayoutCreateInfo plci = {};
    plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
 
    plci.pSetLayouts = &dsl;
-   plci.setLayoutCount = 1;
+   plci.setLayoutCount = !!dsl;
 
    VkPipelineLayout layout;
    if (vkCreatePipelineLayout(dev, &plci, NULL, &layout) != VK_SUCCESS) {
@@ -476,7 +475,7 @@ zink_create_gfx_program(struct zink_context *ctx,
 
    prog->dsl = create_desc_set_layout(screen->dev, stages,
                                       &prog->num_descriptors);
-   if (!prog->dsl)
+   if (prog->num_descriptors && !prog->dsl)
       goto fail;
 
    prog->layout = create_gfx_pipeline_layout(screen->dev, prog->dsl);
@@ -576,7 +575,7 @@ zink_create_compute_program(struct zink_context *ctx, struct zink_shader *shader
    stages[0] = shader;
    comp->dsl = create_desc_set_layout(screen->dev, stages,
                                       &comp->num_descriptors);
-   if (!comp->dsl)
+   if (comp->num_descriptors && !comp->dsl)
       goto fail;
 
    comp->layout = create_compute_pipeline_layout(screen->dev, comp->dsl);