Merge pull request #489 from oneandonlydean/feat/audiopropagation-source-render

feat(libSceAudioPropagation): render silence for propagated sources
This commit is contained in:
Dean
2026-10-05 11:44:05 +13:00
committed by GitHub
4 changed files with 105 additions and 8 deletions
@@ -15,6 +15,7 @@ inline constexpr std::uint32_t SystemMemoryId = 0x010107d4;
inline constexpr std::size_t SystemMemorySize = 0x30;
inline constexpr std::uint32_t RenderInfoId = 0x010107d6;
inline constexpr std::size_t RenderInfoSize = 0x30;
inline constexpr std::uint32_t RenderFormat = 2;
inline constexpr std::uint32_t RayId = 0x010107d7;
inline constexpr std::size_t RaySize = 0x58;
inline constexpr std::uint32_t PortalParamsId = 0x010107d8;
@@ -31,6 +32,15 @@ struct Attribute {
std::uint32_t reserved2;
};
struct RenderInfo {
AudioPropagationStructDescriptor desc;
AudioPropagationHandle source;
void* output;
std::size_t outputSize;
std::uint32_t format;
std::uint32_t reserved;
};
struct PortalParams {
AudioPropagationStructDescriptor desc;
float rows[4][4];
@@ -40,6 +50,9 @@ struct PortalParams {
static_assert(sizeof(AudioPropagationStructDescriptor) == 0x10);
static_assert(sizeof(AudioPropagationSystemMemory) == SystemMemorySize);
static_assert(sizeof(Attribute) == 0x20);
static_assert(sizeof(RenderInfo) == RenderInfoSize);
static_assert(offsetof(RenderInfo, source) == 0x10);
static_assert(offsetof(RenderInfo, format) == 0x28);
static_assert(sizeof(PortalParams) == PortalParamsSize);
static_assert(offsetof(PortalParams, rooms) == 0x50);
@@ -68,7 +81,7 @@ std::int32_t APS5_VABI sceAudioPropagationSourceGetAudioPath(AudioPropagationHan
std::int32_t APS5_VABI sceAudioPropagationSourceGetRays(AudioPropagationHandle source, void* rays, std::uint32_t* count);
std::int32_t APS5_VABI sceAudioPropagationSourceCalculateAudioPaths(AudioPropagationHandle source, const void* rays, std::uint32_t rayCount, std::uint32_t flags, void* paths, std::uint32_t pathCount);
std::int32_t APS5_VABI sceAudioPropagationSourceSetAudioPaths(AudioPropagationHandle source, const void* entries, std::uint32_t count);
std::int32_t APS5_VABI sceAudioPropagationSourceRender(AudioPropagationHandle system, const AudioPropagationStructDescriptor* renderInfo);
std::int32_t APS5_VABI sceAudioPropagationSourceRender(AudioPropagationHandle system, const AudioPropagation::RenderInfo* infos, std::uint32_t count);
}
@@ -1,6 +1,7 @@
#include "AudioPropagation.hpp"
#include <cstdint>
#include <cstring>
#include <mutex>
#include <stdexcept>
#include <string>
@@ -290,10 +291,19 @@ std::int32_t APS5_VABI sceAudioPropagationSourceSetAudioPaths(AudioPropagationHa
return 0;
}
std::int32_t APS5_VABI sceAudioPropagationSourceRender(AudioPropagationHandle system, const AudioPropagationStructDescriptor* renderInfo) {
static_cast<void>(system);
static_cast<void>(renderInfo);
NotImplemented_nid_no_patch(__func__);
std::int32_t APS5_VABI sceAudioPropagationSourceRender(AudioPropagationHandle system, const RenderInfo* infos, std::uint32_t count) {
require(infos != nullptr && count != 0, __func__);
auto& state = registry();
std::lock_guard lock(state.mutex);
requireSystem(state, system, __func__);
for (std::uint32_t index = 0; index < count; ++index) {
const auto& info = infos[index];
requireDescriptor(&info.desc, RenderInfoId, RenderInfoSize, __func__);
require(requireObject(state, info.source, Kind::Source, __func__).system == system, __func__);
require(info.output != nullptr && info.outputSize != 0, __func__);
if (info.format != RenderFormat) throw std::runtime_error(std::string(__func__) + ": render format " + std::to_string(info.format) + " is unknown");
}
for (std::uint32_t index = 0; index < count; ++index) std::memset(infos[index].output, 0, infos[index].outputSize);
return 0;
}
+75 -1
View File
@@ -3,6 +3,7 @@
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <stdexcept>
namespace {
@@ -129,7 +130,80 @@ int main() {
RequireThrows<std::runtime_error>([&] { sceAudioPropagationSourceCalculateAudioPaths(source, rays, 1, 1, nullptr, 0); }, "path calculation with rays");
Require(sceAudioPropagationSourceSetAudioPaths(source, nullptr, 0) == 0, "empty audio paths failed");
RequireThrows<std::runtime_error>([&] { sceAudioPropagationSourceSetAudioPaths(source, rays, 1); }, "set audio paths");
RequireThrows<std::runtime_error>([&] { sceAudioPropagationSourceRender(system, nullptr); }, "render is not modelled");
alignas(16) std::uint8_t otherArena[64]{};
auto otherMemory = Memory();
Require(sceAudioPropagationSystemQueryMemory(options, &otherMemory) == 0, "second query memory failed");
otherMemory.p_cpu_mem = otherArena;
AudioPropagationHandle otherSystem = 0;
Require(sceAudioPropagationSystemCreate(options, &otherMemory, &otherSystem) == 0, "second system create failed");
AudioPropagationHandle otherSource = 0;
Require(sceAudioPropagationSourceCreate(otherSystem, &otherSource) == 0, "second system source create failed");
AudioPropagationHandle secondSource = 0;
Require(sceAudioPropagationSourceCreate(system, &secondSource) == 0, "second source create failed");
float outputs[2][64];
const auto fill = [&] { std::memset(outputs, 0xab, sizeof(outputs)); };
const auto zeroed = [&](int index) {
for (const float sample : outputs[index]) {
if (sample != 0.0f) return false;
}
return true;
};
const auto untouched = [&] {
const auto* bytes = reinterpret_cast<const std::uint8_t*>(outputs);
for (std::size_t index = 0; index < sizeof(outputs); ++index) {
if (bytes[index] != 0xab) return false;
}
return true;
};
AudioPropagation::RenderInfo infos[2]{};
const auto reset = [&] {
infos[0] = {{AudioPropagation::RenderInfoId, AudioPropagation::RenderInfoSize}, source, outputs[0], sizeof(outputs[0]), AudioPropagation::RenderFormat, 0};
infos[1] = {{AudioPropagation::RenderInfoId, AudioPropagation::RenderInfoSize}, secondSource, outputs[1], sizeof(outputs[1]), AudioPropagation::RenderFormat, 0};
fill();
};
reset();
Require(sceAudioPropagationSourceRender(system, infos, 1) == 0, "render failed");
Require(zeroed(0), "render left the output unwritten");
const auto* tail = reinterpret_cast<const std::uint8_t*>(outputs[1]);
Require(tail[0] == 0xab, "render wrote past the output size");
reset();
infos[0].outputSize = sizeof(float) * 16;
Require(sceAudioPropagationSourceRender(system, infos, 2) == 0, "render of two sources failed");
Require(outputs[0][15] == 0.0f && outputs[0][16] != 0.0f && zeroed(1), "render did not write each output for its size");
reset();
RequireThrows<std::invalid_argument>([&] { sceAudioPropagationSourceRender(system, infos, 0); }, "render without infos");
RequireThrows<std::invalid_argument>([&] { sceAudioPropagationSourceRender(system, nullptr, 1); }, "render with null infos");
RequireThrows<std::invalid_argument>([&] { sceAudioPropagationSourceRender(system + 16, infos, 1); }, "render on an unknown system");
infos[1].desc.id = AudioPropagation::RayId;
RequireThrows<std::invalid_argument>([&] { sceAudioPropagationSourceRender(system, infos, 2); }, "render info with a wrong descriptor id");
Require(untouched(), "rejected render wrote an output");
reset();
infos[0].desc.size = 0x28;
RequireThrows<std::invalid_argument>([&] { sceAudioPropagationSourceRender(system, infos, 1); }, "render info with a wrong descriptor size");
reset();
infos[0].source = rooms[0];
RequireThrows<std::invalid_argument>([&] { sceAudioPropagationSourceRender(system, infos, 1); }, "render of a room");
reset();
infos[0].source = otherSource;
RequireThrows<std::invalid_argument>([&] { sceAudioPropagationSourceRender(system, infos, 1); }, "render of another system's source");
reset();
infos[0].output = nullptr;
RequireThrows<std::invalid_argument>([&] { sceAudioPropagationSourceRender(system, infos, 1); }, "render without output");
reset();
infos[0].outputSize = 0;
RequireThrows<std::invalid_argument>([&] { sceAudioPropagationSourceRender(system, infos, 1); }, "render with an empty output");
reset();
infos[1].format = 1;
RequireThrows<std::runtime_error>([&] { sceAudioPropagationSourceRender(system, infos, 2); }, "render with an unknown format");
Require(untouched(), "render with an unknown format wrote an output");
Require(sceAudioPropagationSourceDestroy(system, secondSource) == 0, "second source destroy failed");
reset();
RequireThrows<std::invalid_argument>([&] { sceAudioPropagationSourceRender(system, infos, 2); }, "render of a destroyed source");
Require(sceAudioPropagationSystemDestroy(otherSystem) == 0, "second system destroy failed");
RequireThrows<std::invalid_argument>([&] { sceAudioPropagationRoomDestroy(system, source); }, "room destroy of a source");
RequireThrows<std::invalid_argument>([&] { sceAudioPropagationSourceDestroy(system + 16, source); }, "source destroy with another system");
+2 -2
View File
@@ -14,7 +14,7 @@ Throughout the project, every function at every stage either **does exactly what
- [libSceSaveDataDialog.native](../../core/libs/prx/libSceSaveDataDialog.native/Export.cpp)
- [libSceCommonDialog](../../core/libs/prx/libSceCommonDialog/Export.cpp)
- [libSceHmd](../../core/libs/prx/libSceHmd/Export.cpp) implements only the disconnected-headset path: initialization succeeds, device queries report `NotDetected`, and opening a device returns `DeviceDisconnected`. Headset support, tracking, rendering and additional HMD exports are not implemented; SDK-level ABI compatibility and in-game behaviour remain unverified.
- [libSceAudioPropagation](../../core/libs/prx/libSceAudioPropagation/Export.cpp) implements only the no-acoustic-propagation path: the system keeps a 16-byte header in the title's CPU memory (no GPU memory), rooms, portals, sources and materials are tracked handles, attributes are validated and have no effect, no rays are requested and sources report no audio paths. Ray results, path calculation and audio paths are accepted only when empty and throw otherwise; `sceAudioPropagationSourceRender` is not implemented. Objects still alive when their system is destroyed become unusable, and their later destroy or unregister is a no-op: PPSA21567 releases its reference-counted room, portal and source owners just before `sceAudioPropagationSystemDestroy`, so the order for every object is not proven. Occlusion, reflections and reverb from level geometry are absent; in-game behaviour remains unverified.
- [libSceAudioPropagation](../../core/libs/prx/libSceAudioPropagation/Export.cpp) implements only the no-acoustic-propagation path: the system keeps a 16-byte header in the title's CPU memory (no GPU memory), rooms, portals, sources and materials are tracked handles, attributes are validated and have no effect, no rays are requested and sources report no audio paths. Ray results, path calculation and audio paths are accepted only when empty and throw otherwise; `sceAudioPropagationSourceRender` writes silence (zeroes) to each source's output buffer for the given size, without a dry signal. Objects still alive when their system is destroyed become unusable, and their later destroy or unregister is a no-op: PPSA21567 releases its reference-counted room, portal and source owners just before `sceAudioPropagationSystemDestroy`, so the order for every object is not proven. Occlusion, reflections and reverb from level geometry are absent; in-game behaviour remains unverified.
- [libSceNpCommerce](../../core/libs/prx/libSceNpCommerce/Export.cpp) - the PS Store icon show/hide calls do nothing
- [sceVideoOutOpen](../../core/libs/prx/libSceVideoOut/src/Output.cpp) validates the priority and CPU affinity that the open param requests for the VideoOut service thread but does not apply them: the port's present and vblank threads are host threads, and guest priorities and affinities do not reach host scheduling
- The shader recompiler [skips baryctric coordinates](../../core/shader/recompiler/Recompiler.cpp) (is not even passed to SpirvTargetOptions at row 212).
@@ -47,7 +47,7 @@ Throughout the project, every function at every stage either **does exactly what
- [GQTObcITIXI](../../core/libs/prx/libSceShare/Export.cpp) (libSceShare) - unknown name, signature
- [BnMAMrsfVWo](../../core/libs/prx/libc/src/HeapDiagnostics.cpp) (libc) - unknown name, signature
- AudioIn, NpSessionSignaling and PlayerInvitationDialog exports added without an implementation have assumed signatures
- [libSceAudioPropagation](../../core/libs/prx/libSceAudioPropagation/Export.cpp) (libSceAudioPropagation) - signatures and struct descriptors recovered from PPSA21567's calls (#481), not from documentation. The system options layout is unknown (only checked for non-null); the fourth argument of `sceAudioPropagationSourceCalculateAudioPaths` is unknown; `sceAudioPropagationSourceGetAudioPath` is assumed to output an 8-byte path handle. No error code is known, so invalid input throws instead of returning one
- [libSceAudioPropagation](../../core/libs/prx/libSceAudioPropagation/Export.cpp) (libSceAudioPropagation) - signatures and struct descriptors recovered from PPSA21567's calls (#481), not from documentation. The system options layout is unknown (only checked for non-null); the fourth argument of `sceAudioPropagationSourceCalculateAudioPaths` is unknown; `sceAudioPropagationSourceGetAudioPath` is assumed to output an 8-byte path handle. The meaning of the `RenderInfo` word at +0x28 is unknown (PPSA21567 and PPSA21564 pass 2); only 2 is accepted. Both titles pass one `RenderInfo` per call: a count of 0 throws, and larger counts are handled element by element without proof. No error code is known, so invalid input throws instead of returning one
- [sceAvPlayerStartEx](../../core/libs/prx/libSceAvPlayer/Export.cpp) (libSceAvPlayer) - start info layout unknown; it is ignored and playback starts as with `sceAvPlayerStart`
- [sceAvPlayerInit / sceAvPlayerInitEx](../../core/libs/prx/libSceAvPlayer/src/Player.cpp) (libSceAvPlayer) - behaviour without a memory replacement unknown; frame and sample buffers then come from the guest heap
- [SceAvPlayerVideoEx](../../core/libs/SceTypes.hpp) (libSceAvPlayer) - frame rate field and encoding unknown; it is left zero in frame and stream info