internal MyDepthStencil(int width, int height,
            int sampleCount, int sampleQuality)
        {
            m_resolution = new Vector2I(width, height);
            m_samples = new Vector2I(sampleCount, sampleQuality);

            m_depthSubresource = new MyDepthView(this);
            m_stencilSubresource = new MyStencilView(this);

            Texture2DDescription desc = new Texture2DDescription();
            desc.Width = width;
            desc.Height = height;
            desc.Format = Depth32F ? Format.R32G8X24_Typeless : Format.R24G8_Typeless;
            desc.ArraySize = 1;
            desc.MipLevels = 1;
            desc.BindFlags = BindFlags.DepthStencil | BindFlags.ShaderResource;
            desc.Usage = ResourceUsage.Default;
            desc.CpuAccessFlags = 0;
            desc.SampleDescription.Count = sampleCount;
            desc.SampleDescription.Quality = sampleQuality;
            desc.OptionFlags = 0;
            m_resource = new Texture2D(MyRender11.Device, desc);

            DepthStencilViewDescription dsvDesc = new DepthStencilViewDescription();
            dsvDesc.Format = Depth32F ? Format.D32_Float_S8X24_UInt : Format.D24_UNorm_S8_UInt;
            if (sampleCount == 1)
            {
                dsvDesc.Dimension = DepthStencilViewDimension.Texture2D;
                dsvDesc.Flags = DepthStencilViewFlags.None;
                dsvDesc.Texture2D.MipSlice = 0;
            }
            else
            {
                dsvDesc.Dimension = DepthStencilViewDimension.Texture2DMultisampled;
                dsvDesc.Flags = DepthStencilViewFlags.None;
            }
            m_DSV = new DepthStencilView(MyRender11.Device, m_resource, dsvDesc);
            if (sampleCount == 1)
            {
                dsvDesc.Dimension = DepthStencilViewDimension.Texture2D;
                dsvDesc.Flags = DepthStencilViewFlags.ReadOnlyDepth;
                dsvDesc.Texture2D.MipSlice = 0;
            }
            else
            {
                dsvDesc.Dimension = DepthStencilViewDimension.Texture2DMultisampled;
                dsvDesc.Flags = DepthStencilViewFlags.ReadOnlyDepth;
            }
            m_DSV_roDepth = new DepthStencilView(MyRender11.Device, m_resource, dsvDesc);
            if (sampleCount == 1)
            {
                dsvDesc.Dimension = DepthStencilViewDimension.Texture2D;
                dsvDesc.Flags = DepthStencilViewFlags.ReadOnlyStencil;
                dsvDesc.Texture2D.MipSlice = 0;
            }
            else
            {
                dsvDesc.Dimension = DepthStencilViewDimension.Texture2DMultisampled;
                dsvDesc.Flags = DepthStencilViewFlags.ReadOnlyStencil;
            }
            m_DSV_roStencil = new DepthStencilView(MyRender11.Device, m_resource, dsvDesc);
            dsvDesc.Flags = DepthStencilViewFlags.ReadOnlyStencil | DepthStencilViewFlags.ReadOnlyDepth;
            if (sampleCount == 1)
            {
                dsvDesc.Dimension = DepthStencilViewDimension.Texture2D;
                dsvDesc.Texture2D.MipSlice = 0;
            }
            else
            {
                dsvDesc.Dimension = DepthStencilViewDimension.Texture2DMultisampled;
            }
            m_DSV_ro = new DepthStencilView(MyRender11.Device, m_resource, dsvDesc);

            ShaderResourceViewDescription srvDesc = new ShaderResourceViewDescription();
            srvDesc.Format = Depth32F ? Format.R32_Float_X8X24_Typeless : Format.R24_UNorm_X8_Typeless;
            if (sampleCount == 1)
            {
                srvDesc.Dimension = ShaderResourceViewDimension.Texture2D;
                srvDesc.Texture2D.MipLevels = -1;
                srvDesc.Texture2D.MostDetailedMip = 0;
            }
            else
            {
                srvDesc.Dimension = ShaderResourceViewDimension.Texture2DMultisampled;
            }
            m_SRV_depth = new ShaderResourceView(MyRender11.Device, m_resource, srvDesc);

            srvDesc.Format = Depth32F ? Format.X32_Typeless_G8X24_UInt : Format.X24_Typeless_G8_UInt;
            if (sampleCount == 1)
            {
                srvDesc.Dimension = ShaderResourceViewDimension.Texture2D;
                srvDesc.Texture2D.MipLevels = -1;
                srvDesc.Texture2D.MostDetailedMip = 0;
            }
            else
            {
                srvDesc.Dimension = ShaderResourceViewDimension.Texture2DMultisampled;
            }
            m_SRV_stencil = new ShaderResourceView(MyRender11.Device, m_resource, srvDesc);
        }
        internal MyDepthStencil(int width, int height,
                                int sampleCount, int sampleQuality)
        {
            m_resolution = new Vector2I(width, height);
            m_samples    = new Vector2I(sampleCount, sampleQuality);

            m_depthSubresource   = new MyDepthView(this);
            m_stencilSubresource = new MyStencilView(this);

            Texture2DDescription desc = new Texture2DDescription();

            desc.Width                     = width;
            desc.Height                    = height;
            desc.Format                    = Depth32F ? Format.R32G8X24_Typeless : Format.R24G8_Typeless;
            desc.ArraySize                 = 1;
            desc.MipLevels                 = 1;
            desc.BindFlags                 = BindFlags.DepthStencil | BindFlags.ShaderResource;
            desc.Usage                     = ResourceUsage.Default;
            desc.CpuAccessFlags            = 0;
            desc.SampleDescription.Count   = sampleCount;
            desc.SampleDescription.Quality = sampleQuality;
            desc.OptionFlags               = 0;
            m_resource                     = new Texture2D(MyRender11.Device, desc);

            DepthStencilViewDescription dsvDesc = new DepthStencilViewDescription();

            dsvDesc.Format = Depth32F ? Format.D32_Float_S8X24_UInt : Format.D24_UNorm_S8_UInt;
            if (sampleCount == 1)
            {
                dsvDesc.Dimension          = DepthStencilViewDimension.Texture2D;
                dsvDesc.Flags              = DepthStencilViewFlags.None;
                dsvDesc.Texture2D.MipSlice = 0;
            }
            else
            {
                dsvDesc.Dimension = DepthStencilViewDimension.Texture2DMultisampled;
                dsvDesc.Flags     = DepthStencilViewFlags.None;
            }
            m_DSV = new DepthStencilView(MyRender11.Device, m_resource, dsvDesc);
            if (sampleCount == 1)
            {
                dsvDesc.Dimension          = DepthStencilViewDimension.Texture2D;
                dsvDesc.Flags              = DepthStencilViewFlags.ReadOnlyDepth;
                dsvDesc.Texture2D.MipSlice = 0;
            }
            else
            {
                dsvDesc.Dimension = DepthStencilViewDimension.Texture2DMultisampled;
                dsvDesc.Flags     = DepthStencilViewFlags.ReadOnlyDepth;
            }
            m_DSV_roDepth = new DepthStencilView(MyRender11.Device, m_resource, dsvDesc);
            if (sampleCount == 1)
            {
                dsvDesc.Dimension          = DepthStencilViewDimension.Texture2D;
                dsvDesc.Flags              = DepthStencilViewFlags.ReadOnlyStencil;
                dsvDesc.Texture2D.MipSlice = 0;
            }
            else
            {
                dsvDesc.Dimension = DepthStencilViewDimension.Texture2DMultisampled;
                dsvDesc.Flags     = DepthStencilViewFlags.ReadOnlyStencil;
            }
            m_DSV_roStencil = new DepthStencilView(MyRender11.Device, m_resource, dsvDesc);
            dsvDesc.Flags   = DepthStencilViewFlags.ReadOnlyStencil | DepthStencilViewFlags.ReadOnlyDepth;
            if (sampleCount == 1)
            {
                dsvDesc.Dimension          = DepthStencilViewDimension.Texture2D;
                dsvDesc.Texture2D.MipSlice = 0;
            }
            else
            {
                dsvDesc.Dimension = DepthStencilViewDimension.Texture2DMultisampled;
            }
            m_DSV_ro = new DepthStencilView(MyRender11.Device, m_resource, dsvDesc);

            ShaderResourceViewDescription srvDesc = new ShaderResourceViewDescription();

            srvDesc.Format = Depth32F ? Format.R32_Float_X8X24_Typeless : Format.R24_UNorm_X8_Typeless;
            if (sampleCount == 1)
            {
                srvDesc.Dimension                 = ShaderResourceViewDimension.Texture2D;
                srvDesc.Texture2D.MipLevels       = -1;
                srvDesc.Texture2D.MostDetailedMip = 0;
            }
            else
            {
                srvDesc.Dimension = ShaderResourceViewDimension.Texture2DMultisampled;
            }
            m_SRV_depth = new ShaderResourceView(MyRender11.Device, m_resource, srvDesc);

            srvDesc.Format = Depth32F ? Format.X32_Typeless_G8X24_UInt : Format.X24_Typeless_G8_UInt;
            if (sampleCount == 1)
            {
                srvDesc.Dimension                 = ShaderResourceViewDimension.Texture2D;
                srvDesc.Texture2D.MipLevels       = -1;
                srvDesc.Texture2D.MostDetailedMip = 0;
            }
            else
            {
                srvDesc.Dimension = ShaderResourceViewDimension.Texture2DMultisampled;
            }
            m_SRV_stencil = new ShaderResourceView(MyRender11.Device, m_resource, srvDesc);
        }