/** * 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 */ #pragma once #include #include #include #include #include "CD3D11Device.h" #include "CD3D12Device.h" #include "CD3D12CommandQueue.h" using namespace Microsoft::WRL; #define LG_MAX_DIRTY_RECTS 256 class CInteropResource { private: std::shared_ptr m_dx11Device; std::shared_ptr m_dx12Device; /* this value is likely released, it is only used to check if the texture supplied is different, do not rely on it pointing to valid memory */ void * m_srcTex; ComPtr m_d12Res; D3D11_TEXTURE2D_DESC m_format; ComPtr m_d11Fence; ComPtr m_d12Fence; UINT64 m_fenceValue; bool m_ready; RECT m_dirtyRects[LG_MAX_DIRTY_RECTS]; unsigned m_nbDirtyRects; public: bool Init(std::shared_ptr dx11Device, std::shared_ptr dx12Device, ComPtr srcTex); void Reset(); bool IsReady() { return m_ready; } bool Compare(const ComPtr& srcTex); void Signal(); void Sync(CD3D12CommandQueue& queue); void SetFullDamage(); const ComPtr& GetRes() { return m_d12Res; } const D3D11_TEXTURE2D_DESC& GetFormat() { return m_format; } };