<alyssa>
for buffer map purposes we're a non-blitting driver
rpirea has quit [Quit: rpirea]
rpirea has joined #asahi-gpu
amarioguy has joined #asahi-gpu
<alyssa>
i509vcb: ok your questions
<alyssa>
03:42 <i509vcb> Pixel Data Master (PDM) is the hardware which dispatches fragment shaders? (I'd think fragment since that sounds most similar to pixel)
<alyssa>
yes
<alyssa>
we assume
<alyssa>
powervr term
<alyssa>
04:13 <i509vcb> What specifically makes a pixel shader a pixel shader? A lot of sources I found seem to conflate fragment and pixel shaders
<alyssa>
It's a pixel shader if you use Direct3D and a fragment shader if you don't ;-)
<alyssa>
For AGX, I'm using slightly different definitions
<alyssa>
in APIs, you can have multiple samples per pixel (multisampling)
<alyssa>
and then you can either evaluate the fragment shader once per pixel (outputting the same colour to all samples) or once per sample (different colours per sample)
<alyssa>
that is, the fragment is either a pixel or a sample depending on whether (per-)sample shading is used
<alyssa>
(What controls whether the fragment shader is invokved for every sample? Depends on the API, lots of different reasons it might happen. Kind of an ugly point in GL/Vulkan.)
<alyssa>
Anyway, all other GPUs that I know of implement this in hardware
<alyssa>
You compile a fragment shader and then there's a bit in the command stream that controls whether the hw invokes it once per pixel or once per sample
<alyssa>
AGX does *not* work this way
<alyssa>
Instead, it *always* runs a pixel shader!
<alyssa>
How can that possibly implement sample shading, you ask? (And Metal does support sample shading)
<alyssa>
Well, the "store colour" instruction also takes a mask of samples that it should apply to
<alyssa>
If you pass all-1's then it'll act like a pixel shader
<alyssa>
but if you pass just a single bit set, then it'll write out just that one sample
<alyssa>
(the load colour, discard, emit depth/stencil instructions are similar)
<alyssa>
So, an API level fragment shader needs to get transformed into a AGX pixel shader
<alyssa>
If sample shading is NOT used, this is easy -- just set all the masks to "all samples" and it'll work regardless of the sample count
<alyssa>
If sample shading IS used, the compiler (or driver) has to build a pixel shader that loops over all the samples and executes the fragment shader once per sample
<alyssa>
This lets us run shaders partially per sample and partially per pixel
<alyssa>
If there are calculations that don't depend on the sample ID, only the pixel, then they can happen just once and get shared for all the samples
<alyssa>
and that doesn't require any special hardware, that happens automatically with standard compiler optimizations (either global code motion or loop unrolling with constant subexpression elimination)
<alyssa>
So this isn't just AGX being quirky, it's AGX being awesome :^)
rpirea has quit [Quit: rpirea]
nsklaus has quit [Quit: My Mac has gone to sleep. ZZZzzz…]