#
✕ nick:bloom
#asahi-gpu · 2021-04-14 03:18
bloomwhich unblocks compiler work
#asahi-gpu · 2021-04-14 03:18
bloomGot a varying working in the cmdstream demo
#asahi-gpu · 2021-04-12 16:39
bloom:)
#asahi-gpu · 2021-04-12 03:56
bloomhave ld_var emitted but some cmdbuf work remains to use it in the demo..
#asahi-gpu · 2021-04-12 03:15
bloomthanks :)
#asahi-gpu · 2021-04-12 03:15
bloomld_vary is up next at which point I can start writing real shaders and implementing the heaps of ALU needed for anything interesting
#asahi-gpu · 2021-04-12 03:08
bloomnot bad seeing as I started writing the compiler yesterday :p
#asahi-gpu · 2021-04-12 03:08
bloomFirst shader compiled from GLSL with mesa running successfully on the hardware
#asahi-gpu · 2021-04-12 03:06
bloomYep, there it is.
#asahi-gpu · 2021-04-12 03:04
bloomofc I don't know the regalloc field for FS...
#asahi-gpu · 2021-04-12 03:02
bloomok, now it doesn't fault but there are crazy colours, guessing I screwd up the register alloc
#asahi-gpu · 2021-04-12 03:01
bloomok, stop/trap implemented
#asahi-gpu · 2021-04-12 02:58
bloomAlso, while obviously I can't enforce this, I kindly ask y'all not to make a splash about that before I can get around to blogging ;-P
#asahi-gpu · 2021-04-12 02:52
bloomGlaring problems include missing a stop instruction :-p
#asahi-gpu · 2021-04-12 02:52
bloomIt does not work. Down the debug hole.
#asahi-gpu · 2021-04-12 02:44
bloomdoing all that dev on linux, let's see if it works on macos too :-p
#asahi-gpu · 2021-04-12 02:42
bloomit's gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0), don't get too excited :p
#asahi-gpu · 2021-04-12 02:41
bloomI've just compiled my first shader (from GLSL down to AGX machine code) with Mesa :)
#asahi-gpu · 2021-04-12 02:34
bloomtbd
#asahi-gpu · 2021-04-12 02:26
bloomchrisf: still means a lot more recompiles if the app swaps things in the pipeline
#asahi-gpu · 2021-04-12 01:28
bloomApple has gone the other end... why? well, because they can - Metal requires all this info at pipeline create time anyway, so why not use it? /s
#asahi-gpu · 2021-04-12 01:28
blooma number of architectures are specificalluy designed to eliminate all shader variants in e.g. core OpenGL ES
#asahi-gpu · 2021-04-12 01:27
bloom("shader variants")
#asahi-gpu · 2021-04-12 01:27
bloomrather you have to wait until the app is actually drawing things and potentially have to recompile many times with different shader "keys" - combinations of "leaky" state
#asahi-gpu · 2021-04-12 01:26
bloomThat means you *can't* compile shaders up front,
#asahi-gpu · 2021-04-12 01:26
bloomlikewise the code of the fragment shader depends on the format of the framebuffer
#asahi-gpu · 2021-04-12 01:26
bloomThe code of the vertex shader depends on the format of the vertex attributes,
#asahi-gpu · 2021-04-12 01:24
bloomI am not ok with this
#asahi-gpu · 2021-04-12 01:24
bloomalso, I still can't get over the fact the shaders are keyed to formats
#asahi-gpu · 2021-04-12 01:20
bloomno clue on the extended fields, although IIRC you have a clever way to determine those that I don't :p
#asahi-gpu · 2021-04-12 01:20
bloomthanks!
#asahi-gpu · 2021-04-12 01:05
bloomPatches sent
#asahi-gpu · 2021-04-12 00:44
bloompatches incoming
#asahi-gpu · 2021-04-12 00:30
bloomdougall: https://gitlab.freedesktop.org/mesa/mesa/-/blob/master/src/panfrost/bifrost/bifrost_compile.c#L1471-1517 this was fun to write
#asahi-gpu · 2021-04-12 00:29
bloomThe lowering for Bifrost is super cute
#asahi-gpu · 2021-04-12 00:28
bloomI was secretly hoping there would be Taylor series involved
#asahi-gpu · 2021-04-12 00:28
bloomdougall: sure
#asahi-gpu · 2021-04-12 00:23
bloom(There's no magic for tan. It's just computing fsin and fcos and dividing them. Just looks funny due to aggressive scheduling.)
#asahi-gpu · 2021-04-12 00:21
bloom2. Using a compute shader test (I believe dougallj has a script for this), run each op in isolation and dump the results. Then plot them and see what happens.
#asahi-gpu · 2021-04-12 00:21
bloom1. Just call F and G sin_pt_1 and sin_pt_2 and call it a day. Who cares?
#asahi-gpu · 2021-04-12 00:21
bloomAt this point we have two options:
#asahi-gpu · 2021-04-12 00:20
bloomAll we're doing is a series of reductions to make G and F as simple as possible. Or rather, as small as possible -- they're probably lookup tables.
#asahi-gpu · 2021-04-12 00:19
bloomThe multiplication by four is just another change of units. Now the fraction is angle within a quadrant, and the integer part is the quadrant. This is natural enough given the quadrant (anti)symmetries we have with sin.
#asahi-gpu · 2021-04-12 00:18
bloomand somehow that equals sin?
#asahi-gpu · 2021-04-12 00:18
bloomand reading off, we see take that angle 0 <= x < 1 and calculate... G(F(4 * x)) * F(4 * x)
#asahi-gpu · 2021-04-12 00:17
bloomThere are special one-op instructions dparametrized as 0b1010 and 0b1110... call them F and G
#asahi-gpu · 2021-04-12 00:16
bloomThe last four instructions are where things get mysterious.
#asahi-gpu · 2021-04-12 00:16
bloomObservation 2: The next few instructions are the sequence floor/fsub. We immediately recognize this as the fract(...) function. This is again what we'd expect -- fsin/fcos are periodic, with period 2pi, which is now period 1 after the above change of units.
#asahi-gpu · 2021-04-12 00:15
bloomand for cos we just push forward by 90 degrees.
#asahi-gpu · 2021-04-12 00:15
bloomSo the first thing we do in either sin or cos is divide by tau to change from radians to "times around the circle"

plus ›