vulkan/runtime: add internal parameter to vk_spirv_to_nir

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>
This commit is contained in:
Iván Briano
2023-09-15 14:34:31 -07:00
committed by Marge Bot
parent c8c1109bc6
commit 919f5468eb
4 changed files with 9 additions and 4 deletions

View 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);

View 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.

View 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

View 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");