예제 #1
0
        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
            }
예제 #2
0
        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));
        }