V2 working
All checks were successful
CI / React UI Build (push) Successful in 11s
CI / Native Windows Build And Tests (push) Successful in 2m54s
CI / Windows Release Package (push) Successful in 3m14s

This commit is contained in:
Aiden
2026-05-12 01:59:02 +10:00
parent 2531d871e8
commit e0ca548ef5
32 changed files with 3492 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
#pragma once
#include "SystemFrameTypes.h"
#include <chrono>
#include <condition_variable>
#include <deque>
#include <mutex>
#include <vector>
class SystemFrameExchange
{
public:
SystemFrameExchange() = default;
explicit SystemFrameExchange(const SystemFrameExchangeConfig& config);
void Configure(const SystemFrameExchangeConfig& config);
SystemFrameExchangeConfig Config() const;
bool AcquireForRender(SystemFrame& frame);
bool PublishCompleted(const SystemFrame& frame);
bool ConsumeCompletedForSchedule(SystemFrame& frame);
bool ReleaseScheduledByBytes(void* bytes);
bool WaitForCompletedDepth(std::size_t targetDepth, std::chrono::milliseconds timeout);
void Clear();
SystemFrameExchangeMetrics Metrics() const;
private:
struct Slot
{
std::vector<unsigned char> bytes;
SystemFrameSlotState state = SystemFrameSlotState::Free;
uint64_t generation = 1;
uint64_t frameIndex = 0;
};
bool AcquireFreeLocked(SystemFrame& frame);
bool DropOldestCompletedLocked();
bool IsValidLocked(const SystemFrame& frame) const;
void FillFrameLocked(std::size_t index, SystemFrame& frame);
std::size_t CompletedCountLocked() const;
std::size_t FrameByteCount() const;
mutable std::mutex mMutex;
std::condition_variable mCondition;
SystemFrameExchangeConfig mConfig;
std::vector<Slot> mSlots;
std::deque<std::size_t> mCompletedIndices;
SystemFrameExchangeMetrics mCounters;
};