mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2025-07-20 08:15:46 +00:00
apply amichuchu patch
This commit is contained in:
parent
603176b6e7
commit
1b23e2b8f1
4 changed files with 41 additions and 15 deletions
|
@ -863,6 +863,7 @@ add_library(core STATIC
|
|||
hle/service/nvdrv/nvmemp.cpp
|
||||
hle/service/nvdrv/nvmemp.h
|
||||
hle/service/nvnflinger/binder.h
|
||||
hle/service/nvnflinger/buffer_history.h
|
||||
hle/service/nvnflinger/buffer_item.h
|
||||
hle/service/nvnflinger/buffer_item_consumer.cpp
|
||||
hle/service/nvnflinger/buffer_item_consumer.h
|
||||
|
|
|
@ -14,24 +14,25 @@ class BufferHistoryManager {
|
|||
public:
|
||||
void PushEntry(s32 slot, s64 timestamp, s64 frame_number) {
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
if (entries_.size() >= kMaxHistorySize) {
|
||||
entries_.pop_front();
|
||||
if (history_entries.size() >= kMaxHistorySize) {
|
||||
history_entries.pop_front();
|
||||
}
|
||||
entries_.emplace_back(BufferHistoryEntry{slot, timestamp, frame_number});
|
||||
history_entries.emplace_back(BufferHistoryEntry{slot, timestamp, frame_number});
|
||||
}
|
||||
|
||||
s32 GetHistory(std::span<BufferHistoryEntry> out_entries) {
|
||||
s32 GetHistory(s32 wantedEntries, std::span<BufferHistoryEntry>& entries) {
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
s32 count =
|
||||
std::min<s32>(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];
|
||||
s32 countToCopy = std::min<s32>(wantedEntries, static_cast<s32>(history_entries.size()));
|
||||
auto out_entries = std::vector<BufferHistoryEntry>(countToCopy);
|
||||
for (s32 i = 0; i < countToCopy; ++i) {
|
||||
out_entries[i] = history_entries[history_entries.size() - countToCopy + i];
|
||||
}
|
||||
return count;
|
||||
entries = std::span(out_entries);
|
||||
return countToCopy;
|
||||
}
|
||||
|
||||
private:
|
||||
static constexpr size_t kMaxHistorySize = 16;
|
||||
std::deque<BufferHistoryEntry> entries_;
|
||||
std::deque<BufferHistoryEntry> history_entries;
|
||||
std::mutex mutex_;
|
||||
};
|
|
@ -27,7 +27,7 @@ BufferQueueProducer::BufferQueueProducer(Service::KernelHelpers::ServiceContext&
|
|||
std::shared_ptr<BufferQueueCore> buffer_queue_core_,
|
||||
Service::Nvidia::NvCore::NvMap& nvmap_)
|
||||
: service_context{service_context_}, core{std::move(buffer_queue_core_)}, slots(core->slots),
|
||||
nvmap(nvmap_) {
|
||||
buffer_history(), nvmap(nvmap_) {
|
||||
buffer_wait_event = service_context.CreateEvent("BufferQueue:WaitEvent");
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,18 @@ BufferQueueProducer::~BufferQueueProducer() {
|
|||
service_context.CloseEvent(buffer_wait_event);
|
||||
}
|
||||
|
||||
Status BufferQueueProducer::GetBufferHistory(s32 count, std::span<BufferHistoryEntry>& entries) {
|
||||
if (count <= 0) {
|
||||
LOG_ERROR(Service_Nvnflinger, "count must be positive");
|
||||
entries = std::span<BufferHistoryEntry>();
|
||||
return Status::BadValue;
|
||||
|
||||
} else {
|
||||
buffer_history.GetHistory(count, entries);
|
||||
return Status::NoError;
|
||||
}
|
||||
}
|
||||
|
||||
Status BufferQueueProducer::RequestBuffer(s32 slot, std::shared_ptr<GraphicBuffer>* buf) {
|
||||
LOG_DEBUG(Service_Nvnflinger, "slot {}", slot);
|
||||
|
||||
|
@ -516,6 +528,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;
|
||||
buffer_history.PushEntry(slot, timestamp, static_cast<s64>(core->frame_counter));
|
||||
|
||||
item.acquire_called = slots[slot].acquire_called;
|
||||
item.graphic_buffer = slots[slot].graphic_buffer;
|
||||
|
@ -928,9 +941,18 @@ void BufferQueueProducer::Transact(u32 code, std::span<const u8> parcel_data,
|
|||
}
|
||||
case TransactionId::GetBufferHistory: {
|
||||
LOG_DEBUG(Service_Nvnflinger, "GetBufferHistory");
|
||||
auto out_span = parcel_in.Read<std::span<BufferHistoryEntry>>();
|
||||
s32 count = buffer_history_.GetHistory(out_span);
|
||||
parcel_out.Write(s32(count));
|
||||
auto entries_wanted = parcel_in.Read<s32>();
|
||||
if (entries_wanted <= 0) {
|
||||
parcel_out.Write<s32>(0);
|
||||
status = Status::BadValue;
|
||||
}
|
||||
else {
|
||||
std::span<BufferHistoryEntry> entries;
|
||||
buffer_history.GetHistory(entries_wanted, entries);
|
||||
parcel_out.Write(static_cast<s32>(entries.size()));
|
||||
parcel_out.Write(entries);
|
||||
status = Status::NoError;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <memory>
|
||||
#include <mutex>
|
||||
|
||||
#include "buffer_history.h"
|
||||
#include "common/common_funcs.h"
|
||||
#include "core/hle/service/nvdrv/nvdata.h"
|
||||
#include "core/hle/service/nvnflinger/binder.h"
|
||||
|
@ -59,6 +60,7 @@ public:
|
|||
public:
|
||||
Status RequestBuffer(s32 slot, std::shared_ptr<GraphicBuffer>* buf);
|
||||
Status SetBufferCount(s32 buffer_count);
|
||||
Status GetBufferHistory(s32 count, std::span<BufferHistoryEntry>& entries);
|
||||
Status DequeueBuffer(s32* out_slot, android::Fence* out_fence, bool async, u32 width,
|
||||
u32 height, PixelFormat format, u32 usage);
|
||||
Status DetachBuffer(s32 slot);
|
||||
|
@ -84,7 +86,7 @@ private:
|
|||
|
||||
std::shared_ptr<BufferQueueCore> core;
|
||||
BufferQueueDefs::SlotsType& slots;
|
||||
BufferHistoryManager buffer_history_;
|
||||
BufferHistoryManager buffer_history;
|
||||
u32 sticky_transform{};
|
||||
std::mutex callback_mutex;
|
||||
s32 next_callback_ticket{};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue