From 707dc04b78b540912e178e0a67e1577ff05b2e29 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Thu, 17 Sep 2020 07:32:13 -0400 Subject: [PATCH] zink: no-op descriptor updating for draws without descriptors this is a valid case that we can trivially shortcut to cut down on calls Reviewed-by: Dave Airlie Part-of: --- src/gallium/drivers/zink/zink_draw.c | 6 ++++-- src/gallium/drivers/zink/zink_program.c | 17 ++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/gallium/drivers/zink/zink_draw.c b/src/gallium/drivers/zink/zink_draw.c index cf22962..70d1fd6 100644 --- a/src/gallium/drivers/zink/zink_draw.c +++ b/src/gallium/drivers/zink/zink_draw.c @@ -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); diff --git a/src/gallium/drivers/zink/zink_program.c b/src/gallium/drivers/zink/zink_program.c index 7b5cbf9..31d522d 100644 --- a/src/gallium/drivers/zink/zink_program.c +++ b/src/gallium/drivers/zink/zink_program.c @@ -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); -- 2.7.4