spirv: Let spirv_to_nir() users turn sysvals into input varyings
This is an attempt at simplifying the spirv_to_nir() backend when it comes to choosing between system values and input varyings. Let's patch drivers to do the sysval to input varying conversion on their own so we can get rid of the frag_coord_is_varying field in spirv_to_nir_options and unconditionally create create sysvals for FragCoord, FrontFacing and PointCoord inputs instead of adding new xxx_is_{sysval,varying} flags. Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com> Suggested-by: Jason Ekstrand <jason@jlekstrand.net> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Reviewed-by: Iago Toral Quiroga <itoral@igalia.com> Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Reviewed-by: Hyunjun Ko <zzoon@igalia.com> Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13017>
This commit is contained in:

committed by
Marge Bot

parent
56251f924d
commit
4b62e90e71
@@ -536,6 +536,11 @@ radv_shader_compile_to_nir(struct radv_device *device, struct vk_shader_module *
|
||||
|
||||
free(spec_entries);
|
||||
|
||||
const struct nir_lower_sysvals_to_varyings_options sysvals_to_varyings = {
|
||||
.point_coord = true,
|
||||
};
|
||||
NIR_PASS_V(nir, nir_lower_sysvals_to_varyings, &sysvals_to_varyings);
|
||||
|
||||
/* 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.
|
||||
|
@@ -467,6 +467,12 @@ shader_module_compile_to_nir(struct v3dv_device *device,
|
||||
}
|
||||
assert(nir->info.stage == broadcom_shader_stage_to_gl(stage->stage));
|
||||
|
||||
const struct nir_lower_sysvals_to_varyings_options sysvals_to_varyings = {
|
||||
.frag_coord = true,
|
||||
.point_coord = true,
|
||||
};
|
||||
NIR_PASS_V(nir, nir_lower_sysvals_to_varyings, &sysvals_to_varyings);
|
||||
|
||||
if (unlikely(V3D_DEBUG & (V3D_DEBUG_NIR |
|
||||
v3d_debug_flag_for_shader_stage(
|
||||
broadcom_shader_stage_to_gl(stage->stage))))) {
|
||||
|
@@ -112,6 +112,11 @@ tu_spirv_to_nir(struct tu_device *dev,
|
||||
assert(nir->info.stage == stage);
|
||||
nir_validate_shader(nir, "after spirv_to_nir");
|
||||
|
||||
const struct nir_lower_sysvals_to_varyings_options sysvals_to_varyings = {
|
||||
.point_coord = true,
|
||||
};
|
||||
NIR_PASS_V(nir, nir_lower_sysvals_to_varyings, &sysvals_to_varyings);
|
||||
|
||||
if (unlikely(dev->physical_device->instance->debug_flags & TU_DEBUG_NIR)) {
|
||||
fprintf(stderr, "translated nir:\n");
|
||||
nir_print_shader(nir, stderr);
|
||||
|
@@ -251,6 +251,12 @@ load_spirv(const char *filename, const char *entry, gl_shader_stage stage)
|
||||
stage, entry, &spirv_options,
|
||||
ir3_get_compiler_options(compiler));
|
||||
|
||||
const struct nir_lower_sysvals_to_varyings_options sysvals_to_varyings = {
|
||||
.frag_coord = true,
|
||||
.point_coord = true,
|
||||
};
|
||||
NIR_PASS_V(nir, nir_lower_sysvals_to_varyings, &sysvals_to_varyings);
|
||||
|
||||
nir_print_shader(nir, stdout);
|
||||
|
||||
return nir;
|
||||
|
@@ -529,6 +529,12 @@ lvp_shader_compile_to_ir(struct lvp_pipeline *pipeline,
|
||||
|
||||
free(spec_entries);
|
||||
|
||||
const struct nir_lower_sysvals_to_varyings_options sysvals_to_varyings = {
|
||||
.frag_coord = true,
|
||||
.point_coord = true,
|
||||
};
|
||||
NIR_PASS_V(nir, nir_lower_sysvals_to_varyings, &sysvals_to_varyings);
|
||||
|
||||
NIR_PASS_V(nir, nir_lower_variable_initializers, nir_var_function_temp);
|
||||
NIR_PASS_V(nir, nir_lower_returns);
|
||||
NIR_PASS_V(nir, nir_inline_functions);
|
||||
|
@@ -194,6 +194,11 @@ anv_shader_compile_to_nir(struct anv_device *device,
|
||||
|
||||
free(spec_entries);
|
||||
|
||||
const struct nir_lower_sysvals_to_varyings_options sysvals_to_varyings = {
|
||||
.point_coord = true,
|
||||
};
|
||||
NIR_PASS_V(nir, nir_lower_sysvals_to_varyings, &sysvals_to_varyings);
|
||||
|
||||
if (INTEL_DEBUG & intel_debug_flag_for_shader_stage(stage)) {
|
||||
fprintf(stderr, "NIR (from SPIR-V) for %s shader:\n",
|
||||
gl_shader_stage_name(stage));
|
||||
|
@@ -279,6 +279,14 @@ _mesa_spirv_to_nir(struct gl_context *ctx,
|
||||
|
||||
nir->info.separate_shader = linked_shader->Program->info.separate_shader;
|
||||
|
||||
/* Convert some sysvals to input varyings. */
|
||||
const struct nir_lower_sysvals_to_varyings_options sysvals_to_varyings = {
|
||||
.frag_coord = !ctx->Const.GLSLFragCoordIsSysVal,
|
||||
.point_coord = !ctx->Const.GLSLPointCoordIsSysVal,
|
||||
.front_face = !ctx->Const.GLSLFrontFacingIsSysVal,
|
||||
};
|
||||
NIR_PASS_V(nir, nir_lower_sysvals_to_varyings, &sysvals_to_varyings);
|
||||
|
||||
/* 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.
|
||||
|
@@ -69,6 +69,13 @@ panvk_spirv_to_nir(const void *code,
|
||||
assert(nir->info.stage == stage);
|
||||
nir_validate_shader(nir, "after spirv_to_nir");
|
||||
|
||||
const struct nir_lower_sysvals_to_varyings_options sysvals_to_varyings = {
|
||||
.frag_coord = PAN_ARCH <= 5,
|
||||
.point_coord = PAN_ARCH <= 5,
|
||||
.front_face = PAN_ARCH <= 5,
|
||||
};
|
||||
NIR_PASS_V(nir, nir_lower_sysvals_to_varyings, &sysvals_to_varyings);
|
||||
|
||||
return nir;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user