mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 09:18:37 +00:00
test(shader): collect half-precision fract cases in semantic CI
The semantic CI job discovers tests with unittest. Run the numerical fixture there and retain compiled shader validation in the tool-backed pytest job.
This commit is contained in:
@ -1,17 +1,16 @@
|
||||
"""Exact f16 Fract infinity word measured on gfx1036 (docs/design.md)."""
|
||||
from collections.abc import Callable
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from conftest import Shader, requires_tools
|
||||
from support import mrt0_words
|
||||
from support import mrt0_words, translate_lines
|
||||
|
||||
|
||||
@requires_tools
|
||||
def test_fract_f16_infinity(make_shader: Callable[[str, str], Shader]) -> None:
|
||||
fixture = Path(__file__).with_name("fixtures") / "ps_fract_f16_infinity.asm"
|
||||
shader = make_shader(fixture.read_text(encoding="ascii"), fixture.stem)
|
||||
spvasm = shader.translate()
|
||||
shader.validate(spvasm)
|
||||
for source, clamped in ((0x3E00, 0x3800), (0x7C00, 0), (0xFC00, 0)):
|
||||
words = mrt0_words(spvasm, push_constants=[source] + [0] * 31)
|
||||
assert words == [0x1357FE00, 0x2468FE00, 0x3F800000, 0x12340000 | clamped]
|
||||
class FractInfinityTests(unittest.TestCase):
|
||||
def test_fract_f16_infinity(self) -> None:
|
||||
fixture = Path(__file__).with_name("fixtures") / "ps_fract_f16_infinity.asm"
|
||||
module = translate_lines(fixture.stem, fixture.read_text(encoding="ascii").splitlines())
|
||||
|
||||
for source, clamped in ((0x3E00, 0x3800), (0x7C00, 0), (0xFC00, 0)):
|
||||
with self.subTest(source=hex(source)):
|
||||
words = mrt0_words(module, push_constants=[source] + [0] * 31)
|
||||
self.assertEqual(words, [0x1357FE00, 0x2468FE00, 0x3F800000, 0x12340000 | clamped])
|
||||
|
||||
@ -17,6 +17,7 @@ from conftest import EMPTY_DXBC, KNOWN_VAL_ISSUES, ROOT, SAMPLE_DXBC, make_dxbc,
|
||||
pytestmark = requires_tools
|
||||
|
||||
SAMPLES = sorted(glob.glob(os.path.join(ROOT, "runtime", "test", "shaders", "*.asm")))
|
||||
SAMPLES += sorted(glob.glob(os.path.join(ROOT, "tests", "semantic", "fixtures", "ps_*.asm")))
|
||||
|
||||
# One minimal pixel shader per instruction family listed in the "Supported" section of rdna2spirv.py's docstring.
|
||||
# Each body is wrapped in a program that exports its result so nothing is optimised away.
|
||||
@ -51,7 +52,7 @@ def program(body):
|
||||
|
||||
@pytest.mark.parametrize("path", SAMPLES, ids=[os.path.basename(p) for p in SAMPLES])
|
||||
def test_gpu_samples_translate_and_validate(path, make_shader):
|
||||
"""The hand-written GPU-harness samples must translate to SPIR-V that passes spirv-val."""
|
||||
"""The hand-written GPU-harness and semantic shader samples must translate to valid SPIR-V."""
|
||||
stem = os.path.splitext(os.path.basename(path))[0]
|
||||
name = stem if stem.startswith(("vs_", "ps_", "cs_", "gs_", "ms_")) else "ps_" + stem # the prefix selects the stage
|
||||
if name.startswith(("gs_", "ms_")) and stem not in SAMPLE_DXBC:
|
||||
|
||||
Reference in New Issue
Block a user