From c533508c64b39a5219f9eb461d9091c6703eee57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Franch?= Date: Sat, 3 Oct 2026 18:49:56 +0200 Subject: [PATCH] test(agc): keep shader memory test tables inside one guest page Co-Authored-By: Claude --- .../libSceAgcDriver/tests/ShaderMemory.cpp | 36 ++++++++++++++----- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp b/core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp index 7a14ddaac..77ea23079 100644 --- a/core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp +++ b/core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp @@ -174,7 +174,17 @@ void verifyBindlessTable() { struct alignas(256) Texture { std::array bytes{}; }; static Texture textures[2]; - std::array, 4> heap{}; + struct alignas(4096) GuestTables { + std::array, 4> heap{}; + std::array, 3> materials{}; + std::array output{}; + std::array srt{}; + }; + static GuestTables guest; + auto& heap = guest.heap; + auto& materials = guest.materials; + auto& output = guest.output; + auto& srt = guest.srt; const auto makeTexture = [&](std::uint32_t entry, const Texture& texture) { const auto base = static_cast(reinterpret_cast(texture.bytes.data())); heap[entry] = {static_cast(base >> 8u), static_cast((base >> 40u) & 0xffu) | (Format8888UNorm << 20u) | (3u << 30u), 3u << 14u, 0xfacu | (Type2D << 28u), 0u, 0u, 0u, 0u}; @@ -182,13 +192,11 @@ void verifyBindlessTable() { makeTexture(0, textures[0]); makeTexture(1, textures[1]); heap[3] = heap[0]; - std::array, 3> materials{{{0u, 1u, 0u, 0u}, {0u, 0u, 0u, 0u}, {0u, 3u, 0u, 0u}}}; - std::array output{}; + materials = {{{0u, 1u, 0u, 0u}, {0u, 0u, 0u, 0u}, {0u, 3u, 0u, 0u}}}; const auto bufferDescriptor = [](const void* base, std::uint32_t stride, std::uint32_t records) { const auto address = static_cast(reinterpret_cast(base)); return std::array{static_cast(address), static_cast((address >> 32u) & 0xffffu) | (stride << 16u), records, 0xfacu}; }; - std::array srt{}; const auto fillSrt = [&](std::uint32_t heapRecords) { const auto heapV = bufferDescriptor(heap.data(), 32u, heapRecords); const auto materialV = bufferDescriptor(materials.data(), 16u, 3u); @@ -716,9 +724,14 @@ void verifyWaveUniformValues() { void verifyTwoLaneUniformValues() { using namespace ShaderRecompiler; - static std::array output{}; + struct alignas(4096) GuestTables { + std::array output{}; + std::array srt{}; + }; + static GuestTables guest; + auto& output = guest.output; const auto outputBase = static_cast(reinterpret_cast(output.data())); - static std::array srt{}; + auto& srt = guest.srt; srt = {6u, 7u, 0u, 0u, static_cast(outputBase), static_cast((outputBase >> 32u) & 0xffffu), 64u, 0xfacu}; const auto srtAddress = static_cast(reinterpret_cast(srt.data())); const std::array userData{static_cast(srtAddress), static_cast(srtAddress >> 32u)}; @@ -786,8 +799,15 @@ int main() { require(optimizedSpirv == ValidateAndOptimizeSpirv(minimalSpirv, 0x00401001u, 0x00010000u), "SPIR-V optimization is not deterministic"); #endif const std::array code{0xf4040004u, 0xfa000000u, 0xf4000080u, 0xfa000000u, 0x7e000202u, 0xf80008cfu, 0u, 0xbf810000u}; - std::uint32_t payload = 0x3f800000u; - std::uint64_t table = reinterpret_cast(&payload); + struct alignas(4096) GuestTables { + std::uint32_t payload = 0; + std::uint64_t table = 0; + }; + static GuestTables guest; + auto& payload = guest.payload; + payload = 0x3f800000u; + auto& table = guest.table; + table = reinterpret_cast(&payload); const auto address = reinterpret_cast(&table); const std::array userData{static_cast(address), static_cast(address >> 32u)}; RecompileRequest request{};