#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; } };