1#[cfg(any(feature = "bc6h", feature = "bc7"))]
2use bytemuck::{Pod, Zeroable};
3
4#[cfg(feature = "bc6h")]
6#[cfg_attr(docsrs, doc(cfg(feature = "bc6h")))]
7#[derive(Copy, Clone, Debug, Eq, PartialEq, Pod, Zeroable)]
8#[repr(C)]
9pub struct BC6HSettings {
10 pub(crate) slow_mode: u32,
11 pub(crate) fast_mode: u32,
12 pub(crate) refine_iterations_1p: u32,
13 pub(crate) refine_iterations_2p: u32,
14 pub(crate) fast_skip_threshold: u32,
15}
16
17#[cfg(feature = "bc6h")]
18impl BC6HSettings {
19 pub const fn very_fast() -> Self {
21 Self {
22 slow_mode: false as _,
23 fast_mode: true as _,
24 fast_skip_threshold: 0,
25 refine_iterations_1p: 0,
26 refine_iterations_2p: 0,
27 }
28 }
29
30 pub const fn fast() -> Self {
32 Self {
33 slow_mode: false as _,
34 fast_mode: true as _,
35 fast_skip_threshold: 2,
36 refine_iterations_1p: 0,
37 refine_iterations_2p: 1,
38 }
39 }
40
41 pub const fn basic() -> Self {
43 Self {
44 slow_mode: false as _,
45 fast_mode: false as _,
46 fast_skip_threshold: 4,
47 refine_iterations_1p: 2,
48 refine_iterations_2p: 2,
49 }
50 }
51
52 pub const fn slow() -> Self {
54 Self {
55 slow_mode: true as _,
56 fast_mode: false as _,
57 fast_skip_threshold: 10,
58 refine_iterations_1p: 2,
59 refine_iterations_2p: 2,
60 }
61 }
62
63 pub const fn very_slow() -> Self {
65 Self {
66 slow_mode: true as _,
67 fast_mode: false as _,
68 fast_skip_threshold: 32,
69 refine_iterations_1p: 2,
70 refine_iterations_2p: 2,
71 }
72 }
73}
74
75#[cfg(feature = "bc7")]
76#[cfg_attr(docsrs, doc(cfg(feature = "bc7")))]
77#[derive(Copy, Clone, Debug, Eq, PartialEq, Pod, Zeroable)]
79#[repr(C)]
80pub struct BC7Settings {
81 pub(crate) refine_iterations: [u32; 8],
82 pub(crate) mode_selection: [u32; 4],
83 pub(crate) skip_mode2: u32,
84 pub(crate) fast_skip_threshold_mode1: u32,
85 pub(crate) fast_skip_threshold_mode3: u32,
86 pub(crate) fast_skip_threshold_mode7: u32,
87 pub(crate) mode45_channel0: u32,
88 pub(crate) refine_iterations_channel: u32,
89 pub(crate) channels: u32,
90}
91
92#[cfg(feature = "bc7")]
93#[cfg_attr(docsrs, doc(cfg(feature = "bc7")))]
94impl BC7Settings {
95 pub const fn opaque_ultra_fast() -> Self {
97 Self {
98 channels: 3,
99 mode_selection: [false as _, false as _, false as _, true as _],
100 skip_mode2: true as _,
101 fast_skip_threshold_mode1: 3,
102 fast_skip_threshold_mode3: 1,
103 fast_skip_threshold_mode7: 0,
104 mode45_channel0: 0,
105 refine_iterations_channel: 0,
106 refine_iterations: [2, 2, 2, 1, 2, 2, 1, 0],
107 }
108 }
109
110 pub const fn opaque_very_fast() -> Self {
112 Self {
113 channels: 3,
114 mode_selection: [false as _, true as _, false as _, true as _],
115 skip_mode2: true as _,
116 fast_skip_threshold_mode1: 3,
117 fast_skip_threshold_mode3: 1,
118 fast_skip_threshold_mode7: 0,
119 mode45_channel0: 0,
120 refine_iterations_channel: 0,
121 refine_iterations: [2, 2, 2, 1, 2, 2, 1, 0],
122 }
123 }
124
125 pub const fn opaque_fast() -> Self {
127 Self {
128 channels: 3,
129 mode_selection: [false as _, true as _, false as _, true as _],
130 skip_mode2: true as _,
131 fast_skip_threshold_mode1: 12,
132 fast_skip_threshold_mode3: 4,
133 fast_skip_threshold_mode7: 0,
134 mode45_channel0: 0,
135 refine_iterations_channel: 0,
136 refine_iterations: [2, 2, 2, 1, 2, 2, 2, 0],
137 }
138 }
139
140 pub const fn opaque_basic() -> Self {
142 Self {
143 channels: 3,
144 mode_selection: [true as _, true as _, true as _, true as _],
145 skip_mode2: true as _,
146 fast_skip_threshold_mode1: 12,
147 fast_skip_threshold_mode3: 8,
148 fast_skip_threshold_mode7: 0,
149 mode45_channel0: 0,
150 refine_iterations_channel: 2,
151 refine_iterations: [2, 2, 2, 2, 2, 2, 2, 0],
152 }
153 }
154
155 pub const fn opaque_slow() -> Self {
157 Self {
158 channels: 3,
159 mode_selection: [true as _, true as _, true as _, true as _],
160 skip_mode2: false as _,
161 fast_skip_threshold_mode1: 64,
162 fast_skip_threshold_mode3: 64,
163 fast_skip_threshold_mode7: 0,
164 mode45_channel0: 0,
165 refine_iterations_channel: 4,
166 refine_iterations: [4, 4, 4, 4, 4, 4, 4, 0],
167 }
168 }
169
170 pub const fn alpha_ultrafast() -> Self {
172 Self {
173 channels: 4,
174 mode_selection: [false as _, false as _, true as _, true as _],
175 skip_mode2: true as _,
176 fast_skip_threshold_mode1: 0,
177 fast_skip_threshold_mode3: 0,
178 fast_skip_threshold_mode7: 4,
179 mode45_channel0: 3,
180 refine_iterations_channel: 1,
181 refine_iterations: [2, 1, 2, 1, 1, 1, 2, 2],
182 }
183 }
184
185 pub const fn alpha_very_fast() -> Self {
187 Self {
188 channels: 4,
189 mode_selection: [false as _, true as _, true as _, true as _],
190 skip_mode2: true as _,
191 fast_skip_threshold_mode1: 0,
192 fast_skip_threshold_mode3: 0,
193 fast_skip_threshold_mode7: 4,
194 mode45_channel0: 3,
195 refine_iterations_channel: 2,
196 refine_iterations: [2, 1, 2, 1, 2, 2, 2, 2],
197 }
198 }
199
200 pub const fn alpha_fast() -> Self {
202 Self {
203 channels: 4,
204 mode_selection: [false as _, true as _, true as _, true as _],
205 skip_mode2: true as _,
206 fast_skip_threshold_mode1: 4,
207 fast_skip_threshold_mode3: 4,
208 fast_skip_threshold_mode7: 8,
209 mode45_channel0: 3,
210 refine_iterations_channel: 2,
211 refine_iterations: [2, 1, 2, 1, 2, 2, 2, 2],
212 }
213 }
214
215 pub const fn alpha_basic() -> Self {
217 Self {
218 channels: 4,
219 mode_selection: [true as _, true as _, true as _, true as _],
220 skip_mode2: true as _,
221 fast_skip_threshold_mode1: 12,
222 fast_skip_threshold_mode3: 8,
223 fast_skip_threshold_mode7: 8,
224 mode45_channel0: 0,
225 refine_iterations_channel: 2,
226 refine_iterations: [2, 2, 2, 2, 2, 2, 2, 2],
227 }
228 }
229
230 pub const fn alpha_slow() -> Self {
232 Self {
233 channels: 4,
234 mode_selection: [true as _, true as _, true as _, true as _],
235 skip_mode2: false as _,
236 fast_skip_threshold_mode1: 64,
237 fast_skip_threshold_mode3: 64,
238 fast_skip_threshold_mode7: 64,
239 mode45_channel0: 0,
240 refine_iterations_channel: 4,
241 refine_iterations: [4, 4, 4, 4, 4, 4, 4, 4],
242 }
243 }
244}