Merge pull request #2073 from jdmagic/fix/ampr-clearbuffer-returns-buffer

fix(libSceAmpr): sceAmprCommandBufferClearBuffer returns the detached buffer
This commit is contained in:
Dean
2026-10-09 22:41:40 +13:00
committed by GitHub
2 changed files with 14 additions and 2 deletions
+3 -2
View File
@@ -320,12 +320,13 @@ int APS5_VABI sceAmprAprCommandBufferResetGatherScatterState(Apr::CommandBufferO
return result;
}
int APS5_VABI sceAmprCommandBufferClearBuffer(Apr::CommandBufferObject* buffer) {
void* APS5_VABI sceAmprCommandBufferClearBuffer(Apr::CommandBufferObject* buffer) {
void* memory = buffer->base;
buffer->base = nullptr;
buffer->size = 0;
buffer->offset = 0;
buffer->numCommands = 0;
return 0;
return memory;
}
int APS5_VABI sceAmprCommandBufferConstructMarker(Apr::CommandBufferObject* buffer, std::uint32_t type, const char* text, const std::uint32_t* color) {
+11
View File
@@ -16,6 +16,7 @@ extern "C" {
int APS5_VABI sceAmprCommandBufferConstructor(Apr::CommandBufferObject*);
int APS5_VABI sceAmprAprCommandBufferConstructor(Apr::CommandBufferObject*, std::uint64_t*, std::uint64_t*);
int APS5_VABI sceAmprCommandBufferSetBuffer(Apr::CommandBufferObject*, void*, std::uint32_t);
void* APS5_VABI sceAmprCommandBufferClearBuffer(Apr::CommandBufferObject*);
std::uint32_t APS5_VABI sceAmprCommandBufferGetCurrentOffset(const Apr::CommandBufferObject*);
std::uint32_t APS5_VABI sceAmprCommandBufferGetNumCommands(const Apr::CommandBufferObject*);
int APS5_VABI sceAmprCommandBufferWriteAddressOnCompletion(Apr::CommandBufferObject*, volatile std::uint64_t*, std::uint64_t);
@@ -446,6 +447,15 @@ void TestVersionedCounters() {
Require(sceAmprMeasureCommandSizeWriteCounter_04_00(0, size4, 0, 5) == rejected);
}
void TestClearBuffer() {
Recorder recorder;
Require(sceAmprCommandBufferNop(&recorder.buffer, 1) == 0);
Require(recorder.Offset() != 0 && recorder.Commands() == 1);
Require(sceAmprCommandBufferClearBuffer(&recorder.buffer) == recorder.memory.data());
Require(recorder.buffer.base == nullptr && recorder.buffer.size == 0 && recorder.Offset() == 0 && recorder.Commands() == 0);
Require(sceAmprCommandBufferClearBuffer(&recorder.buffer) == nullptr);
}
void TestConstructed() {
Recorder recorder;
const std::uint8_t payload[5] = {1, 2, 3, 4, 5};
@@ -937,6 +947,7 @@ int main() {
TestNops();
TestVersionedCommands();
TestVersionedCounters();
TestClearBuffer();
TestConstructed();
TestGatherScatter();
TestAmm();