Started adding GetBufferHistory to fix MS: BL (based on Ryujinx's impl), added check to fix __noop
This commit is contained in:
parent
eec52f8808
commit
9fccf8f02a
|
@ -1 +1 @@
|
||||||
Subproject commit c60e2704c88ecb8bf55d69085b9c1bd2a68e5321
|
Subproject commit e1e36d213bea3a0b56d91b454c53a2c94312a5be
|
|
@ -20,7 +20,11 @@ typedef void* HANDLE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MICROPROFILE_ENABLED == 0
|
#if MICROPROFILE_ENABLED == 0
|
||||||
#define MicroProfileOnThreadExit __noop
|
#ifdef _WIN32
|
||||||
|
#define MicroProfileOnThreadExit() __noop
|
||||||
|
#else
|
||||||
|
#define MicroProfileOnThreadExit() 0
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#include <microprofile.h>
|
#include <microprofile.h>
|
||||||
|
|
||||||
|
|
|
@ -101,6 +101,14 @@ Status BufferQueueConsumer::AcquireBuffer(BufferItem* out_buffer,
|
||||||
// slot to the producer, it will wait for the fence to pass. We should fix this
|
// slot to the producer, it will wait for the fence to pass. We should fix this
|
||||||
// by properly waiting for the fence in the BufferItemConsumer.
|
// by properly waiting for the fence in the BufferItemConsumer.
|
||||||
// slots[slot].fence = Fence::NoFence();
|
// slots[slot].fence = Fence::NoFence();
|
||||||
|
|
||||||
|
const auto target_frame_number = slots[slot].frame_number;
|
||||||
|
for (int i = 0; i < core->history.size(); i++) {
|
||||||
|
if (core->history[i].frame_number = target_frame_number) {
|
||||||
|
core->history[i].state = BufferState::Acquired;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the buffer has previously been acquired by the consumer, set graphic_buffer to nullptr to
|
// If the buffer has previously been acquired by the consumer, set graphic_buffer to nullptr to
|
||||||
|
@ -255,6 +263,15 @@ Status BufferQueueConsumer::GetReleasedBuffers(u64* out_slot_mask) {
|
||||||
return Status::NoError;
|
return Status::NoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* SetPresentTime
|
||||||
|
for (int i = 0; i < core->history.size(); i++) {
|
||||||
|
if (core->history[i].frame_number = target_frame_number) {
|
||||||
|
core->history[i].state == BufferState::Acquired;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
void BufferQueueConsumer::Transact(u32 code, std::span<const u8> parcel_data,
|
void BufferQueueConsumer::Transact(u32 code, std::span<const u8> parcel_data,
|
||||||
std::span<u8> parcel_reply, u32 flags) {
|
std::span<u8> parcel_reply, u32 flags) {
|
||||||
// Values used by BnGraphicBufferConsumer onTransact
|
// Values used by BnGraphicBufferConsumer onTransact
|
||||||
|
|
|
@ -10,7 +10,9 @@
|
||||||
|
|
||||||
namespace Service::android {
|
namespace Service::android {
|
||||||
|
|
||||||
BufferQueueCore::BufferQueueCore() = default;
|
BufferQueueCore::BufferQueueCore() {
|
||||||
|
history.resize(8);
|
||||||
|
};
|
||||||
|
|
||||||
BufferQueueCore::~BufferQueueCore() = default;
|
BufferQueueCore::~BufferQueueCore() = default;
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,15 @@ private:
|
||||||
u32 transform_hint{};
|
u32 transform_hint{};
|
||||||
bool is_allocating{};
|
bool is_allocating{};
|
||||||
mutable std::condition_variable_any is_allocating_condition;
|
mutable std::condition_variable_any is_allocating_condition;
|
||||||
|
|
||||||
|
class BufferInfo final {
|
||||||
|
public:
|
||||||
|
u64 frame_number{};
|
||||||
|
s64 queue_time{}, presentation_time{};
|
||||||
|
BufferState state{BufferState::Free};
|
||||||
|
};
|
||||||
|
|
||||||
|
std::vector<BufferInfo> history;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Service::android
|
} // namespace Service::android
|
||||||
|
|
|
@ -512,6 +512,8 @@ Status BufferQueueProducer::QueueBuffer(s32 slot, const QueueBufferInput& input,
|
||||||
slots[slot].buffer_state = BufferState::Queued;
|
slots[slot].buffer_state = BufferState::Queued;
|
||||||
++core->frame_counter;
|
++core->frame_counter;
|
||||||
slots[slot].frame_number = core->frame_counter;
|
slots[slot].frame_number = core->frame_counter;
|
||||||
|
slots[slot].queue_time = 0; // this is not the true value
|
||||||
|
slots[slot].presentation_time = 0; // doesn't need to be set afaik but do it anyway
|
||||||
|
|
||||||
item.acquire_called = slots[slot].acquire_called;
|
item.acquire_called = slots[slot].acquire_called;
|
||||||
item.graphic_buffer = slots[slot].graphic_buffer;
|
item.graphic_buffer = slots[slot].graphic_buffer;
|
||||||
|
@ -528,6 +530,13 @@ Status BufferQueueProducer::QueueBuffer(s32 slot, const QueueBufferInput& input,
|
||||||
item.is_droppable = core->dequeue_buffer_cannot_block || async;
|
item.is_droppable = core->dequeue_buffer_cannot_block || async;
|
||||||
item.swap_interval = swap_interval;
|
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 = slots[slot].queue_time,
|
||||||
|
.state = BufferState::Queued};
|
||||||
|
|
||||||
sticky_transform = sticky_transform_;
|
sticky_transform = sticky_transform_;
|
||||||
|
|
||||||
if (core->queue.empty()) {
|
if (core->queue.empty()) {
|
||||||
|
@ -922,9 +931,28 @@ 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_WARNING(Service_Nvnflinger, "(STUBBED) called");
|
||||||
|
|
||||||
|
std::scoped_lock lock{core->mutex};
|
||||||
|
|
||||||
|
auto buffer_history_count = std::min(parcel_in.Read<s32>(), (s32)core->history.size());
|
||||||
|
|
||||||
|
BufferQueueCore::BufferInfo* info = new BufferQueueCore::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()];
|
||||||
|
LOG_WARNING(Service_Nvnflinger, "frame_number={}, state={}",
|
||||||
|
core->history[(pos - i) % core->history.size()].frame_number,
|
||||||
|
(u32)core->history[(pos - i) % core->history.size()].state);
|
||||||
|
pos--;
|
||||||
|
}
|
||||||
|
|
||||||
|
parcel_out.WriteFlattenedObject<BufferQueueCore::BufferInfo>(info);
|
||||||
|
status = Status::NoError;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
ASSERT_MSG(false, "Unimplemented TransactionId {}", code);
|
ASSERT_MSG(false, "Unimplemented TransactionId {}", code);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -86,6 +86,8 @@ private:
|
||||||
s32 current_callback_ticket{};
|
s32 current_callback_ticket{};
|
||||||
std::condition_variable_any callback_condition;
|
std::condition_variable_any callback_condition;
|
||||||
|
|
||||||
|
u64 position;
|
||||||
|
|
||||||
Service::Nvidia::NvCore::NvMap& nvmap;
|
Service::Nvidia::NvCore::NvMap& nvmap;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,8 @@ struct BufferSlot final {
|
||||||
bool needs_cleanup_on_release{};
|
bool needs_cleanup_on_release{};
|
||||||
bool attached_by_consumer{};
|
bool attached_by_consumer{};
|
||||||
bool is_preallocated{};
|
bool is_preallocated{};
|
||||||
|
|
||||||
|
s64 queue_time{}, presentation_time{};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Service::android
|
} // namespace Service::android
|
||||||
|
|
Loading…
Reference in New Issue