mirror of
https://github.com/gnif/LookingGlass.git
synced 2026-08-09 08:41:31 +00:00
[idd] project: organize driver sources by responsibility
Group the IDD sources and Visual Studio filters by subsystem. Split the device and swap-chain implementations into focused units, rename the context classes, and reduce header coupling.
This commit is contained in:
70
idd/LGIdd/d3d/CInteropResourcePool.cpp
Normal file
70
idd/LGIdd/d3d/CInteropResourcePool.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2026 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., 59
|
||||
* Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "d3d/CInteropResourcePool.h"
|
||||
#include "CDebug.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)
|
||||
{
|
||||
DEBUG_ERROR("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