/// <summary>
        /// Function to perform initialization of the view.
        /// </summary>
        protected override void OnInitialize()
        {
            D3D.DepthStencilViewDescription desc = default(D3D.DepthStencilViewDescription);

            desc.Dimension = D3D.DepthStencilViewDimension.Unknown;

            switch (Resource.ResourceType)
            {
            case ResourceType.Texture1D:
                desc = GetDesc1D();
                break;

            case ResourceType.Texture2D:
                desc = GetDesc2D();
                break;
            }

            if (desc.Dimension == D3D.DepthStencilViewDimension.Unknown)
            {
                throw new GorgonException(GorgonResult.CannotCreate, Resources.GORGFX_VIEW_CANNOT_BIND_UNKNOWN_RESOURCE);
            }

            D3DView = new D3D.DepthStencilView(Resource.Graphics.D3DDevice, Resource.D3DResource, desc)
            {
                DebugName = string.Format("{0} '{1}' Depth Stencil View", Resource.ResourceType, Resource.Name)
            };
        }
Exemple #2
0
        protected bool InitializeViewsDelayed(out DepthStencilView readOnlyView)
        {
            bool hasReadOnlyView = false;

            readOnlyView = null;

            // Perform default initialization
            base.InitializeViews();

            if ((Description.BindFlags & BindFlags.DepthStencil) == 0)
            {
                return(hasReadOnlyView);
            }

            // Create a Depth stencil view on this texture2D
            var depthStencilViewDescription = new SharpDX.Direct3D11.DepthStencilViewDescription
            {
                Format    = (Format)DepthFormat,
                Flags     = SharpDX.Direct3D11.DepthStencilViewFlags.None,
                Dimension = SharpDX.Direct3D11.DepthStencilViewDimension.Texture2D,
                Texture2D = { MipSlice = 0 }
            };

            if (Description.SampleDescription.Count > 1)
            {
                depthStencilViewDescription.Dimension = DepthStencilViewDimension.Texture2DMultisampled;
            }

            // Create the Depth Stencil View
            depthStencilView = ToDispose(new SharpDX.Direct3D11.DepthStencilView(GraphicsDevice, Resource, depthStencilViewDescription)
            {
                Tag = this
            });

            // ReadOnly for feature level Direct3D11
            if (GraphicsDevice.Features.Level >= FeatureLevel.Level_11_0)
            {
                // Create a Depth stencil view on this texture2D
                depthStencilViewDescription.Flags = DepthStencilViewFlags.ReadOnlyDepth;
                if (HasStencil)
                {
                    depthStencilViewDescription.Flags |= DepthStencilViewFlags.ReadOnlyStencil;
                }

                readOnlyView = ToDispose(new SharpDX.Direct3D11.DepthStencilView(GraphicsDevice, Resource, depthStencilViewDescription)
                {
                    Tag = this
                });
                hasReadOnlyView = true;
            }

            return(hasReadOnlyView);
        }
Exemple #3
0
        public void CreateResources(D3D11.Device device, int sampleCount, int sampleQuality, int width, int height)
        {
            FieldOfView = width / (float)height;
            // render target
            D3D11.Texture2DDescription targetTextureDesc = new D3D11.Texture2DDescription()
            {
                Format            = DXGI.Format.R8G8B8A8_UNorm,
                ArraySize         = 1,
                MipLevels         = 1,
                Width             = width,
                Height            = height,
                SampleDescription = new DXGI.SampleDescription(sampleCount, sampleQuality),
                Usage             = D3D11.ResourceUsage.Default,
                BindFlags         = D3D11.BindFlags.RenderTarget | D3D11.BindFlags.ShaderResource,
                CpuAccessFlags    = D3D11.CpuAccessFlags.None,
                OptionFlags       = D3D11.ResourceOptionFlags.None
            };
            using (D3D11.Texture2D target = new D3D11.Texture2D(device, targetTextureDesc)) {
                renderTargetResource = new D3D11.ShaderResourceView(device, target);
                renderTargetView     = new D3D11.RenderTargetView(device, target);
            }

            // depth buffer
            D3D11.Texture2DDescription depthTextureDesc = new D3D11.Texture2DDescription()
            {
                Format            = DXGI.Format.R32_Typeless,
                ArraySize         = 1,
                MipLevels         = 1,
                Width             = width,
                Height            = height,
                SampleDescription = new DXGI.SampleDescription(sampleCount, sampleQuality),
                Usage             = D3D11.ResourceUsage.Default,
                BindFlags         = D3D11.BindFlags.DepthStencil | D3D11.BindFlags.ShaderResource,
                CpuAccessFlags    = D3D11.CpuAccessFlags.None,
                OptionFlags       = D3D11.ResourceOptionFlags.None
            };
            D3D11.DepthStencilViewDescription depthViewDesc = new D3D11.DepthStencilViewDescription()
            {
                Flags     = D3D11.DepthStencilViewFlags.None,
                Dimension = D3D11.DepthStencilViewDimension.Texture2D,
                Format    = DXGI.Format.D32_Float,
            };
            D3D11.ShaderResourceViewDescription depthResourceDesc = new D3D11.ShaderResourceViewDescription()
            {
                Format    = DXGI.Format.R32_Float,
                Dimension = SharpDX.Direct3D.ShaderResourceViewDimension.Texture2D
            };
            depthResourceDesc.Texture2D.MipLevels = 1;
            using (D3D11.Texture2D depthTexture = new D3D11.Texture2D(device, depthTextureDesc)) {
                depthStencilView     = new D3D11.DepthStencilView(device, depthTexture, depthViewDesc);
                depthStencilResource = new D3D11.ShaderResourceView(device, depthTexture, depthResourceDesc);
            }
        }
        /// <summary>
        /// Function to perform initialization of the view.
        /// </summary>
        private protected override D3D11.ResourceView OnCreateNativeView()
        {
            D3D11.DepthStencilViewDescription desc = GetDesc2D();

            Graphics.Log.Print($"'{Texture.Name}': Creating D3D11 depth/stencil view.", LoggingLevel.Simple);

            Graphics.Log.Print($"Depth/Stencil View '{Texture.Name}': {Texture.ResourceType} -> Mip slice: {MipSlice}, Array Index: {ArrayIndex}, Array Count: {ArrayCount}",
                               LoggingLevel.Verbose);

            Native = new D3D11.DepthStencilView(Texture.Graphics.D3DDevice, Texture.D3DResource, desc)
            {
                DebugName = $"'{Texture.Name}'_D3D11DepthStencilView1_2D"
            };

            return(Native);
        }
        public void CreateDepthStencil(
            D3D11.Device device,
            D3D11.Texture2DDescription textureDesc,
            D3D11.DepthStencilViewDescription viewDesc,
            D3D11.ShaderResourceViewDescription resourceViewDesc)
        {
            depthStencil     = new D3D11.Texture2D(device, textureDesc);
            depthStencilSwap = new D3D11.Texture2D(device, textureDesc);


            defaultRenderViews.DSV = new D3D11.DepthStencilView(device, depthStencil, viewDesc);
            swapRenderViews.DSV    = new D3D11.DepthStencilView(device, depthStencil, viewDesc);

            defaultRenderViews.DS_SRVT = new D3D11.ShaderResourceView(device, depthStencil, resourceViewDesc);
            swapRenderViews.DS_SRVT    = new D3D11.ShaderResourceView(device, depthStencil, resourceViewDesc);
        }
Exemple #6
0
        private void InitializeDeviceResources(DXGI.SwapChain swapChain)
        {
            backbufferTexture = swapChain.GetBackBuffer <D3D11.Texture2D>(0);
            backbufferRTV     = new D3D11.RenderTargetView(device, backbufferTexture);

            width  = backbufferTexture.Description.Width;
            height = backbufferTexture.Description.Height;

            D3D11.Texture2DDescription sceneTextureDesc = new D3D11.Texture2DDescription
            {
                CpuAccessFlags    = D3D11.CpuAccessFlags.None,
                BindFlags         = D3D11.BindFlags.RenderTarget | D3D11.BindFlags.ShaderResource,
                Format            = DXGI.Format.R8G8B8A8_UNorm,
                Width             = width,
                Height            = height,
                OptionFlags       = D3D11.ResourceOptionFlags.None,
                MipLevels         = 1,
                ArraySize         = 1,
                SampleDescription = { Count = 1, Quality = 0 },
                Usage             = D3D11.ResourceUsage.Default
            };

            sceneTexture = new D3D11.Texture2D(device, sceneTextureDesc);
            sceneRTV     = new D3D11.RenderTargetView(device, sceneTexture);
            sceneSRV     = new D3D11.ShaderResourceView(device, sceneTexture);

            var depthBufferDesc = new D3D11.Texture2DDescription()
            {
                Width             = width,
                Height            = height,
                MipLevels         = 1,
                ArraySize         = 1,
                Format            = DXGI.Format.R32_Typeless,
                SampleDescription = { Count = 1, Quality = 0 },
                Usage             = D3D11.ResourceUsage.Default,
                BindFlags         = D3D11.BindFlags.DepthStencil | D3D11.BindFlags.ShaderResource,
                CpuAccessFlags    = D3D11.CpuAccessFlags.None,
                OptionFlags       = D3D11.ResourceOptionFlags.None
            };

            using (var depthStencilBufferTexture = new D3D11.Texture2D(device, depthBufferDesc))
            {
                var depthStencilViewDesc = new D3D11.DepthStencilViewDescription()
                {
                    Format    = DXGI.Format.D32_Float,
                    Dimension = D3D11.DepthStencilViewDimension.Texture2D,
                    Texture2D = { MipSlice = 0 }
                };

                depthDSV = new D3D11.DepthStencilView(device, depthStencilBufferTexture, depthStencilViewDesc);

                var shaderResourceViewDesc = new D3D11.ShaderResourceViewDescription()
                {
                    Format    = DXGI.Format.R32_Float,
                    Dimension = SharpDX.Direct3D.ShaderResourceViewDimension.Texture2D,
                    Texture2D = { MipLevels = 1, MostDetailedMip = 0 }
                };

                depthSRV = new D3D11.ShaderResourceView(device, depthStencilBufferTexture, shaderResourceViewDesc);
            }

            var depthStencilDesc = new D3D11.DepthStencilStateDescription()
            {
                IsDepthEnabled   = true,
                DepthWriteMask   = D3D11.DepthWriteMask.All,
                DepthComparison  = D3D11.Comparison.Less,
                IsStencilEnabled = false,
                StencilReadMask  = 0xFF,
                StencilWriteMask = 0xFF,

                FrontFace = new D3D11.DepthStencilOperationDescription()
                {
                    FailOperation      = D3D11.StencilOperation.Keep,
                    DepthFailOperation = D3D11.StencilOperation.Keep,
                    PassOperation      = D3D11.StencilOperation.Keep,
                    Comparison         = D3D11.Comparison.Always
                },

                BackFace = new D3D11.DepthStencilOperationDescription()
                {
                    FailOperation      = D3D11.StencilOperation.Keep,
                    DepthFailOperation = D3D11.StencilOperation.Keep,
                    PassOperation      = D3D11.StencilOperation.Keep,
                    Comparison         = D3D11.Comparison.Always
                }
            };

            depthStencilState = new D3D11.DepthStencilState(device, depthStencilDesc);

            var rasterDesc = new D3D11.RasterizerStateDescription()
            {
                IsAntialiasedLineEnabled = false,
                CullMode                = D3D11.CullMode.Back,
                DepthBias               = 0,
                DepthBiasClamp          = 0.0f,
                IsDepthClipEnabled      = true,
                FillMode                = D3D11.FillMode.Solid,
                IsFrontCounterClockwise = false,
                IsMultisampleEnabled    = false,
                IsScissorEnabled        = false,
                SlopeScaledDepthBias    = 0.0f
            };

            rasterizerState = new D3D11.RasterizerState(device, rasterDesc);
        }
        /// <summary>Initializes the views delayed.</summary>
        /// <param name="readOnlyView">The read only view.</param>
        /// <returns><c>true</c> if it has readonly view, <c>false</c> otherwise.</returns>
        protected bool InitializeViewsDelayed(out DepthStencilView readOnlyView)
        {
            bool hasReadOnlyView = false;
            readOnlyView = null;

            // Perform default initialization
            base.InitializeViews();         
   
            if ((Description.BindFlags & BindFlags.DepthStencil) == 0)
                return hasReadOnlyView;

            // Create a Depth stencil view on this texture2D
            var depthStencilViewDescription = new SharpDX.Direct3D11.DepthStencilViewDescription
                                                  {
                                                      Format = (Format)DepthFormat,
                                                      Flags = SharpDX.Direct3D11.DepthStencilViewFlags.None,
                                                      Dimension = SharpDX.Direct3D11.DepthStencilViewDimension.Texture2D,
                                                      Texture2D = { MipSlice = 0 }
                                                  };
            if (Description.SampleDescription.Count > 1)
                depthStencilViewDescription.Dimension = DepthStencilViewDimension.Texture2DMultisampled;

            // Create the Depth Stencil View
            depthStencilView = ToDispose(new SharpDX.Direct3D11.DepthStencilView(GraphicsDevice, Resource, depthStencilViewDescription) { Tag = this });

            // ReadOnly for feature level Direct3D11
            if (GraphicsDevice.Features.Level >= FeatureLevel.Level_11_0)
            {
                // Create a Depth stencil view on this texture2D
                depthStencilViewDescription.Flags = DepthStencilViewFlags.ReadOnlyDepth;
                if (HasStencil)
                    depthStencilViewDescription.Flags |= DepthStencilViewFlags.ReadOnlyStencil;

                readOnlyView = ToDispose(new SharpDX.Direct3D11.DepthStencilView(GraphicsDevice, Resource, depthStencilViewDescription) { Tag = this });
                hasReadOnlyView = true;
            }

            return hasReadOnlyView;
        }
Exemple #8
0
        public void InitRenderTargets()
        {
            D3D11.DeviceContext deviceContext = deviceResources.DeviceContext;

            var renderTargetDesc = new D3D11.Texture2DDescription()
            {
                Format            = Format.R16G16B16A16_Float,
                ArraySize         = 1,
                MipLevels         = 1,
                Width             = deviceResources.BackBuffer.Description.Width,
                Height            = deviceResources.BackBuffer.Description.Height,
                SampleDescription = sampleDescription,
                Usage             = D3D11.ResourceUsage.Default,
                BindFlags         = D3D11.BindFlags.RenderTarget | D3D11.BindFlags.ShaderResource,
                CpuAccessFlags    = D3D11.CpuAccessFlags.None,
                OptionFlags       = D3D11.ResourceOptionFlags.None
            };

            var depthStencilDesc = new D3D11.Texture2DDescription()
            {
                Format            = Format.R24G8_Typeless,
                ArraySize         = 1,
                MipLevels         = 1,
                Width             = deviceResources.BackBuffer.Description.Width,
                Height            = deviceResources.BackBuffer.Description.Height,
                SampleDescription = sampleDescription,
                Usage             = D3D11.ResourceUsage.Default,
                BindFlags         = D3D11.BindFlags.DepthStencil | D3D11.BindFlags.ShaderResource,
                CpuAccessFlags    = D3D11.CpuAccessFlags.None,
                OptionFlags       = D3D11.ResourceOptionFlags.None
            };

            var depthStencilStateDesc = new D3D11.DepthStencilStateDescription
            {
                IsDepthEnabled  = true,
                DepthComparison = D3D11.Comparison.LessEqual,
                DepthWriteMask  = D3D11.DepthWriteMask.All,
            };


            // Create Descripptions for DepthStencil
            // RenderTarget works without Desc
            D3D11.DepthStencilViewDescription dsvDesc = new D3D11.DepthStencilViewDescription();
            dsvDesc.Format             = Format.D24_UNorm_S8_UInt;
            dsvDesc.Dimension          = D3D11.DepthStencilViewDimension.Texture2D;
            dsvDesc.Texture2D.MipSlice = 0;
            dsvDesc.Flags = 0;

            D3D11.ShaderResourceViewDescription dsSrvtDesc = new D3D11.ShaderResourceViewDescription();
            dsSrvtDesc.Texture2D.MipLevels = 1;
            dsSrvtDesc.Dimension           = ShaderResourceViewDimension.Texture2D;
            dsSrvtDesc.Format = Format.R24_UNorm_X8_Typeless; // TODO: Check Format


            // Create RenderTarget Textures
            renderTargetHandler.CreateRenderTarget(deviceResources.Device, renderTargetDesc);
            renderTargetHandler.CreateDepthStencil(deviceResources.Device, depthStencilDesc, dsvDesc, dsSrvtDesc);


            deviceContext.OutputMerger.SetRenderTargets(
                renderTargetHandler.GetDepthStencilView(),
                renderTargetHandler.GetRenderTargetView()
                );



            // Create DepthStencilState
            var depthStencilState = new D3D11.DepthStencilState(deviceResources.Device, depthStencilStateDesc);

            deviceContext.OutputMerger.SetDepthStencilState(depthStencilState);

            // Create Sampler
            sampler = CreateSampler();
            deviceContext.VertexShader.SetSampler(0, sampler);
            deviceContext.PixelShader.SetSampler(0, sampler);

            deviceContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList;

            Logger.Write(LogType.Info, "Renderer Created");
        }
        private void InitializeViews(out bool hasStencil)
        {
            var nativeDescription = ((Texture2D)Texture).NativeDescription;

            if ((nativeDescription.BindFlags & BindFlags.DepthStencil) == 0)
            {
                throw new InvalidOperationException();
            }

            // Check that the format is supported
            if (ComputeShaderResourceFormat((Format)Texture.Description.Format) == Format.Unknown)
            {
                throw new NotSupportedException("Depth stencil format not supported");
            }

            // Setup the HasStencil flag
            hasStencil = IsStencilFormat(nativeDescription.Format);

            // Create a Depth stencil view on this texture2D
            var depthStencilViewDescription = new SharpDX.Direct3D11.DepthStencilViewDescription
            {
                Format = ComputeDepthViewFormatFromTextureFormat(nativeDescription.Format),
                Flags  = SharpDX.Direct3D11.DepthStencilViewFlags.None,
            };

            if (nativeDescription.ArraySize > 1)
            {
                depthStencilViewDescription.Dimension = SharpDX.Direct3D11.DepthStencilViewDimension.Texture2DArray;
                depthStencilViewDescription.Texture2DArray.ArraySize       = nativeDescription.ArraySize;
                depthStencilViewDescription.Texture2DArray.FirstArraySlice = 0;
                depthStencilViewDescription.Texture2DArray.MipSlice        = 0;
            }
            else
            {
                depthStencilViewDescription.Dimension          = SharpDX.Direct3D11.DepthStencilViewDimension.Texture2D;
                depthStencilViewDescription.Texture2D.MipSlice = 0;
            }

            if (nativeDescription.SampleDescription.Count > 1)
            {
                depthStencilViewDescription.Dimension = DepthStencilViewDimension.Texture2DMultisampled;
            }

            if (isReadOnly)
            {
                if (!IsReadOnlySupported(GraphicsDevice))
                {
                    throw new NotSupportedException("Cannot instantiate ReadOnly DepthStencilBuffer. Not supported on this device.");
                }

                // Create a Depth stencil view on this texture2D
                depthStencilViewDescription.Flags = DepthStencilViewFlags.ReadOnlyDepth;
                if (HasStencil)
                {
                    depthStencilViewDescription.Flags |= DepthStencilViewFlags.ReadOnlyStencil;
                }

                // Create the Depth Stencil View
                NativeDepthStencilView = new SharpDX.Direct3D11.DepthStencilView(GraphicsDevice.NativeDevice, Texture.NativeResource, depthStencilViewDescription);
            }
            else
            {
                // Create the Depth Stencil View
                NativeDepthStencilView = new SharpDX.Direct3D11.DepthStencilView(GraphicsDevice.NativeDevice, Texture.NativeResource, depthStencilViewDescription);
            }
        }
Exemple #10
0
        private void InitializeDeviceResources(DXGI.SwapChain swapChain)
        {
            backbufferTexture = swapChain.GetBackBuffer <D3D11.Texture2D>(0);
            backbufferRTV     = new D3D11.RenderTargetView(device, backbufferTexture);

            width  = backbufferTexture.Description.Width;
            height = backbufferTexture.Description.Height;

            var depthBufferDesc = new D3D11.Texture2DDescription()
            {
                Width             = width,
                Height            = height,
                MipLevels         = 1,
                ArraySize         = 1,
                Format            = DXGI.Format.D24_UNorm_S8_UInt,
                SampleDescription = new DXGI.SampleDescription(1, 0),
                Usage             = D3D11.ResourceUsage.Default,
                BindFlags         = D3D11.BindFlags.DepthStencil,
                CpuAccessFlags    = D3D11.CpuAccessFlags.None,
                OptionFlags       = D3D11.ResourceOptionFlags.None
            };

            using (var depthStencilBufferTexture = new D3D11.Texture2D(device, depthBufferDesc))
            {
                var depthStencilViewDesc = new D3D11.DepthStencilViewDescription()
                {
                    Format    = DXGI.Format.D24_UNorm_S8_UInt,
                    Dimension = D3D11.DepthStencilViewDimension.Texture2D,
                    Texture2D = new D3D11.DepthStencilViewDescription.Texture2DResource()
                    {
                        MipSlice = 0
                    }
                };

                depthDSV = new D3D11.DepthStencilView(device, depthStencilBufferTexture, depthStencilViewDesc);
            }



            var depthStencilDesc = new D3D11.DepthStencilStateDescription()
            {
                IsDepthEnabled   = true,
                DepthWriteMask   = D3D11.DepthWriteMask.All,
                DepthComparison  = D3D11.Comparison.Less,
                IsStencilEnabled = false,
                StencilReadMask  = 0xFF,
                StencilWriteMask = 0xFF,

                FrontFace = new D3D11.DepthStencilOperationDescription()
                {
                    FailOperation      = D3D11.StencilOperation.Keep,
                    DepthFailOperation = D3D11.StencilOperation.Keep,
                    PassOperation      = D3D11.StencilOperation.Keep,
                    Comparison         = D3D11.Comparison.Always
                },

                BackFace = new D3D11.DepthStencilOperationDescription()
                {
                    FailOperation      = D3D11.StencilOperation.Keep,
                    DepthFailOperation = D3D11.StencilOperation.Keep,
                    PassOperation      = D3D11.StencilOperation.Keep,
                    Comparison         = D3D11.Comparison.Always
                }
            };

            depthStencilState = new D3D11.DepthStencilState(device, depthStencilDesc);

            var rasterDesc = new D3D11.RasterizerStateDescription()
            {
                IsAntialiasedLineEnabled = false,
                CullMode                = D3D11.CullMode.Back,
                DepthBias               = 0,
                DepthBiasClamp          = 0.0f,
                IsDepthClipEnabled      = false,
                FillMode                = D3D11.FillMode.Solid,
                IsFrontCounterClockwise = false,
                IsMultisampleEnabled    = false,
                IsScissorEnabled        = false,
                SlopeScaledDepthBias    = 0.0f
            };

            /*var blendDesc = new D3D11.BlendStateDescription();
             * blendDesc.RenderTarget[0].IsBlendEnabled = true;
             * blendDesc.RenderTarget[0].SourceBlend = D3D11.BlendOption.SourceAlpha;
             * blendDesc.RenderTarget[0].DestinationBlend = D3D11.BlendOption.InverseSourceAlpha;
             * blendDesc.RenderTarget[0].BlendOperation = D3D11.BlendOperation.Add;
             * blendDesc.RenderTarget[0].SourceAlphaBlend = D3D11.BlendOption.Zero;
             * blendDesc.RenderTarget[0].DestinationAlphaBlend = D3D11.BlendOption.Zero;
             * blendDesc.RenderTarget[0].AlphaBlendOperation = D3D11.BlendOperation.Add;
             * blendDesc.RenderTarget[0].RenderTargetWriteMask = D3D11.ColorWriteMaskFlags.All;*/

#if ALPHABLENDING
            var blendDesc = new D3D11.BlendStateDescription();
            blendDesc.RenderTarget[0].IsBlendEnabled        = true;
            blendDesc.RenderTarget[0].SourceBlend           = D3D11.BlendOption.SourceAlpha;
            blendDesc.RenderTarget[0].DestinationBlend      = D3D11.BlendOption.InverseSourceAlpha;
            blendDesc.RenderTarget[0].BlendOperation        = D3D11.BlendOperation.Add;
            blendDesc.RenderTarget[0].SourceAlphaBlend      = D3D11.BlendOption.Zero;
            blendDesc.RenderTarget[0].DestinationAlphaBlend = D3D11.BlendOption.One;
            blendDesc.RenderTarget[0].AlphaBlendOperation   = D3D11.BlendOperation.Add;
            blendDesc.RenderTarget[0].RenderTargetWriteMask = D3D11.ColorWriteMaskFlags.All;
#endif

#if ADDITIVEBLENDING
            var blendDesc = new D3D11.BlendStateDescription();
            blendDesc.RenderTarget[0].IsBlendEnabled        = true;
            blendDesc.RenderTarget[0].SourceBlend           = D3D11.BlendOption.SourceAlpha;
            blendDesc.RenderTarget[0].DestinationBlend      = D3D11.BlendOption.DestinationAlpha;
            blendDesc.RenderTarget[0].BlendOperation        = D3D11.BlendOperation.Add;
            blendDesc.RenderTarget[0].SourceAlphaBlend      = D3D11.BlendOption.One;
            blendDesc.RenderTarget[0].DestinationAlphaBlend = D3D11.BlendOption.One;
            blendDesc.RenderTarget[0].AlphaBlendOperation   = D3D11.BlendOperation.Add;
            blendDesc.RenderTarget[0].RenderTargetWriteMask = D3D11.ColorWriteMaskFlags.All;
#endif



            //     RenderTarget[0].BlendOpSharpDX.Direct3D11.BlendOperation.Add RenderTarget[0].SrcBlendAlphaSharpDX.Direct3D11.BlendOption.One
            //     RenderTarget[0].DestBlendAlphaSharpDX.Direct3D11.BlendOption.Zero RenderTarget[0].BlendOpAlphaSharpDX.Direct3D11.BlendOperation.Add
            //     RenderTarget[0].RenderTargetWriteMaskSharpDX.Direct3D11.ColorWriteMaskFlags.All


            blendState      = new D3D11.BlendState(device, blendDesc);
            rasterizerState = new D3D11.RasterizerState(device, rasterDesc);
        }