当前位置: 首页>>代码示例>>C#>>正文


C# ShaderResourceViewDescription类代码示例

本文整理汇总了C#中ShaderResourceViewDescription的典型用法代码示例。如果您正苦于以下问题:C# ShaderResourceViewDescription类的具体用法?C# ShaderResourceViewDescription怎么用?C# ShaderResourceViewDescription使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ShaderResourceViewDescription类属于命名空间,在下文中一共展示了ShaderResourceViewDescription类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RenderTexture

        /// <summary>
        /// Constructor
        /// Creates the texture we will render to based on the supplied width and height
        /// </summary>
        /// <param name="device">The device we will create the texture with</param>
        /// <param name="texWidth"></param>
        /// <param name="texHeight"></param>
        public RenderTexture(Device device, int texWidth, int texHeight)
        {
            Texture2DDescription textureDescription = new Texture2DDescription()
                {
                    Width = texWidth,
                    Height = texHeight,
                    MipLevels = 1,
                    ArraySize = 1,
                    Format = SlimDX.DXGI.Format.R32G32B32A32_Float,
                    SampleDescription = new SlimDX.DXGI.SampleDescription(1, 0),
                    BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource,
                    CpuAccessFlags = CpuAccessFlags.None,
                    OptionFlags = ResourceOptionFlags.None,
                    Usage = ResourceUsage.Default,
                };
            Texture = new Texture2D(device, textureDescription);
            RenderTargetViewDescription renderTargetViewDescription = new RenderTargetViewDescription()
            {
                Format = textureDescription.Format,
                Dimension = RenderTargetViewDimension.Texture2D,
                MipSlice = 0,
            };

            renderTargetView = new RenderTargetView(device, Texture, renderTargetViewDescription);

            ShaderResourceViewDescription shaderResourceViewDescription = new ShaderResourceViewDescription()
            {
                Format = textureDescription.Format,
                Dimension = ShaderResourceViewDimension.Texture2D,
                MostDetailedMip = 0,
                MipLevels = 1
            };

            shaderResourceView = new ShaderResourceView(device, Texture, shaderResourceViewDescription);
        }
开发者ID:nickudell,项目名称:PigmentFramework,代码行数:42,代码来源:RenderTexture.cs

示例2: Resize

        /// <summary>
        /// Resizes the buffer to the nearest power of two >= nElements
        /// and sets Count to nElements
        /// </summary>
        /// <param name="nElements"></param>
        public void Resize( int nElements )
        {
            if( nElements > Capacity || // if we need more than we currently have allocated
                nElements < Capacity / 2 ) // or if the current one is more than twice as big
            {
                Capacity = nElements.RoundUpToNearestPowerOfTwo();

                if( Buffer != null )
                {
                    View.Dispose();
                    Buffer.Dispose();
                }
                Buffer = BufferFactory.CreateDynamicDataBuffer( Capacity, ElementSizeBytes );

                var srv = new ShaderResourceViewDescription()
                {
                    ArraySize = 1,
                    Format = SlimDX.DXGI.Format.R32G32B32A32_Float,
                    Dimension = ShaderResourceViewDimension.Buffer,
                    ElementOffset = 0,
                    ElementWidth = ElementSizeBytes
                };

                View = new ShaderResourceView( D3D10Wrapper.Instance.Device, Buffer, srv );
            }
            Count = nElements;
        }
开发者ID:jiawen,项目名称:libcgt.net,代码行数:32,代码来源:DynamicDataBuffer.cs

示例3: DX11MipSliceRenderTarget2D

        public DX11MipSliceRenderTarget2D(DX11RenderContext context, DX11Texture2D texture, int mipindex, int w, int h)
        {
            this.context = context;
            this.Resource = texture.Resource;

            RenderTargetViewDescription rtd = new RenderTargetViewDescription()
            {
                Dimension = RenderTargetViewDimension.Texture2D,
                Format = texture.Format,
                MipSlice = mipindex
            };

            UnorderedAccessViewDescription uavd = new UnorderedAccessViewDescription()
            {
                Dimension = UnorderedAccessViewDimension.Texture2D,
                Format = texture.Format,
                MipSlice = mipindex,
            };

            ShaderResourceViewDescription srvd = new ShaderResourceViewDescription();
            srvd.Dimension = ShaderResourceViewDimension.Texture2D;
            srvd.MipLevels = 1;
            srvd.MostDetailedMip = mipindex;
            srvd.Format = texture.Format;

            this.SRV = new ShaderResourceView(context.Device, texture.Resource, srvd);
        }
开发者ID:sunep,项目名称:FeralTic,代码行数:27,代码来源:DX11MipSliceRenderTarget2D.cs

示例4: DX11MipSliceRenderTarget

        public DX11MipSliceRenderTarget(DX11RenderContext context, DX11Texture3D texture, int mipindex,int w, int h,int d)
        {
            this.context = context;

            RenderTargetViewDescription rtd = new RenderTargetViewDescription()
            {
                Dimension = RenderTargetViewDimension.Texture3D,
                Format = texture.Format,
                MipSlice = mipindex,
                DepthSliceCount = d           
            };

            ShaderResourceViewDescription srvd = new ShaderResourceViewDescription();
            srvd.Dimension = ShaderResourceViewDimension.Texture3D;
            srvd.MipLevels = 1;
            srvd.MostDetailedMip = mipindex;
            srvd.Format = texture.Format;

            this.RTV = new RenderTargetView(context.Device, texture.Resource, rtd);
            this.SRV = new ShaderResourceView(context.Device, texture.Resource, srvd);

            this.Width = w;
            this.Height = h;
            this.Depth = d;
        }
开发者ID:arturoc,项目名称:FeralTic,代码行数:25,代码来源:DX11MipSliceRenderTarget.cs

示例5: DX11CubeDepthStencil

        public DX11CubeDepthStencil(DX11RenderContext context, int size, SampleDescription sd, Format format)
        {
            this.context = context;

            var texBufferDesc = new Texture2DDescription
            {
                ArraySize = 6,
                BindFlags = BindFlags.DepthStencil | BindFlags.ShaderResource,
                CpuAccessFlags = CpuAccessFlags.None,
                Format = DepthFormatsHelper.GetGenericTextureFormat(format),
                Height = size,
                Width = size,
                OptionFlags = ResourceOptionFlags.TextureCube,
                SampleDescription = sd,
                Usage = ResourceUsage.Default,
                MipLevels = 1
            };

            this.Resource = new Texture2D(context.Device, texBufferDesc);

            this.desc = texBufferDesc;

            //Create faces SRV/RTV
            this.SliceDSV = new DX11SliceDepthStencil[6];

            ShaderResourceViewDescription svd = new ShaderResourceViewDescription()
            {
                Dimension = ShaderResourceViewDimension.TextureCube,
                Format = DepthFormatsHelper.GetSRVFormat(format),
                MipLevels = 1,
                MostDetailedMip = 0,
                First2DArrayFace = 0
            };

            DepthStencilViewDescription dsvd = new DepthStencilViewDescription()
            {
                ArraySize= 6,
                Dimension = DepthStencilViewDimension.Texture2DArray,
                FirstArraySlice = 0,
                Format = DepthFormatsHelper.GetDepthFormat(format),
                MipSlice = 0
            };

            this.DSV = new DepthStencilView(context.Device, this.Resource, dsvd);

            if (context.IsFeatureLevel11)
            {
                dsvd.Flags = DepthStencilViewFlags.ReadOnlyDepth;
                if (format == Format.D24_UNorm_S8_UInt) { dsvd.Flags |= DepthStencilViewFlags.ReadOnlyStencil; }

                this.ReadOnlyDSV = new DepthStencilView(context.Device, this.Resource, dsvd);
            }

            this.SRV = new ShaderResourceView(context.Device, this.Resource, svd);

            for (int i = 0; i < 6; i++)
            {
                this.SliceDSV[i] = new DX11SliceDepthStencil(context, this, i, DepthFormatsHelper.GetDepthFormat(format));
            }
        }
开发者ID:arturoc,项目名称:FeralTic,代码行数:60,代码来源:DX11CubeDepthStencil.cs

示例6: DX11RawBuffer

        public DX11RawBuffer(Device dev, int size, DX11RawBufferFlags flags= new DX11RawBufferFlags())
        {
            this.Size = size;

            BufferDescription bd = new BufferDescription()
            {
                BindFlags = BindFlags.ShaderResource | BindFlags.UnorderedAccess,
                CpuAccessFlags = CpuAccessFlags.None,
                OptionFlags = ResourceOptionFlags.RawBuffer,
                SizeInBytes = this.Size,
                Usage = ResourceUsage.Default,
            };
            this.Buffer = new Buffer(dev, bd);

            ShaderResourceViewDescription srvd = new ShaderResourceViewDescription()
            {
                Format = SlimDX.DXGI.Format.R32_Typeless,
                Dimension = ShaderResourceViewDimension.ExtendedBuffer,
                Flags = ShaderResourceViewExtendedBufferFlags.RawData,
                ElementCount = size / 4
            };
            this.SRV = new ShaderResourceView(dev, this.Buffer, srvd);

            UnorderedAccessViewDescription uavd = new UnorderedAccessViewDescription()
            {
                Format = SlimDX.DXGI.Format.R32_Typeless,
                Dimension = UnorderedAccessViewDimension.Buffer,
                Flags = UnorderedAccessViewBufferFlags.RawData,
                ElementCount = size / 4
            };

            this.UAV = new UnorderedAccessView(dev, this.Buffer, uavd);
        }
开发者ID:arturoc,项目名称:FeralTic,代码行数:33,代码来源:DX11RawBuffer.cs

示例7: DX11SliceRenderTarget

        public DX11SliceRenderTarget(DX11RenderContext context, DX11Texture2D texture, int sliceindex)
        {
            this.isowner = false;
            this.context = context;
            this.parent = texture;
            this.desc = texture.Description;

            RenderTargetViewDescription rtd = new RenderTargetViewDescription()
            {
                ArraySize = 1,
                Dimension = RenderTargetViewDimension.Texture2DArray,
                Format = texture.Format,
                MipSlice = 0,
                FirstArraySlice = sliceindex,
            };

            this.RTV = new RenderTargetView(context.Device, this.parent.Resource, rtd);

            ShaderResourceViewDescription srvd = new ShaderResourceViewDescription()
            {
                ArraySize = 1,
                Dimension = ShaderResourceViewDimension.Texture2DArray,
                Format = texture.Format,
                FirstArraySlice = sliceindex,
                MipLevels = texture.Resource.Description.MipLevels,
                MostDetailedMip = 0
            };

            this.SRV = new ShaderResourceView(context.Device, this.parent.Resource, srvd);
        }
开发者ID:arturoc,项目名称:FeralTic,代码行数:30,代码来源:DX11SliceRenderTarget.cs

示例8: DX11RenderTextureArray

        public DX11RenderTextureArray(DX11RenderContext context, int w, int h, int elemcnt, Format format)
        {
            this.context = context;

            var texBufferDesc = new Texture2DDescription
            {
                ArraySize = elemcnt,
                BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource,
                CpuAccessFlags = CpuAccessFlags.None,
                Format = format,
                Height = h,
                Width = w,
                OptionFlags = ResourceOptionFlags.None,
                SampleDescription = new SampleDescription(1,0),
                Usage = ResourceUsage.Default,
            };

            this.Resource = new Texture2D(context.Device, texBufferDesc);

            RenderTargetViewDescription rtd = new RenderTargetViewDescription()
            {
                ArraySize = elemcnt,
                FirstArraySlice = 0,
                Dimension = RenderTargetViewDimension.Texture2DArray,
                Format = format
            };

            ShaderResourceViewDescription srvd = new ShaderResourceViewDescription()
            {
                ArraySize = elemcnt,
                FirstArraySlice = 0,
                Dimension = ShaderResourceViewDimension.Texture2DArray,
                Format = format,
                MipLevels = 1,
                MostDetailedMip = 0
            };

            this.SRV = new ShaderResourceView(context.Device, this.Resource, srvd);
            this.RTV = new RenderTargetView(context.Device, this.Resource, rtd);

            this.SRVArray = new ShaderResourceView[elemcnt];

            ShaderResourceViewDescription srvad = new ShaderResourceViewDescription()
            {
                ArraySize = 1,
                Dimension = ShaderResourceViewDimension.Texture2DArray,
                Format = format,
                MipLevels = 1,
                MostDetailedMip = 0
            };

            for (int i = 0; i < elemcnt; i++)
            {
                srvad.FirstArraySlice = i;
                this.SRVArray[i] = new ShaderResourceView(context.Device, this.Resource, srvad);
            }

            this.desc = texBufferDesc;
        }
开发者ID:kopffarben,项目名称:FeralTic,代码行数:59,代码来源:DX11RenderTextureArray.cs

示例9: DepthStencilCube

        /// <summary>
        /// Creates render target
        /// </summary>
        /// <param name="rs"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="format"></param>
        public DepthStencilCube( GraphicsDevice device, DepthFormat format, int size, int samples, string debugName = "" )
            : base(device)
        {
            bool msaa	=	samples > 1;

            CheckSamplesCount( samples );

            SampleCount	=	samples;

            Format		=	format;
            SampleCount	=	samples;
            Width		=	size;
            Height		=	size;
            Depth		=	1;

            var	texDesc	=	new Texture2DDescription();
                texDesc.Width				=	Width;
                texDesc.Height				=	Height;
                texDesc.ArraySize			=	6;
                texDesc.BindFlags			=	BindFlags.RenderTarget | BindFlags.ShaderResource;
                texDesc.CpuAccessFlags		=	CpuAccessFlags.None;
                texDesc.Format				=	Converter.ConvertToTex( format );
                texDesc.MipLevels			=	1;
                texDesc.OptionFlags			=	ResourceOptionFlags.TextureCube;
                texDesc.SampleDescription	=	new DXGI.SampleDescription(samples, 0);
                texDesc.Usage				=	ResourceUsage.Default;

            texCube	=	new D3D.Texture2D( device.Device, texDesc );

            var srvDesc	=	new ShaderResourceViewDescription();
                srvDesc.Dimension			=	samples > 1 ? ShaderResourceViewDimension.Texture2DMultisampled : ShaderResourceViewDimension.Texture2D;
                srvDesc.Format				=	Converter.ConvertToSRV( format );
                srvDesc.Texture2D.MostDetailedMip	=	0;
                srvDesc.Texture2D.MipLevels			=	1;

            SRV		=	new ShaderResourceView( device.Device, texCube );

            //
            //	Create surfaces :
            //
            surfaces	=	new DepthStencilSurface[ 6 ];

            for ( int face=0; face<6; face++) {

                var rtvDesc = new DepthStencilViewDescription();
                    rtvDesc.Texture2DArray.MipSlice			=	0;
                    rtvDesc.Texture2DArray.FirstArraySlice	=	face;
                    rtvDesc.Texture2DArray.ArraySize		=	1;
                    rtvDesc.Dimension						=	msaa ? DepthStencilViewDimension.Texture2DMultisampledArray : DepthStencilViewDimension.Texture2DArray;
                    rtvDesc.Format							=	Converter.ConvertToDSV( format );

                var dsv	=	new DepthStencilView( device.Device, texCube, rtvDesc );

                int subResId	=	Resource.CalculateSubResourceIndex( 0, face, 1 );

                surfaces[face]	=	new DepthStencilSurface( dsv, format, Width, Height, SampleCount );
            }
        }
开发者ID:temik911,项目名称:audio,代码行数:65,代码来源:DepthStencilCube.cs

示例10: DepthStencil2D

        /// <summary>
        /// Creates depth stencil texture, view and shader resource with format D24S8
        /// </summary>
        /// <param name="rs"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="format"></param>
        public DepthStencil2D( GraphicsDevice device, DepthFormat format, int width, int height, int samples = 1 )
            : base(device)
        {
            CheckSamplesCount( samples );

            Width		=	width;
            Height		=	height;
            Depth		=	1;
            Format		=	format;
            SampleCount	=	samples;

            var bindFlags	=	BindFlags.DepthStencil;

            if (device.GraphicsProfile==GraphicsProfile.HiDef) {
                bindFlags	|=	BindFlags.ShaderResource;

            } else if (device.GraphicsProfile==GraphicsProfile.Reach) {
                if (samples==1) {
                    bindFlags	|=	BindFlags.ShaderResource;
                }
            }

            var	texDesc	=	new Texture2DDescription();
                texDesc.Width				=	width;
                texDesc.Height				=	height;
                texDesc.ArraySize			=	1;
                texDesc.BindFlags			=	bindFlags;
                texDesc.CpuAccessFlags		=	CpuAccessFlags.None;
                texDesc.Format				=	Converter.ConvertToTex( format );
                texDesc.MipLevels			=	1;
                texDesc.OptionFlags			=	ResourceOptionFlags.None;
                texDesc.SampleDescription	=	new DXGI.SampleDescription(samples, 0);
                texDesc.Usage				=	ResourceUsage.Default;

            var dsvDesc	=	new DepthStencilViewDescription();
                dsvDesc.Dimension			=	samples > 1 ? DepthStencilViewDimension.Texture2DMultisampled : DepthStencilViewDimension.Texture2D;
                dsvDesc.Format				=	Converter.ConvertToDSV( format );
                dsvDesc.Flags				=	DepthStencilViewFlags.None;

            var srvDesc	=	new ShaderResourceViewDescription();
                srvDesc.Dimension			=	samples > 1 ? ShaderResourceViewDimension.Texture2DMultisampled : ShaderResourceViewDimension.Texture2D;
                srvDesc.Format				=	Converter.ConvertToSRV( format );
                srvDesc.Texture2D.MostDetailedMip	=	0;
                srvDesc.Texture2D.MipLevels			=	1;

            tex2D		=	new D3D.Texture2D		( device.Device, texDesc );

            var dsv		=	new DepthStencilView	( device.Device, tex2D,	dsvDesc );

            if (bindFlags.HasFlag( BindFlags.ShaderResource)) {
                SRV		=	new ShaderResourceView	( device.Device, tex2D,	srvDesc );
            }

            surface		=	new DepthStencilSurface	( dsv, format, width, height, samples );
        }
开发者ID:temik911,项目名称:audio,代码行数:62,代码来源:DepthStencil2D.cs

示例11: LoadFromLoadInfo

        public void LoadFromLoadInfo(IO.Files.Texture.TextureLoadInfo loadInfo)
        {
            var texDesc = new Texture2DDescription
            {
                ArraySize = 1,
                BindFlags = BindFlags.ShaderResource,
                CpuAccessFlags = CpuAccessFlags.None,
                Format = loadInfo.Format,
                Height = loadInfo.Height,
                Width = loadInfo.Width,
                MipLevels = loadInfo.Layers.Count,
                OptionFlags = ResourceOptionFlags.None,
                SampleDescription = new SampleDescription(1, 0),
                Usage = ResourceUsage.Default
            };

            if (mTexture != gDefaultTexture)
            {
                if (mTexture != null)
                    mTexture.Dispose();
                if (NativeView != null)
                    NativeView.Dispose();
            }

            var boxes = new DataBox[texDesc.MipLevels];
            var streams = new DataStream[texDesc.MipLevels];
            try
            {
                for(var i = 0; i < texDesc.MipLevels; ++i)
                {
                    streams[i] = new DataStream(loadInfo.Layers[i].Length, true, true);
                    streams[i].WriteRange(loadInfo.Layers[i]);
                    streams[i].Position = 0;
                    boxes[i] = new DataBox(streams[i].DataPointer, loadInfo.RowPitchs[i], 0);
                }

                mTexture = new Texture2D(mContext.Device, texDesc, boxes);
                var srvd = new ShaderResourceViewDescription
                {
                    Dimension = SharpDX.Direct3D.ShaderResourceViewDimension.Texture2D,
                    Format = loadInfo.Format,
                    Texture2D = new ShaderResourceViewDescription.Texture2DResource { MipLevels = boxes.Length, MostDetailedMip = 0 }
                };

                NativeView = new ShaderResourceView(mContext.Device, mTexture, srvd);
            }
            finally
            {
                foreach (var stream in streams)
                {
                    if (stream != null)
                        stream.Dispose();
                }
            }
        }
开发者ID:Linrasis,项目名称:WoWEditor,代码行数:55,代码来源:Texture.cs

示例12: GetSRVSlice

        public ShaderResourceView GetSRVSlice(int slice, int count)
        {
            ShaderResourceViewDescription rtd = new ShaderResourceViewDescription()
            {
                ArraySize = count,
                FirstArraySlice = slice,
                Dimension = ShaderResourceViewDimension.Texture2DArray,
                Format = this.Format
            };

            return new ShaderResourceView(context.Device, this.Resource, rtd);
        }
开发者ID:arturoc,项目名称:FeralTic,代码行数:12,代码来源:DX11RenderTextureArray.cs

示例13: DX11RenderTextureArray

        public DX11RenderTextureArray(DX11RenderContext context, int w, int h, int elemcnt, Format format, bool buildslices = true, int miplevels = 0)
        {
            this.context = context;

            var texBufferDesc = new Texture2DDescription
            {
                ArraySize = elemcnt,
                BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource,
                CpuAccessFlags = CpuAccessFlags.None,
                Format = format,
                Height = h,
                Width = w,
                OptionFlags = miplevels == 0 ? ResourceOptionFlags.GenerateMipMaps : ResourceOptionFlags.None,
                SampleDescription = new SampleDescription(1,0),
                Usage = ResourceUsage.Default,
                MipLevels= miplevels
            };

            this.Resource = new Texture2D(context.Device, texBufferDesc);

            RenderTargetViewDescription rtd = new RenderTargetViewDescription()
            {
                ArraySize = elemcnt,
                FirstArraySlice = 0,
                Dimension = RenderTargetViewDimension.Texture2DArray,
                Format = format
            };

            ShaderResourceViewDescription srvd = new ShaderResourceViewDescription()
            {
                ArraySize = elemcnt,
                FirstArraySlice = 0,
                Dimension = ShaderResourceViewDimension.Texture2DArray,
                Format = format,
                MipLevels = this.Resource.Description.MipLevels,
                MostDetailedMip = 0
            };

            this.SRV = new ShaderResourceView(context.Device, this.Resource, srvd);
            this.RTV = new RenderTargetView(context.Device, this.Resource, rtd);

            this.desc = texBufferDesc;

            this.SliceRTV = new DX11SliceRenderTarget[this.ElemCnt];

            if (buildslices)
            {
                for (int i = 0; i < this.ElemCnt; i++)
                {
                    this.SliceRTV[i] = new DX11SliceRenderTarget(this.context, this, i);
                }
            }
        }
开发者ID:arturoc,项目名称:FeralTic,代码行数:53,代码来源:DX11RenderTextureArray.cs

示例14: CreateShaderResourceView

        private void CreateShaderResourceView()
        {
            var shaderResourceViewDesc = new ShaderResourceViewDescription();
            shaderResourceViewDesc.ArraySize = layerCount;
            shaderResourceViewDesc.Dimension = ShaderResourceViewDimension.Texture2DArray;
            shaderResourceViewDesc.FirstArraySlice = 0;
            shaderResourceViewDesc.Format = format;
            shaderResourceViewDesc.MipLevels = 1;
            shaderResourceViewDesc.MostDetailedMip = 0;

            shaderResourceViewAsArray = new ShaderResourceView(device, texture, shaderResourceViewDesc);
        }
开发者ID:TheProjecter,项目名称:romantiquex,代码行数:12,代码来源:RenderTargetArrayHolder.cs

示例15: DX11DepthStencil

        public DX11DepthStencil(DX11RenderContext context, int w, int h, SampleDescription sd, Format format)
        {
            this.context = context;
            var depthBufferDesc = new Texture2DDescription
            {
                ArraySize = 1,
                BindFlags = BindFlags.DepthStencil | BindFlags.ShaderResource,
                CpuAccessFlags = CpuAccessFlags.None,
                Format = DepthFormatsHelper.GetGenericTextureFormat(format),
                Height = h,
                Width = w,
                MipLevels = 1,
                OptionFlags = ResourceOptionFlags.None,
                SampleDescription = sd,
                Usage = ResourceUsage.Default
            };

            this.Resource = new Texture2D(context.Device, depthBufferDesc);

            ShaderResourceViewDescription srvd = new ShaderResourceViewDescription()
            {
                ArraySize = 1,
                Format = DepthFormatsHelper.GetSRVFormat(format),
                Dimension = sd.Count == 1 ? ShaderResourceViewDimension.Texture2D : ShaderResourceViewDimension.Texture2DMultisampled,
                MipLevels = 1,
                MostDetailedMip = 0
            };

            this.SRV = new ShaderResourceView(context.Device, this.Resource, srvd);

            DepthStencilViewDescription dsvd = new DepthStencilViewDescription()
            {
                Format = DepthFormatsHelper.GetDepthFormat(format),
                Dimension = sd.Count == 1 ? DepthStencilViewDimension.Texture2D : DepthStencilViewDimension.Texture2DMultisampled,
                MipSlice = 0
            };

            this.DSV = new DepthStencilView(context.Device, this.Resource, dsvd);

            //Read only dsv only supported in dx11 minimum
            if (context.IsFeatureLevel11)
            {
                dsvd.Flags = DepthStencilViewFlags.ReadOnlyDepth;
                if (format == Format.D24_UNorm_S8_UInt) { dsvd.Flags |= DepthStencilViewFlags.ReadOnlyStencil; }

                this.ReadOnlyDSV = new DepthStencilView(context.Device, this.Resource, dsvd);
            }

            this.desc = depthBufferDesc;
            this.isowner = true;
        }
开发者ID:kopffarben,项目名称:FeralTic,代码行数:51,代码来源:DX11DepthStencil.cs


注:本文中的ShaderResourceViewDescription类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。