diff --git a/src/intel/compiler/elk/elk_compiler.c b/src/intel/compiler/elk/elk_compiler.c index a0c657bd4d7..d0e93efe5db 100644 --- a/src/intel/compiler/elk/elk_compiler.c +++ b/src/intel/compiler/elk/elk_compiler.c @@ -25,83 +25,11 @@ #include "elk_shader.h" #include "elk_eu.h" #include "elk_nir.h" +#include "elk_nir_options.h" #include "dev/intel_debug.h" #include "compiler/nir/nir.h" #include "util/u_debug.h" -#define COMMON_OPTIONS \ - .has_uclz = true, \ - .lower_fdiv = true, \ - .lower_scmp = true, \ - .lower_flrp16 = true, \ - .lower_fmod = true, \ - .lower_ufind_msb = true, \ - .lower_uadd_carry = true, \ - .lower_usub_borrow = true, \ - .lower_flrp64 = true, \ - .lower_fisnormal = true, \ - .lower_isign = true, \ - .lower_ldexp = true, \ - .lower_bitfield_extract = true, \ - .lower_bitfield_insert = true, \ - .lower_device_index_to_zero = true, \ - .vectorize_io = true, \ - .vectorize_tess_levels = true, \ - .use_interpolated_input_intrinsics = true, \ - .lower_insert_byte = true, \ - .lower_insert_word = true, \ - .vertex_id_zero_based = true, \ - .lower_base_vertex = true, \ - .support_16bit_alu = true, \ - .lower_uniforms_to_ubo = true - -#define COMMON_SCALAR_OPTIONS \ - .lower_to_scalar = true, \ - .lower_pack_half_2x16 = true, \ - .lower_pack_snorm_2x16 = true, \ - .lower_pack_snorm_4x8 = true, \ - .lower_pack_unorm_2x16 = true, \ - .lower_pack_unorm_4x8 = true, \ - .lower_unpack_half_2x16 = true, \ - .lower_unpack_snorm_2x16 = true, \ - .lower_unpack_snorm_4x8 = true, \ - .lower_unpack_unorm_2x16 = true, \ - .lower_unpack_unorm_4x8 = true, \ - .lower_hadd64 = true, \ - .avoid_ternary_with_two_constants = true, \ - .has_pack_32_4x8 = true, \ - .max_unroll_iterations = 32, \ - .force_indirect_unrolling = nir_var_function_temp, \ - .divergence_analysis_options = \ - (nir_divergence_single_patch_per_tcs_subgroup | \ - nir_divergence_single_patch_per_tes_subgroup | \ - nir_divergence_shader_record_ptr_uniform) - -const struct nir_shader_compiler_options elk_scalar_nir_options = { - COMMON_OPTIONS, - COMMON_SCALAR_OPTIONS, -}; - -const struct nir_shader_compiler_options elk_vector_nir_options = { - COMMON_OPTIONS, - - /* In the vec4 backend, our dpN instruction replicates its result to all the - * components of a vec4. We would like NIR to give us replicated fdot - * instructions because it can optimize better for us. - */ - .fdot_replicates = true, - - .lower_usub_sat = true, - .lower_pack_snorm_2x16 = true, - .lower_pack_unorm_2x16 = true, - .lower_unpack_snorm_2x16 = true, - .lower_unpack_unorm_2x16 = true, - .lower_extract_byte = true, - .lower_extract_word = true, - .intel_vec4 = true, - .max_unroll_iterations = 32, -}; - struct elk_compiler * elk_compiler_create(void *mem_ctx, const struct intel_device_info *devinfo) { diff --git a/src/intel/compiler/elk/elk_nir.h b/src/intel/compiler/elk/elk_nir.h index 6a9ecb4ba63..f621fdcda19 100644 --- a/src/intel/compiler/elk/elk_nir.h +++ b/src/intel/compiler/elk/elk_nir.h @@ -32,9 +32,6 @@ extern "C" { #endif -extern const struct nir_shader_compiler_options elk_scalar_nir_options; -extern const struct nir_shader_compiler_options elk_vector_nir_options; - int elk_type_size_vec4(const struct glsl_type *type, bool bindless); int elk_type_size_dvec4(const struct glsl_type *type, bool bindless); diff --git a/src/intel/compiler/elk/elk_nir_options.c b/src/intel/compiler/elk/elk_nir_options.c new file mode 100644 index 00000000000..2a07b9356c0 --- /dev/null +++ b/src/intel/compiler/elk/elk_nir_options.c @@ -0,0 +1,79 @@ +/* + * Copyright 2024 Intel Corporation + * SPDX-License-Identifier: MIT + */ + +#include "elk_nir_options.h" + +#define COMMON_OPTIONS \ + .has_uclz = true, \ + .lower_fdiv = true, \ + .lower_scmp = true, \ + .lower_flrp16 = true, \ + .lower_fmod = true, \ + .lower_ufind_msb = true, \ + .lower_uadd_carry = true, \ + .lower_usub_borrow = true, \ + .lower_flrp64 = true, \ + .lower_fisnormal = true, \ + .lower_isign = true, \ + .lower_ldexp = true, \ + .lower_bitfield_extract = true, \ + .lower_bitfield_insert = true, \ + .lower_device_index_to_zero = true, \ + .vectorize_io = true, \ + .vectorize_tess_levels = true, \ + .use_interpolated_input_intrinsics = true, \ + .lower_insert_byte = true, \ + .lower_insert_word = true, \ + .vertex_id_zero_based = true, \ + .lower_base_vertex = true, \ + .support_16bit_alu = true, \ + .lower_uniforms_to_ubo = true + +#define COMMON_SCALAR_OPTIONS \ + .lower_to_scalar = true, \ + .lower_pack_half_2x16 = true, \ + .lower_pack_snorm_2x16 = true, \ + .lower_pack_snorm_4x8 = true, \ + .lower_pack_unorm_2x16 = true, \ + .lower_pack_unorm_4x8 = true, \ + .lower_unpack_half_2x16 = true, \ + .lower_unpack_snorm_2x16 = true, \ + .lower_unpack_snorm_4x8 = true, \ + .lower_unpack_unorm_2x16 = true, \ + .lower_unpack_unorm_4x8 = true, \ + .lower_hadd64 = true, \ + .avoid_ternary_with_two_constants = true, \ + .has_pack_32_4x8 = true, \ + .max_unroll_iterations = 32, \ + .force_indirect_unrolling = nir_var_function_temp, \ + .divergence_analysis_options = \ + (nir_divergence_single_patch_per_tcs_subgroup | \ + nir_divergence_single_patch_per_tes_subgroup | \ + nir_divergence_shader_record_ptr_uniform) + +const struct nir_shader_compiler_options elk_scalar_nir_options = { + COMMON_OPTIONS, + COMMON_SCALAR_OPTIONS, +}; + +const struct nir_shader_compiler_options elk_vector_nir_options = { + COMMON_OPTIONS, + + /* In the vec4 backend, our dpN instruction replicates its result to all the + * components of a vec4. We would like NIR to give us replicated fdot + * instructions because it can optimize better for us. + */ + .fdot_replicates = true, + + .lower_usub_sat = true, + .lower_pack_snorm_2x16 = true, + .lower_pack_unorm_2x16 = true, + .lower_unpack_snorm_2x16 = true, + .lower_unpack_unorm_2x16 = true, + .lower_extract_byte = true, + .lower_extract_word = true, + .intel_vec4 = true, + .max_unroll_iterations = 32, +}; diff --git a/src/intel/compiler/elk/elk_nir_options.h b/src/intel/compiler/elk/elk_nir_options.h new file mode 100644 index 00000000000..99096498106 --- /dev/null +++ b/src/intel/compiler/elk/elk_nir_options.h @@ -0,0 +1,22 @@ +/* + * Copyright 2024 Intel Corporation + * SPDX-License-Identifier: MIT + */ + +#ifndef ELK_NIR_OPTIONS_H +#define ELK_NIR_OPTIONS_H + +#include "nir.h" + +#ifdef __cplusplus +extern "C" { +#endif + +extern const struct nir_shader_compiler_options elk_scalar_nir_options; +extern const struct nir_shader_compiler_options elk_vector_nir_options; + +#ifdef __cplusplus +} +#endif + +#endif /* ELK_NIR_OPTIONS_H */ diff --git a/src/intel/compiler/elk/meson.build b/src/intel/compiler/elk/meson.build index 1e3da937bbe..fe5ee365de4 100644 --- a/src/intel/compiler/elk/meson.build +++ b/src/intel/compiler/elk/meson.build @@ -88,6 +88,8 @@ libintel_compiler_elk_files = files( 'elk_nir_lower_alpha_to_coverage.c', 'elk_nir_lower_cs_intrinsics.c', 'elk_nir_lower_storage_image.c', + 'elk_nir_options.h', + 'elk_nir_options.c', 'elk_nir_private.h', 'elk_packed_float.c', 'elk_predicated_break.cpp',