vulkan/runtime: add internal parameter to vk_spirv_to_nir
authorIván Briano <ivan.briano@intel.com>
Fri, 15 Sep 2023 21:34:31 +0000 (14:34 -0700)
committerMarge Bot <emma+marge@anholt.net>
Mon, 9 Oct 2023 23:37:51 +0000 (23:37 +0000)
If used to compile internal shaders, it will lack the flag while running
through all the optimization passes it does.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25281>

src/intel/vulkan/anv_internal_kernels.c
src/vulkan/runtime/vk_nir.c
src/vulkan/runtime/vk_nir.h
src/vulkan/runtime/vk_pipeline.c

index 51b02ae..0a5d65e 100644 (file)
@@ -165,12 +165,11 @@ compile_upload_spirv(struct anv_device *device,
    nir_shader* nir =
       vk_spirv_to_nir(&device->vk, spirv_source, spirv_source_size * 4,
                       stage, "main", 0, NULL, &spirv_options,
-                      nir_options, NULL);
+                      nir_options, true /* internal */,
+                      NULL);
 
    assert(nir != NULL);
 
-   nir->info.internal = true;
-
    NIR_PASS_V(nir, nir_lower_vars_to_ssa);
    NIR_PASS_V(nir, nir_opt_cse);
    NIR_PASS_V(nir, nir_opt_gcm, true);
index 7d48dc7..c36d38b 100644 (file)
@@ -120,6 +120,7 @@ vk_spirv_to_nir(struct vk_device *device,
                 const VkSpecializationInfo *spec_info,
                 const struct spirv_to_nir_options *spirv_options,
                 const struct nir_shader_compiler_options *nir_options,
+                bool internal,
                 void *mem_ctx)
 {
    assert(spirv_size_B >= 4 && spirv_size_B % 4 == 0);
@@ -149,6 +150,8 @@ vk_spirv_to_nir(struct vk_device *device,
    if (mem_ctx != NULL)
       ralloc_steal(mem_ctx, nir);
 
+   nir->info.internal = internal;
+
    /* We have to lower away local constant initializers right before we
     * inline functions.  That way they get properly initialized at the top
     * of the function and not at the top of its caller.
index 7f8faf6..48b1ba8 100644 (file)
@@ -47,6 +47,7 @@ vk_spirv_to_nir(struct vk_device *device,
                 const VkSpecializationInfo *spec_info,
                 const struct spirv_to_nir_options *spirv_options,
                 const struct nir_shader_compiler_options *nir_options,
+                bool internal,
                 void *mem_ctx);
 
 #ifdef __cplusplus
index 9d3d6d4..50a87e1 100644 (file)
@@ -147,7 +147,9 @@ vk_pipeline_shader_stage_to_nir(struct vk_device *device,
    nir_shader *nir = vk_spirv_to_nir(device, spirv_data, spirv_size, stage,
                                      info->pName, subgroup_size,
                                      info->pSpecializationInfo,
-                                     spirv_options, nir_options, mem_ctx);
+                                     spirv_options, nir_options,
+                                     false /* internal */,
+                                     mem_ctx);
    if (nir == NULL)
       return vk_errorf(device, VK_ERROR_UNKNOWN, "spirv_to_nir failed");