public static DX11SwapChain FromHandle(DxDevice device, IntPtr handle, Format format, SampleDescription sampledesc) { DX11SwapChain swapShain = new DX11SwapChain(); swapShain.device = device; SwapChainDescription sd = new SwapChainDescription() { BufferCount = 2, ModeDescription = new ModeDescription(0, 0, new Rational(60, 1), format), IsWindowed = true, OutputHandle = handle, SampleDescription = sampledesc, SwapEffect = SwapEffect.Discard, Usage = Usage.RenderTargetOutput | Usage.ShaderInput, Flags = SwapChainFlags.None }; if (device.IsFeatureLevel11 && sampledesc.Count == 1) { sd.Usage |= Usage.UnorderedAccess; } swapShain.swapchain = new SwapChain(device.Factory, device.Device, sd); swapShain.Initialize(); return(swapShain); }
public static DX11SwapChain FlipSequential(DxDevice device, IntPtr handle, Format format, Rational refreshRate) { DX11SwapChain swapShain = new DX11SwapChain(); swapShain.device = device; SwapChainDescription sd = new SwapChainDescription() { BufferCount = 2, ModeDescription = new ModeDescription(0, 0, refreshRate, format), IsWindowed = true, OutputHandle = handle, SampleDescription = new SampleDescription(1, 0), SwapEffect = SwapEffect.FlipSequential, Usage = Usage.RenderTargetOutput, Flags = SwapChainFlags.None }; swapShain.swapchain = new SwapChain(device.Factory, device.Device, sd); swapShain.Initialize(); return(swapShain); }
public static DX11SwapChain FromComposition(DxDevice dxDevice, int w, int h) { DX11SwapChain swapShain = new DX11SwapChain(); swapShain.device = dxDevice; var desc = new SharpDX.DXGI.SwapChainDescription1() { Width = w, Height = h, Format = SharpDX.DXGI.Format.B8G8R8A8_UNorm, Stereo = false, SampleDescription = new SharpDX.DXGI.SampleDescription(1, 0), Usage = SharpDX.DXGI.Usage.BackBuffer | SharpDX.DXGI.Usage.RenderTargetOutput | Usage.ShaderInput, BufferCount = 2, Scaling = SharpDX.DXGI.Scaling.None, SwapEffect = SharpDX.DXGI.SwapEffect.FlipSequential, AlphaMode = AlphaMode.Premultiplied }; swapShain.swapchain = new SwapChain1(dxDevice.Factory, dxDevice.Device, ref desc); swapShain.Initialize(); return(swapShain); }