Merge pull request #775 from adriadam10/feat/agc-context-state-op-size

feat(agc): implement sceAgcDcbContextStateOpGetSize
This commit is contained in:
Dean
2026-10-06 12:44:25 +13:00
committed by GitHub
4 changed files with 85 additions and 3 deletions
+13
View File
@@ -161,6 +161,19 @@ if(BUILD_TESTING)
endif()
endif()
add_test_executable(agc_context_state_size_tests EXCLUDE_FROM_ALL tests/ContextStateSize.cpp)
target_include_directories(agc_context_state_size_tests PRIVATE ${LIBS_INCLUDE_DIR})
target_link_libraries(agc_context_state_size_tests PRIVATE libSceAgc libc)
configure_windows_unwind(agc_context_state_size_tests)
if(BUILD_TESTING)
set_target_properties(agc_context_state_size_tests PROPERTIES EXCLUDE_FROM_ALL FALSE)
add_test(NAME agc_context_state_size_tests COMMAND agc_context_state_size_tests)
if(WIN32)
set_tests_properties(agc_context_state_size_tests PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
endif()
endif()
add_test_executable(agc_interpolant_mapping_tests EXCLUDE_FROM_ALL tests/InterpolantMapping.cpp)
target_include_directories(agc_interpolant_mapping_tests PRIVATE ${LIBS_INCLUDE_DIR})
target_link_libraries(agc_interpolant_mapping_tests PRIVATE libSceAgc libc)
@@ -16,9 +16,14 @@ uint32_t* APS5_VABI sceAgcDcbContextStateOp(CommandBuffer* buf, uint32_t operati
}
uint64_t APS5_VABI sceAgcDcbContextStateOpGetSize(uint32_t operation) {
(void)operation;
NotImplemented_nid_no_patch(__func__);
return 0;
Agc::Command::Require(operation <= 3, __func__, "invalid context state operation");
if (operation == 0) {
return 5 * sizeof(std::uint32_t);
}
if (operation == 3) {
return 32 * sizeof(std::uint32_t);
}
return 27 * sizeof(std::uint32_t);
}
APS5_EXPORT("qj7QZpgr9Uw", sceAgcDcbContextStateAnotherOp);
@@ -0,0 +1,63 @@
#include "SceTypes.hpp"
#include "prx/libc/include/general/VabiMacros.hpp"
#include "prx/libc/include/Shutdown.hpp"
#include <array>
#include <cstdint>
#include <cstdio>
#include <stdexcept>
extern "C" std::uint64_t APS5_VABI sceAgcDcbContextStateOpGetSize(std::uint32_t operation);
extern "C" std::uint32_t* APS5_VABI sceAgcDcbContextStateAnotherOp(CommandBuffer* buf, std::uint32_t operation);
namespace {
void check(bool condition, const char* message) {
if (!condition) throw std::runtime_error(message);
}
template <typename TAction>
void expectFailure(TAction action) {
try {
action();
} catch (const std::runtime_error& error) {
check(error.what()[0] != '\0', "empty exception message");
return;
}
throw std::runtime_error("expected an exception");
}
void testSizes() {
const std::array<std::uint64_t, 4> sizes{20, 108, 108, 128};
for (std::uint32_t operation = 0; operation < sizes.size(); ++operation) {
check(sceAgcDcbContextStateOpGetSize(operation) == sizes[operation], "context state size mismatch");
std::array<std::uint32_t, 64> words{};
CommandBuffer buffer{words.data(), words.data() + words.size(), words.data(), words.data() + words.size(),
nullptr, nullptr, 0};
check(sceAgcDcbContextStateAnotherOp(&buffer, operation) == words.data(), "context state op did not start at the cursor");
const auto written = static_cast<std::uint64_t>(buffer.cursor_up - words.data()) * sizeof(std::uint32_t);
check(written == sizes[operation], "context state size differs from the written packets");
}
}
void testRejections() {
expectFailure([] { sceAgcDcbContextStateOpGetSize(4); });
expectFailure([] { sceAgcDcbContextStateOpGetSize(0xffffffffu); });
}
}
int main() {
try {
testSizes();
testRejections();
LibcRunShutdown_nid_postfix();
std::puts("AGC context state size tests passed");
return 0;
} catch (const std::exception& error) {
std::fprintf(stderr, "%s\n", error.what());
try { LibcRunShutdown_nid_postfix(); }
catch (const std::exception& shutdown) { std::fprintf(stderr, "shutdown: %s\n", shutdown.what()); }
return 1;
}
}
+1
View File
@@ -48,6 +48,7 @@ Throughout the project, every function at every stage either **does exactly what
- [sceAgcGetIsTrinityMode](../../core/libs/prx/libSceAgc/Misc/src/Platform.cpp) (libSceAgc) - signature from the only PPSA26344 call (a pointer to a one-byte flag, result ignored); a null pointer throws because its error code is unknown
- [zARR5aCmkoY](../../core/libs/prx/libSceAgc/DcbFlow/src/Control.cpp) (libSceAgc) - unknown name, signature
- [qj7QZpgr9Uw](../../core/libs/prx/libSceAgc/DcbState/src/ContextState.cpp) (libSceAgc) - unknown name
- [sceAgcDcbContextStateOpGetSize](../../core/libs/prx/libSceAgc/DcbState/src/ContextState.cpp) (libSceAgc) - sizes from KytyPS5 only (5, 27, 27 and 32 dwords), equal to what `qj7QZpgr9Uw` writes; KytyPS5 returns 0 for an operation above 3, here it throws
- [fd5Bp5tGTgo](../../core/libs/prx/libSceAgc/Misc/src/ShaderFusion.cpp) (libSceAgc) - unknown name
- [dolOmWH+huQ](../../core/libs/prx/libSceAgc/Misc/src/ShaderFusion.cpp) (libSceAgc) - unknown name
- [dbOlWdppb4o](../../core/libs/prx/libSceAgc/Shader/src/InterpolantMapping.cpp) (libSceAgc) - unknown name; same arguments as `sceAgcCreateInterpolantMapping`; the `SPI_PS_INPUT_CNTL` bits for `is_f16` 2 inputs follow KytyPS5, not confirmed on hardware