mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2025-07-20 17:35:46 +00:00
[service, nvnflinger] Implement GetBufferHistory
Should help with UE4 games and many other buffer dependant titles. Thanks to master Camille for the code and Shinmegumi for the placement! Co-authored-by: CamilleLaVey <camillelavey99@gmail.com> Co-committed-by: CamilleLaVey <camillelavey99@gmail.com>
This commit is contained in:
parent
7cb8a1acd3
commit
885ce4c58c
3 changed files with 41 additions and 5 deletions
27
src/core/hle/service/nvnflinger/buffer_history.h
Normal file
27
src/core/hle/service/nvnflinger/buffer_history.h
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include <deque>
|
||||||
|
#include <mutex>
|
||||||
|
#include <common/assert.h>
|
||||||
|
|
||||||
|
struct BufferHistoryEntry { s32 slot; s64 timestamp; s64 frame_number; };
|
||||||
|
|
||||||
|
class BufferHistoryManager { public: void PushEntry(s32 slot, s64 timestamp, s64 frame_number) { std::lock_guardstd::mutex lock(mutex_); if (entries_.size() >= kMaxHistorySize) entries_.pop_front();
|
||||||
|
|
||||||
|
entries_.emplace_back(BufferHistoryEntry{slot, timestamp, frame_number});
|
||||||
|
}
|
||||||
|
|
||||||
|
s32 GetHistory(std::span<BufferHistoryEntry> out_entries) {
|
||||||
|
std::lock_guard<std::mutex> lock(mutex_);
|
||||||
|
|
||||||
|
s32 count = std::min(static_cast<s32>(entries_.size()), static_cast<s32>(out_entries.size()));
|
||||||
|
|
||||||
|
for (s32 i = 0; i < count; ++i)
|
||||||
|
out_entries[i] = entries_[entries_.size() - count + i];
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
private: static constexpr size_t kMaxHistorySize = 16; std::deque<BufferHistoryEntry> entries_; std::mutex mutex_; };
|
|
@ -1,3 +1,6 @@
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
||||||
// SPDX-FileCopyrightText: Copyright 2014 The Android Open Source Project
|
// SPDX-FileCopyrightText: Copyright 2014 The Android Open Source Project
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
@ -16,6 +19,7 @@
|
||||||
#include "core/hle/service/nvnflinger/parcel.h"
|
#include "core/hle/service/nvnflinger/parcel.h"
|
||||||
#include "core/hle/service/nvnflinger/ui/graphic_buffer.h"
|
#include "core/hle/service/nvnflinger/ui/graphic_buffer.h"
|
||||||
#include "core/hle/service/nvnflinger/window.h"
|
#include "core/hle/service/nvnflinger/window.h"
|
||||||
|
#include "core/hle/service/nvnflinger/buffer_history.h"
|
||||||
|
|
||||||
namespace Service::android {
|
namespace Service::android {
|
||||||
|
|
||||||
|
@ -922,11 +926,11 @@ void BufferQueueProducer::Transact(u32 code, std::span<const u8> parcel_data,
|
||||||
status = SetBufferCount(buffer_count);
|
status = SetBufferCount(buffer_count);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TransactionId::GetBufferHistory:
|
case TransactionId::GetBufferHistory: {
|
||||||
LOG_WARNING(Service_Nvnflinger, "(STUBBED) called, transaction=GetBufferHistory");
|
LOG_DEBUG(Service_Nvnflinger, "GetBufferHistory");
|
||||||
break;
|
auto out_span = request.PopRaw<std::span<BufferHistoryEntry>>();
|
||||||
default:
|
s32 count = buffer_history_.GetHistory(out_span);
|
||||||
ASSERT_MSG(false, "Unimplemented TransactionId {}", code);
|
response.Push(s32(count));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
||||||
// SPDX-FileCopyrightText: Copyright 2014 The Android Open Source Project
|
// SPDX-FileCopyrightText: Copyright 2014 The Android Open Source Project
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
@ -80,6 +83,8 @@ private:
|
||||||
|
|
||||||
std::shared_ptr<BufferQueueCore> core;
|
std::shared_ptr<BufferQueueCore> core;
|
||||||
BufferQueueDefs::SlotsType& slots;
|
BufferQueueDefs::SlotsType& slots;
|
||||||
|
BufferHistoryManager buffer_history_;
|
||||||
|
buffer_history_.PushEntry(slot, timestamp, frame_number);
|
||||||
u32 sticky_transform{};
|
u32 sticky_transform{};
|
||||||
std::mutex callback_mutex;
|
std::mutex callback_mutex;
|
||||||
s32 next_callback_ticket{};
|
s32 next_callback_ticket{};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue