Пример #1
0
        private void Dispose(bool disposing)
        {
            if (mDepthView != null)
            {
                mDepthView.Dispose();
                mDepthView = null;
            }

            if (mOldDepthView != null)
            {
                mOldDepthView.Dispose();
                mOldDepthView = null;
            }

            if (mOldRenderTarget != null)
            {
                mOldRenderTarget.Dispose();
                mOldRenderTarget = null;
            }

            if (mDepthTexture != null)
            {
                mDepthTexture.Dispose();
                mDepthTexture = null;
            }

            if (Native != null)
            {
                Native.Dispose();
                Native = null;
            }

            if (Texture != null)
            {
                Texture.Dispose();
                Texture = null;
            }

            mContext = null;
        }
Пример #2
0
        // ReSharper disable once FunctionComplexityOverflow
        public void Resize(int width, int height, bool bgra)
        {
            if (Texture != null)
            {
                Texture.Dispose();
            }

            if (Native != null)
            {
                Native.Dispose();
            }

            var texDesc = new Texture2DDescription
            {
                ArraySize         = 1,
                BindFlags         = BindFlags.RenderTarget,
                CpuAccessFlags    = CpuAccessFlags.None,
                Format            = bgra ? SharpDX.DXGI.Format.B8G8R8A8_UNorm : SharpDX.DXGI.Format.R8G8B8A8_UNorm,
                Height            = height,
                MipLevels         = 1,
                OptionFlags       = ResourceOptionFlags.None,
                SampleDescription = mContext.Multisampling,
                Usage             = ResourceUsage.Default,
                Width             = width
            };

            Texture = new Texture2D(mContext.Device, texDesc);

            var rtvd = new RenderTargetViewDescription
            {
                Dimension = RenderTargetViewDimension.Texture2DMultisampled,
                Format    = texDesc.Format,

                Texture2DMS = new RenderTargetViewDescription.Texture2DMultisampledResource()
            };

            Native = new RenderTargetView(mContext.Device, Texture, rtvd);

            if (mDepthTexture != null)
            {
                mDepthTexture.Dispose();
            }

            if (mDepthView != null)
            {
                mDepthView.Dispose();
            }

            texDesc = new Texture2DDescription
            {
                ArraySize         = 1,
                BindFlags         = BindFlags.DepthStencil,
                CpuAccessFlags    = CpuAccessFlags.None,
                Format            = SharpDX.DXGI.Format.D24_UNorm_S8_UInt,
                Height            = height,
                MipLevels         = 1,
                OptionFlags       = ResourceOptionFlags.None,
                SampleDescription = mContext.Multisampling,
                Usage             = ResourceUsage.Default,
                Width             = width
            };

            mDepthTexture = new Texture2D(mContext.Device, texDesc);

            var dsvd = new DepthStencilViewDescription
            {
                Dimension   = DepthStencilViewDimension.Texture2DMultisampled,
                Flags       = DepthStencilViewFlags.None,
                Format      = SharpDX.DXGI.Format.D24_UNorm_S8_UInt,
                Texture2DMS = new DepthStencilViewDescription.Texture2DMultisampledResource()
            };

            mDepthView = new DepthStencilView(mContext.Device, mDepthTexture, dsvd);
        }