zink: cleanup zink_pipeline_layout_create
authorSoroushIMG <soroush.kashani@imgtec.com>
Mon, 24 Oct 2022 14:13:28 +0000 (15:13 +0100)
committerSoroushIMG <soroush.kashani@imgtec.com>
Wed, 26 Oct 2022 15:23:45 +0000 (16:23 +0100)
move the hashing to the caller, since it's not related to this.
Additionally, remove dependance on zink_program argument.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19163>

src/gallium/drivers/zink/zink_descriptors.c
src/gallium/drivers/zink/zink_program.c
src/gallium/drivers/zink/zink_program.h

index 57440ef..e9caa26 100644 (file)
@@ -457,7 +457,9 @@ zink_descriptor_program_init(struct zink_context *ctx, struct zink_program *pg)
    }
    pg->dd.binding_usage = has_bindings;
    if (!has_bindings && !push_count && !pg->dd.bindless) {
-      pg->layout = zink_pipeline_layout_create(screen, pg, &pg->compat_id);
+      pg->layout = zink_pipeline_layout_create(screen, pg->dsl, pg->num_dsl, pg->is_compute);
+      if (pg->layout)
+         pg->compat_id = _mesa_hash_data(pg->dsl, pg->num_dsl * sizeof(pg->dsl[0]));
       return !!pg->layout;
    }
 
@@ -521,9 +523,10 @@ zink_descriptor_program_init(struct zink_context *ctx, struct zink_program *pg)
       pg->dd.binding_usage |= BITFIELD_MASK(ZINK_DESCRIPTOR_BASE_TYPES);
    }
 
-   pg->layout = zink_pipeline_layout_create(screen, pg, &pg->compat_id);
+   pg->layout = zink_pipeline_layout_create(screen, pg->dsl, pg->num_dsl, pg->is_compute);
    if (!pg->layout)
       return false;
+   pg->compat_id = _mesa_hash_data(pg->dsl, pg->num_dsl * sizeof(pg->dsl[0]));
 
    VkDescriptorUpdateTemplateCreateInfo template[ZINK_DESCRIPTOR_NON_BINDLESS_TYPES] = {0};
    /* type of template */
index e3561db..e696346 100644 (file)
@@ -784,22 +784,20 @@ zink_update_compute_program(struct zink_context *ctx)
 }
 
 VkPipelineLayout
-zink_pipeline_layout_create(struct zink_screen *screen, struct zink_program *pg, uint32_t *compat)
+zink_pipeline_layout_create(struct zink_screen *screen, VkDescriptorSetLayout *dsl, unsigned num_dsl, bool is_compute)
 {
    VkPipelineLayoutCreateInfo plci = {0};
    plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
 
-   plci.pSetLayouts = pg->dsl;
-   plci.setLayoutCount = pg->num_dsl;
+   plci.pSetLayouts = dsl;
+   plci.setLayoutCount = num_dsl;
 
    VkPushConstantRange pcr[2] = {0};
-   if (pg->is_compute) {
-      if (((struct zink_compute_program*)pg)->shader->nir->info.stage == MESA_SHADER_KERNEL) {
-         pcr[0].stageFlags = VK_SHADER_STAGE_COMPUTE_BIT;
-         pcr[0].offset = 0;
-         pcr[0].size = sizeof(struct zink_cs_push_constant);
-         plci.pushConstantRangeCount = 1;
-      }
+   if (is_compute) {
+      pcr[0].stageFlags = VK_SHADER_STAGE_COMPUTE_BIT;
+      pcr[0].offset = 0;
+      pcr[0].size = sizeof(struct zink_cs_push_constant);
+      plci.pushConstantRangeCount = 1;
    } else {
       pcr[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT;
       pcr[0].offset = offsetof(struct zink_gfx_push_constant, draw_mode_is_indexed);
@@ -818,8 +816,6 @@ zink_pipeline_layout_create(struct zink_screen *screen, struct zink_program *pg,
       return VK_NULL_HANDLE;
    }
 
-   *compat = _mesa_hash_data(pg->dsl, pg->num_dsl * sizeof(pg->dsl[0]));
-
    return layout;
 }
 
index 2bcf279..1cd9df1 100644 (file)
@@ -221,7 +221,7 @@ zink_program_reference(struct zink_screen *screen,
 }
 
 VkPipelineLayout
-zink_pipeline_layout_create(struct zink_screen *screen, struct zink_program *pg, uint32_t *compat);
+zink_pipeline_layout_create(struct zink_screen *screen, VkDescriptorSetLayout *dsl, unsigned num_dsl, bool is_compute);
 
 void
 zink_program_update_compute_pipeline_state(struct zink_context *ctx, struct zink_compute_program *comp, const uint block[3]);