"""Prepared geometry keeps rendered output and readable temporal state exact.""" import os from pathlib import Path import random import struct import subprocess import tempfile import unittest ROOT = Path(__file__).resolve().parents[1] @unittest.skipUnless(os.environ.get('D4R_RUN_GPU_TESTS') == '1', 'opt-in GPU test') class PreparedWireGpuTests(unittest.TestCase): def test_prepared_matches_reference_with_poisoned_invalid_history(self): runner = os.environ['D4R_DUMP_RUNNER'] kernel = ROOT/'build/wine-nvcuda/generated'/(os.environ.get('D4R_GPU_ARCH', 'gfx1101')+'.hsaco') w,h,rw,rh=65,67,21,22 pitch,dp,mp,cp,idp=w*8+16,w*4+12,w*4+20,rw*8+16,rw*4+12 pixels=w*h rng=random.Random(746) rgba=lambda: struct.pack('<4e',rng.uniform(.05,1),rng.uniform(.05,1),rng.uniform(.05,1),.5) current=b''.join(b''.join(rgba() for _ in range(w))+b'\xa5'*16 for _ in range(h)) source=b''.join(struct.pack('<4e',.125,.125,.125,.75)*rw+b'\xa5'*16 for _ in range(rh)) previous=bytearray(b''.join(struct.pack('<4e',.125,.125,.125,.75)*w+b'\xa5'*16 for _ in range(h))) ages=bytes(rng.choice((0,3,4,15,16,255)) for _ in range(pixels)) previous_depth=bytearray(struct.pack('