mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-10 01:28:44 +02:00
Merge pull request #1037 from Raghav314/fix/agc-unwritten-user-data
fix(agc): read unwritten user data registers as zero
This commit is contained in:
@@ -12,6 +12,8 @@ void require(bool condition, const char* reason);
|
||||
|
||||
std::uint32_t readRegister(const Registers& registers, std::uint32_t offset);
|
||||
|
||||
std::uint32_t readUserData(const Registers& shader, std::uint32_t offset);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -21,4 +21,9 @@ std::uint32_t readRegister(const Registers& registers, std::uint32_t offset) {
|
||||
return it->second;
|
||||
}
|
||||
|
||||
std::uint32_t readUserData(const Registers& shader, std::uint32_t offset) {
|
||||
const auto it = shader.find(offset);
|
||||
return it == shader.end() ? 0u : it->second;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ void Driver::dispatch(QueueState& queue, std::span<const std::uint32_t> packet,
|
||||
const auto userCount = (readRegister(queue.shader, 0x213) >> 1u) & 0x1fu;
|
||||
std::vector<std::uint32_t> userData;
|
||||
for (std::uint32_t i = 0; i < userCount; ++i) {
|
||||
userData.push_back(readRegister(queue.shader, 0x240 + i));
|
||||
userData.push_back(readUserData(queue.shader, 0x240 + i));
|
||||
}
|
||||
auto compute = Graphics::DecodeComputeStageInfo(queue.shader);
|
||||
std::vector<ShaderRecompiler::MemoryRegion> memory{{snapshot.codeAddress, std::as_bytes(std::span(snapshot.code))}};
|
||||
|
||||
@@ -40,7 +40,7 @@ std::shared_ptr<DrawDecode> Driver::decodeDraw(const QueueState& queue, const Su
|
||||
};
|
||||
for (std::uint32_t i = 0; i < userCount; ++i) {
|
||||
Graphics::NoteRegisterRead(Graphics::RegisterBank::Shader, userDataBase + i);
|
||||
result.userData.push_back(readRegister(queue.shader, userDataBase + i));
|
||||
result.userData.push_back(readUserData(queue.shader, userDataBase + i));
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "prx/libSceAgcDriver/Execution/include/Pm4.hpp"
|
||||
#include "prx/libSceAgcDriver/Execution/include/GuestMemory.hpp"
|
||||
#include "prx/libSceAgcDriver/Execution/include/Driver.hpp"
|
||||
#include "prx/libSceAgcDriver/Execution/include/Driver/Diagnostics.hpp"
|
||||
#include "prx/libSceAgcDriver/Submit/include/Dcb.hpp"
|
||||
#include "prx/libSceAgcDriver/Submit/include/Acb.hpp"
|
||||
#include "prx/libc/include/Shutdown.hpp"
|
||||
@@ -867,6 +868,14 @@ void testAsyncMemoryFailure() {
|
||||
|
||||
}
|
||||
|
||||
void testUnwrittenUserData() {
|
||||
AgcDriver::Registers shader{{0x8c, 0x100}, {0x8d, 0}, {0x240, 0x200}};
|
||||
check(AgcDriver::DriverDetail::readUserData(shader, 0x8c) == 0x100 && AgcDriver::DriverDetail::readUserData(shader, 0x240) == 0x200, "a written user data register was not read");
|
||||
check(AgcDriver::DriverDetail::readUserData(shader, 0x8d) == 0, "a user data register written as zero was not read");
|
||||
check(AgcDriver::DriverDetail::readUserData(shader, 0x95) == 0 && AgcDriver::DriverDetail::readUserData(shader, 0x241) == 0, "an unwritten user data register does not read zero");
|
||||
expectFailure([&] { static_cast<void>(AgcDriver::DriverDetail::readRegister(shader, 0x95)); }, "required shader register");
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
try {
|
||||
if (argc == 2 && std::string(argv[1]) == "failure") {
|
||||
@@ -893,6 +902,7 @@ int main(int argc, char** argv) {
|
||||
testConditionalWrite();
|
||||
testConditionalWriteSubmission();
|
||||
testPredication();
|
||||
testUnwrittenUserData();
|
||||
testDriverSubmission();
|
||||
testPredicatedSubmission();
|
||||
testConditionalSubmission();
|
||||
|
||||
@@ -67,6 +67,7 @@ Throughout the project, every function at every stage either **does exactly what
|
||||
- [sceUserServiceGetNpAccountId](../../core/libs/prx/libSceUserService/Export.cpp) (libSceUserService) - the account id for a user with no linked PSN account is assumed to be 0 with success; libSceNpManager's `sceNpGetAccountIdA` answers the same question with `SCE_NP_ERROR_SIGNED_OUT`
|
||||
- [sceUserServiceGetUserColor](../../core/libs/prx/libSceUserService/Export.cpp) (libSceUserService) - the default profile colour is assumed to be blue (0)
|
||||
- [sceAgcSetSubmitMode](../../core/libs/prx/libSceAgc/Misc/src/Suspend.cpp) (libSceAgc) - mode values unknown; only 0 is accepted
|
||||
- [User data registers](../../core/libs/prx/libSceAgcDriver/Execution/src/Driver/Diagnostics.cpp) (AGC driver) - a `SPI_SHADER_USER_DATA_*` or `COMPUTE_USER_DATA_*` register the title never wrote reads as 0 when a stage's RSRC2 count covers it, as Kyty (zeroed `UserSgprInfo`) and SharpEmu (missing registers read 0) do, and as AMD PAL and Mesa initialize them; the console's value is not confirmed
|
||||
- [SET_PREDICATION](../../core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp) (AGC driver) - boolean predication follows the AMD PM4 encoding [Mesa](https://gitlab.freedesktop.org/mesa/mesa/-/blob/main/src/amd/common/sid.h) uses: operation 3 reads 64 bits and 4 reads 32 bits, and bit 8 runs predicated packets when the value is non-zero (clear: when it is zero); the bit 12 hint is ignored. The address must have its low 4 bits clear, as `sceAgcDcbSetPredication` writes it. Query predication (Z-pass, primitive count), a predicated COND_EXEC, predicated command buffer chains and flips in predicated command buffers throw
|
||||
- [sceAgcGetGsOversubscription](../../core/libs/prx/libSceAgc/Shader/src/GsOversubscription.cpp) (libSceAgc) - signature and occupancy formula (base and expanded vertex/export capacities, budget shift, `GE_PC_ALLOC` / `SPI_SHADER_PGM_RSRC4_GS` encoding) follow KytyPS5 only, not confirmed on hardware or a title; a negative or NaN factor that gives a negative target, a missing GS context register or a zero `GE_MAX_OUTPUT_PER_SUBGROUP` throws
|
||||
- [sceAgcCbCondWrite](../../core/libs/prx/libSceAgc/Cb/src/Branch.cpp) (libSceAgc) - argument order and the 9-dword COND_WRITE layout follow the clean-room [OpenAGC](https://github.com/OpenAGC/OpenAGC/blob/main/src/game_compat.c) and [sharpemu](https://github.com/sharpemu/sharpemu/blob/main/src/SharpEmu.Libs/Agc/AgcExports.CommandPackets.cs), which agree on them; SharpProspero lists another order. The write space is accepted only as 1 (memory), the one value both encode the same way, and other values throw.
|
||||
|
||||
Reference in New Issue
Block a user