blob: ff09c213305114d1b3cacc93fbaf787cf2b91996 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
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)
}
|