"""tools/ps_oracle.py: the msgpack subset, the PAL ELF rewrite that puts new pixel-shader code in a pipeline binary, the binary file format, and (with LEONIDA_PS_ORACLE_BUILD set to a runtime build and an AMD GPU selected) a real draw with patched code. Standard library only.""" import contextlib import io import os import struct import sys import tempfile import unittest from unittest.mock import patch ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.insert(0, os.path.join(ROOT, "tools")) import ps_oracle as P # noqa: E402 S_ENDPGM = struct.pack(" 41 VGPRs, rounded to the wave64 granule 4 rsrc1 = struct.unpack_from("