vulkan/nir: Don't remove dead XFB outputs

Fixes: 21b405fbbc ("vulkan: Add a vk_shader_module_to_nir() helper")
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17644>
This commit is contained in:
Jason Ekstrand 2022-07-20 13:45:45 -05:00 committed by Marge Bot
parent 87ab287436
commit bd93d6f693
1 changed files with 14 additions and 1 deletions

View File

@ -64,6 +64,16 @@ spirv_nir_debug(void *private_data,
}
}
static bool
is_not_xfb_output(nir_variable *var, void *data)
{
if (var->data.mode != nir_var_shader_out)
return true;
return !var->data.explicit_xfb_buffer &&
!var->data.explicit_xfb_stride;
}
nir_shader *
vk_spirv_to_nir(struct vk_device *device,
const uint32_t *spirv_data, size_t spirv_size_B,
@ -127,10 +137,13 @@ vk_spirv_to_nir(struct vk_device *device,
NIR_PASS_V(nir, nir_split_var_copies);
NIR_PASS_V(nir, nir_split_per_member_structs);
nir_remove_dead_variables_options dead_vars_opts = {
.can_remove_var = is_not_xfb_output,
};
NIR_PASS_V(nir, nir_remove_dead_variables,
nir_var_shader_in | nir_var_shader_out | nir_var_system_value |
nir_var_shader_call_data | nir_var_ray_hit_attrib,
NULL);
&dead_vars_opts);
/* This needs to happen after remove_dead_vars because GLSLang likes to
* insert dead clip/cull vars and we don't want to clip/cull based on