diff --git a/src/asahi/vulkan/hk_shader.c b/src/asahi/vulkan/hk_shader.c index 8cec01f403f..0be94cf99db 100644 --- a/src/asahi/vulkan/hk_shader.c +++ b/src/asahi/vulkan/hk_shader.c @@ -794,8 +794,6 @@ hk_lower_nir(struct hk_device *dev, nir_shader *nir, if (nir->info.stage == MESA_SHADER_FRAGMENT) { NIR_PASS(_, nir, nir_lower_input_attachments, &(nir_input_attachment_options){ - .use_fragcoord_sysval = true, - .use_layer_id_sysval = true, .use_view_id_for_layer = is_multiview, }); diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 0bb53d2dac2..b12223909e6 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -6042,8 +6042,6 @@ bool nir_lower_idiv(nir_shader *shader, const nir_lower_idiv_options *options); typedef struct nir_input_attachment_options { bool use_ia_coord_intrin; - bool use_fragcoord_sysval; - bool use_layer_id_sysval; bool use_view_id_for_layer; bool unscaled_depth_stencil_ir3; uint32_t unscaled_input_attachment_ir3; diff --git a/src/compiler/nir/nir_lower_input_attachments.c b/src/compiler/nir/nir_lower_input_attachments.c index 323b1887b54..c65261d66bc 100644 --- a/src/compiler/nir/nir_lower_input_attachments.c +++ b/src/compiler/nir/nir_lower_input_attachments.c @@ -28,59 +28,34 @@ static nir_def * load_frag_coord(nir_builder *b, nir_deref_instr *deref, const nir_input_attachment_options *options) { - if (options->use_fragcoord_sysval) { - nir_def *frag_coord = nir_load_frag_coord(b); - if (options->unscaled_input_attachment_ir3 || - options->unscaled_depth_stencil_ir3) { - nir_variable *var = nir_deref_instr_get_variable(deref); - unsigned base = var->data.index; - nir_def *unscaled_frag_coord = nir_load_frag_coord_unscaled_ir3(b); - if (deref->deref_type == nir_deref_type_array && - options->unscaled_input_attachment_ir3) { - nir_def *unscaled = - nir_i2b(b, nir_iand(b, nir_ishr(b, nir_imm_int(b, options->unscaled_input_attachment_ir3 >> base), deref->arr.index.ssa), - nir_imm_int(b, 1))); - frag_coord = nir_bcsel(b, unscaled, unscaled_frag_coord, frag_coord); - } else { - assert(deref->deref_type == nir_deref_type_var); - bool unscaled = base == NIR_VARIABLE_NO_INDEX ? options->unscaled_depth_stencil_ir3 : ((options->unscaled_input_attachment_ir3 >> base) & 1); - frag_coord = unscaled ? unscaled_frag_coord : frag_coord; - } + nir_def *frag_coord = nir_load_frag_coord(b); + if (options->unscaled_input_attachment_ir3 || + options->unscaled_depth_stencil_ir3) { + nir_variable *var = nir_deref_instr_get_variable(deref); + unsigned base = var->data.index; + nir_def *unscaled_frag_coord = nir_load_frag_coord_unscaled_ir3(b); + if (deref->deref_type == nir_deref_type_array && + options->unscaled_input_attachment_ir3) { + nir_def *unscaled = + nir_i2b(b, nir_iand(b, nir_ishr(b, nir_imm_int(b, options->unscaled_input_attachment_ir3 >> base), deref->arr.index.ssa), + nir_imm_int(b, 1))); + frag_coord = nir_bcsel(b, unscaled, unscaled_frag_coord, frag_coord); + } else { + assert(deref->deref_type == nir_deref_type_var); + bool unscaled = base == NIR_VARIABLE_NO_INDEX ? options->unscaled_depth_stencil_ir3 : ((options->unscaled_input_attachment_ir3 >> base) & 1); + frag_coord = unscaled ? unscaled_frag_coord : frag_coord; } - return frag_coord; } - - nir_variable *pos = nir_get_variable_with_location(b->shader, nir_var_shader_in, - VARYING_SLOT_POS, glsl_vec4_type()); - - /** - * From Vulkan spec: - * "The OriginLowerLeft execution mode must not be used; fragment entry - * points must declare OriginUpperLeft." - * - * So at this point origin_upper_left should be true - */ - assert(b->shader->info.fs.origin_upper_left == true); - - return nir_load_var(b, pos); + return frag_coord; } static nir_def * load_layer_id(nir_builder *b, const nir_input_attachment_options *options) { - 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_get_variable_with_location(b->shader, nir_var_shader_in, - slot, glsl_int_type()); - layer_id->data.interpolation = INTERP_MODE_FLAT; - - return nir_load_var(b, layer_id); + if (options->use_view_id_for_layer) + return nir_load_view_index(b); + else + return nir_load_layer_id(b); } static nir_def * diff --git a/src/freedreno/vulkan/tu_shader.cc b/src/freedreno/vulkan/tu_shader.cc index 437a4e20aa5..741b24e348e 100644 --- a/src/freedreno/vulkan/tu_shader.cc +++ b/src/freedreno/vulkan/tu_shader.cc @@ -2781,8 +2781,6 @@ tu_shader_create(struct tu_device *dev, if (nir->info.stage == MESA_SHADER_FRAGMENT) { const nir_input_attachment_options att_options = { - .use_fragcoord_sysval = true, - .use_layer_id_sysval = true, /* When using multiview rendering, we must use * gl_ViewIndex as the layer id to pass to the texture * sampling function. gl_Layer doesn't work when diff --git a/src/gallium/drivers/iris/iris_program_cache.c b/src/gallium/drivers/iris/iris_program_cache.c index 37d2fc8a4b4..febf6b8c21b 100644 --- a/src/gallium/drivers/iris/iris_program_cache.c +++ b/src/gallium/drivers/iris/iris_program_cache.c @@ -408,10 +408,7 @@ iris_ensure_indirect_generation_shader(struct iris_batch *batch) NIR_PASS(_, nir, nir_propagate_invariant, false); NIR_PASS(_, nir, nir_lower_input_attachments, - &(nir_input_attachment_options) { - .use_fragcoord_sysval = true, - .use_layer_id_sysval = true, - }); + &(nir_input_attachment_options) { }); /* Reset sizes before gathering information */ nir->global_mem_size = 0; diff --git a/src/intel/vulkan/anv_internal_kernels.c b/src/intel/vulkan/anv_internal_kernels.c index 4cb275edff4..f43eeeef864 100644 --- a/src/intel/vulkan/anv_internal_kernels.c +++ b/src/intel/vulkan/anv_internal_kernels.c @@ -104,10 +104,7 @@ compile_shader(struct anv_device *device, if (stage == MESA_SHADER_FRAGMENT) { NIR_PASS(_, nir, nir_lower_input_attachments, - &(nir_input_attachment_options) { - .use_fragcoord_sysval = true, - .use_layer_id_sysval = true, - }); + &(nir_input_attachment_options) { }); } else { nir_lower_compute_system_values_options options = { .has_base_workgroup_id = true, diff --git a/src/intel/vulkan/anv_shader_compile.c b/src/intel/vulkan/anv_shader_compile.c index f3bd6325316..ad8cf30ed59 100644 --- a/src/intel/vulkan/anv_shader_compile.c +++ b/src/intel/vulkan/anv_shader_compile.c @@ -1300,10 +1300,7 @@ anv_shader_lower_nir(struct anv_device *device, if (nir->info.stage == MESA_SHADER_FRAGMENT) { NIR_PASS(_, nir, nir_lower_wpos_center); NIR_PASS(_, nir, nir_lower_input_attachments, - &(nir_input_attachment_options) { - .use_fragcoord_sysval = true, - .use_layer_id_sysval = true, - }); + &(nir_input_attachment_options) { }); } if (nir->info.stage == MESA_SHADER_COMPUTE && diff --git a/src/intel/vulkan_hasvk/anv_pipeline.c b/src/intel/vulkan_hasvk/anv_pipeline.c index c983022f156..342535cd46a 100644 --- a/src/intel/vulkan_hasvk/anv_pipeline.c +++ b/src/intel/vulkan_hasvk/anv_pipeline.c @@ -477,10 +477,7 @@ anv_pipeline_lower_nir(struct anv_pipeline *pipeline, if (nir->info.stage == MESA_SHADER_FRAGMENT) { NIR_PASS(_, nir, nir_lower_wpos_center); NIR_PASS(_, nir, nir_lower_input_attachments, - &(nir_input_attachment_options) { - .use_fragcoord_sysval = true, - .use_layer_id_sysval = true, - }); + &(nir_input_attachment_options) { }); } NIR_PASS(_, nir, anv_nir_lower_ycbcr_textures, layout); diff --git a/src/kosmickrisp/compiler/nir_to_msl.c b/src/kosmickrisp/compiler/nir_to_msl.c index fc4e34a624a..752e2cf5b23 100644 --- a/src/kosmickrisp/compiler/nir_to_msl.c +++ b/src/kosmickrisp/compiler/nir_to_msl.c @@ -1910,10 +1910,7 @@ msl_preprocess_nir(struct nir_shader *nir) NIR_PASS(_, nir, nir_lower_system_values); if (nir->info.stage == MESA_SHADER_FRAGMENT) { - nir_input_attachment_options input_attachment_options = { - .use_fragcoord_sysval = true, - .use_layer_id_sysval = true, - }; + nir_input_attachment_options input_attachment_options = { }; NIR_PASS(_, nir, nir_lower_input_attachments, &input_attachment_options); /* KK_WORKAROUND_4 */ NIR_PASS(_, nir, nir_lower_is_helper_invocation); diff --git a/src/microsoft/spirv_to_dxil/dxil_spirv_nir.c b/src/microsoft/spirv_to_dxil/dxil_spirv_nir.c index 6478041c319..00866108c5f 100644 --- a/src/microsoft/spirv_to_dxil/dxil_spirv_nir.c +++ b/src/microsoft/spirv_to_dxil/dxil_spirv_nir.c @@ -967,8 +967,6 @@ dxil_spirv_nir_passes(nir_shader *nir, if (nir->info.stage == MESA_SHADER_FRAGMENT) { NIR_PASS(_, nir, nir_lower_input_attachments, &(nir_input_attachment_options){ - .use_fragcoord_sysval = true, - .use_layer_id_sysval = true, .use_view_id_for_layer = !conf->lower_view_index, }); diff --git a/src/panfrost/vulkan/panvk_vX_nir_lower_descriptors.c b/src/panfrost/vulkan/panvk_vX_nir_lower_descriptors.c index 2b62633f02c..36f4be115ac 100644 --- a/src/panfrost/vulkan/panvk_vX_nir_lower_descriptors.c +++ b/src/panfrost/vulkan/panvk_vX_nir_lower_descriptors.c @@ -1094,10 +1094,7 @@ lower_input_attachment_loads(nir_shader *nir, &ia_load_ctx); /* Lower the remaining input attachment loads. */ - struct nir_input_attachment_options lower_input_attach_opts = { - .use_fragcoord_sysval = true, - .use_layer_id_sysval = true, - }; + struct nir_input_attachment_options lower_input_attach_opts = { }; NIR_PASS(progress, nir, nir_lower_input_attachments, &lower_input_attach_opts);