diff options
| author | Lucas Fryzek <lucas.fryzek@fryzekconcepts.com> | 2025-11-24 19:39:30 -0500 |
|---|---|---|
| committer | Lucas Fryzek <lucas.fryzek@fryzekconcepts.com> | 2025-11-24 19:39:30 -0500 |
| commit | b5f3587df4048d2ba807721ff2faea8c8a43a93f (patch) | |
| tree | 6913f730a41822b98fecd5e82b7cae46164fd9c0 /src/frygon/compiler/fgcc/api.rs | |
| parent | 41c700fdbf1d79dfb571105ee93bfa46da6c8428 (diff) | |
WIPfrygon
Diffstat (limited to 'src/frygon/compiler/fgcc/api.rs')
| -rw-r--r-- | src/frygon/compiler/fgcc/api.rs | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/src/frygon/compiler/fgcc/api.rs b/src/frygon/compiler/fgcc/api.rs new file mode 100644 index 00000000000..ff09c213305 --- /dev/null +++ b/src/frygon/compiler/fgcc/api.rs @@ -0,0 +1,108 @@ +// Copyright © 2025 Lucas Francisco Fryzek +// SPDX-License-Identifier: MIT + +use compiler::bindings::*; +use fgcc_bindings::*; + +fn nir_options(dev: &fg_device_info) -> nir_shader_compiler_options { + let mut op: nir_shader_compiler_options = Default::default(); + + op.lower_fdiv = true; + op.fuse_ffma16 = true; + op.fuse_ffma32 = true; + op.fuse_ffma64 = true; + op.lower_flrp16 = true; + op.lower_flrp32 = true; + op.lower_flrp64 = true; + op.lower_fsqrt = true; // TODO + op.lower_bitfield_extract = false; + op.lower_bitfield_extract8 = true; + op.lower_bitfield_extract16 = true; + op.lower_bitfield_insert = true; + op.lower_pack_half_2x16 = true; + op.lower_pack_unorm_2x16 = true; + op.lower_pack_snorm_2x16 = true; + op.lower_pack_unorm_4x8 = true; + op.lower_pack_snorm_4x8 = true; + op.lower_unpack_half_2x16 = true; + op.lower_unpack_unorm_2x16 = true; + op.lower_unpack_snorm_2x16 = true; + op.lower_unpack_unorm_4x8 = true; + op.lower_unpack_snorm_4x8 = true; + op.lower_insert_byte = true; + op.lower_insert_word = true; + op.lower_cs_local_index_to_id = true; + op.lower_device_index_to_zero = true; + op.lower_isign = true; + op.lower_uadd_sat = true; // TODO + op.lower_usub_sat = true; // TODO + op.lower_iadd_sat = true; // TODO + op.lower_doubles_options = nir_lower_drcp + | nir_lower_dsqrt + | nir_lower_drsq + | nir_lower_dtrunc + | nir_lower_dfloor + | nir_lower_dceil + | nir_lower_dfract + | nir_lower_dround_even + | nir_lower_dsat + | nir_lower_dminmax; + op.lower_int64_options = !(nir_lower_icmp64 + | nir_lower_iadd64 + | nir_lower_ineg64 + | nir_lower_shift64 + | nir_lower_imul_2x32_64 + | nir_lower_vote_ieq64 + | nir_lower_conv64) + | nir_lower_vote_ieq64 + | nir_lower_shift64; + op.lower_ldexp = true; + op.lower_fmod = true; + op.lower_ffract = true; + op.lower_fpow = true; + op.lower_scmp = true; + op.lower_uadd_carry = true; + op.lower_usub_borrow = true; + /* + op.has_iadd3 = dev.sm >= 70; + op.has_imad32 = dev.sm >= 70; + op.has_sdot_4x8 = dev.sm >= 70; + op.has_udot_4x8 = dev.sm >= 70; + op.has_sudot_4x8 = dev.sm >= 70; + */ + // We set .ftz on f32 by default so we can support fmulz whenever the client + // doesn't explicitly request denorms. + op.has_fmulz_no_denorms = true; + op.has_find_msb_rev = true; + op.has_pack_half_2x16_rtz = true; + //op.has_bfm = dev.sm >= 70; + op.discard_is_demote = true; + + op.max_unroll_iterations = 32; + op.scalarize_ddx = true; + + op +} + +#[no_mangle] +pub extern "C" fn fgcc_nir_options( + fgcc: *const fgcc_compiler, +) -> *const nir_shader_compiler_options { + assert!(!fgcc.is_null()); + let fgcc = unsafe { &*fgcc }; + &fgcc.nir_options +} + +#[no_mangle] +pub extern "C" fn fgcc_compiler_create( + dev: *const fg_device_info, +) -> *mut fgcc_compiler { + assert!(!dev.is_null()); + let dev = unsafe { &*dev }; + + let nak = Box::new(fgcc_compiler { + nir_options: nir_options(dev), + }); + + Box::into_raw(nak) +} |