public unsafe Win7Output(GraphicsDevice device, IntPtr hwnd, OutputConfiguration desc) : base(device, desc) { _allocator = device.CreateAllocator(ExecutionContext.Graphics); _presentContext = device.CreateList(ExecutionContext.Graphics, _allocator.Ptr, null).As <ID3D12GraphicsCommandList>(); _presentFlags = desc.SyncInterval > 0 ? D3D12_DOWNLEVEL_PRESENT_FLAGS.D3D12_DOWNLEVEL_PRESENT_FLAG_WAIT_FOR_VBLANK : 0; _hwnd = hwnd; _presentQueue = device.GraphicsQueue; if (!ComPtr.TryQueryInterface(_presentQueue.GetQueue(), out ID3D12CommandQueueDownlevel * pDownlevel)) { ThrowHelper.ThrowPlatformNotSupportedException("Not on windows7"); } _queue = new(pDownlevel); RECT window; _ = Windows.GetClientRect(hwnd, &window); InternalResize(new Size(width: window.right - window.left, height: window.bottom - window.top)); }
internal VideoOutput(GraphicsDevice device, OutputConfiguration desc) : base(device, desc) { _ = !device.TryQueryInterface(out _bufferWriterContract); _maybeHwnd = default; }
private protected Output(GraphicsDevice device, OutputConfiguration desc) { _device = device; _desc = desc; }
/// <summary> /// Creates a new <see cref="Output"/> to a WinRT ISwapChainPanelNative /// </summary> /// <param name="device">The <see cref="GraphicsDevice"/> that will output to this buffer</param> /// <param name="desc">The <see cref="OutputConfiguration"/> for this output</param> /// <param name="swapChainPanelNative">The IUnknown* for the ISwapChainPanelNative to bind to</param> /// <param name="outputArea">The <see cref="Size"/> of the rendered output</param> /// <returns>A new <see cref="Output"/></returns> public static Output CreateForSwapChainPanel(GraphicsDevice device, OutputConfiguration desc, void *swapChainPanelNative, Size outputArea) { return(new SwapChainOutput(device, outputArea, IOutputOwner.FromSwapChainPanel(swapChainPanelNative), desc)); }
/// <summary> /// Creates a new <see cref="Output"/> to a WinRT ICoreWindow /// </summary> /// <param name="device">The <see cref="GraphicsDevice"/> that will output to this buffer</param> /// <param name="desc">The <see cref="OutputConfiguration"/> for this output</param> /// <param name="window">The IUnknown* for the window to bind to</param> /// <param name="outputArea">Optionally, the <see cref="Size"/> of the rendered output. By default, this will be the entire window</param> /// <returns>A new <see cref="Output"/></returns> public static Output CreateForWinRT(GraphicsDevice device, OutputConfiguration desc, void *window, Size outputArea = default) { return(new SwapChainOutput(device, outputArea, IOutputOwner.FromICoreWindow(window), desc)); }
/// <summary> /// Creates a new <see cref="Output"/> to a WinRT ICoreWindow /// </summary> /// <param name="device">The <see cref="GraphicsDevice"/> that will output to this buffer</param> /// <param name="desc">The <see cref="OutputConfiguration"/> for this output</param> /// <param name="window">The <see cref="ICoreWindowsOwner"/> that owns the window</param> /// <param name="outputArea">Optionally, the <see cref="Size"/> of the rendered output. By default, this will be the entire window</param> /// <returns>A new <see cref="Output"/></returns> public static Output CreateForWinRT(GraphicsDevice device, OutputConfiguration desc, ICoreWindowsOwner window, Size outputArea = default) => CreateForWinRT(device, desc, window.GetIUnknownForWindow(), outputArea);
/// <summary> /// Creates a new <see cref="Output"/> to a Win32 Window backed by a HWND /// </summary> /// <param name="device">The <see cref="GraphicsDevice"/> that will output to this buffer</param> /// <param name="desc">The <see cref="OutputConfiguration"/> for this output</param> /// <param name="window">The HWND for the window to bind to</param> /// <param name="outputArea">Optionally, the <see cref="Size"/> of the rendered output. By default, this will be the entire window</param> /// <returns>A new <see cref="Output"/></returns> public static Output CreateForWin32(GraphicsDevice device, OutputConfiguration desc, IntPtr window, Size outputArea = default) { return(new SwapChainOutput(device, outputArea, IOutputOwner.FromHwnd(window), desc)); }
//public static Output CreateForVideoOutput(GraphicsDevice device, OutputConfiguration desc, Size outputArea) //{ // throw new NotImplementedException(); //} /// <summary> /// Creates a new <see cref="Output"/> to a Win32 Window backed by a HWND /// </summary>u /// <param name="device">The <see cref="GraphicsDevice"/> that will output to this buffer</param> /// <param name="desc">The <see cref="OutputConfiguration"/> for this output</param> /// <param name="window">The <see cref="IHwndOwner"/> that owns the window</param> /// <param name="outputArea">Optionally, the <see cref="Size"/> of the rendered output. By default, this will be the entire window</param> /// <returns>A new <see cref="Output"/></returns> public static Output CreateForWin32(GraphicsDevice device, OutputConfiguration desc, IHwndOwner window, Size outputArea = default) => CreateForWin32(device, desc, window.GetHwnd(), outputArea);
/// <summary> /// Creates a new <see cref="Output"/> to a <see cref="IOutputOwner"/> /// </summary> /// <param name="desc">The <see cref="OutputConfiguration"/> for this output</param> /// <param name="device">The <see cref="GraphicsDevice"/> that will output to this buffer</param> /// <param name="window">The <see cref="IOutputOwner"/> that owns the window</param> /// <param name="outputArea">Optionally, the <see cref="Size"/> of the rendered output. By default, this will be the entire window</param> /// <returns>A new <see cref="Output"/></returns> public static Output Create(OutputConfiguration desc, GraphicsDevice device, IOutputOwner window, Size outputArea = default) { return(new SwapChainOutput(device, outputArea, window, desc)); }
internal SwapChainOutput(GraphicsDevice device, Size size, IOutputOwner owner, OutputConfiguration desc) : base(device, desc) { _device = device; var swapChainDesc = CreateDesc(desc, size); if (UseSeperatePresentQueue()) { _presentQueue = new CommandQueue(device, ExecutionContext.Graphics, enableTdr: true); _presentQueueIsSeperate = true; } else { _presentQueue = device.GraphicsQueue; } using var factory = CreateFactory(); using UniqueComPtr <IDXGISwapChain1> swapChain = default; var pQueue = (IUnknown *)_presentQueue.GetQueue(); var ppChain = (IDXGISwapChain1 **)&swapChain; IDXGIOutput *pRestrict = null; Guard.ThrowIfFailed( owner.Type switch { OutputType.Hwnd => factory.Ptr->CreateSwapChainForHwnd( pQueue, owner.GetOutput(), &swapChainDesc, null, pRestrict, ppChain ), OutputType.ICoreWindow => factory.Ptr->CreateSwapChainForCoreWindow( pQueue, (IUnknown *)owner.GetOutput(), &swapChainDesc, pRestrict, ppChain ), OutputType.SwapChainPanel => factory.Ptr->CreateSwapChainForComposition( pQueue, &swapChainDesc, pRestrict, ppChain ), _ => E_INVALIDARG, // this way we fail if weird enum arg provided }