nir/lower_input_attachments: Support loading layer id via gl_ViewIndex
This is required on adreno when the special multiview mode is switched on. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5719>
This commit is contained in:
@@ -4461,6 +4461,7 @@ bool nir_lower_idiv(nir_shader *shader, enum nir_lower_idiv_path path);
|
||||
typedef struct nir_input_attachment_options {
|
||||
bool use_fragcoord_sysval;
|
||||
bool use_layer_id_sysval;
|
||||
bool use_view_id_for_layer;
|
||||
} nir_input_attachment_options;
|
||||
|
||||
bool nir_lower_input_attachments(nir_shader *shader,
|
||||
|
@@ -53,17 +53,22 @@ load_frag_coord(const nir_input_attachment_options *options, nir_builder *b)
|
||||
static nir_ssa_def *
|
||||
load_layer_id(const nir_input_attachment_options *options, nir_builder *b)
|
||||
{
|
||||
if (options->use_layer_id_sysval)
|
||||
return nir_load_layer_id(b);
|
||||
if (options->use_layer_id_sysval) {
|
||||
if (options->use_view_id_for_layer)
|
||||
return nir_load_view_index(b);
|
||||
else
|
||||
return nir_load_layer_id(b);
|
||||
}
|
||||
|
||||
gl_varying_slot slot = options->use_view_id_for_layer ?
|
||||
VARYING_SLOT_VIEW_INDEX : VARYING_SLOT_LAYER;
|
||||
nir_variable *layer_id =
|
||||
nir_find_variable_with_location(b->shader, nir_var_shader_in,
|
||||
VARYING_SLOT_LAYER);
|
||||
nir_find_variable_with_location(b->shader, nir_var_shader_in, slot);
|
||||
|
||||
if (layer_id == NULL) {
|
||||
layer_id = nir_variable_create(b->shader, nir_var_shader_in,
|
||||
glsl_int_type(), NULL);
|
||||
layer_id->data.location = VARYING_SLOT_LAYER;
|
||||
layer_id->data.location = slot;
|
||||
layer_id->data.interpolation = INTERP_MODE_FLAT;
|
||||
layer_id->data.driver_location = b->shader->num_inputs++;
|
||||
}
|
||||
|
Reference in New Issue
Block a user