mirror of
https://github.com/libretro/parallel-dc.git
synced 2026-11-10 11:21:28 -10:00
The renderers used glm for one thing: the three transforms a frame is drawn with - guest coordinates to clip space, to the viewport, to the scissor rectangle. Each is a scale and then a move along each axis and never anything else, and they were built as 4x4 matrices by multiplying 4x4 matrices together. core/rend/xform.h, plain C89, keeps a transform as the six numbers that are not 0 or 1. Putting two together is three multiplications and three multiply-adds in place of sixty-four multiplications; a point goes through one with a multiply-add an axis. A shader still gets a 4x4 matrix, written out from the six. The Vulkan uniform and push constant structures hold plain arrays of the same size and layout. Same floats: the old class and the new were run side by side on 600,000 random frames - render to texture or not, any clip rectangle, screen size, scaling, depth scale - and every element of all three matrices, and a point and a size taken through each, came out the same. (That needed glm; tools/rend/xform_test.sh, which stays, checks the transforms against 4x4 matrices multiplied out in full.) Code: setting the three up is 324 instructions where it was 666, and measured on its own about thirteen times as fast (20 million set-ups: 1.16 s to 0.09 s). The six objects that used glm are 1458 instructions smaller together; the one that grew, the Vulkan drawer, grew by which of vulkan.hpp's exception constructors the compiler chose to emit, not by this. glm had also been bringing <cmath> into four files that did not ask for it; they do now. The live test passes on gl, glcore and vulkan, per-pixel renderers included.