#pragma once #define NOMINMAX #include #include #include #include #include #include #include #include #include #include #include #include "Trace.h" namespace Microsoft { namespace WRL { namespace Wrappers { // Adds a wrapper for thread handles to the existing set of WRL handle wrapper classes typedef HandleT Thread; } } } namespace Microsoft { namespace IndirectDisp { /// /// Manages the creation and lifetime of a Direct3D render device. /// struct IndirectSampleMonitor { static constexpr size_t szEdidBlock = 128; static constexpr size_t szModeList = 3; const BYTE pEdidBlock[szEdidBlock]; const struct SampleMonitorMode { DWORD Width; DWORD Height; DWORD VSync; } pModeList[szModeList]; const DWORD ulPreferredModeIdx; }; /// /// Manages the creation and lifetime of a Direct3D render device. /// struct Direct3DDevice { Direct3DDevice(LUID AdapterLuid); Direct3DDevice(); HRESULT Init(); LUID AdapterLuid; Microsoft::WRL::ComPtr DxgiFactory; Microsoft::WRL::ComPtr Adapter; Microsoft::WRL::ComPtr Device; Microsoft::WRL::ComPtr DeviceContext; }; /// /// Manages a thread that consumes buffers from an indirect display swap-chain object. /// class SwapChainProcessor { public: SwapChainProcessor(IDDCX_SWAPCHAIN hSwapChain, std::shared_ptr Device, HANDLE NewFrameEvent); ~SwapChainProcessor(); private: static DWORD CALLBACK RunThread(LPVOID Argument); void Run(); void RunCore(); IDDCX_SWAPCHAIN m_hSwapChain; std::shared_ptr m_Device; HANDLE m_hAvailableBufferEvent; Microsoft::WRL::Wrappers::Thread m_hThread; Microsoft::WRL::Wrappers::Event m_hTerminateEvent; }; /// /// Provides a sample implementation of an indirect display driver. /// class IndirectDeviceContext { public: IndirectDeviceContext(_In_ WDFDEVICE WdfDevice); virtual ~IndirectDeviceContext(); void InitAdapter(); void FinishInit(UINT ConnectorIndex); protected: WDFDEVICE m_WdfDevice; IDDCX_ADAPTER m_Adapter; }; class IndirectMonitorContext { public: IndirectMonitorContext(_In_ IDDCX_MONITOR Monitor); virtual ~IndirectMonitorContext(); void AssignSwapChain(IDDCX_SWAPCHAIN SwapChain, LUID RenderAdapter, HANDLE NewFrameEvent); void UnassignSwapChain(); private: IDDCX_MONITOR m_Monitor; std::unique_ptr m_ProcessingThread; } ; } }