spirv: Emit SYSTEM_VALUE_LAYER_ID for fragment shaders
We have nir_lower_sysvals_to_varyings() so we can just have that lower it for the drivers who don't want a sysval. Most have to support the sysval version anyway for various lowering so making them all have to support both is pretty annoying. Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@intel.com> Reviewed-by: Emma Anholt <emma@anholt.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38562>
This commit is contained in:
committed by
Marge Bot
parent
701a9c269e
commit
0c36c39103
@@ -294,6 +294,7 @@ preprocess_nir(nir_shader *nir)
|
||||
const struct nir_lower_sysvals_to_varyings_options sysvals_to_varyings = {
|
||||
.frag_coord = true,
|
||||
.point_coord = true,
|
||||
.layer_id = true,
|
||||
};
|
||||
NIR_PASS(_, nir, nir_lower_sysvals_to_varyings, &sysvals_to_varyings);
|
||||
|
||||
|
||||
@@ -941,16 +941,17 @@ vtn_get_builtin_location(struct vtn_builder *b,
|
||||
break;
|
||||
case SpvBuiltInLayer:
|
||||
case SpvBuiltInLayerPerViewNV:
|
||||
*location = VARYING_SLOT_LAYER;
|
||||
if (b->shader->info.stage == MESA_SHADER_FRAGMENT) {
|
||||
*mode = nir_var_shader_in;
|
||||
*interp_mode = INTERP_MODE_FLAT;
|
||||
*location = SYSTEM_VALUE_LAYER_ID;
|
||||
set_mode_system_value(b, mode);
|
||||
} else if (b->shader->info.stage == MESA_SHADER_GEOMETRY) {
|
||||
*location = VARYING_SLOT_LAYER;
|
||||
*mode = nir_var_shader_out;
|
||||
} else if (b->supported_capabilities.ShaderViewportIndexLayerEXT &&
|
||||
(b->shader->info.stage == MESA_SHADER_VERTEX ||
|
||||
b->shader->info.stage == MESA_SHADER_TESS_EVAL ||
|
||||
b->shader->info.stage == MESA_SHADER_MESH)) {
|
||||
*location = VARYING_SLOT_LAYER;
|
||||
*mode = nir_var_shader_out;
|
||||
} else {
|
||||
vtn_fail("invalid stage for SpvBuiltInLayer");
|
||||
|
||||
@@ -232,6 +232,7 @@ tu_spirv_to_nir(struct tu_device *dev,
|
||||
|
||||
const struct nir_lower_sysvals_to_varyings_options sysvals_to_varyings = {
|
||||
.point_coord = true,
|
||||
.layer_id = true,
|
||||
};
|
||||
NIR_PASS(_, nir, nir_lower_sysvals_to_varyings, &sysvals_to_varyings);
|
||||
|
||||
|
||||
@@ -333,6 +333,7 @@ lvp_shader_lower(struct lvp_device *pdevice, nir_shader *nir, struct lvp_pipelin
|
||||
const struct nir_lower_sysvals_to_varyings_options sysvals_to_varyings = {
|
||||
.frag_coord = true,
|
||||
.point_coord = true,
|
||||
.layer_id = true,
|
||||
};
|
||||
NIR_PASS(_, nir, nir_lower_sysvals_to_varyings, &sysvals_to_varyings);
|
||||
|
||||
|
||||
@@ -905,6 +905,7 @@ dxil_spirv_nir_passes(nir_shader *nir,
|
||||
.frag_coord = true,
|
||||
.point_coord = true,
|
||||
.front_face = true,
|
||||
.layer_id = true,
|
||||
};
|
||||
NIR_PASS(_, nir, nir_lower_sysvals_to_varyings, &sysvals_to_varyings);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user