ChanServ changed the topic of #panfrost to: Panfrost - FLOSS Mali Midgard & Bifrost - Logs https://oftc.irclog.whitequark.org/panfrost - <macc24> i have been here before it was popular
camus has quit [Remote host closed the connection]
camus has joined #panfrost
atler is now known as Guest853
atler has joined #panfrost
wwilly has quit [Ping timeout: 480 seconds]
Guest853 has quit [Ping timeout: 480 seconds]
br has quit []
br has joined #panfrost
thecycoone has quit []
thecycoone has joined #panfrost
davidlt_ has joined #panfrost
davidlt_ has quit [Ping timeout: 480 seconds]
Danct12 has quit [Quit: Quitting]
Danct12 has joined #panfrost
wwilly has joined #panfrost
wwilly has quit [Remote host closed the connection]
camus1 has joined #panfrost
davidlt_ has joined #panfrost
camus has quit [Remote host closed the connection]
<alyssa>
macc24: A page from ~the~ my architecture specification for Valhall.
<macc24>
huh
<alyssa>
(It turns out writing docs is an excellent way to procrastinate on writing code!)
<macc24>
bbl
<alyssa>
I jest.
<alyssa>
If a shader uses a constant value (e.g. `gl_FragColor = foo + 0.2345`), there are 3 possible ways that constant can be encoded in Valhall:
<alyssa>
* Embedded in the command stream directly. This only works for addition. Otherwise you waste an instruction adding 0.
<alyssa>
* Promoted to a uniform and then accessed as a uniform. This is 'free' except uniforms are limited, and this competes with the encoding used by actual uniforms.
<alyssa>
* As a lookup into a fixed table of "common" constants. This is completely free, with the caveat that it only works for a small number of very special values... not that Arm tells us which they are!
<alyssa>
Rather than trying to guess constants and see how the Arm compiler handles them, I wrote a program to dump the lookup table from the hardware itself.
<HdkR>
Nice!
<alyssa>
It's, uh, not pretty. But I started writing an assembler for Valhall, and this was an easy use ... bash script to generate programs that add zero to a given index into the LUT and store them to memory mapped by an OpenCL program, assemble those with my assembler, push it to the device of adb, replace the shader in vivo with panwrap LD_PRELOAD'd, and dump the resulting OpenCL memory to get the value.
<alyssa>
Doing that gave me the 32 special values that are hardcoded into Valhall's silicon, which are in the "Value" column of the linked PDF.
<alyssa>
But it's not enough to know _what_ the values are, we should also understand _why_ these values were picked.
<alyssa>
We can't /know/ what Arm's hardware engineers were thinking, but we can make very firm guesses. So the last column of the table are my interpretations of the values.
<HdkR>
All the integer ones are easy. Scale by N different ways
<alyssa>
Yep.
<alyssa>
Nothing here is terribly surprising :)
<alyssa>
So I took all the data I dumped and stored it as XML with description attributes on the elements*
<robclark>
adreno has a similar thing for encoding float immeds in instructions (or rather, the groups of instructions which can encode immeds).. I call it "FLUT".. I assume they (and arm) just collected a bunch of shaders of useful games/benchmarks and did some scripting to figure out which values show up more frequently
<HdkR>
Loads of people must be multiplying by 0.1 :D
<robclark>
(int immeds you can just directly encode, assuming they fit in the # of bits avail)
<alyssa>
So then all the tooling I'm building up (assembler, disassembler, compiler encoding, and documentation generator) can get access to everything and nothing goes out of sync.
<alyssa>
* the XMPP people are rubbing off
<alyssa>
robclark: Yeah, presumably. Curious thing here is that Valhall doesn't let int immeds be encoded directly, which is why rows 5-15 are "needed" even though it's silly.
<alyssa>
Apple represents the other extreme -- there is no LUT. Instead you only have 8-bit ints for your immediates ... with the twist that floating-point instructions interpret the int as a 3:5 minifloat :-)