mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-10-11 18:08:08 +00:00
[idd] rewrite to support DirectX12 copy
This commit is contained in:
47
idd/LGIdd/CInteropResourcePool.cpp
Normal file
47
idd/LGIdd/CInteropResourcePool.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
#include "CInteropResourcePool.h"
|
||||
#include "Debug.h"
|
||||
|
||||
void CInteropResourcePool::Init(std::shared_ptr<CD3D11Device> dx11Device, std::shared_ptr<CD3D12Device> dx12Device)
|
||||
{
|
||||
Reset();
|
||||
m_dx11Device = dx11Device;
|
||||
m_dx12Device = dx12Device;
|
||||
}
|
||||
|
||||
void CInteropResourcePool::Reset()
|
||||
{
|
||||
for (unsigned i = 0; i < POOL_SIZE; ++i)
|
||||
m_pool[i].Reset();
|
||||
m_dx11Device.reset();
|
||||
m_dx12Device.reset();
|
||||
}
|
||||
|
||||
CInteropResource* CInteropResourcePool::Get(ComPtr<ID3D11Texture2D> srcTex)
|
||||
{
|
||||
CInteropResource * res;
|
||||
unsigned freeSlot = POOL_SIZE;
|
||||
for (unsigned i = 0; i < POOL_SIZE; ++i)
|
||||
{
|
||||
res = &m_pool[i];
|
||||
if (!res->IsReady())
|
||||
{
|
||||
freeSlot = min(freeSlot, i);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (res->Compare(srcTex))
|
||||
return res;
|
||||
}
|
||||
|
||||
if (freeSlot == POOL_SIZE)
|
||||
{
|
||||
DBGPRINT("Interop Resouce Pool Full");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
res = &m_pool[freeSlot];
|
||||
if (!res->Init(m_dx11Device, m_dx12Device, srcTex))
|
||||
return nullptr;
|
||||
|
||||
return res;
|
||||
}
|
Reference in New Issue
Block a user