by spicyjpeg · 3y ago · 0 comments
This is actually implemented in a slightly funky way on the PS1. The DMA unit responsible for sending commands to the GPU allows for a display list to be built in memory as a linked list of variable-length packets, each of which can hold zero or more commands. What Sony's libraries do is essentially generating the ordering table as an array of 8192 empty packets linked to each other, then allowing actual command packets to be allocated elsewhere (typically using a simple bump allocator) and "spliced" into the link from one empty packet to the next one. The PS1's vertex transformation coprocessor, the GTE, also keeps track of the Z coordinates of the last 4 vertices processed and has an instruction to quickly average them out so that the resulting value can be used as an index into the ordering table.
I wrote a few SDK-less bare metal C examples showing how to build an ordering table [1] and leverage it for 3D polygon sorting [2], should anybody want to check those out.
[1] https://github.com/spicyjpeg/ps1-bare-metal/blob/main/src/07...
[2] https://github.com/spicyjpeg/ps1-bare-metal/blob/main/src/08...
I'm guessing this explains the PSX-specific artefacts you would see when rotated triangles would "clip" into each other at the seams of models. The ordering would just come from the average Z coord of the plane.
[1] https://en.wikipedia.org/wiki/Texture_mapping#Affine_texture...
Maybe the coordinate values passed from GTE to GPU are "shadowed" with extra data about the transformation, that is then retrieved further down the pipeline
I suppose there could be multiple approaches
This isn't an easy problem to solve. I can't think of a way you could back figure the Z from the rendered data. The only other solution I can think of is to somehow break the models up into smaller polys as they are loaded into memory. If you break them up the individual triangles will be smaller and the lack of perspective won't show.