From 540d556a8f43dcf95afd0007fe24f5cec5cbea0e Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Mon, 6 Feb 2023 10:49:52 -0500 Subject: [PATCH] pan/bi: Allow specializing bifrost_nir_options by arch We need different settings for Bifrost and Valhall. Keeping everything static simplifies lifetimes. Signed-off-by: Alyssa Rosenzweig Reviewed-by: Boris Brezillon Part-of: --- src/panfrost/compiler/bifrost_compile.h | 124 ++++++++++++------------ src/panfrost/lib/pan_shader.c | 2 +- 2 files changed, 64 insertions(+), 62 deletions(-) diff --git a/src/panfrost/compiler/bifrost_compile.h b/src/panfrost/compiler/bifrost_compile.h index 58d265bf7f0..86f966fb540 100644 --- a/src/panfrost/compiler/bifrost_compile.h +++ b/src/panfrost/compiler/bifrost_compile.h @@ -33,67 +33,69 @@ void bifrost_compile_shader_nir(nir_shader *nir, struct util_dynarray *binary, struct pan_shader_info *info); -static const nir_shader_compiler_options bifrost_nir_options = { - .lower_scmp = true, - .lower_flrp16 = true, - .lower_flrp32 = true, - .lower_flrp64 = true, - .lower_ffract = true, - .lower_fmod = true, - .lower_fdiv = true, - .lower_isign = true, - .lower_find_lsb = true, - .lower_ifind_msb = true, - .lower_fdph = true, - .lower_fsqrt = true, +#define DEFINE_OPTIONS(arch) \ + static const nir_shader_compiler_options bifrost_nir_options_v##arch = { \ + .lower_scmp = true, \ + .lower_flrp16 = true, \ + .lower_flrp32 = true, \ + .lower_flrp64 = true, \ + .lower_ffract = true, \ + .lower_fmod = true, \ + .lower_fdiv = true, \ + .lower_isign = true, \ + .lower_find_lsb = true, \ + .lower_ifind_msb = true, \ + .lower_fdph = true, \ + .lower_fsqrt = true, \ + \ + .lower_fsign = true, \ + \ + .lower_bitfield_insert_to_shifts = true, \ + .lower_bitfield_extract_to_shifts = true, \ + .lower_insert_byte = true, \ + .lower_rotate = true, \ + \ + .lower_pack_half_2x16 = true, \ + .lower_pack_unorm_2x16 = true, \ + .lower_pack_snorm_2x16 = true, \ + .lower_pack_unorm_4x8 = true, \ + .lower_pack_snorm_4x8 = true, \ + .lower_unpack_half_2x16 = true, \ + .lower_unpack_unorm_2x16 = true, \ + .lower_unpack_snorm_2x16 = true, \ + .lower_unpack_unorm_4x8 = true, \ + .lower_unpack_snorm_4x8 = true, \ + .lower_pack_split = true, \ + \ + .lower_doubles_options = \ + nir_lower_dmod, /* TODO: Don't lower supported 64-bit operations */ \ + .lower_int64_options = ~0, /* TODO: Use IMULD on v7 */ \ + .lower_mul_high = true, \ + .lower_fisnormal = true, \ + .lower_uadd_carry = true, \ + .lower_usub_borrow = true, \ + \ + .has_fsub = true, \ + .has_isub = true, \ + .vectorize_io = true, \ + .vectorize_vec2_16bit = true, \ + .fuse_ffma16 = true, \ + .fuse_ffma32 = true, \ + .fuse_ffma64 = true, \ + .use_interpolated_input_intrinsics = true, \ + \ + .lower_uniforms_to_ubo = true, \ + \ + .has_cs_global_id = true, \ + .lower_cs_local_index_to_id = true, \ + .max_unroll_iterations = 32, \ + .force_indirect_unrolling = \ + (nir_var_shader_in | nir_var_shader_out | nir_var_function_temp), \ + .force_indirect_unrolling_sampler = true, \ + \ + .use_scoped_barrier = true, \ + }; - .lower_fsign = true, - - .lower_bitfield_insert_to_shifts = true, - .lower_bitfield_extract_to_shifts = true, - .lower_insert_byte = true, - .lower_rotate = true, - - .lower_pack_half_2x16 = true, - .lower_pack_unorm_2x16 = true, - .lower_pack_snorm_2x16 = true, - .lower_pack_unorm_4x8 = true, - .lower_pack_snorm_4x8 = true, - .lower_unpack_half_2x16 = true, - .lower_unpack_unorm_2x16 = true, - .lower_unpack_snorm_2x16 = true, - .lower_unpack_unorm_4x8 = true, - .lower_unpack_snorm_4x8 = true, - .lower_pack_split = true, - - .lower_doubles_options = nir_lower_dmod, - /* TODO: Don't lower supported 64-bit operations */ - .lower_int64_options = ~0, - /* TODO: Use IMULD on v7 */ - .lower_mul_high = true, - .lower_fisnormal = true, - .lower_uadd_carry = true, - .lower_usub_borrow = true, - - .has_fsub = true, - .has_isub = true, - .vectorize_io = true, - .vectorize_vec2_16bit = true, - .fuse_ffma16 = true, - .fuse_ffma32 = true, - .fuse_ffma64 = true, - .use_interpolated_input_intrinsics = true, - - .lower_uniforms_to_ubo = true, - - .has_cs_global_id = true, - .lower_cs_local_index_to_id = true, - .max_unroll_iterations = 32, - .force_indirect_unrolling = - (nir_var_shader_in | nir_var_shader_out | nir_var_function_temp), - .force_indirect_unrolling_sampler = true, - - .use_scoped_barrier = true, -}; +DEFINE_OPTIONS(6); #endif diff --git a/src/panfrost/lib/pan_shader.c b/src/panfrost/lib/pan_shader.c index 4386eddc598..1fe84913be7 100644 --- a/src/panfrost/lib/pan_shader.c +++ b/src/panfrost/lib/pan_shader.c @@ -36,7 +36,7 @@ const nir_shader_compiler_options * GENX(pan_shader_get_compiler_options)(void) { #if PAN_ARCH >= 6 - return &bifrost_nir_options; + return &bifrost_nir_options_v6; #else return &midgard_nir_options; #endif