Example #1
0
        protected override void BeginRenderPassCore(RenderPassDescriptor descriptor)
        {
            // Setup color attachments.
            int renderTargetCount = 0;

            for (var i = 0; i < descriptor.ColorAttachments.Length; ++i)
            {
                ref var colorAttachment = ref descriptor.ColorAttachments[i];

                var textureView = (D3D11TextureView)colorAttachment.Attachment;
                RenderTargetViews[i] = textureView.RenderTargetView;

                switch (colorAttachment.LoadAction)
                {
                case LoadAction.Clear:
                    _context.ClearRenderTargetView(
                        RenderTargetViews[i],
                        D3DConvert.Convert(colorAttachment.ClearColor)
                        );
                    break;

                default:
                    break;
                }

                renderTargetCount++;
            }
Example #2
0
        public D3D12Swapchain(D3D12GraphicsDevice device, PresentationParameters presentationParameters)
            : base(device,
                   presentationParameters,
                   ((D3D12CommandQueue)device.GraphicsQueue).NativeQueue,
                   2, 2)
        {
            _backbufferTextures = new D3D12Texture[_frameCount];
            for (int i = 0; i < _frameCount; i++)
            {
                var backBufferTexture  = _swapChain.GetBackBuffer <Resource>(i);
                var d3dTextureDesc     = backBufferTexture.Description;
                var textureDescription = TextureDescription.Texture2D(
                    (int)d3dTextureDesc.Width,
                    d3dTextureDesc.Height,
                    d3dTextureDesc.MipLevels,
                    d3dTextureDesc.DepthOrArraySize,
                    D3DConvert.Convert(d3dTextureDesc.Format),
                    D3D12Convert.Convert(d3dTextureDesc.Flags),
                    (SampleCount)d3dTextureDesc.SampleDescription.Count);

                _backbufferTextures[i] = new D3D12Texture(device, textureDescription, backBufferTexture);
            }

            Initialize(_backbufferTextures);
        }
Example #3
0
        public D3D11Swapchain(D3D11GraphicsDevice device, PresentationParameters presentationParameters)
            : base(device, presentationParameters, device.D3DDevice, 2, 1)
        {
            var backBufferTexture  = Resource.FromSwapChain <Texture2D>(_swapChain, 0);
            var d3dTextureDesc     = backBufferTexture.Description;
            var textureDescription = TextureDescription.Texture2D(
                d3dTextureDesc.Width,
                d3dTextureDesc.Height,
                d3dTextureDesc.MipLevels,
                d3dTextureDesc.ArraySize,
                D3DConvert.Convert(d3dTextureDesc.Format),
                D3D11Utils.Convert(d3dTextureDesc.BindFlags),
                (SampleCount)d3dTextureDesc.SampleDescription.Count);

            BackbufferTexture = new D3D11Texture(device, textureDescription, backBufferTexture);
            Initialize(new[] { BackbufferTexture });
        }