From 83ec5869d7584e56120a979a305bcbffeb1a9720 Mon Sep 17 00:00:00 2001 From: Maufeat Date: Sat, 19 Jul 2025 03:59:04 +0200 Subject: [PATCH 1/4] structure changes --- src/core/hle/service/nvnflinger/buffer_queue_producer.cpp | 2 -- src/core/hle/service/nvnflinger/buffer_slot.h | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/core/hle/service/nvnflinger/buffer_queue_producer.cpp b/src/core/hle/service/nvnflinger/buffer_queue_producer.cpp index 80497aaaf7..09f7166a91 100644 --- a/src/core/hle/service/nvnflinger/buffer_queue_producer.cpp +++ b/src/core/hle/service/nvnflinger/buffer_queue_producer.cpp @@ -530,9 +530,7 @@ Status BufferQueueProducer::QueueBuffer(s32 slot, const QueueBufferInput& input, item.is_droppable = core->dequeue_buffer_cannot_block || async; item.swap_interval = swap_interval; - // TODO: .queue_time should be changed to the correct value position = (position + 1) % 8; - LOG_WARNING(Service_Nvnflinger, "position={}", position); core->history[position] = {.frame_number = core->frame_counter, .queue_time = timestamp, .state = BufferState::Queued}; diff --git a/src/core/hle/service/nvnflinger/buffer_slot.h b/src/core/hle/service/nvnflinger/buffer_slot.h index 02a696f7da..5b5cbb6fbd 100644 --- a/src/core/hle/service/nvnflinger/buffer_slot.h +++ b/src/core/hle/service/nvnflinger/buffer_slot.h @@ -15,7 +15,7 @@ namespace Service::android { class GraphicBuffer; -enum class BufferState : u32 { +enum class BufferState : s32 { Free = 0, Dequeued = 1, Queued = 2, From f248e6f721eeb4662289c8bf5cce68bbffef8e92 Mon Sep 17 00:00:00 2001 From: Maufeat Date: Sat, 19 Jul 2025 13:23:09 +0200 Subject: [PATCH 2/4] add history vector initialization --- src/core/hle/service/nvnflinger/buffer_queue_core.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/hle/service/nvnflinger/buffer_queue_core.h b/src/core/hle/service/nvnflinger/buffer_queue_core.h index 76e319076c..341634352b 100644 --- a/src/core/hle/service/nvnflinger/buffer_queue_core.h +++ b/src/core/hle/service/nvnflinger/buffer_queue_core.h @@ -92,7 +92,7 @@ private: bool is_allocating{}; mutable std::condition_variable_any is_allocating_condition; - std::vector history; + std::vector history{8}; }; } // namespace Service::android From dd11abfdbbb6a5663d7bc7bad6938ee18c8f0650 Mon Sep 17 00:00:00 2001 From: Maufeat Date: Sat, 19 Jul 2025 14:03:57 +0200 Subject: [PATCH 3/4] add: amimi's changes --- .../nvnflinger/buffer_queue_producer.cpp | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/core/hle/service/nvnflinger/buffer_queue_producer.cpp b/src/core/hle/service/nvnflinger/buffer_queue_producer.cpp index 09f7166a91..7bc801a620 100644 --- a/src/core/hle/service/nvnflinger/buffer_queue_producer.cpp +++ b/src/core/hle/service/nvnflinger/buffer_queue_producer.cpp @@ -512,7 +512,7 @@ Status BufferQueueProducer::QueueBuffer(s32 slot, const QueueBufferInput& input, slots[slot].buffer_state = BufferState::Queued; ++core->frame_counter; slots[slot].frame_number = core->frame_counter; - slots[slot].queue_time = 0; + slots[slot].queue_time = timestamp; slots[slot].presentation_time = 0; item.acquire_called = slots[slot].acquire_called; @@ -934,13 +934,20 @@ void BufferQueueProducer::Transact(u32 code, std::span parcel_data, break; } case TransactionId::GetBufferHistory: { - LOG_WARNING(Service_Nvnflinger, "(STUBBED) called"); + LOG_WARNING(Service_Nvnflinger, "called, transaction=GetBufferHistory"); std::scoped_lock lock{core->mutex}; auto buffer_history_count = std::min(parcel_in.Read(), (s32)core->history.size()); - BufferInfo* info = new BufferInfo[buffer_history_count]; + if (buffer_history_count <= 0) { + parcel_out.Write(Status::BadValue); + parcel_out.Write(0); + status = Status::None; + break; + } + + auto info = new BufferInfo[buffer_history_count]; auto pos = position; for (int i = 0; i < buffer_history_count; i++) { info[i] = core->history[(pos - i) % core->history.size()]; @@ -950,8 +957,10 @@ void BufferQueueProducer::Transact(u32 code, std::span parcel_data, pos--; } + parcel_out.Write(Status::NoError); + parcel_out.Write(buffer_history_count); parcel_out.WriteFlattenedObject(info); - status = Status::NoError; + status = Status::None; break; } default: @@ -959,7 +968,9 @@ void BufferQueueProducer::Transact(u32 code, std::span parcel_data, break; } - parcel_out.Write(status); + if (status != Status::None) { + parcel_out.Write(status); + } const auto serialized = parcel_out.Serialize(); std::memcpy(parcel_reply.data(), serialized.data(), From 843d6fcbfe5ac3bde26404ea521e1b9a8a8f31d8 Mon Sep 17 00:00:00 2001 From: Maufeat Date: Sat, 19 Jul 2025 14:05:42 +0200 Subject: [PATCH 4/4] little fix after amicuchu changes --- src/core/hle/service/nvnflinger/buffer_queue_producer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/hle/service/nvnflinger/buffer_queue_producer.cpp b/src/core/hle/service/nvnflinger/buffer_queue_producer.cpp index 7bc801a620..4317aee1c4 100644 --- a/src/core/hle/service/nvnflinger/buffer_queue_producer.cpp +++ b/src/core/hle/service/nvnflinger/buffer_queue_producer.cpp @@ -532,7 +532,7 @@ Status BufferQueueProducer::QueueBuffer(s32 slot, const QueueBufferInput& input, position = (position + 1) % 8; core->history[position] = {.frame_number = core->frame_counter, - .queue_time = timestamp, + .queue_time = slots[slot].queue_time, .state = BufferState::Queued}; sticky_transform = sticky_transform_;