"""rdna2spirv.py --bary-fallback: raw barycentric reads without VK_KHR_fragment_shader_barycentric. The input is the GPU test runtime/test/shaders/ps_bary (hand-written, no game data; fixture from regen_fixtures.py). It reads the raw barycentric pair (v0 = i, v1 = j) next to v_interp. By default the translator gives the pair as BaryCoordKHR.y / .z. With --bary-fallback the same values come from an ordinary vec3 input at the lowest location no attribute uses; tools/bary_fallback_gs.py writes the pass-through geometry shader that fills it. On the GPU, run_gpu_tests.py / check.py with LEONIDA_BARY_FALLBACK=1 check ps_bary through that GS. Here: * the module declares neither the capability nor the extension nor the builtin, and the metadata names the input (the lowest free location, also for sparse attributes such as attr30 alone); * the shader reads i and j from the new input exactly as it reads them from BaryCoordKHR (one-lane interpreter); * a shader that doesn't read the pair translates to the same module with and without the flag; * the GS text has the vertex count, the one-hot weights and the locations the PS expects, and refuses a collision. """ import gc import json import math from pathlib import Path import os import re import shutil import struct import subprocess import sys import tempfile import unittest import warnings import support import rdna2spirv import bary_fallback_gs I, J = 0.3125, 0.4375 # exact in binary32, i + j < 1 ATTR0 = (0.75, 0.5, 0.0, 1.0) def f32_bits(x): return struct.unpack("