Beispiel #1
0
        protected override void SetFramebufferCore(Framebuffer fb)
        {
            D3D11Framebuffer d3dFB = Util.AssertSubtype <Framebuffer, D3D11Framebuffer>(fb);

            if (d3dFB.IsSwapchainFramebuffer)
            {
                _gd.CommandListsReferencingSwapchain.Add(this);
            }

            _context.OutputMerger.SetRenderTargets(d3dFB.DepthStencilView, d3dFB.RenderTargetViews);
        }
Beispiel #2
0
        protected override void SetFramebufferCore(Framebuffer fb)
        {
            D3D11Framebuffer d3dFB = Util.AssertSubtype <Framebuffer, D3D11Framebuffer>(fb);

            if (d3dFB.Swapchain != null)
            {
                d3dFB.Swapchain.AddCommandListReference(this);
                _referencedSwapchains.Add(d3dFB.Swapchain);
            }

            _context.OutputMerger.SetRenderTargets(d3dFB.DepthStencilView, d3dFB.RenderTargetViews);
        }
        private void RecreateSwapchainFramebuffer(int width, int height)
        {
            // NOTE: Perhaps this should be deferred until all CommandLists naturally remove their references to the swapchain.
            // The actual resize could be done in ExecuteCommands() when it is found that this list is empty.
            foreach (D3D11CommandList d3dCL in CommandListsReferencingSwapchain)
            {
                d3dCL.Reset();
            }

            _swapChainFramebuffer?.Dispose();

            _swapChain.ResizeBuffers(2, width, height, Format.B8G8R8A8_UNorm, SwapChainFlags.None);

            // Get the backbuffer from the swapchain
            using (SharpDX.Direct3D11.Texture2D backBufferTexture = _swapChain.GetBackBuffer <SharpDX.Direct3D11.Texture2D>(0))
                using (SharpDX.Direct3D11.Texture2D depthBufferTexture = new SharpDX.Direct3D11.Texture2D(
                           _device,
                           new Texture2DDescription()
                {
                    Format = Format.D16_UNorm,
                    ArraySize = 1,
                    MipLevels = 1,
                    Width = backBufferTexture.Description.Width,
                    Height = backBufferTexture.Description.Height,
                    SampleDescription = new SampleDescription(1, 0),
                    Usage = ResourceUsage.Default,
                    BindFlags = BindFlags.DepthStencil,
                    CpuAccessFlags = CpuAccessFlags.None,
                    OptionFlags = ResourceOptionFlags.None
                }))
                {
                    D3D11Texture           backBufferVdTexture = new D3D11Texture(backBufferTexture);
                    D3D11Texture           depthVdTexture      = new D3D11Texture(depthBufferTexture);
                    FramebufferDescription desc = new FramebufferDescription(depthVdTexture, backBufferVdTexture);
                    _swapChainFramebuffer = new D3D11Framebuffer(_device, ref desc);
                    _swapChainFramebuffer.IsSwapchainFramebuffer = true;
                }
        }
Beispiel #4
0
        private void ResetManagedState()
        {
            _numVertexBindings = 0;
            Util.ClearArray(_vertexBindings);
            _vertexStrides = null;
            Util.ClearArray(_vertexOffsets);

            _fb = null;

            Util.ClearArray(_viewports);
            Util.ClearArray(_scissors);
            _viewportsChanged    = false;
            _scissorRectsChanged = false;

            _ib                = null;
            _pipeline          = null;
            _blendState        = null;
            _depthStencilState = null;
            _rasterizerState   = null;
            _primitiveTopology = SharpDX.Direct3D.PrimitiveTopology.Undefined;
            _inputLayout       = null;
            _vertexShader      = null;
            _geometryShader    = null;
            _hullShader        = null;
            _domainShader      = null;
            _pixelShader       = null;
            Util.ClearArray(_resourceSets);

            Util.ClearArray(_vertexBoundUniformBuffers);
            Util.ClearArray(_vertexBoundTextureViews);
            Util.ClearArray(_vertexBoundSamplers);

            Util.ClearArray(_fragmentBoundUniformBuffers);
            Util.ClearArray(_fragmentBoundTextureViews);
            Util.ClearArray(_fragmentBoundSamplers);
        }