mirror of
https://github.com/gnif/LookingGlass.git
synced 2026-08-22 07:01:30 +00:00
[idd] capture: version frame graph changes
This commit is contained in:
@@ -319,7 +319,8 @@ struct CFrameExec::Core : std::enable_shared_from_this<CFrameExec::Core>
|
||||
|
||||
CfgResult Init(const CFrameGraph& source,
|
||||
const std::shared_ptr<CD3D11Device>& d11Device,
|
||||
const std::shared_ptr<CD3D12Device>& d12Device, CTexHub& texHub)
|
||||
const std::shared_ptr<CD3D12Device>& d12Device, CTexHub& texHub,
|
||||
bool inheritedFull)
|
||||
{
|
||||
d11 = d11Device;
|
||||
d12 = d12Device;
|
||||
@@ -329,14 +330,15 @@ struct CFrameExec::Core : std::enable_shared_from_this<CFrameExec::Core>
|
||||
if (!d11 || !d12 || !device || !graph.Generation())
|
||||
return CfgResult::FAILED;
|
||||
|
||||
const GraphNode * nodes = graph.Nodes(nodeCount);
|
||||
const GraphNode * nodes = graph.Nodes(nodeCount);
|
||||
const GraphLeaf * leaves = graph.Leaves(leafCount);
|
||||
if (!nodes || !leaves || !nodeCount ||
|
||||
nodeCount > FRAME_GRAPH_MAX_NODES ||
|
||||
leafCount > TRANSPORT_MAX_INSTANCES)
|
||||
return CfgResult::REJECTED;
|
||||
|
||||
unsigned texLeaves = 0;
|
||||
unsigned texLeaves = 0;
|
||||
bool continuous = true;
|
||||
for (unsigned leaf = 0; leaf < leafCount; ++leaf)
|
||||
if (leaves[leaf].tex)
|
||||
{
|
||||
@@ -347,11 +349,14 @@ struct CFrameExec::Core : std::enable_shared_from_this<CFrameExec::Core>
|
||||
d11Node[leaves[leaf].node] |=
|
||||
leaves[leaf].cfg.profile.storage ==
|
||||
FrameStorage::D3D11_TEXTURE;
|
||||
continuous &= leaves[leaf].continuous;
|
||||
++texLeaves;
|
||||
}
|
||||
|
||||
if (!texLeaves)
|
||||
return CfgResult::ACCEPTED;
|
||||
Atomic::Store(forceFull, inheritedFull || !continuous,
|
||||
std::memory_order_relaxed);
|
||||
if (!nodes[0].texRefs || !queue.Init(device.Get(),
|
||||
D3D12_COMMAND_LIST_TYPE_DIRECT, L"Frame Graph",
|
||||
CD3D12CommandSlot::FAST, EXEC_LANES, false, true))
|
||||
@@ -413,6 +418,12 @@ struct CFrameExec::Core : std::enable_shared_from_this<CFrameExec::Core>
|
||||
return CfgResult::ACCEPTED;
|
||||
}
|
||||
|
||||
bool NeedsFull()
|
||||
{
|
||||
CSRWExclusiveLock lock(runLock);
|
||||
return Atomic::Load(forceFull, std::memory_order_acquire);
|
||||
}
|
||||
|
||||
FrameContentRef Content(uint64_t serial, const D12FrameFormat& format,
|
||||
uint64_t captureTime, bool full, FrameDamage damage,
|
||||
const RECT * rects, unsigned count)
|
||||
@@ -689,14 +700,16 @@ CfgResult CFrameExec::Prep(const CFrameGraph& graph) noexcept
|
||||
{
|
||||
std::shared_ptr<CD3D11Device> d11;
|
||||
std::shared_ptr<CD3D12Device> d12;
|
||||
CTexHub * hub = nullptr;
|
||||
std::shared_ptr<Core> active;
|
||||
CTexHub * hub = nullptr;
|
||||
{
|
||||
CSRWSharedLock lock(m_lock);
|
||||
if (m_pending)
|
||||
return CfgResult::REJECTED;
|
||||
d11 = m_d11;
|
||||
d12 = m_d12;
|
||||
hub = m_hub;
|
||||
d11 = m_d11;
|
||||
d12 = m_d12;
|
||||
active = m_active;
|
||||
hub = m_hub;
|
||||
}
|
||||
if (!d11 || !d12 || !hub)
|
||||
return CfgResult::FAILED;
|
||||
@@ -716,7 +729,8 @@ CfgResult CFrameExec::Prep(const CFrameGraph& graph) noexcept
|
||||
CfgResult result = CfgResult::FAILED;
|
||||
try
|
||||
{
|
||||
result = next->Init(graph, d11, d12, *hub);
|
||||
result = next->Init(graph, d11, d12, *hub,
|
||||
!active || active->NeedsFull());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
||||
@@ -241,7 +241,7 @@ unsigned CFrameGraph::Checkpoint(const FrameProfile& requested)
|
||||
}
|
||||
|
||||
bool CFrameGraph::Add(BackendId id, uint32_t epoch, bool required,
|
||||
bool primary, bool tex, const FrameCfg& cfg)
|
||||
bool primary, bool tex, bool continuous, const FrameCfg& cfg)
|
||||
{
|
||||
if (!id || !epoch || !Can(cfg) ||
|
||||
m_leafCount == TRANSPORT_MAX_INSTANCES)
|
||||
@@ -260,14 +260,15 @@ bool CFrameGraph::Add(BackendId id, uint32_t epoch, bool required,
|
||||
}
|
||||
|
||||
GraphLeaf& leaf = m_leaves[m_leafCount++];
|
||||
leaf = GraphLeaf {};
|
||||
leaf.id = id;
|
||||
leaf.epoch = epoch;
|
||||
leaf.node = node;
|
||||
leaf.required = required;
|
||||
leaf.primary = primary;
|
||||
leaf.tex = tex;
|
||||
leaf.cfg = cfg;
|
||||
leaf = GraphLeaf {};
|
||||
leaf.id = id;
|
||||
leaf.epoch = epoch;
|
||||
leaf.node = node;
|
||||
leaf.required = required;
|
||||
leaf.primary = primary;
|
||||
leaf.tex = tex;
|
||||
leaf.continuous = continuous;
|
||||
leaf.cfg = cfg;
|
||||
|
||||
for (unsigned current = node;
|
||||
current != FRAME_GRAPH_ROOT; current = m_nodes[current].parent)
|
||||
@@ -299,7 +300,8 @@ bool CFrameGraph::Seal()
|
||||
|
||||
bool CFrameGraph::Stamp(uint64_t generation)
|
||||
{
|
||||
if (!m_sealed || m_generation || !generation)
|
||||
if (!m_sealed || m_generation || !generation ||
|
||||
!m_leafCount || !m_nodeCount)
|
||||
return false;
|
||||
m_generation = generation;
|
||||
return true;
|
||||
@@ -307,12 +309,29 @@ bool CFrameGraph::Stamp(uint64_t generation)
|
||||
|
||||
bool CFrameGraph::Same(const GraphCfg& cfg) const
|
||||
{
|
||||
return m_sealed && Frame::Same(m_cfg, cfg);
|
||||
return Ready() && Frame::Same(m_cfg, cfg);
|
||||
}
|
||||
|
||||
const GraphLeaf * CFrameGraph::FindLeaf(BackendId id, uint32_t epoch,
|
||||
bool tex, const FrameCfg& frame) const
|
||||
{
|
||||
if (!Ready())
|
||||
return nullptr;
|
||||
for (unsigned i = 0; i < m_leafCount; ++i)
|
||||
{
|
||||
const GraphLeaf& leaf = m_leaves[i];
|
||||
if (leaf.id == id &&
|
||||
leaf.epoch == epoch &&
|
||||
leaf.tex == tex &&
|
||||
Frame::Same(leaf.cfg, frame))
|
||||
return &leaf;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool CFrameGraph::Need(FrameOp op) const
|
||||
{
|
||||
if (!m_sealed || op == FrameOp::SRC)
|
||||
if (!Ready() || op == FrameOp::SRC)
|
||||
return false;
|
||||
for (unsigned i = 1; i < m_nodeCount; ++i)
|
||||
if (m_nodes[i].op == op && m_nodes[i].refs)
|
||||
@@ -322,7 +341,7 @@ bool CFrameGraph::Need(FrameOp op) const
|
||||
|
||||
bool CFrameGraph::Want(FrameSignal signal) const
|
||||
{
|
||||
if (!m_sealed)
|
||||
if (!Ready())
|
||||
return false;
|
||||
for (unsigned i = 0; i < m_leafCount; ++i)
|
||||
if (m_leaves[i].cfg.profile.signal == signal)
|
||||
@@ -332,7 +351,7 @@ bool CFrameGraph::Want(FrameSignal signal) const
|
||||
|
||||
bool CFrameGraph::Shared(unsigned node) const
|
||||
{
|
||||
if (!m_sealed || !node || node >= m_nodeCount ||
|
||||
if (!Ready() || !node || node >= m_nodeCount ||
|
||||
!m_nodes[node].texRefs)
|
||||
return false;
|
||||
for (unsigned i = 0; i < m_leafCount; ++i)
|
||||
@@ -346,7 +365,7 @@ bool CFrameGraph::Shared(unsigned node) const
|
||||
bool CFrameGraph::Desc(unsigned nodeIndex,
|
||||
const FrameContentRef& content, FrameDesc& desc) const
|
||||
{
|
||||
if (!content)
|
||||
if (!Ready() || !content)
|
||||
return false;
|
||||
|
||||
const D12FrameFormat& source = content->format;
|
||||
@@ -358,8 +377,7 @@ bool CFrameGraph::Desc(unsigned nodeIndex,
|
||||
if (!validProfile || !Frame::Same(sourceProfile, m_cfg.src))
|
||||
return false;
|
||||
|
||||
if (!m_sealed ||
|
||||
!nodeIndex ||
|
||||
if (!nodeIndex ||
|
||||
nodeIndex >= m_nodeCount ||
|
||||
!content->serial ||
|
||||
source.width != m_cfg.srcWidth ||
|
||||
@@ -412,7 +430,7 @@ bool CFrameGraph::Desc(unsigned nodeIndex,
|
||||
bool CFrameGraph::Desc(unsigned leaf, const FrameContentRef& content,
|
||||
LeafDesc& desc) const
|
||||
{
|
||||
if (!m_sealed || leaf >= m_leafCount)
|
||||
if (!Ready() || leaf >= m_leafCount)
|
||||
return false;
|
||||
|
||||
const GraphLeaf& route = m_leaves[leaf];
|
||||
@@ -430,12 +448,12 @@ bool CFrameGraph::Desc(unsigned leaf, const FrameContentRef& content,
|
||||
|
||||
const GraphNode * CFrameGraph::Nodes(unsigned& count) const
|
||||
{
|
||||
count = m_sealed ? m_nodeCount : 0;
|
||||
count = Ready() ? m_nodeCount : 0;
|
||||
return count ? m_nodes : nullptr;
|
||||
}
|
||||
|
||||
const GraphLeaf * CFrameGraph::Leaves(unsigned& count) const
|
||||
{
|
||||
count = m_sealed ? m_leafCount : 0;
|
||||
count = Ready() ? m_leafCount : 0;
|
||||
return count ? m_leaves : nullptr;
|
||||
}
|
||||
|
||||
@@ -85,12 +85,14 @@ struct GraphNode
|
||||
|
||||
struct GraphLeaf
|
||||
{
|
||||
BackendId id = 0;
|
||||
uint32_t epoch = 0;
|
||||
unsigned node = 0;
|
||||
bool required = false;
|
||||
bool primary = false;
|
||||
bool tex = false;
|
||||
BackendId id = 0;
|
||||
uint32_t epoch = 0;
|
||||
unsigned node = 0;
|
||||
bool required = false;
|
||||
bool primary = false;
|
||||
bool tex = false;
|
||||
// Partial damage remains valid across the preceding graph generation.
|
||||
bool continuous = false;
|
||||
FrameCfg cfg;
|
||||
};
|
||||
|
||||
@@ -152,10 +154,13 @@ public:
|
||||
bool Begin(const GraphCfg& cfg);
|
||||
bool Can(const FrameCfg& cfg) const;
|
||||
bool Add(BackendId id, uint32_t epoch, bool required, bool primary,
|
||||
bool tex, const FrameCfg& cfg);
|
||||
bool tex, bool continuous, const FrameCfg& cfg);
|
||||
bool Seal();
|
||||
bool Stamp(uint64_t generation);
|
||||
bool Ready() const { return m_sealed && m_generation; }
|
||||
bool Same(const GraphCfg& cfg) const;
|
||||
const GraphLeaf * FindLeaf(BackendId id, uint32_t epoch, bool tex,
|
||||
const FrameCfg& frame) const;
|
||||
bool Want(FrameSignal signal) const;
|
||||
bool Need(FrameOp op) const;
|
||||
bool Shared(unsigned node) const;
|
||||
@@ -165,7 +170,7 @@ public:
|
||||
LeafDesc& desc) const;
|
||||
|
||||
const GraphCfg& Cfg() const { return m_cfg; }
|
||||
uint64_t Generation() const { return m_generation; }
|
||||
uint64_t Generation() const { return Ready() ? m_generation : 0; }
|
||||
const GraphNode * Nodes(unsigned& count) const;
|
||||
const GraphLeaf * Leaves(unsigned& count) const;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user