diff options
| author | Adonais Romero González <[email protected]> | 2020-03-26 11:18:09 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-03-26 11:18:09 -0700 |
| commit | dd4fad494b996f5729be98e0271ea74ef1a5d2ad (patch) | |
| tree | c880d395a1db3ac998eae9aa4ada7c9497a9a918 /video/IndirectDisplay/IddSampleDriver/Driver.h | |
| parent | 9b58d9a908a45a55452b87d001789d27fbf0e8ee (diff) | |
| parent | 3ba36f46f9ff71b33776f8e6acef52c44b9e0a35 (diff) | |
Add Indirect Display Driver sample (#459)132485
* Add Indirect Display Driver sample
* minor cleanup
* Update sample notification email
* Update inf with Pnplockdown=1
Co-authored-by: Shantanu Gupta <[email protected]>
Diffstat (limited to 'video/IndirectDisplay/IddSampleDriver/Driver.h')
| -rw-r--r-- | video/IndirectDisplay/IddSampleDriver/Driver.h | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/video/IndirectDisplay/IddSampleDriver/Driver.h b/video/IndirectDisplay/IddSampleDriver/Driver.h new file mode 100644 index 00000000..df69b0e4 --- /dev/null +++ b/video/IndirectDisplay/IddSampleDriver/Driver.h @@ -0,0 +1,103 @@ +#pragma once + +#define NOMINMAX +#include <windows.h> +#include <bugcodes.h> +#include <wudfwdm.h> +#include <wdf.h> +#include <iddcx.h> + +#include <dxgi1_5.h> +#include <d3d11_2.h> +#include <avrt.h> +#include <wrl.h> + +#include <memory> +#include <vector> + +#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<HandleTraits::HANDLENullTraits> Thread; + } + } +} + +namespace Microsoft +{ + namespace IndirectDisp + { + /// <summary> + /// Manages the creation and lifetime of a Direct3D render device. + /// </summary> + struct Direct3DDevice + { + Direct3DDevice(LUID AdapterLuid); + Direct3DDevice(); + HRESULT Init(); + + LUID AdapterLuid; + Microsoft::WRL::ComPtr<IDXGIFactory5> DxgiFactory; + Microsoft::WRL::ComPtr<IDXGIAdapter1> Adapter; + Microsoft::WRL::ComPtr<ID3D11Device> Device; + Microsoft::WRL::ComPtr<ID3D11DeviceContext> DeviceContext; + }; + + /// <summary> + /// Manages a thread that consumes buffers from an indirect display swap-chain object. + /// </summary> + class SwapChainProcessor + { + public: + SwapChainProcessor(IDDCX_SWAPCHAIN hSwapChain, std::shared_ptr<Direct3DDevice> Device, HANDLE NewFrameEvent); + ~SwapChainProcessor(); + + private: + static DWORD CALLBACK RunThread(LPVOID Argument); + + void Run(); + void RunCore(); + + public: + IDDCX_SWAPCHAIN m_hSwapChain; + std::shared_ptr<Direct3DDevice> m_Device; + HANDLE m_hAvailableBufferEvent; + Microsoft::WRL::Wrappers::Thread m_hThread; + Microsoft::WRL::Wrappers::Event m_hTerminateEvent; + }; + + /// <summary> + /// Provides a sample implementation of an indirect display driver. + /// </summary> + class IndirectDeviceContext + { + public: + IndirectDeviceContext(_In_ WDFDEVICE WdfDevice); + virtual ~IndirectDeviceContext(); + + void InitAdapter(); + void FinishInit(); + + void AssignSwapChain(IDDCX_SWAPCHAIN SwapChain, LUID RenderAdapter, HANDLE NewFrameEvent); + void UnassignSwapChain(); + + protected: + + WDFDEVICE m_WdfDevice; + IDDCX_ADAPTER m_Adapter; + IDDCX_MONITOR m_Monitor; + + std::unique_ptr<SwapChainProcessor> m_ProcessingThread; + + public: + static const DISPLAYCONFIG_VIDEO_SIGNAL_INFO s_KnownMonitorModes[]; + static const BYTE s_KnownMonitorEdid[]; + }; + } +} |
