From b31b4e3caa2ff49cd256b7ab8342e3369d507d9e Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Mon, 24 Apr 2023 12:02:21 +0200 Subject: [PATCH] early-access version 3528 --- README.md | 2 +- .../nvnflinger/buffer_queue_consumer.cpp | 32 +++---------------- .../service/nvnflinger/buffer_queue_core.cpp | 4 --- src/core/hle/service/nvnflinger/buffer_slot.h | 1 - .../hle/service/nvnflinger/nvnflinger.cpp | 11 ++++--- src/video_core/query_cache.h | 13 ++++++-- 6 files changed, 22 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index f0920112c..8a40e0e6d 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 3527. +This is the source code for early-access 3528. ## Legal Notice diff --git a/src/core/hle/service/nvnflinger/buffer_queue_consumer.cpp b/src/core/hle/service/nvnflinger/buffer_queue_consumer.cpp index 8b37d8663..51291539d 100755 --- a/src/core/hle/service/nvnflinger/buffer_queue_consumer.cpp +++ b/src/core/hle/service/nvnflinger/buffer_queue_consumer.cpp @@ -92,14 +92,6 @@ Status BufferQueueConsumer::AcquireBuffer(BufferItem* out_buffer, LOG_DEBUG(Service_Nvnflinger, "acquiring slot={}", slot); - // If the front buffer is still being tracked, update its slot state - if (core->StillTracking(*front)) { - slots[slot].acquire_called = true; - slots[slot].needs_cleanup_on_release = false; - slots[slot].buffer_state = BufferState::Acquired; - slots[slot].fence = Fence::NoFence(); - } - // If the buffer has previously been acquired by the consumer, set graphic_buffer to nullptr to // avoid unnecessarily remapping this buffer on the consumer side. if (out_buffer->acquire_called) { @@ -142,29 +134,13 @@ Status BufferQueueConsumer::ReleaseBuffer(s32 slot, u64 frame_number, const Fenc ++current; } - if (slots[slot].buffer_state == BufferState::Acquired) { - slots[slot].fence = release_fence; - slots[slot].buffer_state = BufferState::Free; + slots[slot].buffer_state = BufferState::Free; - nvmap.FreeHandle(slots[slot].graphic_buffer->BufferId(), true); + nvmap.FreeHandle(slots[slot].graphic_buffer->BufferId(), true); - listener = core->connected_producer_listener; + listener = core->connected_producer_listener; - LOG_DEBUG(Service_Nvnflinger, "releasing slot {}", slot); - } else if (slots[slot].needs_cleanup_on_release) { - LOG_DEBUG(Service_Nvnflinger, "releasing a stale buffer slot {} (state = {})", slot, - slots[slot].buffer_state); - - slots[slot].needs_cleanup_on_release = false; - - return Status::StaleBufferSlot; - } else { - LOG_ERROR(Service_Nvnflinger, - "attempted to release buffer slot {} but its state was {}", slot, - slots[slot].buffer_state); - - return Status::BadValue; - } + LOG_DEBUG(Service_Nvnflinger, "releasing slot {}", slot); core->SignalDequeueCondition(); } diff --git a/src/core/hle/service/nvnflinger/buffer_queue_core.cpp b/src/core/hle/service/nvnflinger/buffer_queue_core.cpp index 4745c4980..2dbe29616 100755 --- a/src/core/hle/service/nvnflinger/buffer_queue_core.cpp +++ b/src/core/hle/service/nvnflinger/buffer_queue_core.cpp @@ -86,10 +86,6 @@ void BufferQueueCore::FreeBufferLocked(s32 slot) { slots[slot].graphic_buffer.reset(); - if (slots[slot].buffer_state == BufferState::Acquired) { - slots[slot].needs_cleanup_on_release = true; - } - slots[slot].buffer_state = BufferState::Free; slots[slot].frame_number = UINT32_MAX; slots[slot].acquire_called = false; diff --git a/src/core/hle/service/nvnflinger/buffer_slot.h b/src/core/hle/service/nvnflinger/buffer_slot.h index 37daca78b..d25bca049 100755 --- a/src/core/hle/service/nvnflinger/buffer_slot.h +++ b/src/core/hle/service/nvnflinger/buffer_slot.h @@ -31,7 +31,6 @@ struct BufferSlot final { u64 frame_number{}; Fence fence; bool acquire_called{}; - bool needs_cleanup_on_release{}; bool attached_by_consumer{}; bool is_preallocated{}; }; diff --git a/src/core/hle/service/nvnflinger/nvnflinger.cpp b/src/core/hle/service/nvnflinger/nvnflinger.cpp index 64ea0d790..aa3356611 100755 --- a/src/core/hle/service/nvnflinger/nvnflinger.cpp +++ b/src/core/hle/service/nvnflinger/nvnflinger.cpp @@ -46,8 +46,11 @@ void Nvnflinger::SplitVSync(std::stop_token stop_token) { vsync_signal.wait(false); vsync_signal.store(false); - const auto lock_guard = Lock(); + guard->lock(); + Compose(); + + guard->unlock(); } } @@ -67,9 +70,8 @@ Nvnflinger::Nvnflinger(Core::System& system_, HosBinderDriverServer& hos_binder_ [this](std::uintptr_t, s64 time, std::chrono::nanoseconds ns_late) -> std::optional { vsync_signal.store(true); - const auto lock_guard = Lock(); + { const auto lock_guard = Lock(); } vsync_signal.notify_one(); - return std::chrono::nanoseconds(GetNextTicks()); }); @@ -266,9 +268,8 @@ void Nvnflinger::Compose() { SCOPE_EXIT({ display.SignalVSyncEvent(); }); // Don't do anything for displays without layers. - if (!display.HasLayers()) { + if (!display.HasLayers()) continue; - } // TODO(Subv): Support more than 1 layer. VI::Layer& layer = display.GetLayer(0); diff --git a/src/video_core/query_cache.h b/src/video_core/query_cache.h index f7bcc4788..1df98eb29 100755 --- a/src/video_core/query_cache.h +++ b/src/video_core/query_cache.h @@ -137,7 +137,7 @@ public: query = Register(type, *cpu_addr, host_ptr, timestamp.has_value()); } - auto result = query->BindCounter(Stream(type).Current()); + auto result = query->BindCounter(Stream(type).Current(), timestamp); if (result) { auto async_job_id = query->GetAsyncJob(); auto& async_job = slot_async_jobs[async_job_id]; @@ -411,11 +411,19 @@ public: // When counter is nullptr it means that it's just been reset. We are supposed to write a // zero in these cases. const u64 value = counter ? counter->Query(async) : 0; + if (async) { + return value; + } + std::memcpy(host_ptr, &value, sizeof(u64)); + + if (timestamp) { + std::memcpy(host_ptr + TIMESTAMP_OFFSET, &*timestamp, sizeof(u64)); + } return value; } /// Binds a counter to this query. - std::optional BindCounter(std::shared_ptr counter_) { + std::optional BindCounter(std::shared_ptr counter_, std::optional timestamp_) { std::optional result{}; if (counter) { // If there's an old counter set it means the query is being rewritten by the game. @@ -423,6 +431,7 @@ public: result = std::make_optional(Flush()); } counter = std::move(counter_); + timestamp = timestamp_; return result; }