Files
mandy/tests/test_vertex_input_locations.py
ItsNotRexed 4c52ce27a6 Seven fixes from an outside contributor (sent as patches, applied without the author's name)
- rdna2spirv: declare each packed vertex input register once; a register whose elements disagree on the component
  type is refused (SHADER-644).
- runtime: a title's VirtualAlloc drops the console's MEM_GRAPHICS / MEM_TITLE type bits the host rejects (RT-217).
- runtime: XPersistentLocalStorageImpl is served from <overlay>\persistent with the package's 2048 MB quota
  (RT-219; layout from the public docs, not measured in a caller).
- runtime: G:\ names the package and T:\ a scratch folder in the overlay; paths under the configured folders and
  every path with no folders configured stay host paths (RT-218).
- winhttp_offline: header blocks and timeouts the host WinHTTP rejects are rejected the same way.
- cfg_structure.run: a limit of zero or less runs no blocks.
- shader_meta: an s_movk_i32 with a register operand and a float immediate beyond float32 are left unknown instead
  of raising.

Each comes with a test that fails on the old code. Conflicts with main resolved here (internal_dir() hides T:'s
folder; both file_system_test blocks kept).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 16:55:46 -05:00

44 lines
1.6 KiB
Python

"""Unit tests for rdna2spirv.vertex_input_locations (standard library only, no game data).
python -I tests/test_vertex_input_locations.py
SHADER-644: a packed vertex ISG1 signature declares xy and zw of one register as two elements. Each register must
become one Vulkan vertex input, or the SPIR-V declares %vin{reg} twice and fails spirv-val.
"""
import os
import sys
import unittest
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, os.path.join(ROOT, "tools"))
import rdna2spirv # noqa: E402
FLOAT, UINT = 3, 1
class VertexInputLocationsTest(unittest.TestCase):
def test_distinct_registers_keep_order(self):
sig = [(2, 0xF, 0, FLOAT), (0, 0x7, 0, FLOAT), (1, 0x3, 0, UINT)]
self.assertEqual(rdna2spirv.vertex_input_locations(sig), [(2, FLOAT), (0, FLOAT), (1, UINT)])
def test_packed_register_is_declared_once(self):
sig = [(0, 0x3, 0, FLOAT), (0, 0xC, 0, FLOAT), (1, 0xF, 0, FLOAT)]
self.assertEqual(rdna2spirv.vertex_input_locations(sig), [(0, FLOAT), (1, FLOAT)])
def test_three_elements_in_one_register(self):
sig = [(4, 0x1, 0, UINT), (4, 0x2, 0, UINT), (4, 0xC, 0, UINT)]
self.assertEqual(rdna2spirv.vertex_input_locations(sig), [(4, UINT)])
def test_mixed_component_types_in_one_register_are_rejected(self):
sig = [(0, 0x3, 0, FLOAT), (0, 0xC, 0, UINT)]
with self.assertRaises(rdna2spirv.Unsupported):
rdna2spirv.vertex_input_locations(sig)
def test_empty_signature(self):
self.assertEqual(rdna2spirv.vertex_input_locations([]), [])
if __name__ == "__main__":
unittest.main()