mirror of
https://github.com/gnif/LookingGlass.git
synced 2026-08-22 15:11:31 +00:00
[idd] capture: restore direct software publication
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -22,77 +22,24 @@
|
|||||||
|
|
||||||
#include "capture/CFrameProcessor.h"
|
#include "capture/CFrameProcessor.h"
|
||||||
|
|
||||||
|
#include <atomic>
|
||||||
|
|
||||||
class CSoftwareFrameProcessor final : public CFrameProcessor
|
class CSoftwareFrameProcessor final : public CFrameProcessor
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
enum ProductState
|
struct CopyContext
|
||||||
{
|
{
|
||||||
PRODUCT_FREE,
|
FrameCopyBatch batch;
|
||||||
PRODUCT_PREPARING,
|
|
||||||
PRODUCT_READY,
|
|
||||||
PRODUCT_PUBLISHING,
|
|
||||||
PRODUCT_RETAINED,
|
|
||||||
PRODUCT_COMPLETING,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Product
|
|
||||||
{
|
|
||||||
ProductState state = PRODUCT_FREE;
|
|
||||||
ProductState restoreState = PRODUCT_FREE;
|
|
||||||
ProductState completedState = PRODUCT_FREE;
|
|
||||||
ComPtr<ID3D12Resource> resource;
|
|
||||||
D12FrameFormat srcFormat = {};
|
|
||||||
D12FrameFormat dstFormat = {};
|
|
||||||
RECT dirtyRects[LG_MAX_DIRTY_RECTS] = {};
|
|
||||||
unsigned nbDirtyRects = 0;
|
|
||||||
RECT previousDirtyRects[LG_MAX_DIRTY_RECTS] = {};
|
|
||||||
unsigned nbPreviousDirtyRects = 0;
|
|
||||||
unsigned pitch = 0;
|
|
||||||
size_t frameSize = 0;
|
|
||||||
uint64_t sequence = 0;
|
|
||||||
uint64_t captureTime = 0;
|
|
||||||
uint64_t postProcessStart = 0;
|
|
||||||
uint64_t prepareCopyStart = 0;
|
|
||||||
uint64_t prepareReady = 0;
|
|
||||||
uint64_t prepareGPUStart = 0;
|
|
||||||
uint64_t prepareGPUEnd = 0;
|
|
||||||
uint64_t timingStart = 0;
|
uint64_t timingStart = 0;
|
||||||
unsigned timingEffectIndex = 0;
|
std::atomic<bool> completionDone = false;
|
||||||
uint64_t timingToken = 0;
|
std::atomic<bool> completionSucceeded = false;
|
||||||
bool prepareTimingValid = false;
|
|
||||||
bool sourceReady = false;
|
|
||||||
bool batchCommitted = false;
|
|
||||||
bool productNotified = false;
|
|
||||||
bool executeActive = false;
|
|
||||||
bool completionDone = false;
|
|
||||||
bool completionSucceeded = false;
|
|
||||||
FrameCopyBatch batch = {};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Product m_products[CAPTURE_PIPELINE_SLOTS];
|
// The unindexed copy-slot API permits exactly one in-flight submission.
|
||||||
mutable CSRWLock m_productLock;
|
CopyContext m_copy;
|
||||||
Wrappers::Event m_productAvailableEvent;
|
|
||||||
|
|
||||||
static void CompletionFunction(
|
static void CompletionFunction(
|
||||||
CD3D12CommandSlot * slot, bool result, void * param1, void * param2);
|
CD3D12CommandSlot * slot, bool result, void * param1, void * param2);
|
||||||
int AcquireProduct();
|
|
||||||
int WaitForProduct();
|
|
||||||
void RestoreProduct(unsigned productIndex, ProductState state);
|
|
||||||
void FinishProduct(
|
|
||||||
unsigned productIndex, bool publishing, bool result);
|
|
||||||
void MarkSourceReady(unsigned productIndex, uint64_t sequence);
|
|
||||||
void MarkBatchCommitted(unsigned productIndex, uint64_t sequence);
|
|
||||||
bool EnsureProductResource(unsigned productIndex, size_t frameSize);
|
|
||||||
bool BeginExecute(unsigned productIndex, uint64_t sequence,
|
|
||||||
ProductState state);
|
|
||||||
void EndExecute(unsigned productIndex, uint64_t sequence,
|
|
||||||
bool& completed, bool& succeeded);
|
|
||||||
bool PrepareBatch(Product& product, unsigned productIndex,
|
|
||||||
const FramePlan& plan, uint64_t copyStart);
|
|
||||||
void CompleteBatch(CD3D12CommandSlot * slot, Product& product,
|
|
||||||
unsigned productIndex, bool publishing, bool result);
|
|
||||||
void ResetProducts();
|
|
||||||
void SignalProductState(bool available = false);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CSoftwareFrameProcessor(IFrameTransport * transport,
|
CSoftwareFrameProcessor(IFrameTransport * transport,
|
||||||
@@ -101,10 +48,7 @@ public:
|
|||||||
CSRWLock * pipelineLock, HANDLE terminateEvent);
|
CSRWLock * pipelineLock, HANDLE terminateEvent);
|
||||||
|
|
||||||
bool Submit(const FrameSubmission& submission) override;
|
bool Submit(const FrameSubmission& submission) override;
|
||||||
bool HasReadyFrame() const override;
|
bool HasReadyFrame() const override { return false; }
|
||||||
bool Publish(const FramePlan& plan, uint64_t publishStart) override;
|
bool Publish(const FramePlan&, uint64_t) override { return false; }
|
||||||
bool UsesCadence() const override { return false; }
|
bool UsesCadence() const override { return false; }
|
||||||
bool IsValid() const override;
|
|
||||||
void Reset() override;
|
|
||||||
void ResetPipeline() override;
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -666,13 +666,17 @@ bool CFrameHub::GetFramePlan(
|
|||||||
return plan.count != 0;
|
return plan.count != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CFrameHub::GetImmediateFramePlan(uint64_t now, FramePlan& plan)
|
bool CFrameHub::GetImmediatePrimaryFramePlan(
|
||||||
|
uint64_t now, FramePlan& plan)
|
||||||
{
|
{
|
||||||
plan = {};
|
plan = {};
|
||||||
SinkRef refs[FRAME_MAX_SINKS];
|
SinkRef refs[FRAME_MAX_SINKS];
|
||||||
const unsigned count = Snapshot(refs);
|
const unsigned count = Snapshot(refs);
|
||||||
for (unsigned i = 0; i < count; ++i)
|
for (unsigned i = 0; i < count; ++i)
|
||||||
{
|
{
|
||||||
|
if (!refs[i].primary)
|
||||||
|
continue;
|
||||||
|
|
||||||
Sink& sink = *refs[i].sink;
|
Sink& sink = *refs[i].sink;
|
||||||
CSRWSharedLock call(sink.callLock);
|
CSRWSharedLock call(sink.callLock);
|
||||||
if (!Atomic::Load(sink.active, std::memory_order_acquire) ||
|
if (!Atomic::Load(sink.active, std::memory_order_acquire) ||
|
||||||
@@ -693,8 +697,9 @@ bool CFrameHub::GetImmediateFramePlan(uint64_t now, FramePlan& plan)
|
|||||||
CFrameScheduler::Schedule schedule = {};
|
CFrameScheduler::Schedule schedule = {};
|
||||||
bool periodic = false;
|
bool periodic = false;
|
||||||
bool republish = false;
|
bool republish = false;
|
||||||
sink.target->GetPublishTarget(
|
if (!sink.target->GetPublishTarget(
|
||||||
now, target, schedule, periodic, republish);
|
now, target, schedule, periodic, republish))
|
||||||
|
continue;
|
||||||
|
|
||||||
if (plan.count == FRAME_MAX_SINKS)
|
if (plan.count == FRAME_MAX_SINKS)
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ public:
|
|||||||
bool NeedsFrame() const override;
|
bool NeedsFrame() const override;
|
||||||
bool GetFramePlan(
|
bool GetFramePlan(
|
||||||
uint64_t now, bool productReady, FramePlan& plan) override;
|
uint64_t now, bool productReady, FramePlan& plan) override;
|
||||||
bool GetImmediateFramePlan(
|
bool GetImmediatePrimaryFramePlan(
|
||||||
uint64_t now, FramePlan& plan) override;
|
uint64_t now, FramePlan& plan) override;
|
||||||
void MissFramePlan(const FramePlan& plan, uint64_t now) override;
|
void MissFramePlan(const FramePlan& plan, uint64_t now) override;
|
||||||
bool PrepareFrameBatch(const FramePlan& plan,
|
bool PrepareFrameBatch(const FramePlan& plan,
|
||||||
|
|||||||
@@ -1215,14 +1215,27 @@ CfgResult CTransportManager::Cfg(const GraphCfg& cfg,
|
|||||||
Entry& entry = *entries[i];
|
Entry& entry = *entries[i];
|
||||||
bool frameService = false;
|
bool frameService = false;
|
||||||
bool required = false;
|
bool required = false;
|
||||||
|
bool primary = false;
|
||||||
{
|
{
|
||||||
CSRWSharedLock entryLock(entry.lock);
|
CSRWSharedLock entryLock(entry.lock);
|
||||||
frameService =
|
frameService =
|
||||||
(entry.config.services & TRANSPORT_SERVICE_FRAME) != 0;
|
(entry.config.services & TRANSPORT_SERVICE_FRAME) != 0;
|
||||||
required = entry.required;
|
required = entry.required;
|
||||||
|
primary = entry.primary;
|
||||||
}
|
}
|
||||||
|
// Software capture writes directly into the primary frame target.
|
||||||
|
// Secondary routes add fan-out work and can require staging copies.
|
||||||
if (!frameService)
|
if (!frameService)
|
||||||
continue;
|
continue;
|
||||||
|
if (cfg.mode == GpuMode::SOFTWARE && !primary)
|
||||||
|
{
|
||||||
|
if (required)
|
||||||
|
{
|
||||||
|
result = CfgResult::REJECTED;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!BeginCall(entry, Call::CFG, true))
|
if (!BeginCall(entry, Call::CFG, true))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ public:
|
|||||||
virtual bool NeedsFrame() const = 0;
|
virtual bool NeedsFrame() const = 0;
|
||||||
virtual bool GetFramePlan(
|
virtual bool GetFramePlan(
|
||||||
uint64_t now, bool productReady, FramePlan& plan) = 0;
|
uint64_t now, bool productReady, FramePlan& plan) = 0;
|
||||||
virtual bool GetImmediateFramePlan(
|
virtual bool GetImmediatePrimaryFramePlan(
|
||||||
uint64_t now, FramePlan& plan) = 0;
|
uint64_t now, FramePlan& plan) = 0;
|
||||||
virtual void MissFramePlan(const FramePlan& plan, uint64_t now) = 0;
|
virtual void MissFramePlan(const FramePlan& plan, uint64_t now) = 0;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user