A texture's handle may come from memory too. One game's material programs take each texture's from a table of
materials in a storage buffer: an LDG.E.64 at a record that the draw's constant buffers pick (in one program
c[0][0x520] + ((c[4][0x88] & 0xfffff) + c[5][0x2ec]) * 32 + 0x18, with a SEL on an ISETP of the index's top
bits), then R2UR into the uniform register pair of a TEX, TLD, TLD4, TXD or TXQ whose handle is in a
uniform register (0xf60, 0xf66, 0xf63, 0xf6c, 0xf6f: the texture's word, then the sampler's index, the word >> 20),
or into a TEX.B's handle register. The translator refused these programs: about 320 draws a frame of the first 3D
scene, which was then a white screen. It now keeps the instructions that make each such handle in ShaderInfo.memh,
where every value they read is the draw's (constant buffer words, immediates, and words loaded from addresses made
of them), and
the slot names the value that is the handle (SNX_TEX_MEMORY, SH_PROBE in shader.h): a register as one of those
instructions leaves it. Each value one of them reads has one unguarded writer before it on every path, and no other
kept instruction between the two writes it, so the list run in program order gives what the program computes. The
renderer runs it on the CPU for each draw (sm86_eval in gpu/shader/sm86_eval.c, the translation's arithmetic,
which a test checks against the translated program), on the draw's constant buffers and guest memory, a pending write
there landed first, and binds the handle as a constant buffer's (memh_handle in vk/render.c, vk_memory_handles
for dispatches). As with gbuf_pointer, a word the GPU writes later in the stream than the draw is recorded is read
as it was then: the material tables are the CPU's, but a table a program wrote in the same frame would give the
older handles. A handle whose address differs from invocation to invocation (one game's lights and decals: a cell of
a grid in world space, then the cell's list, in a loop) is bound as no texture, which samples zeros
(SH_PROBE_NONE), and the log names the program once: the draw goes on without it. An array of the pool's textures
indexed on the GPU would sample them, but the renderer would have to make each texture such a handle can name, which
no draw tells it.
A program whose FADD, FMUL, FFMA or I2F has a directed rounding mode is translated through f64, which keeps the
rounding exact. Apple's GPUs have no shaderFloat64, and the runtime skipped each such program: one game's title
sequence drew black, and 10 of its compute programs never ran. g_spirv_translate.float64 is the device's capability
now, and the translator keeps those operations in f32, as rounds to nearest, where it is 0. A float scale of FMUL is a
power of two, so it stays exact.
snx-shaderc DIR --sm86 --no-doubles --out DIR translates a recorded compute program again, as a device without
doubles has it, and without the game (--sm86 needs no header, which a compute program has none of). Of one game's 14
compute programs, 10 make a pipeline on KosmicKrisp and 4, its largest (1 MB of SPIR-V and more), do not: the Metal
compiler service ends with an XPC error after Mesa's own retries, about 30 s each, and the game lost 220 s of presents
before it ran again. MoltenVK makes all 14. The modules pass spirv-val, and the validation layer says nothing of
them, so the programs are not in doubt: a compiler service that crashes on one of them is the driver's, and the
largest are the ones it cannot take.
A program that still holds f64, which the runtime no longer emits on such a device, fails sooner and says why: Mesa's
Metal backend prints itself into the module as t192 = ALU u2f64 and the Metal compiler rejects the text, so
KosmicKrisp has no conversion to a double at all. The game shows its title menu on either driver, after the stall on
KosmicKrisp, and vulkan_driver=moltenvk skips the stall.
Made from docs/platforms/nx/ounce.md at 69237645142c. GPL-3.0-or-later.