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 diff --git a/src/core/hle/service/nvnflinger/buffer_queue_producer.cpp b/src/core/hle/service/nvnflinger/buffer_queue_producer.cpp index 80497aaaf7..4317aee1c4 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; @@ -530,11 +530,9 @@ 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, + .queue_time = slots[slot].queue_time, .state = BufferState::Queued}; sticky_transform = sticky_transform_; @@ -936,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()]; @@ -952,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: @@ -961,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(), 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,