mirror of
https://github.com/gnif/LookingGlass.git
synced 2026-08-22 15:11:31 +00:00
[idd] d3d: add leased D3D11 texture interop
This commit is contained in:
@@ -313,6 +313,17 @@ bool CFrameGraph::Want(FrameSignal signal) const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CFrameGraph::Shared(unsigned node) const
|
||||
{
|
||||
if (!m_sealed || !node || node >= m_nodeCount)
|
||||
return false;
|
||||
for (unsigned i = 0; i < m_leafCount; ++i)
|
||||
if (m_leaves[i].node == node &&
|
||||
m_leaves[i].cfg.profile.storage == FrameStorage::D3D11_TEXTURE)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CFrameGraph::Desc(unsigned leaf, const FrameContentRef& content,
|
||||
LeafDesc& desc) const
|
||||
{
|
||||
|
||||
@@ -153,6 +153,7 @@ public:
|
||||
bool Same(const GraphCfg& cfg) const;
|
||||
bool Want(FrameSignal signal) const;
|
||||
bool Need(FrameOp op) const;
|
||||
bool Shared(unsigned node) const;
|
||||
bool Desc(unsigned leaf, const FrameContentRef& content,
|
||||
LeafDesc& desc) const;
|
||||
|
||||
|
||||
@@ -95,8 +95,9 @@ struct CTexCore
|
||||
unsigned node = 0;
|
||||
unsigned count = 0;
|
||||
FrameProfile profile;
|
||||
D3D12_RESOURCE_DESC desc = {};
|
||||
D3D12_RESOURCE_STATES read = D3D12_RESOURCE_STATE_COMMON;
|
||||
D3D12_RESOURCE_DESC desc = {};
|
||||
D3D12_RESOURCE_STATES read = D3D12_RESOURCE_STATE_COMMON;
|
||||
bool shared = false;
|
||||
Slot slots[CTexPool::MAX_SLOTS];
|
||||
|
||||
TexResult Acquire(unsigned& index, uint64_t& generation)
|
||||
@@ -279,10 +280,11 @@ CFrameTex::CFrameTex(uint64_t graphValue, uint64_t poolValue,
|
||||
unsigned nodeValue, unsigned slotValue, uint64_t versionValue,
|
||||
const FrameProfile& profileValue,
|
||||
const FrameDesc& frameValue, const ComPtr<ID3D12Resource>& res,
|
||||
const D12Sync& sync, D3D12_RESOURCE_STATES state) :
|
||||
const D12Sync& sync, D3D12_RESOURCE_STATES state, bool sharedValue) :
|
||||
m_res(res),
|
||||
m_sync(sync),
|
||||
m_state(state),
|
||||
m_shared(sharedValue),
|
||||
graph(graphValue),
|
||||
pool(poolValue),
|
||||
node(nodeValue),
|
||||
@@ -389,7 +391,7 @@ bool TexWrite::Seal(const FrameDesc& frame, const D12Sync& sync,
|
||||
|
||||
CFrameTex * raw = new (std::nothrow) CFrameTex(core->graph, core->id,
|
||||
core->node, m_index, m_version, core->profile, desc, resource, sync,
|
||||
core->read);
|
||||
core->read, core->shared);
|
||||
if (!raw)
|
||||
{
|
||||
core->Drop(index, generation);
|
||||
@@ -429,7 +431,7 @@ void TexWrite::Cancel()
|
||||
TexResult CTexPool::Init(ID3D12Device3 * device, uint64_t graph,
|
||||
unsigned node, const FrameProfile& profile,
|
||||
const D3D12_RESOURCE_DESC& desc, D3D12_RESOURCE_STATES state,
|
||||
unsigned slots)
|
||||
unsigned slots, bool shared)
|
||||
{
|
||||
if (!device || !graph || !node || !slots || slots > MAX_SLOTS ||
|
||||
profile.storage != FrameStorage::D3D12_TEXTURE ||
|
||||
@@ -468,6 +470,7 @@ TexResult CTexPool::Init(ID3D12Device3 * device, uint64_t graph,
|
||||
core->profile = profile;
|
||||
core->desc = desc;
|
||||
core->read = state;
|
||||
core->shared = shared;
|
||||
|
||||
D3D12_HEAP_PROPERTIES heap = {};
|
||||
heap.Type = D3D12_HEAP_TYPE_DEFAULT;
|
||||
@@ -478,8 +481,12 @@ TexResult CTexPool::Init(ID3D12Device3 * device, uint64_t graph,
|
||||
|
||||
for (unsigned i = 0; i < slots; ++i)
|
||||
{
|
||||
const D3D12_HEAP_FLAGS flags = shared ?
|
||||
static_cast<D3D12_HEAP_FLAGS>(D3D12_HEAP_FLAG_SHARED |
|
||||
D3D12_HEAP_FLAG_CREATE_NOT_ZEROED) :
|
||||
D3D12_HEAP_FLAG_CREATE_NOT_ZEROED;
|
||||
const HRESULT hr = device->CreateCommittedResource(&heap,
|
||||
D3D12_HEAP_FLAG_CREATE_NOT_ZEROED, &desc, state, nullptr,
|
||||
flags, &desc, state, nullptr,
|
||||
IID_PPV_ARGS(&core->slots[i].res));
|
||||
if (FAILED(hr))
|
||||
{
|
||||
|
||||
@@ -47,11 +47,12 @@ private:
|
||||
ComPtr<ID3D12Resource> m_res;
|
||||
D12Sync m_sync;
|
||||
D3D12_RESOURCE_STATES m_state;
|
||||
bool m_shared;
|
||||
|
||||
CFrameTex(uint64_t graph, uint64_t pool, unsigned node, unsigned slot,
|
||||
uint64_t version, const FrameProfile& profile, const FrameDesc& frame,
|
||||
const ComPtr<ID3D12Resource>& res, const D12Sync& sync,
|
||||
D3D12_RESOURCE_STATES state);
|
||||
D3D12_RESOURCE_STATES state, bool shared);
|
||||
|
||||
public:
|
||||
CFrameTex(const CFrameTex&) = delete;
|
||||
@@ -68,6 +69,7 @@ public:
|
||||
ID3D12Resource * Get() const { return m_res.Get(); }
|
||||
const D12Sync& Sync() const { return m_sync; }
|
||||
D3D12_RESOURCE_STATES State() const { return m_state; }
|
||||
bool Shared() const { return m_shared; }
|
||||
bool Wait(CD3D12CommandSlot& cmd) const;
|
||||
D12SyncState Status() const { return m_sync.State(); }
|
||||
bool Ready() const { return m_sync.Done(); }
|
||||
@@ -152,7 +154,7 @@ public:
|
||||
|
||||
TexResult Init(ID3D12Device3 * device, uint64_t graph, unsigned node,
|
||||
const FrameProfile& profile, const D3D12_RESOURCE_DESC& desc,
|
||||
D3D12_RESOURCE_STATES state, unsigned slots);
|
||||
D3D12_RESOURCE_STATES state, unsigned slots, bool shared = false);
|
||||
void Reset();
|
||||
TexResult Try(TexWrite& write);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user