From 473a4f8d1c5e7302a18e24949ffc8f3afae3d385 Mon Sep 17 00:00:00 2001 From: SamG-Coder <13449963+SamG-Coder@users.noreply.github.com> Date: Fri, 25 Sep 2026 07:22:06 +1000 Subject: [PATCH] fix(agc): preserve strict shader linkage failures --- .../prx/libSceAgc/Shader/src/LinkShaders.cpp | 9 ++------ core/libs/tests/GuestShaderLink.cpp | 6 +++++- docs/YAMAGI_QUAKE2.md | 21 +++++++++++++++++++ 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/core/libs/prx/libSceAgc/Shader/src/LinkShaders.cpp b/core/libs/prx/libSceAgc/Shader/src/LinkShaders.cpp index cac2bb956..8f0b7e266 100644 --- a/core/libs/prx/libSceAgc/Shader/src/LinkShaders.cpp +++ b/core/libs/prx/libSceAgc/Shader/src/LinkShaders.cpp @@ -3,7 +3,6 @@ #include "prx/libSceAgc/Shader/include/ShaderConstants.hpp" #include #include -#include extern "C" int APS5_VABI sceAgcCreatePrimState(ShaderRegister*, ShaderRegister*, const Shader*, const Shader*, std::uint32_t); extern "C" int APS5_VABI sceAgcCreateInterpolantMapping(ShaderRegister*, const Shader*, const Shader*); @@ -23,12 +22,8 @@ extern "C" int APS5_VABI sceAgcLinkShaders(ShaderRegister* context, ShaderRegist // and 32 interpolant registers. Publish only after both helpers succeed. std::array contextValues{}; std::array primitiveValues{}; - try { - sceAgcCreatePrimState(contextValues.data(), primitiveValues.data(), nullptr, vertex, primitiveType); - sceAgcCreateInterpolantMapping(contextValues.data() + 2, vertex, pixel); - } catch (const std::runtime_error&) { - return GRAPHICS5_ERROR_INVALID_SHADER_PROGRAM; - } + sceAgcCreatePrimState(contextValues.data(), primitiveValues.data(), nullptr, vertex, primitiveType); + sceAgcCreateInterpolantMapping(contextValues.data() + 2, vertex, pixel); std::copy(contextValues.begin(), contextValues.end(), context); std::copy(primitiveValues.begin(), primitiveValues.end(), primitive); return 0; diff --git a/core/libs/tests/GuestShaderLink.cpp b/core/libs/tests/GuestShaderLink.cpp index 4163bb538..5e8f3b31a 100644 --- a/core/libs/tests/GuestShaderLink.cpp +++ b/core/libs/tests/GuestShaderLink.cpp @@ -4,6 +4,7 @@ #include #include #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); @@ -58,7 +59,10 @@ int main() { Require(std::memcmp(primitive.data(), savedPrimitive.data(), sizeof(primitive)) == 0); pixel.num_input_semantics = 0; special.ge_cntl.offset = 0; - Require(sceAgcLinkShaders(context.data(), primitive.data(), nullptr, &vertex, &pixel, 4) == GRAPHICS5_ERROR_INVALID_SHADER_PROGRAM); + bool rejected = false; + try { sceAgcLinkShaders(context.data(), primitive.data(), nullptr, &vertex, &pixel, 4); } + catch (const std::runtime_error&) { rejected = true; } + Require(rejected); Require(std::memcmp(context.data(), savedContext.data(), sizeof(context)) == 0); special.ge_cntl.offset = GE_CNTL; Require(sceAgcLinkShaders(context.data(), primitive.data(), nullptr, &vertex, nullptr, 2) == 0); diff --git a/docs/YAMAGI_QUAKE2.md b/docs/YAMAGI_QUAKE2.md index 0563951e6..9e9173fd6 100644 --- a/docs/YAMAGI_QUAKE2.md +++ b/docs/YAMAGI_QUAKE2.md @@ -510,3 +510,24 @@ wait modes, and rendering a game frame remain unverified. The unchanged game now resolves both rendering-wait imports and stops at `Z4QosVuAsA0` (`pthread_once`). Guest entry-point execution has not yet occurred. + +## Follow-up: once initialization and architecture audit + +Implemented pthread_once with the guest 16-byte control layout, a SysV callback, +serialized initialization, and publication of initialized data to waiting callers. +Independent controls can initialize recursively; an initializer that unwinds with +a C++ exception resets its control for retry. Guest thread cancellation and fork +recovery are not implemented. Tests use host threads calling the guest ABI and do +not establish that guest pthread_create works. + +All twenty-eight CTest cases pass. The unchanged converted game now stops at +`NesIgTmfF0Q` (`bsearch`) with exit `0xc0000139`, before guest entry. + +The README architecture remains the target: native executable relinking and +in-process replacement system libraries. There is no replacement game engine or +game source in these additions. Windows compatibility tests do not establish +Linux compatibility or a successful game launch. Shader register layout and the +internal rendering-wait encoding still require actual game execution validation. +The shader-link wrapper now propagates unsupported-state runtime exceptions from +its helpers, preserving the README's strict failure policy; its regression test +checks the exception and that output registers are not partially published.