mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-10 01:28:44 +02:00
feat(agcDriver): add opcode 18 handling as clearing
This commit is contained in:
@@ -12,7 +12,7 @@ Execution reaches `_start`, stack unwinding and exception handling tables are bu
|
||||
Audio output and video output initialization pass
|
||||
Reaches the `main` function with render loop (deep call chain, ~64KB stack frame function) - init and shader loading from disk fully complete.
|
||||
|
||||
Now: `AGC driver: unsupported PM4 opcode 18 at DWORD 0`.
|
||||
Now: `AGC driver: unsupported PM4 opcode 159 at DWORD 2`.
|
||||
|
||||
## Disclaimer
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef CORE_LIBS_PRX_LIBSCEAGCDRIVER_EXECUTION_INCLUDE_QUEUESTATE_HPP
|
||||
#define CORE_LIBS_PRX_LIBSCEAGCDRIVER_EXECUTION_INCLUDE_QUEUESTATE_HPP
|
||||
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
|
||||
namespace AgcDriver {
|
||||
|
||||
using Registers = std::map<std::uint32_t, std::uint32_t>;
|
||||
|
||||
struct QueueState {
|
||||
Registers shader;
|
||||
Registers context;
|
||||
Registers userConfig;
|
||||
|
||||
void ClearContext() {
|
||||
context.clear();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "prx/libSceAgcDriver/Execution/include/Driver.hpp"
|
||||
#include "prx/libSceAgcDriver/Execution/include/QueueState.hpp"
|
||||
#include "prx/libSceAgcDriver/Execution/include/VulkanDevice.hpp"
|
||||
#include "prx/libSceAgcDriver/Execution/include/VideoOutput.hpp"
|
||||
#include "prx/libc/include/Shutdown.hpp"
|
||||
@@ -72,14 +73,6 @@ void checkRange(const void* pointer, std::size_t bytes, std::size_t alignment) {
|
||||
#endif
|
||||
}
|
||||
|
||||
using Registers = std::map<std::uint32_t, std::uint32_t>;
|
||||
|
||||
struct QueueState {
|
||||
Registers shader;
|
||||
Registers context;
|
||||
Registers userConfig;
|
||||
};
|
||||
|
||||
struct ShaderSnapshot {
|
||||
std::uint64_t codeAddress;
|
||||
std::uint64_t headerAddress;
|
||||
@@ -336,6 +329,11 @@ private:
|
||||
const auto packet = commands.subspan(cursor, count);
|
||||
const auto opcode = (header >> 8u) & 0xffu;
|
||||
switch (opcode) {
|
||||
case 0x12:
|
||||
require(queue == 0, "CLEAR_STATE in compute queue");
|
||||
require(count == 2, "invalid CLEAR_STATE packet size");
|
||||
require((packet[1] & ~0xfu) == 0, "unsupported CLEAR_STATE payload bits");
|
||||
break;
|
||||
case 0x10:
|
||||
require((packet[1] & 0xffff0000u) != 0x68750000u, "marker NOP is not implemented");
|
||||
break;
|
||||
@@ -407,6 +405,9 @@ private:
|
||||
const auto count = static_cast<std::size_t>((header >> 16u) & 0x3fffu) + 2;
|
||||
const auto packet = std::span(submission.commands).subspan(cursor, count);
|
||||
switch ((header >> 8u) & 0xffu) {
|
||||
case 0x12:
|
||||
queue.ClearContext();
|
||||
break;
|
||||
case 0x10:
|
||||
if (header == FlipPacketHeader) {
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "prx/libSceAgcDriver/Execution/include/Driver.hpp"
|
||||
#include "prx/libSceAgcDriver/Execution/include/QueueState.hpp"
|
||||
#include "prx/libc/include/Shutdown.hpp"
|
||||
#include "prx/libSceAgcDriver/Submit/include/Dcb.hpp"
|
||||
#include "prx/libSceAgcDriver/Submit/include/Acb.hpp"
|
||||
@@ -82,6 +83,40 @@ void testValidation() {
|
||||
AgcDriverWaitIdle_nid_postfix();
|
||||
}
|
||||
|
||||
void testClearState() {
|
||||
AgcDriver::QueueState graphics{{{0x20c, 1}}, {{0x10, 17}, {0x11, 23}}, {{0x242, 5}}};
|
||||
const auto shader = graphics.shader;
|
||||
const auto userConfig = graphics.userConfig;
|
||||
graphics.ClearContext();
|
||||
check(graphics.context.empty(), "CLEAR_STATE retained context registers");
|
||||
check(graphics.shader == shader && graphics.userConfig == userConfig, "CLEAR_STATE reset unrelated registers");
|
||||
graphics.context.emplace(0x10, 31);
|
||||
graphics.ClearContext();
|
||||
check(graphics.context.empty(), "repeated CLEAR_STATE retained context registers");
|
||||
|
||||
std::array<std::uint32_t, 3> words{0xc0001200, 0, 0};
|
||||
Packet packet{words.data(), 2, 0, {}};
|
||||
expectFailure([&] { sceAgcDriverSubmitAcb(0x20, &packet); });
|
||||
words[1] = 0x10;
|
||||
expectFailure([&] { sceAgcDriverSubmitDcb(&packet); });
|
||||
words[1] = 0;
|
||||
words[0] = 0xc0011200;
|
||||
packet.dw_num = 3;
|
||||
expectFailure([&] { sceAgcDriverSubmitDcb(&packet); });
|
||||
words[0] = 0xc0001201;
|
||||
packet.dw_num = 2;
|
||||
expectFailure([&] { sceAgcDriverSubmitDcb(&packet); });
|
||||
words[0] = 0xc0001200;
|
||||
packet.dw_num = 1;
|
||||
expectFailure([&] { sceAgcDriverSubmitDcb(&packet); });
|
||||
packet.dw_num = 2;
|
||||
for (std::uint32_t state = 0; state <= 0xf; ++state) {
|
||||
words[1] = state;
|
||||
check(sceAgcDriverSubmitDcb(&packet) == 0, "CLEAR_STATE submit failed");
|
||||
}
|
||||
AgcDriverWaitIdle_nid_postfix();
|
||||
}
|
||||
|
||||
void testSubmissions() {
|
||||
std::vector<std::thread> producers;
|
||||
std::array<std::exception_ptr, 4> errors{};
|
||||
@@ -131,6 +166,7 @@ int main() {
|
||||
try {
|
||||
testEvents();
|
||||
testValidation();
|
||||
testClearState();
|
||||
testSubmissions();
|
||||
testWorkerFailure();
|
||||
check(expectFailure([] { LibcRunShutdown_nid_postfix(); }).find("required shader register") != std::string::npos, "shutdown lost worker failure");
|
||||
|
||||
Reference in New Issue
Block a user