lavapipe: split out spirv compile of shaders
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Mon, 6 Mar 2023 19:16:56 +0000 (14:16 -0500)
committerMarge Bot <emma+marge@anholt.net>
Wed, 8 Mar 2023 18:25:01 +0000 (18:25 +0000)
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21778>

src/gallium/frontends/lavapipe/lvp_pipeline.c

index 1288223..aa45d27 100644 (file)
@@ -355,14 +355,11 @@ lvp_shader_optimize(nir_shader *nir)
 }
 
 static VkResult
-lvp_shader_compile_to_ir(struct lvp_pipeline *pipeline,
-                         const VkPipelineShaderStageCreateInfo *sinfo)
+compile_spirv(struct lvp_device *pdevice, const VkPipelineShaderStageCreateInfo *sinfo, nir_shader **nir)
 {
-   struct lvp_device *pdevice = pipeline->device;
    gl_shader_stage stage = vk_to_mesa_shader_stage(sinfo->stage);
    assert(stage <= MESA_SHADER_COMPUTE && stage != MESA_SHADER_NONE);
    VkResult result;
-   nir_shader *nir;
 
    const struct spirv_to_nir_options spirv_options = {
       .environment = NIR_SPIRV_VULKAN,
@@ -417,7 +414,19 @@ lvp_shader_compile_to_ir(struct lvp_pipeline *pipeline,
 
    result = vk_pipeline_shader_stage_to_nir(&pdevice->vk, sinfo,
                                             &spirv_options, pdevice->physical_device->drv_options[stage],
-                                            NULL, &nir);
+                                            NULL, nir);
+   return result;
+}
+
+static VkResult
+lvp_shader_compile_to_ir(struct lvp_pipeline *pipeline,
+                         const VkPipelineShaderStageCreateInfo *sinfo)
+{
+   struct lvp_device *pdevice = pipeline->device;
+   gl_shader_stage stage = vk_to_mesa_shader_stage(sinfo->stage);
+   assert(stage <= MESA_SHADER_COMPUTE && stage != MESA_SHADER_NONE);
+   nir_shader *nir;
+   VkResult result = compile_spirv(pdevice, sinfo, &nir);
    if (result != VK_SUCCESS)
       return result;