示例#1
0
文件: Buffer.cs 项目: oeoen/SharpDX
        /// <summary>
        /// Get a reference to the data contained in the resource and deny GPU access to the resource.
        /// </summary>
        /// <remarks>
        /// For the CPU to write the contents of a resource, the resource must be created with the dynamic usage flag, D3D10_USAGE_DYNAMIC.  To both read and write those contents, the resource must be created with the staging usage flag, D3D10_USAGE_STAGING. (For more information about  these flags, see <see cref="SharpDX.Direct3D10.ResourceUsage"/>.) ID3D10Buffer::Map will retrieve a reference to the resource data.  For a discussion on how to access resources efficiently, see {{Copying and Accessing Resource Data (Direct3D 10)}}. Call <see cref="SharpDX.Direct3D10.Buffer.Unmap"/> to signify that the application has finished accessing the resource. ID3D10Buffer::Map has a few other restrictions. For example:  The same buffer cannot be mapped multiple times; in other words, do not call ID3D10Buffer::Map on a buffer that is already mapped. Any buffer that is bound to the pipeline must be unmapped before any rendering operation (that is, <see cref="SharpDX.Direct3D10.Device.Draw"/>)  can be executed.    Differences between Direct3D 9 and Direct3D 10: ID3D10Buffer::Map in Direct3D 10 is analogous to resource {{Lock}} in Direct3D 9.   ?
        /// </remarks>
        /// <param name="mode">Flag that specifies the CPU's permissions for the reading and writing of a resource. For possible values, see <see cref="SharpDX.Direct3D10.MapMode"/>. </param>
        /// <param name="mapFlags">Flag that specifies what the CPU should do when the GPU is busy (see <see cref="SharpDX.Direct3D10.MapFlags"/>). This flag is optional. </param>
        /// <returns>If this function succeeds returns a <see cref="SharpDX.DataStream"/> with the size this buffer.</returns>
        /// <unmanaged>HRESULT ID3D10Buffer::Map([In] D3D10_MAP MapType,[In] int MapFlags,[Out] void** ppData)</unmanaged>
        public DataStream Map(SharpDX.Direct3D10.MapMode mode, SharpDX.Direct3D10.MapFlags mapFlags)
        {
            int    sizeInBytes = Description.SizeInBytes;
            IntPtr data;

            Map(mode, mapFlags, out data);
            bool canRead  = mode == MapMode.Read || mode == MapMode.ReadWrite;
            bool canWrite = mode != MapMode.Read;

            return(new DataStream(data, sizeInBytes, canRead, canWrite));
        }
示例#2
0
文件: Buffer.cs 项目: oeoen/SharpDX
 /// <summary>
 /// Get a reference to the data contained in the resource and deny GPU access to the resource.
 /// </summary>
 /// <remarks>
 /// For the CPU to write the contents of a resource, the resource must be created with the dynamic usage flag, D3D10_USAGE_DYNAMIC.  To both read and write those contents, the resource must be created with the staging usage flag, D3D10_USAGE_STAGING. (For more information about  these flags, see <see cref="SharpDX.Direct3D10.ResourceUsage"/>.) ID3D10Buffer::Map will retrieve a reference to the resource data.  For a discussion on how to access resources efficiently, see {{Copying and Accessing Resource Data (Direct3D 10)}}. Call <see cref="SharpDX.Direct3D10.Buffer.Unmap"/> to signify that the application has finished accessing the resource. ID3D10Buffer::Map has a few other restrictions. For example:  The same buffer cannot be mapped multiple times; in other words, do not call ID3D10Buffer::Map on a buffer that is already mapped. Any buffer that is bound to the pipeline must be unmapped before any rendering operation (that is, <see cref="SharpDX.Direct3D10.Device.Draw"/>)  can be executed.    Differences between Direct3D 9 and Direct3D 10: ID3D10Buffer::Map in Direct3D 10 is analogous to resource {{Lock}} in Direct3D 9.   ?
 /// </remarks>
 /// <param name="mapType">Flag that specifies the CPU's permissions for the reading and writing of a resource. For possible values, see <see cref="SharpDX.Direct3D10.MapMode"/>. </param>
 /// <returns>If this function succeeds returns a <see cref="SharpDX.DataStream"/> with the size this buffer.</returns>
 /// <unmanaged>HRESULT ID3D10Buffer::Map([In] D3D10_MAP MapType,[In] int MapFlags,[Out] void** ppData)</unmanaged>
 public DataStream Map(SharpDX.Direct3D10.MapMode mapType)
 {
     return(Map(mapType, MapFlags.None));
 }