mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-10 01:28:44 +02:00
feat(libSceAgc): implement command packet functions
This commit is contained in:
@@ -321,7 +321,7 @@ struct RtcTick {
|
||||
};
|
||||
|
||||
struct CommandBuffer {
|
||||
using Callback = bool (*)(CommandBuffer*, std::uint32_t, void*);
|
||||
using Callback = bool (APS5_VABI *)(CommandBuffer*, std::uint32_t, void*);
|
||||
std::uint32_t* bottom;
|
||||
std::uint32_t* top;
|
||||
std::uint32_t* cursor_up;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#include "prx/libSceAgc/Command/Memory.hpp"
|
||||
#include "prx/libSceAgc/Command/Packet.hpp"
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include "SceTypes.hpp"
|
||||
@@ -55,27 +57,14 @@ uint32_t* APS5_VABI sceAgcAcbDispatchIndirect(CommandBuffer* buf, const volatile
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint32_t* APS5_VABI sceAgcAcbDmaData(CommandBuffer* buf, uint8_t dst, uint8_t dst_cache_policy, uint64_t dst_address_or_offset, uint8_t src, uint8_t src_cache_policy, uint64_t src_address_or_offset_or_immediate, uint32_t num_bytes, uint8_t wait_for_previous, uint8_t write_confirm) {
|
||||
(void)buf;
|
||||
(void)dst;
|
||||
(void)dst_cache_policy;
|
||||
(void)dst_address_or_offset;
|
||||
(void)src;
|
||||
(void)src_cache_policy;
|
||||
(void)src_address_or_offset_or_immediate;
|
||||
(void)num_bytes;
|
||||
(void)wait_for_previous;
|
||||
(void)write_confirm;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return nullptr;
|
||||
std::uint32_t* APS5_VABI sceAgcAcbDmaData(CommandBuffer* buf, std::uint8_t dst, std::uint8_t dstCachePolicy, std::uint64_t dstAddress, std::uint8_t src, std::uint8_t srcCachePolicy, std::uint64_t srcAddress, std::uint32_t numBytes, std::uint8_t waitForPrevious, std::uint8_t writeConfirm) {
|
||||
return Agc::Command::WriteDma(buf, true, 0, dst, dstCachePolicy, dstAddress, src, srcCachePolicy, srcAddress, numBytes, waitForPrevious, writeConfirm, 0, __func__);
|
||||
}
|
||||
|
||||
uint32_t* APS5_VABI sceAgcAcbEventWrite(CommandBuffer* buf, uint8_t event_type, const volatile void* address) {
|
||||
(void)buf;
|
||||
(void)event_type;
|
||||
(void)address;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return nullptr;
|
||||
std::uint32_t* APS5_VABI sceAgcAcbEventWrite(CommandBuffer* buf, std::uint8_t eventType, const volatile void* address) {
|
||||
Agc::Command::CheckBits(eventType, 0x3fu, __func__);
|
||||
Agc::Command::Require(address == nullptr, __func__, "ACB event address is not supported");
|
||||
return Agc::Command::Emit(buf, 0x46u, {eventType | (eventType == 7 ? 0x400u : 0u)}, __func__);
|
||||
}
|
||||
|
||||
uint32_t APS5_VABI sceAgcAcbJumpGetSize(void) {
|
||||
@@ -112,30 +101,12 @@ uint32_t* APS5_VABI sceAgcAcbSetMarker(CommandBuffer* buf, const char* str, uint
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint32_t* APS5_VABI sceAgcAcbWaitRegMem(CommandBuffer* buf, uint8_t size, uint8_t compare_function, uint8_t cache_policy, const volatile void* address, uint64_t reference, uint64_t mask, uint32_t poll_cycles) {
|
||||
(void)buf;
|
||||
(void)size;
|
||||
(void)compare_function;
|
||||
(void)cache_policy;
|
||||
(void)address;
|
||||
(void)reference;
|
||||
(void)mask;
|
||||
(void)poll_cycles;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return nullptr;
|
||||
std::uint32_t* APS5_VABI sceAgcAcbWaitRegMem(CommandBuffer* buf, std::uint8_t size, std::uint8_t compareFunction, std::uint8_t cachePolicy, const volatile void* address, std::uint64_t reference, std::uint64_t mask, std::uint32_t pollCycles) {
|
||||
return Agc::Command::WriteWait(buf, size, compareFunction, 0, cachePolicy, address, reference, mask, pollCycles, __func__);
|
||||
}
|
||||
|
||||
uint32_t* APS5_VABI sceAgcAcbWriteData(CommandBuffer* buf, uint8_t dst, uint8_t cache_policy, uint64_t address_or_offset, const void* data, uint32_t num_dwords, uint8_t increment, uint8_t write_confirm) {
|
||||
(void)buf;
|
||||
(void)dst;
|
||||
(void)cache_policy;
|
||||
(void)address_or_offset;
|
||||
(void)data;
|
||||
(void)num_dwords;
|
||||
(void)increment;
|
||||
(void)write_confirm;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return nullptr;
|
||||
std::uint32_t* APS5_VABI sceAgcAcbWriteData(CommandBuffer* buf, std::uint8_t dst, std::uint8_t cachePolicy, std::uint64_t address, const void* data, std::uint32_t numDwords, std::uint8_t increment, std::uint8_t writeConfirm) {
|
||||
return Agc::Command::WriteData(buf, true, dst, cachePolicy, address, data, numDwords, increment, writeConfirm, __func__);
|
||||
}
|
||||
std::uint64_t APS5_VABI sceAgcAcbCopyDataGetSize() {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
add_library(libSceAgc SHARED EXCLUDE_FROM_ALL
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Command/Packet.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Command/Memory.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Export.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Shader/Export.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Shader/ShaderUtils.cpp
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include "prx/libSceAgc/Command/Packet.hpp"
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include "SceTypes.hpp"
|
||||
@@ -5,30 +6,24 @@
|
||||
|
||||
extern "C" {
|
||||
|
||||
uint32_t* APS5_VABI sceAgcCbBranch(CommandBuffer* buf, uint8_t mode, uint8_t compare_function, const volatile uint64_t* compare_addr, uint64_t mask, uint64_t reference, uint8_t cache_policy1, const volatile uint32_t* buffer1, uint32_t size_in_dwords1, uint8_t cache_policy2, const volatile uint32_t* buffer2, uint32_t size_in_dwords2) {
|
||||
(void)buf;
|
||||
(void)mode;
|
||||
(void)compare_function;
|
||||
(void)compare_addr;
|
||||
(void)mask;
|
||||
(void)reference;
|
||||
(void)cache_policy1;
|
||||
(void)buffer1;
|
||||
(void)size_in_dwords1;
|
||||
(void)cache_policy2;
|
||||
(void)buffer2;
|
||||
(void)size_in_dwords2;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return nullptr;
|
||||
std::uint32_t* APS5_VABI sceAgcCbBranch(CommandBuffer* buf, std::uint8_t mode, std::uint8_t compareFunction, const volatile std::uint64_t* compareAddress, std::uint64_t mask, std::uint64_t reference, std::uint8_t cachePolicy1, const volatile std::uint32_t* buffer1, std::uint32_t sizeInDwords1, std::uint8_t cachePolicy2, const volatile std::uint32_t* buffer2, std::uint32_t sizeInDwords2) {
|
||||
Agc::Command::CheckBits(mode, 3, __func__);
|
||||
Agc::Command::CheckBits(compareFunction, 7, __func__);
|
||||
Agc::Command::CheckBits(cachePolicy1, 3, __func__);
|
||||
Agc::Command::CheckBits(cachePolicy2, 3, __func__);
|
||||
Agc::Command::CheckBits(sizeInDwords1, 0xfffffu, __func__);
|
||||
Agc::Command::CheckBits(sizeInDwords2, 0xfffffu, __func__);
|
||||
const auto address = reinterpret_cast<std::uintptr_t>(compareAddress);
|
||||
const auto first = reinterpret_cast<std::uintptr_t>(buffer1);
|
||||
const auto second = reinterpret_cast<std::uintptr_t>(buffer2);
|
||||
Agc::Command::CheckAddress(address, 8, __func__);
|
||||
Agc::Command::CheckAddress(first, 4, __func__);
|
||||
Agc::Command::CheckAddress(second, 4, __func__);
|
||||
return Agc::Command::Emit(buf, 0x3fu, {mode | (static_cast<std::uint32_t>(compareFunction) << 8u), static_cast<std::uint32_t>(address), static_cast<std::uint32_t>(address >> 32u), static_cast<std::uint32_t>(mask), static_cast<std::uint32_t>(mask >> 32u), static_cast<std::uint32_t>(reference), static_cast<std::uint32_t>(reference >> 32u), static_cast<std::uint32_t>(first), static_cast<std::uint32_t>(first >> 32u), sizeInDwords1 | (static_cast<std::uint32_t>(cachePolicy1) << 28u), static_cast<std::uint32_t>(second), static_cast<std::uint32_t>(second >> 32u), sizeInDwords2 | (static_cast<std::uint32_t>(cachePolicy2) << 28u)}, __func__);
|
||||
}
|
||||
|
||||
uint32_t* APS5_VABI sceAgcCbSetUcRegisterRangeDirect(CommandBuffer* buf, uint32_t offset, const uint32_t* values, uint32_t num) {
|
||||
(void)buf;
|
||||
(void)offset;
|
||||
(void)values;
|
||||
(void)num;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return nullptr;
|
||||
std::uint32_t* APS5_VABI sceAgcCbSetUcRegisterRangeDirect(CommandBuffer* buf, std::uint32_t offset, const std::uint32_t* values, std::uint32_t numValues) {
|
||||
return Agc::Command::WriteRegisterRange(buf, 0x79u, offset, values, numValues, __func__);
|
||||
}
|
||||
|
||||
uint32_t* APS5_VABI sceAgcCbCondWrite(CommandBuffer* buf, uint32_t cond, uint32_t a, uint32_t b, uint32_t c) {
|
||||
@@ -41,19 +36,13 @@ uint32_t* APS5_VABI sceAgcCbCondWrite(CommandBuffer* buf, uint32_t cond, uint32_
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint32_t APS5_VABI sceAgcCbBranchGetSize() {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
std::uint32_t APS5_VABI sceAgcCbBranchGetSize() {
|
||||
return 56;
|
||||
}
|
||||
|
||||
uint32_t* APS5_VABI sceAgcCbDispatch(CommandBuffer* buf, uint32_t thread_group_x, uint32_t thread_group_y, uint32_t thread_group_z, uint32_t modifier) {
|
||||
(void)buf;
|
||||
(void)thread_group_x;
|
||||
(void)thread_group_y;
|
||||
(void)thread_group_z;
|
||||
(void)modifier;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return nullptr;
|
||||
std::uint32_t* APS5_VABI sceAgcCbDispatch(CommandBuffer* buf, std::uint32_t threadGroupX, std::uint32_t threadGroupY, std::uint32_t threadGroupZ, std::uint32_t modifier) {
|
||||
Agc::Command::CheckBits(modifier, 0xa038u, __func__);
|
||||
return Agc::Command::Emit(buf, 0x15u, {threadGroupX, threadGroupY, threadGroupZ, modifier | 0x41u}, __func__);
|
||||
}
|
||||
|
||||
uint32_t APS5_VABI sceAgcCbDispatchGetSize(void) {
|
||||
@@ -61,11 +50,8 @@ uint32_t APS5_VABI sceAgcCbDispatchGetSize(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t* APS5_VABI sceAgcCbNop_nid_postfix(CommandBuffer* buf, uint32_t size_in_dwords) {
|
||||
(void)buf;
|
||||
(void)size_in_dwords;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return nullptr;
|
||||
std::uint32_t* APS5_VABI sceAgcCbNop_nid_postfix(CommandBuffer* buf, std::uint32_t sizeInDwords) {
|
||||
return Agc::Command::WriteNop(buf, sizeInDwords, __func__);
|
||||
}
|
||||
|
||||
uint32_t APS5_VABI sceAgcCbNopGetSize(uint32_t size_in_dwords) {
|
||||
@@ -96,13 +82,8 @@ uint32_t* APS5_VABI sceAgcCbReleaseMem(CommandBuffer* buf, uint8_t action, uint1
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint32_t* APS5_VABI sceAgcCbSetShRegisterRangeDirect(CommandBuffer* buf, uint32_t offset, const uint32_t* values, uint32_t num_values) {
|
||||
(void)buf;
|
||||
(void)offset;
|
||||
(void)values;
|
||||
(void)num_values;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return nullptr;
|
||||
std::uint32_t* APS5_VABI sceAgcCbSetShRegisterRangeDirect(CommandBuffer* buf, std::uint32_t offset, const std::uint32_t* values, std::uint32_t numValues) {
|
||||
return Agc::Command::WriteRegisterRange(buf, 0x76u, offset, values, numValues, __func__);
|
||||
}
|
||||
|
||||
uint32_t APS5_VABI sceAgcCbSetShRegisterRangeDirectGetSize(uint32_t num_values) {
|
||||
@@ -111,19 +92,11 @@ uint32_t APS5_VABI sceAgcCbSetShRegisterRangeDirectGetSize(uint32_t num_values)
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t* APS5_VABI sceAgcCbSetShRegistersDirect(CommandBuffer* buf, const volatile ShaderRegister* regs, uint32_t num_regs) {
|
||||
(void)buf;
|
||||
(void)regs;
|
||||
(void)num_regs;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return nullptr;
|
||||
std::uint32_t* APS5_VABI sceAgcCbSetShRegistersDirect(CommandBuffer* buf, const volatile ShaderRegister* regs, std::uint32_t numRegs) {
|
||||
return Agc::Command::WriteRegisters(buf, 0x76u, regs, numRegs, true, __func__);
|
||||
}
|
||||
std::uint32_t* APS5_VABI sceAgcCbSetUcRegistersDirect(CommandBuffer* buf, const volatile ShaderRegister* regs, std::uint32_t numRegs) {
|
||||
(void)buf;
|
||||
(void)regs;
|
||||
(void)numRegs;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
return Agc::Command::WriteRegisters(buf, 0x79u, regs, numRegs, false, __func__);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
#include "prx/libSceAgc/Command/Memory.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
|
||||
namespace Agc::Command {
|
||||
|
||||
std::uint32_t* WriteDma(CommandBuffer* buffer, bool compute, std::uint8_t engine, std::uint8_t dst, std::uint8_t dstCachePolicy, std::uint64_t dstAddress, std::uint8_t src, std::uint8_t srcCachePolicy, std::uint64_t srcAddress, std::uint32_t numBytes, std::uint8_t waitForPrevious, std::uint8_t writeConfirm, std::uint8_t blockEngine, const char* function) {
|
||||
CheckBits(engine, 1, function);
|
||||
CheckBits(dst, 0xfu, function);
|
||||
CheckBits(dstCachePolicy, 3, function);
|
||||
CheckBits(srcCachePolicy, 3, function);
|
||||
CheckBits(waitForPrevious, 1, function);
|
||||
CheckBits(writeConfirm, 1, function);
|
||||
CheckBits(blockEngine, 1, function);
|
||||
CheckBits(numBytes, 0x3ffffffu, function);
|
||||
if (src == 0x14u || src == 0x24u || (!compute && src == 0x64u) || (compute && src == 0x25u)) {
|
||||
const auto slot = src == 0x14u ? 0u : src == 0x24u ? 1u : 2u;
|
||||
srcAddress = (engine == 1 ? 0x30148u : 0x30174u) + slot * 8u;
|
||||
} else {
|
||||
CheckBits(src, 0xfu, function);
|
||||
}
|
||||
const auto control = engine | (static_cast<std::uint32_t>(srcCachePolicy) << 13u) | ((dst & 3u) << 20u) | (static_cast<std::uint32_t>(dstCachePolicy) << 25u) | ((src & 3u) << 29u) | (static_cast<std::uint32_t>(blockEngine) << 31u);
|
||||
const auto command = numBytes | ((src & 4u) << 24u) | ((dst & 4u) << 25u) | ((src & 8u) << 25u) | ((dst & 8u) << 26u) | (static_cast<std::uint32_t>(waitForPrevious) << 30u) | (static_cast<std::uint32_t>(writeConfirm) << 31u);
|
||||
return Emit(buffer, 0x50u, {control, static_cast<std::uint32_t>(srcAddress), static_cast<std::uint32_t>(srcAddress >> 32u), static_cast<std::uint32_t>(dstAddress), static_cast<std::uint32_t>(dstAddress >> 32u), command}, function);
|
||||
}
|
||||
|
||||
std::uint32_t* WriteData(CommandBuffer* buffer, bool compute, std::uint8_t dst, std::uint8_t cachePolicy, std::uint64_t address, const void* data, std::uint32_t count, std::uint8_t increment, std::uint8_t writeConfirm, const char* function) {
|
||||
Require(data != nullptr && count != 0 && count <= 0x3ffdu, function, "invalid write data payload");
|
||||
CheckBits(dst, compute ? 0xfu : 0x1fu, function);
|
||||
CheckBits(cachePolicy, 3, function);
|
||||
CheckBits(increment, 1, function);
|
||||
CheckBits(writeConfirm, 1, function);
|
||||
Require(compute || (address & 3u) == 0, function, "misaligned write address");
|
||||
Require(dst != 0 || writeConfirm == 0, function, "register writes do not support write confirmation");
|
||||
std::vector<std::uint32_t> snapshot(count);
|
||||
std::memcpy(snapshot.data(), data, count * sizeof(std::uint32_t));
|
||||
const auto destination = compute ? static_cast<std::uint32_t>(dst) << 8u : ((dst & 1u) << 30u) | ((dst & 0x1eu) << 7u);
|
||||
auto* packet = Allocate(buffer, count + 4u, function);
|
||||
packet[0] = Header(0x37u, count + 4u);
|
||||
packet[1] = destination | (static_cast<std::uint32_t>(increment) << 16u) | (static_cast<std::uint32_t>(writeConfirm) << 20u) | (static_cast<std::uint32_t>(cachePolicy) << 25u);
|
||||
packet[2] = static_cast<std::uint32_t>(address);
|
||||
packet[3] = static_cast<std::uint32_t>(address >> 32u);
|
||||
std::copy(snapshot.begin(), snapshot.end(), packet + 4);
|
||||
return packet;
|
||||
}
|
||||
|
||||
std::uint32_t* WriteWait(CommandBuffer* buffer, std::uint8_t size, std::uint8_t compareFunction, std::uint8_t operation, std::uint8_t cachePolicy, const volatile void* address, std::uint64_t reference, std::uint64_t mask, std::uint32_t pollCycles, const char* function) {
|
||||
CheckBits(size, 1, function);
|
||||
Require(compareFunction <= 6, function, "invalid wait comparison");
|
||||
CheckBits(operation, size == 0 ? 0xfu : 7u, function);
|
||||
CheckBits(cachePolicy, 3, function);
|
||||
Require((pollCycles >> 4u) <= 0xffffu, function, "wait poll interval overflow");
|
||||
if (size == 0) {
|
||||
CheckBits(reference, 0xffffffffu, function);
|
||||
CheckBits(mask, 0xffffffffu, function);
|
||||
}
|
||||
const auto guestAddress = reinterpret_cast<std::uintptr_t>(address);
|
||||
CheckAddress(guestAddress, size == 0 ? 4 : 8, function);
|
||||
CheckBits(guestAddress, 0xffffffffffffull, function);
|
||||
const auto waitSize = size == 0 ? 7u : 9u;
|
||||
auto* packet = Allocate(buffer, waitSize + 7u, function);
|
||||
packet[0] = Header(0x79u, 4, 1);
|
||||
packet[1] = 0x342u;
|
||||
packet[2] = (size == 0 ? 0xc8010000u : 0xc8020000u) | static_cast<std::uint32_t>(guestAddress >> 32u);
|
||||
packet[3] = static_cast<std::uint32_t>(guestAddress);
|
||||
auto* wait = packet + 4;
|
||||
wait[0] = Header(size == 0 ? 0x3cu : 0x93u, waitSize);
|
||||
const auto opBits = size == 0 ? ((operation & 3u) << 8u) | ((operation & 0xcu) << 4u) : ((operation & 1u) << 8u) | ((operation & 6u) << 5u);
|
||||
wait[1] = 0x10u | compareFunction | opBits | (static_cast<std::uint32_t>(cachePolicy) << 25u);
|
||||
wait[2] = static_cast<std::uint32_t>(guestAddress);
|
||||
wait[3] = static_cast<std::uint32_t>(guestAddress >> 32u);
|
||||
wait[4] = static_cast<std::uint32_t>(reference);
|
||||
if (size == 0) {
|
||||
wait[5] = static_cast<std::uint32_t>(mask);
|
||||
} else {
|
||||
wait[5] = static_cast<std::uint32_t>(reference >> 32u);
|
||||
wait[6] = static_cast<std::uint32_t>(mask);
|
||||
wait[7] = static_cast<std::uint32_t>(mask >> 32u);
|
||||
}
|
||||
wait[waitSize - 1u] = pollCycles >> 4u;
|
||||
wait[waitSize] = Header(0x79u, 3, 1);
|
||||
wait[waitSize + 1u] = 0x342u;
|
||||
wait[waitSize + 2u] = 0xc8000000u;
|
||||
return packet;
|
||||
}
|
||||
|
||||
std::uint32_t* ValidateWait(std::uint32_t* packet, const char* function) {
|
||||
CheckAddress(reinterpret_cast<std::uintptr_t>(packet), 4, function);
|
||||
Require(packet[0] == Header(0x79u, 4, 1) && packet[1] == 0x342u, function, "invalid wait wrapper");
|
||||
const auto tag = packet[2] & 0xffff0000u;
|
||||
Require(tag == 0xc8010000u || tag == 0xc8020000u, function, "invalid wait tag");
|
||||
const auto size = tag == 0xc8010000u ? 7u : 9u;
|
||||
auto* wait = packet + 4;
|
||||
ValidatePacket(wait, size == 7 ? 0x3cu : 0x93u, size, function);
|
||||
Require(wait[size] == Header(0x79u, 3, 1) && wait[size + 1u] == 0x342u && wait[size + 2u] == 0xc8000000u, function, "invalid wait end tag");
|
||||
return wait;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
#ifndef CORE_LIBS_PRX_LIBSCEAGC_COMMAND_MEMORY_HPP
|
||||
#define CORE_LIBS_PRX_LIBSCEAGC_COMMAND_MEMORY_HPP
|
||||
|
||||
#include "prx/libSceAgc/Command/Packet.hpp"
|
||||
|
||||
namespace Agc::Command {
|
||||
|
||||
std::uint32_t* WriteDma(CommandBuffer* buffer, bool compute, std::uint8_t engine, std::uint8_t dst, std::uint8_t dstCachePolicy, std::uint64_t dstAddress, std::uint8_t src, std::uint8_t srcCachePolicy, std::uint64_t srcAddress, std::uint32_t numBytes, std::uint8_t waitForPrevious, std::uint8_t writeConfirm, std::uint8_t blockEngine, const char* function);
|
||||
std::uint32_t* WriteData(CommandBuffer* buffer, bool compute, std::uint8_t dst, std::uint8_t cachePolicy, std::uint64_t address, const void* data, std::uint32_t count, std::uint8_t increment, std::uint8_t writeConfirm, const char* function);
|
||||
std::uint32_t* WriteWait(CommandBuffer* buffer, std::uint8_t size, std::uint8_t compareFunction, std::uint8_t operation, std::uint8_t cachePolicy, const volatile void* address, std::uint64_t reference, std::uint64_t mask, std::uint32_t pollCycles, const char* function);
|
||||
std::uint32_t* ValidateWait(std::uint32_t* packet, const char* function);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,148 @@
|
||||
#include "prx/libSceAgc/Command/Packet.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace Agc::Command {
|
||||
|
||||
void Require(bool condition, const char* function, const char* reason) {
|
||||
if (!condition) {
|
||||
throw std::runtime_error(std::string(function) + ": " + reason);
|
||||
}
|
||||
}
|
||||
|
||||
void CheckBits(std::uint64_t value, std::uint64_t mask, const char* function) {
|
||||
Require((value & ~mask) == 0, function, "reserved bits are set");
|
||||
}
|
||||
|
||||
void CheckAddress(std::uint64_t address, std::uint32_t alignment, const char* function) {
|
||||
Require(address != 0 && (address & (alignment - 1u)) == 0, function, "null or misaligned address");
|
||||
}
|
||||
|
||||
std::uint32_t Header(std::uint32_t opcode, std::uint32_t count, std::uint32_t flags) {
|
||||
Require(count >= 2 && count <= 0x4001u && opcode <= 0xffu && flags <= 0xffu, __func__, "invalid packet header");
|
||||
return 0xc0000000u | ((count - 2u) << 16u) | (opcode << 8u) | flags;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
std::uint32_t available(const CommandBuffer& buffer, const char* function) {
|
||||
const auto bottom = reinterpret_cast<std::uintptr_t>(buffer.bottom);
|
||||
const auto top = reinterpret_cast<std::uintptr_t>(buffer.top);
|
||||
const auto up = reinterpret_cast<std::uintptr_t>(buffer.cursor_up);
|
||||
const auto down = reinterpret_cast<std::uintptr_t>(buffer.cursor_down);
|
||||
Require(((bottom | top | up | down) & 3u) == 0, function, "misaligned command buffer");
|
||||
Require(bottom <= up && up <= down && down <= top, function, "invalid command buffer cursors");
|
||||
Require(bottom != 0 || top == 0, function, "null command buffer storage");
|
||||
const auto count = (down - up) / sizeof(std::uint32_t);
|
||||
Require(count >= buffer.reserved_dw, function, "reserved space exceeds command buffer capacity");
|
||||
Require(count - buffer.reserved_dw <= std::numeric_limits<std::uint32_t>::max(), function, "command buffer capacity overflow");
|
||||
return static_cast<std::uint32_t>(count - buffer.reserved_dw);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::uint32_t* Allocate(CommandBuffer* buffer, std::uint32_t count, const char* function) {
|
||||
Require(buffer != nullptr && count != 0, function, "null command buffer or empty allocation");
|
||||
if (available(*buffer, function) < count) {
|
||||
Require(buffer->callback != nullptr, function, "command buffer exhausted");
|
||||
Require(count <= std::numeric_limits<std::uint32_t>::max() - buffer->reserved_dw, function, "command buffer allocation overflow");
|
||||
Require(buffer->callback(buffer, count + buffer->reserved_dw, buffer->user_data), function, "command buffer allocation callback failed");
|
||||
Require(available(*buffer, function) >= count, function, "command buffer allocation callback returned insufficient space");
|
||||
}
|
||||
auto* result = buffer->cursor_up;
|
||||
buffer->cursor_up += count;
|
||||
return result;
|
||||
}
|
||||
|
||||
std::uint32_t* Emit(CommandBuffer* buffer, std::uint32_t opcode, std::initializer_list<std::uint32_t> payload, const char* function) {
|
||||
Require(payload.size() <= 0x4000u, function, "packet payload exceeds maximum size");
|
||||
const auto count = static_cast<std::uint32_t>(payload.size()) + 1u;
|
||||
const auto header = Header(opcode, count);
|
||||
auto* packet = Allocate(buffer, count, function);
|
||||
packet[0] = header;
|
||||
std::copy(payload.begin(), payload.end(), packet + 1);
|
||||
return packet;
|
||||
}
|
||||
|
||||
void ValidatePacket(const std::uint32_t* packet, std::uint32_t opcode, std::uint32_t count, const char* function) {
|
||||
CheckAddress(reinterpret_cast<std::uintptr_t>(packet), 4, function);
|
||||
Require(packet[0] == Header(opcode, count), function, "unexpected packet type, size or flags");
|
||||
}
|
||||
|
||||
std::uint32_t* WriteNop(CommandBuffer* buffer, std::uint32_t count, const char* function) {
|
||||
const auto header = Header(0x10u, count);
|
||||
auto* packet = Allocate(buffer, count, function);
|
||||
packet[0] = header;
|
||||
std::fill_n(packet + 1, count - 1u, 0u);
|
||||
return packet;
|
||||
}
|
||||
|
||||
std::uint32_t* WriteRegisterRange(CommandBuffer* buffer, std::uint32_t opcode, std::uint32_t offset, const std::uint32_t* values, std::uint32_t count, const char* function) {
|
||||
Require(count != 0 && count <= 0x3fffu && offset <= 0xffffu && count <= 0x10000u - offset, function, "invalid register range");
|
||||
CheckAddress(reinterpret_cast<std::uintptr_t>(values), 4, function);
|
||||
const std::vector<std::uint32_t> snapshot(values, values + count);
|
||||
auto* packet = Allocate(buffer, count + 2u, function);
|
||||
packet[0] = Header(opcode, count + 2u);
|
||||
packet[1] = offset;
|
||||
std::copy(snapshot.begin(), snapshot.end(), packet + 2);
|
||||
return packet;
|
||||
}
|
||||
|
||||
std::uint32_t* WriteRegisters(CommandBuffer* buffer, std::uint32_t opcode, const volatile ShaderRegister* registers, std::uint32_t count, bool snapshotAll, const char* function) {
|
||||
Require(count != 0, function, "empty register list");
|
||||
CheckAddress(reinterpret_cast<std::uintptr_t>(registers), 4, function);
|
||||
std::vector<ShaderRegister> snapshot;
|
||||
if (snapshotAll) {
|
||||
snapshot.reserve(count);
|
||||
for (std::uint32_t i = 0; i < count; ++i) {
|
||||
snapshot.push_back({registers[i].offset, registers[i].value});
|
||||
CheckBits(snapshot.back().offset, 0xffffu, function);
|
||||
}
|
||||
}
|
||||
const auto offsetAt = [&](std::uint32_t index) { return snapshotAll ? snapshot[index].offset : registers[index].offset; };
|
||||
const auto valueAt = [&](std::uint32_t index) { return snapshotAll ? snapshot[index].value : registers[index].value; };
|
||||
std::uint32_t* first = nullptr;
|
||||
std::uint32_t index = 0;
|
||||
while (index < count) {
|
||||
const auto offset = offsetAt(index);
|
||||
CheckBits(offset, 0xffffu, function);
|
||||
std::vector<std::uint32_t> values{valueAt(index++)};
|
||||
while (index < count && offsetAt(index) == offset + values.size() && values.size() < 0x3fffu) {
|
||||
CheckBits(offsetAt(index), 0xffffu, function);
|
||||
values.push_back(valueAt(index++));
|
||||
}
|
||||
auto* packet = WriteRegisterRange(buffer, opcode, offset, values.data(), static_cast<std::uint32_t>(values.size()), function);
|
||||
if (first == nullptr) {
|
||||
first = packet;
|
||||
}
|
||||
}
|
||||
return first;
|
||||
}
|
||||
|
||||
std::uint32_t* WriteIndirectRegisters(CommandBuffer* buffer, std::uint32_t opcode, const volatile ShaderRegister* registers, std::uint32_t count, const char* function) {
|
||||
const auto address = reinterpret_cast<std::uintptr_t>(registers);
|
||||
CheckAddress(address, 4, function);
|
||||
CheckBits(count, 0x3fffu, function);
|
||||
return Emit(buffer, opcode, {static_cast<std::uint32_t>(address), static_cast<std::uint32_t>(address >> 32u), 0x80000000u, count}, function);
|
||||
}
|
||||
|
||||
void PatchIndirectAddress(std::uint32_t* packet, std::uint32_t opcode, const volatile ShaderRegister* registers, const char* function) {
|
||||
ValidatePacket(packet, opcode, 5, function);
|
||||
Require(packet[3] == 0x80000000u && (packet[4] & ~0x3fffu) == 0, function, "invalid indirect register packet");
|
||||
const auto address = reinterpret_cast<std::uintptr_t>(registers);
|
||||
CheckAddress(address, 4, function);
|
||||
packet[1] = static_cast<std::uint32_t>(address);
|
||||
packet[2] = static_cast<std::uint32_t>(address >> 32u);
|
||||
}
|
||||
|
||||
void PatchIndirectCount(std::uint32_t* packet, std::uint32_t opcode, std::uint32_t count, const char* function) {
|
||||
ValidatePacket(packet, opcode, 5, function);
|
||||
Require(packet[3] == 0x80000000u && packet[4] <= 0x3fffu && count <= 0x3fffu - packet[4], function, "indirect register count overflow or invalid packet");
|
||||
packet[4] += count;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
#ifndef CORE_LIBS_PRX_LIBSCEAGC_COMMAND_PACKET_HPP
|
||||
#define CORE_LIBS_PRX_LIBSCEAGC_COMMAND_PACKET_HPP
|
||||
|
||||
#include <cstdint>
|
||||
#include <initializer_list>
|
||||
#include "SceTypes.hpp"
|
||||
|
||||
namespace Agc::Command {
|
||||
|
||||
void Require(bool condition, const char* function, const char* reason);
|
||||
void CheckBits(std::uint64_t value, std::uint64_t mask, const char* function);
|
||||
void CheckAddress(std::uint64_t address, std::uint32_t alignment, const char* function);
|
||||
std::uint32_t Header(std::uint32_t opcode, std::uint32_t count, std::uint32_t flags = 0);
|
||||
std::uint32_t* Allocate(CommandBuffer* buffer, std::uint32_t count, const char* function);
|
||||
std::uint32_t* Emit(CommandBuffer* buffer, std::uint32_t opcode, std::initializer_list<std::uint32_t> payload, const char* function);
|
||||
void ValidatePacket(const std::uint32_t* packet, std::uint32_t opcode, std::uint32_t count, const char* function);
|
||||
std::uint32_t* WriteNop(CommandBuffer* buffer, std::uint32_t count, const char* function);
|
||||
std::uint32_t* WriteRegisterRange(CommandBuffer* buffer, std::uint32_t opcode, std::uint32_t offset, const std::uint32_t* values, std::uint32_t count, const char* function);
|
||||
std::uint32_t* WriteRegisters(CommandBuffer* buffer, std::uint32_t opcode, const volatile ShaderRegister* registers, std::uint32_t count, bool snapshotAll, const char* function);
|
||||
std::uint32_t* WriteIndirectRegisters(CommandBuffer* buffer, std::uint32_t opcode, const volatile ShaderRegister* registers, std::uint32_t count, const char* function);
|
||||
void PatchIndirectAddress(std::uint32_t* packet, std::uint32_t opcode, const volatile ShaderRegister* registers, const char* function);
|
||||
void PatchIndirectCount(std::uint32_t* packet, std::uint32_t opcode, std::uint32_t count, const char* function);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,3 +1,4 @@
|
||||
#include "prx/libSceAgc/Command/Packet.hpp"
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include "SceTypes.hpp"
|
||||
@@ -122,11 +123,9 @@ uint32_t APS5_VABI sceAgcDcbDrawIndirectGetSize(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t* APS5_VABI sceAgcDcbSetIndexBuffer(CommandBuffer* buf, uint64_t index_addr) {
|
||||
(void)buf;
|
||||
(void)index_addr;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return nullptr;
|
||||
std::uint32_t* APS5_VABI sceAgcDcbSetIndexBuffer(CommandBuffer* buf, std::uint64_t indexAddress) {
|
||||
Agc::Command::CheckAddress(indexAddress, 2, __func__);
|
||||
return Agc::Command::Emit(buf, 0x26u, {static_cast<std::uint32_t>(indexAddress), static_cast<std::uint32_t>(indexAddress >> 32u)}, __func__);
|
||||
}
|
||||
|
||||
uint32_t* APS5_VABI sceAgcDcbSetIndexCount(CommandBuffer* buf, uint32_t index_count) {
|
||||
@@ -136,24 +135,18 @@ uint32_t* APS5_VABI sceAgcDcbSetIndexCount(CommandBuffer* buf, uint32_t index_co
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint32_t* APS5_VABI sceAgcDcbSetIndexSize(CommandBuffer* buf, uint8_t index_size, uint8_t cache_policy) {
|
||||
(void)buf;
|
||||
(void)index_size;
|
||||
(void)cache_policy;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return nullptr;
|
||||
std::uint32_t* APS5_VABI sceAgcDcbSetIndexSize(CommandBuffer* buf, std::uint8_t indexSize, std::uint8_t cachePolicy) {
|
||||
Agc::Command::Require(indexSize <= 2, __func__, "invalid index element size");
|
||||
Agc::Command::CheckBits(cachePolicy, 3, __func__);
|
||||
return Agc::Command::Emit(buf, 0x7au, {0x20000243u, 0x400u | indexSize | (static_cast<std::uint32_t>(cachePolicy) << 6u)}, __func__);
|
||||
}
|
||||
|
||||
uint32_t* APS5_VABI sceAgcDcbSetNumInstances(CommandBuffer* buf, uint32_t num_instances) {
|
||||
(void)buf;
|
||||
(void)num_instances;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return nullptr;
|
||||
std::uint32_t* APS5_VABI sceAgcDcbSetNumInstances(CommandBuffer* buf, std::uint32_t numInstances) {
|
||||
return Agc::Command::Emit(buf, 0x2fu, {numInstances}, __func__);
|
||||
}
|
||||
|
||||
uint32_t APS5_VABI sceAgcDcbSetNumInstancesGetSize(void) {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
std::uint32_t APS5_VABI sceAgcDcbSetNumInstancesGetSize() {
|
||||
return 8;
|
||||
}
|
||||
|
||||
uint32_t* APS5_VABI sceAgcDcbSetBaseIndirectArgs(CommandBuffer* buf, uint32_t shader_type, const volatile void* indirect_base_addr) {
|
||||
@@ -164,17 +157,16 @@ uint32_t* APS5_VABI sceAgcDcbSetBaseIndirectArgs(CommandBuffer* buf, uint32_t sh
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint32_t* APS5_VABI sceAgcDcbGetLodStats(CommandBuffer* buf, uint8_t cache_policy, const volatile void* buffer, uint32_t buffer_size_in_bytes, uint32_t reset_count, uint8_t force_reset, uint8_t report_and_reset, uint32_t reporting_interval_in_100k_clocks) {
|
||||
(void)buf;
|
||||
(void)cache_policy;
|
||||
(void)buffer;
|
||||
(void)buffer_size_in_bytes;
|
||||
(void)reset_count;
|
||||
(void)force_reset;
|
||||
(void)report_and_reset;
|
||||
(void)reporting_interval_in_100k_clocks;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return nullptr;
|
||||
std::uint32_t* APS5_VABI sceAgcDcbGetLodStats(CommandBuffer* buf, std::uint8_t cachePolicy, const volatile void* buffer, std::uint32_t bufferSizeInBytes, std::uint32_t resetCount, std::uint8_t forceReset, std::uint8_t reportAndReset, std::uint32_t reportingIntervalIn100kClocks) {
|
||||
Agc::Command::CheckBits(cachePolicy, 3, __func__);
|
||||
Agc::Command::CheckBits(resetCount, 0xffu, __func__);
|
||||
Agc::Command::CheckBits(forceReset, 1, __func__);
|
||||
Agc::Command::CheckBits(reportAndReset, 1, __func__);
|
||||
Agc::Command::CheckBits(reportingIntervalIn100kClocks, 0xffu, __func__);
|
||||
const auto address = reinterpret_cast<std::uintptr_t>(buffer);
|
||||
Agc::Command::CheckAddress(address, 64, __func__);
|
||||
const auto control = (static_cast<std::uint32_t>(cachePolicy) << 28u) | (static_cast<std::uint32_t>(reportAndReset) << 19u) | (static_cast<std::uint32_t>(forceReset) << 18u) | (resetCount << 10u) | (reportingIntervalIn100kClocks << 2u);
|
||||
return Agc::Command::Emit(buf, 0x8eu, {bufferSizeInBytes, static_cast<std::uint32_t>(address), static_cast<std::uint32_t>(address >> 32u), control}, __func__);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#include "prx/libSceAgc/Command/Memory.hpp"
|
||||
#include "prx/libSceAgc/Command/Packet.hpp"
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include "SceTypes.hpp"
|
||||
@@ -50,21 +52,8 @@ uint32_t* APS5_VABI sceAgcDcbCopyData(CommandBuffer* buf, uint8_t dst, uint8_t d
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint32_t* APS5_VABI sceAgcDcbDmaData(CommandBuffer* buf, uint8_t engine, uint8_t dst, uint8_t dst_cache_policy, uint64_t dst_address_or_offset, uint8_t src, uint8_t src_cache_policy, uint64_t src_address_or_offset_or_immediate, uint32_t num_bytes, uint8_t wait_for_previous, uint8_t write_confirm, uint8_t block_engine) {
|
||||
(void)buf;
|
||||
(void)engine;
|
||||
(void)dst;
|
||||
(void)dst_cache_policy;
|
||||
(void)dst_address_or_offset;
|
||||
(void)src;
|
||||
(void)src_cache_policy;
|
||||
(void)src_address_or_offset_or_immediate;
|
||||
(void)num_bytes;
|
||||
(void)wait_for_previous;
|
||||
(void)write_confirm;
|
||||
(void)block_engine;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return nullptr;
|
||||
std::uint32_t* APS5_VABI sceAgcDcbDmaData(CommandBuffer* buf, std::uint8_t engine, std::uint8_t dst, std::uint8_t dstCachePolicy, std::uint64_t dstAddress, std::uint8_t src, std::uint8_t srcCachePolicy, std::uint64_t srcAddress, std::uint32_t numBytes, std::uint8_t waitForPrevious, std::uint8_t writeConfirm, std::uint8_t blockEngine) {
|
||||
return Agc::Command::WriteDma(buf, false, engine, dst, dstCachePolicy, dstAddress, src, srcCachePolicy, srcAddress, numBytes, waitForPrevious, writeConfirm, blockEngine, __func__);
|
||||
}
|
||||
|
||||
uint32_t* APS5_VABI sceAgcDcbDispatchIndirect(CommandBuffer* buf, uint32_t data_offset_in_bytes, uint32_t flags) {
|
||||
@@ -80,12 +69,16 @@ uint32_t APS5_VABI sceAgcDcbDispatchIndirectGetSize(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t* APS5_VABI sceAgcDcbEventWrite(CommandBuffer* buf, uint8_t event_type, const volatile void* address) {
|
||||
(void)buf;
|
||||
(void)event_type;
|
||||
(void)address;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return nullptr;
|
||||
std::uint32_t* APS5_VABI sceAgcDcbEventWrite(CommandBuffer* buf, std::uint8_t eventType, const volatile void* address) {
|
||||
Agc::Command::CheckBits(eventType, 0x3fu, __func__);
|
||||
if ((eventType & 0xfeu) == 0x38u) {
|
||||
const auto guestAddress = reinterpret_cast<std::uintptr_t>(address);
|
||||
Agc::Command::CheckAddress(guestAddress, 8, __func__);
|
||||
return Agc::Command::Emit(buf, 0x46u, {0x100u | eventType, static_cast<std::uint32_t>(guestAddress), static_cast<std::uint32_t>(guestAddress >> 32u)}, __func__);
|
||||
}
|
||||
Agc::Command::Require(address == nullptr, __func__, "this event does not use an address");
|
||||
const auto eventIndex = eventType == 7 || eventType == 15 || eventType == 16 ? 0x400u : 0u;
|
||||
return Agc::Command::Emit(buf, 0x46u, {eventIndex | eventType}, __func__);
|
||||
}
|
||||
|
||||
uint32_t* APS5_VABI sceAgcDcbJump(CommandBuffer* buf, uint8_t mode, uint8_t cache_policy, const uint32_t* target, uint32_t size_in_dwords) {
|
||||
@@ -133,24 +126,12 @@ uint32_t APS5_VABI sceAgcDcbRewindGetSize(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t* APS5_VABI sceAgcDcbStallCommandBufferParser(CommandBuffer* buf) {
|
||||
(void)buf;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return nullptr;
|
||||
std::uint32_t* APS5_VABI sceAgcDcbStallCommandBufferParser(CommandBuffer* buf) {
|
||||
return Agc::Command::Emit(buf, 0x42u, {0}, __func__);
|
||||
}
|
||||
|
||||
uint32_t* APS5_VABI sceAgcDcbWaitRegMem(CommandBuffer* buf, uint8_t size, uint8_t compare_function, uint8_t op, uint8_t cache_policy, const volatile void* address, uint64_t reference, uint64_t mask, uint32_t poll_cycles) {
|
||||
(void)buf;
|
||||
(void)size;
|
||||
(void)compare_function;
|
||||
(void)op;
|
||||
(void)cache_policy;
|
||||
(void)address;
|
||||
(void)reference;
|
||||
(void)mask;
|
||||
(void)poll_cycles;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return nullptr;
|
||||
std::uint32_t* APS5_VABI sceAgcDcbWaitRegMem(CommandBuffer* buf, std::uint8_t size, std::uint8_t compareFunction, std::uint8_t operation, std::uint8_t cachePolicy, const volatile void* address, std::uint64_t reference, std::uint64_t mask, std::uint32_t pollCycles) {
|
||||
return Agc::Command::WriteWait(buf, size, compareFunction, operation, cachePolicy, address, reference, mask, pollCycles, __func__);
|
||||
}
|
||||
|
||||
uint32_t APS5_VABI sceAgcDcbWaitOnAddressGetSize(uint32_t size) {
|
||||
@@ -167,17 +148,8 @@ uint32_t* APS5_VABI sceAgcDcbWaitUntilSafeForRendering(CommandBuffer* buf, uint3
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint32_t* APS5_VABI sceAgcDcbWriteData(CommandBuffer* buf, uint8_t dst, uint8_t cache_policy, uint64_t address_or_offset, const void* data, uint32_t num_dwords, uint8_t increment, uint8_t write_confirm) {
|
||||
(void)buf;
|
||||
(void)dst;
|
||||
(void)cache_policy;
|
||||
(void)address_or_offset;
|
||||
(void)data;
|
||||
(void)num_dwords;
|
||||
(void)increment;
|
||||
(void)write_confirm;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return nullptr;
|
||||
std::uint32_t* APS5_VABI sceAgcDcbWriteData(CommandBuffer* buf, std::uint8_t dst, std::uint8_t cachePolicy, std::uint64_t address, const void* data, std::uint32_t numDwords, std::uint8_t increment, std::uint8_t writeConfirm) {
|
||||
return Agc::Command::WriteData(buf, false, dst, cachePolicy, address, data, numDwords, increment, writeConfirm, __func__);
|
||||
}
|
||||
|
||||
uint32_t APS5_VABI sceAgcDcbWriteDataGetSize(uint32_t num_dwords) {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include "prx/libSceAgc/Command/Packet.hpp"
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include "SceTypes.hpp"
|
||||
@@ -22,15 +23,13 @@ uint32_t APS5_VABI sceAgcDcbQueueEndOfShaderActionGetSize() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t APS5_VABI sceAgcDcbGetLodStatsGetSize() {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
std::uint32_t APS5_VABI sceAgcDcbGetLodStatsGetSize() {
|
||||
return 20;
|
||||
}
|
||||
|
||||
uint32_t APS5_VABI sceAgcDcbSetShRegistersIndirectGetSize(uint32_t num_regs) {
|
||||
(void)num_regs;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
std::uint32_t APS5_VABI sceAgcDcbSetShRegistersIndirectGetSize(std::uint32_t numRegs) {
|
||||
Agc::Command::CheckBits(numRegs, 0x3fffu, __func__);
|
||||
return 20;
|
||||
}
|
||||
|
||||
uint32_t APS5_VABI sceAgcDcbSetBaseDrawIndirectArgsGetSize() {
|
||||
@@ -49,12 +48,8 @@ uint32_t APS5_VABI sceAgcDcbSetCxRegisterDirectGetSize(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t* APS5_VABI sceAgcDcbSetCxRegistersIndirect(CommandBuffer* buf, const volatile ShaderRegister* regs, uint32_t num_regs) {
|
||||
(void)buf;
|
||||
(void)regs;
|
||||
(void)num_regs;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return nullptr;
|
||||
std::uint32_t* APS5_VABI sceAgcDcbSetCxRegistersIndirect(CommandBuffer* buf, const volatile ShaderRegister* regs, std::uint32_t numRegs) {
|
||||
return Agc::Command::WriteIndirectRegisters(buf, 0x9fu, regs, numRegs, __func__);
|
||||
}
|
||||
|
||||
uint32_t* APS5_VABI sceAgcDcbSetShRegisterDirect(CommandBuffer* buf, ShaderRegister reg) {
|
||||
@@ -64,12 +59,8 @@ uint32_t* APS5_VABI sceAgcDcbSetShRegisterDirect(CommandBuffer* buf, ShaderRegis
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint32_t* APS5_VABI sceAgcDcbSetShRegistersIndirect(CommandBuffer* buf, const volatile ShaderRegister* regs, uint32_t num_regs) {
|
||||
(void)buf;
|
||||
(void)regs;
|
||||
(void)num_regs;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return nullptr;
|
||||
std::uint32_t* APS5_VABI sceAgcDcbSetShRegistersIndirect(CommandBuffer* buf, const volatile ShaderRegister* regs, std::uint32_t numRegs) {
|
||||
return Agc::Command::WriteIndirectRegisters(buf, 0x63u, regs, numRegs, __func__);
|
||||
}
|
||||
|
||||
uint32_t* APS5_VABI sceAgcDcbSetUcRegisterDirect(CommandBuffer* buf, ShaderRegister reg) {
|
||||
@@ -79,12 +70,8 @@ uint32_t* APS5_VABI sceAgcDcbSetUcRegisterDirect(CommandBuffer* buf, ShaderRegis
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint32_t* APS5_VABI sceAgcDcbSetUcRegistersIndirect(CommandBuffer* buf, const volatile ShaderRegister* regs, uint32_t num_regs) {
|
||||
(void)buf;
|
||||
(void)regs;
|
||||
(void)num_regs;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return nullptr;
|
||||
std::uint32_t* APS5_VABI sceAgcDcbSetUcRegistersIndirect(CommandBuffer* buf, const volatile ShaderRegister* regs, std::uint32_t numRegs) {
|
||||
return Agc::Command::WriteIndirectRegisters(buf, 0x64u, regs, numRegs, __func__);
|
||||
}
|
||||
|
||||
uint32_t* APS5_VABI sceAgcDcbContextStateOp(CommandBuffer* buf, uint32_t operation) {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#include "prx/libSceAgc/Command/Memory.hpp"
|
||||
#include "prx/libSceAgc/Command/Packet.hpp"
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include "SceTypes.hpp"
|
||||
@@ -5,18 +7,18 @@
|
||||
|
||||
extern "C" {
|
||||
|
||||
int APS5_VABI sceAgcDmaDataPatchSetDstAddressOrOffset(uint32_t* cmd, uint64_t dst_address_or_offset) {
|
||||
(void)cmd;
|
||||
(void)dst_address_or_offset;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
int APS5_VABI sceAgcDmaDataPatchSetDstAddressOrOffset(std::uint32_t* cmd, std::uint64_t address) {
|
||||
Agc::Command::ValidatePacket(cmd, 0x50u, 7, __func__);
|
||||
cmd[4] = static_cast<std::uint32_t>(address);
|
||||
cmd[5] = static_cast<std::uint32_t>(address >> 32u);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI sceAgcDmaDataPatchSetSrcAddressOrOffsetOrImmediate(uint32_t* cmd, uint64_t src_address_or_offset_or_immediate) {
|
||||
(void)cmd;
|
||||
(void)src_address_or_offset_or_immediate;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
int APS5_VABI sceAgcDmaDataPatchSetSrcAddressOrOffsetOrImmediate(std::uint32_t* cmd, std::uint64_t address) {
|
||||
Agc::Command::ValidatePacket(cmd, 0x50u, 7, __func__);
|
||||
cmd[2] = static_cast<std::uint32_t>(address);
|
||||
cmd[3] = static_cast<std::uint32_t>(address >> 32u);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI sceAgcJumpPatchSetTarget(uint32_t* cmd, const volatile uint32_t* target, uint32_t size_in_dwords) {
|
||||
@@ -34,11 +36,8 @@ int APS5_VABI sceAgcQueueEndOfPipeActionPatchAddress(uint32_t* cmd, const volati
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t* APS5_VABI sceAgcSetNop(CommandBuffer* buf, uint32_t size_dw) {
|
||||
(void)buf;
|
||||
(void)size_dw;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return nullptr;
|
||||
std::uint32_t* APS5_VABI sceAgcSetNop(CommandBuffer* buf, std::uint32_t sizeDw) {
|
||||
return Agc::Command::WriteNop(buf, sizeDw, __func__);
|
||||
}
|
||||
|
||||
int APS5_VABI sceAgcQueueEndOfPipeActionPatchData(uint32_t* cmd, uint32_t context_id, uint32_t data_sel, uint64_t data) {
|
||||
@@ -57,18 +56,24 @@ int APS5_VABI sceAgcRewindPatchSetRewindState(uint32_t* cmd, uint8_t state) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI sceAgcWaitRegMemPatchAddress(uint32_t* cmd, const volatile void* address) {
|
||||
(void)cmd;
|
||||
(void)address;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
int APS5_VABI sceAgcWaitRegMemPatchAddress(std::uint32_t* cmd, const volatile void* address) {
|
||||
auto* wait = Agc::Command::ValidateWait(cmd, __func__);
|
||||
const auto guestAddress = reinterpret_cast<std::uintptr_t>(address);
|
||||
const auto alignment = ((wait[0] >> 8u) & 0xffu) == 0x3cu ? 4u : 8u;
|
||||
Agc::Command::CheckAddress(guestAddress, alignment, __func__);
|
||||
Agc::Command::CheckBits(guestAddress, 0xffffffffffffull, __func__);
|
||||
cmd[2] = (cmd[2] & 0xffff0000u) | static_cast<std::uint32_t>(guestAddress >> 32u);
|
||||
cmd[3] = static_cast<std::uint32_t>(guestAddress);
|
||||
wait[2] = static_cast<std::uint32_t>(guestAddress);
|
||||
wait[3] = static_cast<std::uint32_t>(guestAddress >> 32u);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI sceAgcWaitRegMemPatchReference(uint32_t* cmd, uint64_t reference) {
|
||||
(void)cmd;
|
||||
(void)reference;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
int APS5_VABI sceAgcWaitRegMemPatchReference(std::uint32_t* cmd, std::uint64_t reference) {
|
||||
auto* wait = Agc::Command::ValidateWait(cmd, __func__);
|
||||
Agc::Command::CheckBits(reference, 0xffffffffu, __func__);
|
||||
wait[4] = static_cast<std::uint32_t>(reference);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI sceAgcCondExecPatchSetCommandAddress(uint32_t* cmd, const volatile uint32_t* command) {
|
||||
@@ -85,18 +90,14 @@ int APS5_VABI sceAgcCondExecPatchSetEnd(uint32_t* cmd, const volatile uint32_t*
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI sceAgcSetCxRegIndirectPatchAddRegisters(uint32_t* cmd, uint32_t num_regs) {
|
||||
(void)cmd;
|
||||
(void)num_regs;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
int APS5_VABI sceAgcSetCxRegIndirectPatchAddRegisters(std::uint32_t* cmd, std::uint32_t numRegs) {
|
||||
Agc::Command::PatchIndirectCount(cmd, 0x9fu, numRegs, __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI sceAgcSetCxRegIndirectPatchSetAddress(uint32_t* cmd, const volatile ShaderRegister* regs) {
|
||||
(void)cmd;
|
||||
(void)regs;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
int APS5_VABI sceAgcSetCxRegIndirectPatchSetAddress(std::uint32_t* cmd, const volatile ShaderRegister* regs) {
|
||||
Agc::Command::PatchIndirectAddress(cmd, 0x9fu, regs, __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI sceAgcSetCxRegIndirectPatchSetNumRegisters(uint32_t* cmd, uint32_t num_regs) {
|
||||
@@ -106,18 +107,14 @@ int APS5_VABI sceAgcSetCxRegIndirectPatchSetNumRegisters(uint32_t* cmd, uint32_t
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI sceAgcSetShRegIndirectPatchAddRegisters(uint32_t* cmd, uint32_t num_regs) {
|
||||
(void)cmd;
|
||||
(void)num_regs;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
int APS5_VABI sceAgcSetShRegIndirectPatchAddRegisters(std::uint32_t* cmd, std::uint32_t numRegs) {
|
||||
Agc::Command::PatchIndirectCount(cmd, 0x63u, numRegs, __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI sceAgcSetShRegIndirectPatchSetAddress(uint32_t* cmd, const volatile ShaderRegister* regs) {
|
||||
(void)cmd;
|
||||
(void)regs;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
int APS5_VABI sceAgcSetShRegIndirectPatchSetAddress(std::uint32_t* cmd, const volatile ShaderRegister* regs) {
|
||||
Agc::Command::PatchIndirectAddress(cmd, 0x63u, regs, __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI sceAgcSetShRegIndirectPatchSetNumRegisters(uint32_t* cmd, uint32_t num_regs) {
|
||||
@@ -127,18 +124,14 @@ int APS5_VABI sceAgcSetShRegIndirectPatchSetNumRegisters(uint32_t* cmd, uint32_t
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI sceAgcSetUcRegIndirectPatchAddRegisters(uint32_t* cmd, uint32_t num_regs) {
|
||||
(void)cmd;
|
||||
(void)num_regs;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
int APS5_VABI sceAgcSetUcRegIndirectPatchAddRegisters(std::uint32_t* cmd, std::uint32_t numRegs) {
|
||||
Agc::Command::PatchIndirectCount(cmd, 0x64u, numRegs, __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI sceAgcSetUcRegIndirectPatchSetAddress(uint32_t* cmd, const volatile ShaderRegister* regs) {
|
||||
(void)cmd;
|
||||
(void)regs;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
int APS5_VABI sceAgcSetUcRegIndirectPatchSetAddress(std::uint32_t* cmd, const volatile ShaderRegister* regs) {
|
||||
Agc::Command::PatchIndirectAddress(cmd, 0x64u, regs, __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI sceAgcSetUcRegIndirectPatchSetNumRegisters(uint32_t* cmd, uint32_t num_regs) {
|
||||
|
||||
Reference in New Issue
Block a user