gpu: add clean-room AMD RDNA2 (XS2 / GFX10.3) disassembler and HLSL/DXBC shader lifter #51

Open
github-bot wants to merge 1 commit from github-bot/gh-51 into main AGit
Owner

@⁠ma30ih on GitHub · 2026-11-24 22:49 UTC · original
ma30ih:feat/rdna2-xs2-shader-lifter → main · +2975 −40 · 12 files · 1 commits · open

Summary

Adds a clean-room AMD RDNA2 (GFX10.3) XS2 container parser, instruction decoder/disassembler, control-flow graph builder, and HLSL-to-DXBC shader lifter under scarlettx::gpu, wiring XS2\0 shader translation into TranslateXboxShaderToPc and d3d12_xs PSO creation.

Changes

  • RDNA2 XS2 Decoder & Lifter (include/scarlettx/gpu/rdna2_xs2.h, src/gpu/rdna2_xs2.cpp):
    • ParseXs2Container / BuildXs2Container supporting stages, wave modes (Wave32/Wave64), SGPR/VGPR counts, compute [numthreads], and CBV/SRV/UAV/vertex input bindings.
    • GFX10.3 32-bit/64-bit decoder & disassembler covering SOP2, SOP1, SOPK, SOPC, SOPP, VOP2, VOP1, VOPC, VOP3, SMEM, MUBUF, FLAT, and EXP (with 32-bit inline literals and modifiers).
    • Basic-block CFG reconstruction (BuildRdna2Cfg) and structured HLSL emission (LiftXs2ToHlsl / LiftXs2ToDxbc via CompileHlslToDxbc to SM 5.0 / 5.1).
  • Shader IR & d3d12_xs Integration (include/scarlettx/gpu/shader_ir.h, src/gpu/shader_ir.cpp, src/shims/d3d12_xs_shim.cpp):
    • Replaced StatusCode::UnsupportedFormat for XS2\0 in TranslateXboxShaderToPc with LiftXs2ToDxbc, and populated disassembly_summary / lifted_hlsl metadata.
    • Updated ProxyCreateGraphicsPipelineState and ProxyCreateComputePipelineState to lift XS2\0 shaders before creating host ID3D12PipelineState objects.
  • Tests & Status (tests/test_rdna2_xs2.cpp, tests/test_shader_pipeline.cpp, tools/generate_status.py, CMakeLists.txt):
    • Added test_rdna2_xs2 verifying GFX10.3 decoding/disassembly, multi-block CFG branching (S_CBRANCH_SCC1, S_BRANCH, V_CNDMASK_B32), and live D3D12 WARP Compute & Graphics execution.
    • Updated test_shader_pipeline for real XS2\0 lifting and truncated-header error handling, and regenerated status reports (RDNA2 XS2 Shader Lifting: 8 of 16 / 50%).

Verification

  • cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release && cmake --build build (MSVC 19.51 x64): 0 errors, 0 warnings.
  • ctest --test-dir build --output-on-failure: 27/27 passed (100%).
**@⁠ma30ih** on GitHub · 2026-11-24 22:49 UTC · [original](https://github.com/Freminet/ScarlettX/pull/51) `ma30ih:feat/rdna2-xs2-shader-lifter` → `main` · +2975 −40 · 12 files · 1 commits · open ### Summary Adds a clean-room AMD RDNA2 (GFX10.3) `XS2` container parser, instruction decoder/disassembler, control-flow graph builder, and HLSL-to-DXBC shader lifter under `scarlettx::gpu`, wiring `XS2\0` shader translation into `TranslateXboxShaderToPc` and `d3d12_xs` PSO creation. ### Changes - **RDNA2 `XS2` Decoder & Lifter (`include/scarlettx/gpu/rdna2_xs2.h`, `src/gpu/rdna2_xs2.cpp`)**: - `ParseXs2Container` / `BuildXs2Container` supporting stages, wave modes (`Wave32`/`Wave64`), SGPR/VGPR counts, compute `[numthreads]`, and CBV/SRV/UAV/vertex input bindings. - GFX10.3 32-bit/64-bit decoder & disassembler covering `SOP2`, `SOP1`, `SOPK`, `SOPC`, `SOPP`, `VOP2`, `VOP1`, `VOPC`, `VOP3`, `SMEM`, `MUBUF`, `FLAT`, and `EXP` (with 32-bit inline literals and modifiers). - Basic-block CFG reconstruction (`BuildRdna2Cfg`) and structured HLSL emission (`LiftXs2ToHlsl` / `LiftXs2ToDxbc` via `CompileHlslToDxbc` to SM 5.0 / 5.1). - **Shader IR & `d3d12_xs` Integration (`include/scarlettx/gpu/shader_ir.h`, `src/gpu/shader_ir.cpp`, `src/shims/d3d12_xs_shim.cpp`)**: - Replaced `StatusCode::UnsupportedFormat` for `XS2\0` in `TranslateXboxShaderToPc` with `LiftXs2ToDxbc`, and populated `disassembly_summary` / `lifted_hlsl` metadata. - Updated `ProxyCreateGraphicsPipelineState` and `ProxyCreateComputePipelineState` to lift `XS2\0` shaders before creating host `ID3D12PipelineState` objects. - **Tests & Status (`tests/test_rdna2_xs2.cpp`, `tests/test_shader_pipeline.cpp`, `tools/generate_status.py`, `CMakeLists.txt`)**: - Added `test_rdna2_xs2` verifying GFX10.3 decoding/disassembly, multi-block CFG branching (`S_CBRANCH_SCC1`, `S_BRANCH`, `V_CNDMASK_B32`), and live D3D12 WARP Compute & Graphics execution. - Updated `test_shader_pipeline` for real `XS2\0` lifting and truncated-header error handling, and regenerated status reports (`RDNA2 XS2 Shader Lifting`: `8 of 16` / `50%`). ### Verification - `cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release && cmake --build build` (MSVC 19.51 x64): 0 errors, 0 warnings. - `ctest --test-dir build --output-on-failure`: **27/27 passed** (`100%`).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 19:57:03 +00:00
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/51/head:github-bot/gh-51'
git switch 'github-bot/gh-51'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-51'
git switch 'github-bot/gh-51'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-51'
git switch 'github-bot/gh-51'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-51'
git switch 'main'
git merge --squash 'github-bot/gh-51'
git switch 'main'
git merge --ff-only 'github-bot/gh-51'
git switch 'main'
git merge 'github-bot/gh-51'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.