[Mesa-dev] [PATCH 12/21] anv/pipeline: Drop anv_pipeline_add_compiled_stage

Jason Ekstrand jason at jlekstrand.net
Sat Oct 28 18:36:20 UTC 2017


We can set active_stages much more directly and then it's just candy
around setting pipeline->stages[stage].
---
 src/intel/vulkan/anv_pipeline.c  | 30 ++++++++++++------------------
 src/intel/vulkan/genX_pipeline.c |  2 --
 2 files changed, 12 insertions(+), 20 deletions(-)

diff --git a/src/intel/vulkan/anv_pipeline.c b/src/intel/vulkan/anv_pipeline.c
index ec14c73..0e58f83 100644
--- a/src/intel/vulkan/anv_pipeline.c
+++ b/src/intel/vulkan/anv_pipeline.c
@@ -533,15 +533,6 @@ anv_pipeline_upload_kernel(struct anv_pipeline *pipeline,
 }
 
 
-static void
-anv_pipeline_add_compiled_stage(struct anv_pipeline *pipeline,
-                                gl_shader_stage stage,
-                                struct anv_shader_bin *shader)
-{
-   pipeline->shaders[stage] = shader;
-   pipeline->active_stages |= mesa_to_vk_shader_stage(stage);
-}
-
 static VkResult
 anv_pipeline_compile_vs(struct anv_pipeline *pipeline,
                         struct anv_pipeline_cache *cache,
@@ -600,7 +591,7 @@ anv_pipeline_compile_vs(struct anv_pipeline *pipeline,
       ralloc_free(mem_ctx);
    }
 
-   anv_pipeline_add_compiled_stage(pipeline, MESA_SHADER_VERTEX, bin);
+   pipeline->shaders[MESA_SHADER_VERTEX] = bin;
 
    return VK_SUCCESS;
 }
@@ -761,8 +752,8 @@ anv_pipeline_compile_tcs_tes(struct anv_pipeline *pipeline,
       ralloc_free(mem_ctx);
    }
 
-   anv_pipeline_add_compiled_stage(pipeline, MESA_SHADER_TESS_CTRL, tcs_bin);
-   anv_pipeline_add_compiled_stage(pipeline, MESA_SHADER_TESS_EVAL, tes_bin);
+   pipeline->shaders[MESA_SHADER_TESS_CTRL] = tcs_bin;
+   pipeline->shaders[MESA_SHADER_TESS_EVAL] = tes_bin;
 
    return VK_SUCCESS;
 }
@@ -826,7 +817,7 @@ anv_pipeline_compile_gs(struct anv_pipeline *pipeline,
       ralloc_free(mem_ctx);
    }
 
-   anv_pipeline_add_compiled_stage(pipeline, MESA_SHADER_GEOMETRY, bin);
+   pipeline->shaders[MESA_SHADER_GEOMETRY] = bin;
 
    return VK_SUCCESS;
 }
@@ -942,7 +933,7 @@ anv_pipeline_compile_fs(struct anv_pipeline *pipeline,
       ralloc_free(mem_ctx);
    }
 
-   anv_pipeline_add_compiled_stage(pipeline, MESA_SHADER_FRAGMENT, bin);
+   pipeline->shaders[MESA_SHADER_FRAGMENT] = bin;
 
    return VK_SUCCESS;
 }
@@ -954,11 +945,15 @@ anv_pipeline_compile_graphics(struct anv_pipeline *pipeline,
 {
    struct anv_pipeline_stage stages[MESA_SHADER_STAGES] = {};
 
+   pipeline->active_stages = 0;
+
    VkResult result;
    for (uint32_t i = 0; i < info->stageCount; i++) {
       gl_shader_stage stage = vk_to_mesa_shader_stage(info->pStages[i].stage);
       const VkPipelineShaderStageCreateInfo *sinfo = &info->pStages[i];
 
+      pipeline->active_stages |= info->pStages[i].stage;
+
       stages[stage].stage = stage;
       stages[stage].module = anv_shader_module_from_handle(sinfo->module);
       stages[stage].entrypoint = sinfo->pName;
@@ -1005,7 +1000,7 @@ anv_pipeline_compile_graphics(struct anv_pipeline *pipeline,
             anv_pipeline_cache_search(cache, &stages[s].cache_key,
                                       sizeof(stages[s].cache_key));
          if (bin)
-            anv_pipeline_add_compiled_stage(pipeline, s, bin);
+            pipeline->shaders[s] = bin;
       }
    }
 
@@ -1124,7 +1119,8 @@ anv_pipeline_compile_cs(struct anv_pipeline *pipeline,
       ralloc_free(mem_ctx);
    }
 
-   anv_pipeline_add_compiled_stage(pipeline, MESA_SHADER_COMPUTE, bin);
+   pipeline->active_stages = VK_SHADER_STAGE_COMPUTE_BIT;
+   pipeline->shaders[MESA_SHADER_COMPUTE] = bin;
 
    return VK_SUCCESS;
 }
@@ -1381,8 +1377,6 @@ anv_pipeline_init(struct anv_pipeline *pipeline,
     */
    memset(pipeline->shaders, 0, sizeof(pipeline->shaders));
 
-   pipeline->active_stages = 0;
-
    result = anv_pipeline_compile_graphics(pipeline, cache, pCreateInfo);
    if (result != VK_SUCCESS) {
       anv_reloc_list_finish(&pipeline->batch_relocs, alloc);
diff --git a/src/intel/vulkan/genX_pipeline.c b/src/intel/vulkan/genX_pipeline.c
index c2fa9c0..b52ed6e 100644
--- a/src/intel/vulkan/genX_pipeline.c
+++ b/src/intel/vulkan/genX_pipeline.c
@@ -1786,8 +1786,6 @@ compute_pipeline_create(
     */
    memset(pipeline->shaders, 0, sizeof(pipeline->shaders));
 
-   pipeline->active_stages = 0;
-
    pipeline->needs_data_cache = false;
 
    assert(pCreateInfo->stage.stage == VK_SHADER_STAGE_COMPUTE_BIT);
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list