"""SHADER-562: a mesh shader's LDS array covers its constant ds offsets with the access's own element size. read2/write2 offset0/offset1 count elements: 4 bytes for _b32, 8 for _b64, x64 for st64 (`ds_const_extent`, as the compute path does since SHADER-309). The mesh loop counted every element as 8 bytes, so a 32 KiB mesh shader whose st64 b32 offsets stay inside its allocation still doubled its array to 64 KiB. The programs and the PSV0 part are written here; no game data. """ import os import struct import sys import unittest HERE = os.path.dirname(os.path.abspath(__file__)) if HERE not in sys.path: sys.path.insert(0, HERE) # python -I leaves the script's folder off sys.path import support # noqa: E402 (support puts tools/ on sys.path, honouring LEONIDA_TOOLS_DIR) rdna2spirv = support.rdna2spirv def mesh_dxbc(group_shared, threads=128): """DXBC with one PSV0 part: the fields mesh_psv() reads (stage 13, 64/64 triangles, NumThreads, shared bytes).""" r = bytearray(48) struct.pack_into("