Skip to content

feat(freepvr-twin): add offline Volcanic 3D (VDM/PPP/ISP/PBE) and USC (UVSW/SMP/EMITPIX) validators (#4) - #16

Closed
saariuslystoned wants to merge 2 commits into
mainfrom
feat/4-freepvr-twin-3d-vdm-isp-pbe-usc
Closed

saariuslystoned wants to merge 2 commits into
mainfrom
feat/4-freepvr-twin-3d-vdm-isp-pbe-usc

Conversation

@saariuslystoned

Copy link
Copy Markdown
Contributor

Addresses #4 (offline G4.2 + G4.3 validation milestones in freepvr-twin: Volcanic 3D control stream validators for VDM/PPP/ISP/PBE, vertex/fragment USC encodings & sequencing validators for UVSW/SMP/EMITPIX, and G4.4 smoke fixtures).

Summary

  • Volcanic 3D control stream validators (freepvr-twin): validates VDM (PPP/PDS/INDEX_LIST/TERMINATE, alignment, topology, zero-count, truncation), PPP (word counts, region-clip bounds, Rogue-bit rejection), ISP (ISP_CTL, ISP_AA/TE_AA), and PBE (non-zero VA, Rogue shift2 rejection, format, clip bounds, tile OOB), exposed via freecs-validate --kind 3d-job --input bundle.json.
  • Volcanic vertex/fragment USC ISA (freeusc_sim.py): adds clean-room encode/decode, execution, and static sequencing validators for UVSW (write-before-endtask, single endtask, write-after-endtask), SMP (descriptor/dst bounds, dmn/lodm), and EMITPIX (exact-once end-flag sequencing).
  • Offline G4.4 smoke fixtures & tests (fixtures.py, freepvr-twin/tests/test_g4_3d.py, tests/test_g4_3d_offline.py): clear color (0xFF3366CC), single colored triangle (0xFF00FF00 VS+FS), and textured quad (SMP+EMITPIX), runnable via freeusc-sim --fixture clear_color|tri_vertex|tri_fragment|textured_quad.

Verification

  • python3 -m unittest discover -s freepvr-twin/tests -v: 64/64 PASS
  • python3 -m unittest discover -s tests -v: 12/12 PASS
  • ./scripts/clean-room-audit.sh: PASS (0 violations, 67 files)
  • Existing CLI self-tests + new --kind 3d-job & --fixture checks + git diff --check: PASS

…PBE/USC validators

- _to_u32/_to_u64 strict type checks (reject string/float/non-list, non-integral floats)
- VDM/PPP ISP/PBE validators catch TypeError/OverflowError in addition to ValueError
- ISP AA negative-shift guard (0..3 range check before 1<<aa)
- ISP None/dict type guards, safe-int helper, MSP/ZLS dead-code removal
- PBE fb_width/height safe-int, VA-aware surface OOB check
- 3D bundle DCE qwords KeyError fix, geom/frag type guards, shader or-vs-None fix
- decode_stream FAIL-CLOSED (type/value validation, EOI scan, dword element checks)
- freecs _to_u helpers hardened for base validator reuse
- Adding test_g4_hardening regression suite (13 fail-closed cases)
@saariuslystoned

Copy link
Copy Markdown
Contributor Author

Adversarial Hardening & Public-Roads Audit Receipt (5c27a874)

  • Prior PR head: b1e6f78a → Hardened head: 5c27a874
  • Fixes landed (68 fuzz crashes → 0 crashes across 17.5k+ randomized VDM/PPP/ISP/PBE/bundle/USC + 14k mixed-type streams):
    • Surface OOB check (va + stride * height >= 2^48) replacing dead stride*(h/32) check
    • Fail-closed handling for malformed 3D bundles (DCE_MISSING_QWORDS, explicit None/type checks for ISP/PPP/geom/frag/HWRT/shader lists)
    • Hardened decode_stream (bytes/type/length guards returning USC_DECODE_ERROR) & freecs _to_u helpers + freepvr-twin/tests/test_g4_hardening.py
  • Verification: python3 -m unittest discover -s tests (12 OK), python3 -m unittest discover -s freepvr-twin/tests (77 OK), ./scripts/clean-room-audit.sh PASS (0 violations; private-term diff scan clean).

@saariuslystoned

Copy link
Copy Markdown
Contributor Author

Closing this PR after vetting against silicon-proven PowerVR Volcanic (DXT-48-1536) Stage G4 3D hardware behavior. Several bitfields and control-stream formats in this branch were pre-silicon guesses that contradict real hardware and would reject valid Volcanic descriptors:

  1. Synthetic 32-bit VDMCTRL stream (g3d.py): Volcanic DXT-48-1536 has no 32-bit VDMCTRL stream (0x00000000/0xC0000000); it uses 64-bit QWORD DCE streams (DCE_RESIDENT_DESC0/1, DCE_HANDLE_ENTRY, DCE_PPP_STATE_UPDATE, DCE_SHADER_STATE, DCE_DRAW, DCE_SCISSOR, DCE_STREAM_TERM), which freecs.py on main already validates via validate_dce_stream().
  2. Wrong PBE linestride field and alignment check (g3d.py, fixtures.py): Reads stride = (rw0 >> 39) & 0xFFFF from PBESTATE_REG_WORD0 and rejects non-4-aligned values. On Volcanic silicon, linestride = (pixels - 1) lives in PBESTATE_REG_WORD2[47:32], and (width - 1) is routinely odd (e.g. 255, 1343), so this validator rejects real linear render-target PBE descriptors.
  3. Mismatched SMP bitfield layout (freeusc_isa.py):
    • SMP_DST_BITS and SMP_COORD_BITS are swapped (((1,2),(0,16),...) is coord, ((1,0),(0,22),...) is dst).
    • SMP_DMN_BITS (((0,23),(1,25))) is actually lodm; dmn is ((1,22),(1,23)).
    • SMP_SBMODE_BITS (((0,13),(0,29))) is actually chan (0=1ch..3=4ch), while sb_mode is W2[20:18] (mislabeled lodm).
    • Missing fcnorm (W1[30]), int_coords (W1[27]), nncoords (W2[25]), proj (W2[14]), and pplod (W2[12]).
  4. Reversed PSB_RD dst bits (freeusc_isa.py): Upper 4 bits of PSBRD_DST_BITS are reversed (26,25,24,23 instead of silicon-verified 23,24,25,26).
  5. Truncated PSB_WR source slots & invalid fragment fixtures (freeusc_isa.py, fixtures.py): PSBWR_SRC0_BITS and PSBWR_SRC1_BITS are 9-bit instead of 10-bit (missing {2,3} and {1,5}), and the fragment fixtures omit mandatory CTRL.OLCHK (0x800101dc), use CTRL.LIMM bcc=4 instead of silicon-required bcc=1, and conflate fragment POUTWRITE (wr_mode=1) with EOT EMITPIX.FREEP (wr_mode=3).

Follow-up work for #4 will land a clean PR porting the exact silicon-verified Volcanic DCE/PBE/EMI/SMP/PSB_WR/PSB_RD encodings on top of current main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant