#asahi-gpu · 2021-04-16 22:45
bloomthat it is..#asahi-gpu · 2021-04-16 21:49
glibcprecise sin is expensive, there's no getting around that (either instruction, or LUT)#asahi-gpu · 2021-04-16 21:27
bloomdefault in Metal is fast::sin(x) which is super cheap#asahi-gpu · 2021-04-16 21:27
chrisfouch#asahi-gpu · 2021-04-16 21:19
bloom(~90 instructions)#asahi-gpu · 2021-04-16 21:18
bloomThe assembly prduced for precise::sin(x) is horrifying#asahi-gpu · 2021-04-16 20:13
bloom(was trying to find out if there's an xchg/swap instruction)#asahi-gpu · 2021-04-16 20:12
bloomDunno if that's deliberate.#asahi-gpu · 2021-04-16 20:12
bloomnote: Metal compiler likes bitop_mov more than xor#asahi-gpu · 2021-04-16 19:57
bloomalso, modifiers are unsupported (both float and int mods)#asahi-gpu · 2021-04-16 19:57
bloomto change sizes, iadd/fadd are used.#asahi-gpu · 2021-04-16 19:57
bloomnote to self: `convert` is only for data type converts#asahi-gpu · 2021-04-16 19:39
bloomInteresting... Metal implements unary fneg/fabs with bitop (twiddling the sign bit) instead of fadd.#asahi-gpu · 2021-04-16 03:58
dougallyeah, that sounds much better :) g'night!#asahi-gpu · 2021-04-16 03:57
bloomwill test tomorrow 😴#asahi-gpu · 2021-04-16 03:56
bloom" wrote a proper C encoder#asahi-gpu · 2021-04-16 03:56
bloomdougall: "# okay, this is very lazy#asahi-gpu · 2021-04-16 03:09
bloomso now all the known float ops are handled#asahi-gpu · 2021-04-16 03:09
bloomand implemented in the compiler :)#asahi-gpu · 2021-04-16 00:43
bloom:)#asahi-gpu · 2021-04-16 00:18
dougallbloom: great solve! that all properly makes sense now :)#asahi-gpu · 2021-04-15 21:50
bloomsimilarly interesting patterns with depth/stencil writeouts, et#asahi-gpu · 2021-04-15 21:50
bloomand if you look at how MRT writeout works you can see a pair of bits moving along in those unk48 ("writeout" in dougall's)#asahi-gpu · 2021-04-15 21:49
bloomI *suspect* that controls some detail of the tilebuffer#asahi-gpu · 2021-04-15 21:49
bloomyep..#asahi-gpu · 2021-04-15 21:43
glibcwith early-z, no alpha-to-coverage or other weird features#asahi-gpu · 2021-04-15 21:42
glibcthat appears even in empty fragment shaders#asahi-gpu · 2021-04-15 21:42
glibc# 48 00 C2 00 -unk48 h0, 2l, u0l.neg#asahi-gpu · 2021-04-15 18:21
bloom(Up to constants, sin_pt_2 is the "sinc" function.)#asahi-gpu · 2021-04-15 18:18
bloomAnd that's how AGX computes sine and cosine!#asahi-gpu · 2021-04-15 18:17
bloom(This requires the value to be finite, since Inf * 0 and NaN * 0 are both NaN under standard IEEE 754 rules.)#asahi-gpu · 2021-04-15 18:16
bloom(Is sin_pt_2(0) undefined? Maybe, maybe not. It doesn't matter, as long as it's value satisfies sin_pt_2(0) * 0 = 0 since sin(0) = 0.)#asahi-gpu · 2021-04-15 18:15
bloomsin_pt_2(x) = sin((pi/2) * |x|) / |x|#asahi-gpu · 2021-04-15 18:15
bloomAs well as:#asahi-gpu · 2021-04-15 18:15
bloom{ fract(x) - 1 if 3 <= x < 4#asahi-gpu · 2021-04-15 18:15
bloom{ - fract(x) if 2 <= x < 3#asahi-gpu · 2021-04-15 18:15
bloom{ 1 - fract(x) if 1 <= x < 2#asahi-gpu · 2021-04-15 18:14
bloom{ fract(x) if 0 <= x < 1#asahi-gpu · 2021-04-15 18:14
bloomsin_pt_1(x) =#asahi-gpu · 2021-04-15 18:14
bloomOr more clearly:#asahi-gpu · 2021-04-15 18:14
bloom{ x - 4 if 3 <= x < 4#asahi-gpu · 2021-04-15 18:14
bloom{ 2 - x if 2 <= x < 3#asahi-gpu · 2021-04-15 18:14
bloom{ 2 - x if 1 <= x < 2#asahi-gpu · 2021-04-15 18:13
bloom{ x if 0 <= x < 1#asahi-gpu · 2021-04-15 18:13
bloomsin_pt_1(x) =#asahi-gpu · 2021-04-15 18:13
bloomsin_pt_1 : [0, 4] -> [-1, 1], sin_pt_2 : [-1, 1] -> R#asahi-gpu · 2021-04-15 18:12
bloomPutting it together, we get definitions:#asahi-gpu · 2021-04-15 18:12
bloomThe last detail I glossed is the units. sin_pt_2 wants its angle as [-1, 1] but sin_pt_1 takes in a rotation [0, 4]. This doesn't affect any of the math, but it means the constants work out to nice integers.#asahi-gpu · 2021-04-15 18:11
bloomLikewise for the fourth quadrant, where we both complement and flip the sign.#asahi-gpu · 2021-04-15 18:11
bloomFor xin the second quadrant, recall sin(x + pi/2) = cos(x) = sin(pi/2 - x). So rather than flip the sign, we take the arithmetic complement.