From 2187436d0d34c5fc8cd9019a1608bfc6ab1a640f Mon Sep 17 00:00:00 2001 From: SamG-Coder <13449963+SamG-Coder@users.noreply.github.com> Date: Fri, 25 Sep 2026 07:10:15 +1000 Subject: [PATCH] feat(agc): expose legacy register defaults entry point --- .../libSceAgc/Misc/src/RegisterDefaults.cpp | 5 +++++ core/libs/tests/GuestShaderLink.cpp | 19 +++++++++++++++++++ docs/YAMAGI_QUAKE2.md | 18 ++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/core/libs/prx/libSceAgc/Misc/src/RegisterDefaults.cpp b/core/libs/prx/libSceAgc/Misc/src/RegisterDefaults.cpp index 4866a9186..820fb9a77 100644 --- a/core/libs/prx/libSceAgc/Misc/src/RegisterDefaults.cpp +++ b/core/libs/prx/libSceAgc/Misc/src/RegisterDefaults.cpp @@ -9,6 +9,11 @@ extern "C" { +void* APS5_VABI sceAgcGetRegisterDefaults() { + // The legacy API has no version argument; use the baseline public table. + return Agc::Command::GetRegisterDefaults(0, false, __func__); +} + void* APS5_VABI sceAgcGetRegisterDefaults2(std::uint32_t version) { return Agc::Command::GetRegisterDefaults(version, false, __func__); } diff --git a/core/libs/tests/GuestShaderLink.cpp b/core/libs/tests/GuestShaderLink.cpp index 17f32efc5..4163bb538 100644 --- a/core/libs/tests/GuestShaderLink.cpp +++ b/core/libs/tests/GuestShaderLink.cpp @@ -5,9 +5,28 @@ #include #include extern "C" int APS5_VABI sceAgcLinkShaders(ShaderRegister*, ShaderRegister*, const void*, const Shader*, const Shader*, std::uint32_t); +extern "C" void* APS5_VABI sceAgcGetRegisterDefaults(); +extern "C" void* APS5_VABI sceAgcGetRegisterDefaults2(std::uint32_t); static void Require(bool value) { if (!value) std::abort(); } int main() { using namespace ShaderRegs; + auto* defaults = static_cast(sceAgcGetRegisterDefaults()); + Require(defaults && defaults == sceAgcGetRegisterDefaults()); + Require(defaults == sceAgcGetRegisterDefaults2(0)); + // These are the byte offsets used by native callers, independent of the + // private C++ structure used to construct the defaults object. + ShaderRegister** contextBlocks = nullptr; + std::uint32_t contextCount = 0; + std::memcpy(&contextBlocks, defaults, sizeof(contextBlocks)); + std::memcpy(&contextCount, defaults + 0x20, sizeof(contextCount)); + Require(contextBlocks && contextBlocks[0] && contextCount == 523); + bool hasRenderTarget = false; + bool hasRasterizer = false; + for (std::uint32_t i = 0; i < contextCount; ++i) { + hasRenderTarget |= contextBlocks[0][i].offset == 0x318; + hasRasterizer |= contextBlocks[0][i].offset == 0x205; + } + Require(hasRenderTarget && hasRasterizer); ShaderSpecialRegs special{}; special.vgt_shader_stages_en = {VGT_SHADER_STAGES_EN, VGT_SHADER_STAGES_NGG_BIT}; special.vgt_gs_out_prim_type = {VGT_GS_OUT_PRIM_TYPE, 0}; diff --git a/docs/YAMAGI_QUAKE2.md b/docs/YAMAGI_QUAKE2.md index d30259ec1..6516b9272 100644 --- a/docs/YAMAGI_QUAKE2.md +++ b/docs/YAMAGI_QUAKE2.md @@ -448,3 +448,21 @@ The unchanged game resolves sceAgcLinkShaders and stops at `Wi82ArQtAwg` (`sceAgcGetRegisterDefaults`). The project already has a versioned defaults implementation; the legacy entry point still needs its contract verified. Guest entry-point execution and rendered output remain unverified. + +## Follow-up: legacy register-defaults entry point + +Added the no-argument sceAgcGetRegisterDefaults export using the existing +baseline public table. The legacy caller reads its context-block pointer at +offset 0 and its context-record count at offset 0x20; tests now exercise that +layout directly, scan all 523 context records, check render-target/rasterizer +register presence, and verify stable pointers across calls. + +Selecting public version zero is a compatibility assumption based on the legacy +API lacking a version parameter; it has not been compared with a captured +console response. Versioned APIs remain available. All twenty-five tests pass. + +The unchanged game now stops at `0MtUJ3BpGhE` +(`sceAgcDriverGetWaitRenderingPacketSizeInDwords`). The corresponding +sceAgcDriverWaitUntilSafeForRendering import is also absent. These need a real +command-packet and buffer-ownership implementation, not a zero-size/no-op shim. +Guest entry-point execution and rendered output are still unverified.