Update src/core/hle/service/nvnflinger/buffer_queue_producer.cpp
Some checks failed
eden-license / license-header (pull_request) Failing after 40s
Some checks failed
eden-license / license-header (pull_request) Failing after 40s
Changed GetBufferHistory to resemble Ryujinx a little bit more in the functionality.
This commit is contained in:
parent
881bd82d6e
commit
9464083c72
1 changed files with 31 additions and 9 deletions
|
@ -946,22 +946,44 @@ void BufferQueueProducer::Transact(u32 code, std::span<const u8> parcel_data,
|
||||||
case TransactionId::GetBufferHistory: {
|
case TransactionId::GetBufferHistory: {
|
||||||
LOG_DEBUG(Service_Nvnflinger, "called, transaction=GetBufferHistory");
|
LOG_DEBUG(Service_Nvnflinger, "called, transaction=GetBufferHistory");
|
||||||
|
|
||||||
const s32 requested_value = parcel_in.Read<s32>();
|
const s32 request = parcel_in.Read<s32>();
|
||||||
if (requested_value <= 0) {
|
if (request <= 0) {
|
||||||
parcel_out.Write(Status::BadValue);
|
parcel_out.Write(Status::BadValue);
|
||||||
parcel_out.Write<s32>(0);
|
parcel_out.Write<s32>(0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr s32 buffer_history_size = BufferQueueCore::BUFFER_HISTORY_SIZE ;
|
constexpr u32 history_max = BufferQueueCore::BUFFER_HISTORY_SIZE;
|
||||||
const s32 buffer_history_count = (requested_value < buffer_history_size) ?
|
std::array<BufferHistoryInfo, history_max> buffer_history_snapshot{};
|
||||||
requested_value : buffer_history_size;
|
s32 valid_index{};
|
||||||
|
{
|
||||||
|
std::scoped_lock lk(core->mutex);
|
||||||
|
|
||||||
parcel_out.Write(Status::NoError);
|
const u32 current_history_pos = core->buffer_history_pos;
|
||||||
parcel_out.Write<s32>(buffer_history_count);
|
u32 index_reversed{};
|
||||||
for (s32 i = 0; i < buffer_history_count; ++i) {
|
for (u32 i = 0; i < history_max; ++i) {
|
||||||
parcel_out.Write(core->buffer_history[i]);
|
// Wrap values backwards e.g. 7, 6, 5, etc. in the range of 0-7
|
||||||
|
index_reversed = (current_history_pos + history_max - i) % history_max;
|
||||||
|
const auto& current_history_buffer = core->buffer_history[index_reversed];
|
||||||
|
|
||||||
|
// Here we use the frame number as a terminator.
|
||||||
|
// Because a buffer without frame_number is not considered complete
|
||||||
|
if (current_history_buffer.frame_number == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer_history_snapshot[valid_index] = current_history_buffer;
|
||||||
|
++valid_index;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const s32 limit = std::min(request, valid_index);
|
||||||
|
parcel_out.Write(Status::NoError);
|
||||||
|
parcel_out.Write<s32>(limit);
|
||||||
|
for (s32 i = 0; i < limit; ++i) {
|
||||||
|
parcel_out.Write(buffer_history_snapshot[i]);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue