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


C# DataStream.CopyTo方法代码示例

本文整理汇总了C#中DataStream.CopyTo方法的典型用法代码示例。如果您正苦于以下问题:C# DataStream.CopyTo方法的具体用法?C# DataStream.CopyTo怎么用?C# DataStream.CopyTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataStream的用法示例。


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

示例1: Pass

        /// <summary>
        /// The most general shader pass method.
        /// </summary>
        /// <param name="context">The device context to use.</param>
        /// <param name="shader">The pixel shader.</param>
        /// <param name="viewport">The render viewport.</param>
        /// <param name="rtv">A render target.</param>
        /// <param name="srv">Shader resources.</param>
        /// <param name="uav">Unordered access views.</param>
        /// <param name="cbuffer">A data stream to fill the constant buffer with.</param>
        public void Pass(DeviceContext context, String shader, ViewportF viewport, RenderTargetView rtv, ShaderResourceView[] srv, UnorderedAccessView[] uav, DataStream cbuffer)
        {
            if (shader == null) throw new ArgumentNullException("Shader code cannot be null.");
            context.PixelShader.Set(CompilePixelShader(Device, shader));

            if (uav != null) context.OutputMerger.SetTargets(1, uav, new[] { rtv });
            else context.OutputMerger.SetTargets(new[] { rtv });

            if (srv != null) context.PixelShader.SetShaderResources(0, srv);
            context.PixelShader.SetConstantBuffer(0, constantBuffer);
            context.Rasterizer.SetViewports(new[] { viewport });
            context.PixelShader.SetSampler(0, sampler);

            if (cbuffer != null)
            {
                DataStream stream;
                context.MapSubresource(constantBuffer, MapMode.WriteDiscard, MapFlags.None, out stream);
                cbuffer.CopyTo(stream);
                context.UnmapSubresource(constantBuffer, 0);
                stream.Dispose();
            }

            ExecuteShaderPass(context);
        }
开发者ID:TomCrypto,项目名称:Insight,代码行数:34,代码来源:SurfacePass.cs

示例2: CopyStream

 /// <summary>
 /// Convenience method to copy the contents of a DataStream into a
 /// constant buffer. The buffer must have CPU read access, and its
 /// position will be reset to zero before copying (by convention).
 /// </summary>
 /// <param name="context">Device context to use.</param>
 /// <param name="buffer">Constant buffer.</param>
 /// <param name="stream">The data stream.</param>
 protected static void CopyStream(DeviceContext context, Buffer buffer, DataStream stream)
 {
     DataStream staging = null;
     try
     {
         context.MapSubresource(buffer, MapMode.WriteDiscard, MapFlags.None, out staging);
         stream.Position = 0; stream.CopyTo(staging);
         context.UnmapSubresource(buffer, 0);
     }
     finally
     {
         if (staging != null) staging.Dispose();
     }
 }
开发者ID:TomCrypto,项目名称:Insight,代码行数:22,代码来源:Material.cs


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