示例#1
0
        public override void UpdateBuffer(Buffer buffer, uint bufferOffsetInBytes, IntPtr source, uint sizeInBytes)
        {
            D3D11Buffer d3dBuffer = Util.AssertSubtype <Buffer, D3D11Buffer>(buffer);

            if (sizeInBytes == 0)
            {
                return;
            }

            ResourceRegion?subregion = null;

            if ((d3dBuffer.Buffer.Description.BindFlags & BindFlags.ConstantBuffer) != BindFlags.ConstantBuffer)
            {
                // For a shader-constant buffer; set pDstBox to null. It is not possible to use
                // this method to partially update a shader-constant buffer

                subregion = new ResourceRegion()
                {
                    Left   = (int)bufferOffsetInBytes,
                    Right  = (int)(sizeInBytes + bufferOffsetInBytes),
                    Bottom = 1,
                    Back   = 1
                };
            }

            if (bufferOffsetInBytes == 0)
            {
                _context.UpdateSubresource(d3dBuffer.Buffer, 0, subregion, source, 0, 0);
            }
            else
            {
                _context1.UpdateSubresource1(d3dBuffer.Buffer, 0, subregion, source, 0, 0, 0);
            }
        }
示例#2
0
        public void CopyRegion(GraphicsResource source, int sourceSubresource, ResourceRegion?sourceRegion, GraphicsResource destination, int destinationSubResource, int dstX = 0, int dstY = 0, int dstZ = 0)
        {
            if (source is Texture && destination is Texture)
            {
                if (((Texture)source).Usage == GraphicsResourceUsage.Staging || ((Texture)destination).Usage == GraphicsResourceUsage.Staging)
                {
                    throw new NotImplementedException("Copy region of staging resources is not supported yet");
                }

                NativeCommandList.CopyTextureRegion(
                    new TextureCopyLocation(destination.NativeResource, sourceSubresource),
                    dstX, dstY, dstZ,
                    new TextureCopyLocation(source.NativeResource, sourceSubresource),
                    sourceRegion.HasValue
                        ? (SharpDX.Direct3D12.ResourceRegion?) new SharpDX.Direct3D12.ResourceRegion
                {
                    Left   = sourceRegion.Value.Left,
                    Top    = sourceRegion.Value.Top,
                    Front  = sourceRegion.Value.Front,
                    Right  = sourceRegion.Value.Right,
                    Bottom = sourceRegion.Value.Bottom,
                    Back   = sourceRegion.Value.Back
                }
                    : null);
            }
            else if (source is Buffer && destination is Buffer)
            {
                NativeCommandList.CopyBufferRegion(destination.NativeResource, dstX,
                                                   source.NativeResource, sourceRegion?.Left ?? 0, sourceRegion.HasValue ? sourceRegion.Value.Right - sourceRegion.Value.Left : ((Buffer)source).SizeInBytes);
            }
        }
示例#3
0
        public unsafe override void UpdateBuffer(Buffer buffer, uint bufferOffsetInBytes, IntPtr source, uint sizeInBytes)
        {
            D3D11Buffer d3dBuffer = Util.AssertSubtype <Buffer, D3D11Buffer>(buffer);

            if (sizeInBytes == 0)
            {
                return;
            }

            bool useMap = (buffer.Usage & BufferUsage.Dynamic) == BufferUsage.Dynamic;

            if (useMap)
            {
                if (bufferOffsetInBytes != 0)
                {
                    throw new NotImplementedException("bufferOffsetInBytes must be 0 for Dynamic Buffers.");
                }
                SharpDX.DataBox db = _context.MapSubresource(
                    d3dBuffer.Buffer,
                    0,
                    SharpDX.Direct3D11.MapMode.WriteDiscard,
                    MapFlags.None);
                if (sizeInBytes < 1024)
                {
                    Unsafe.CopyBlock(db.DataPointer.ToPointer(), source.ToPointer(), sizeInBytes);
                }
                else
                {
                    System.Buffer.MemoryCopy(source.ToPointer(), db.DataPointer.ToPointer(), buffer.SizeInBytes, sizeInBytes);
                }
                _context.UnmapSubresource(d3dBuffer.Buffer, 0);
            }
            else
            {
                ResourceRegion?subregion = null;
                if ((d3dBuffer.Buffer.Description.BindFlags & BindFlags.ConstantBuffer) != BindFlags.ConstantBuffer)
                {
                    // For a shader-constant buffer; set pDstBox to null. It is not possible to use
                    // this method to partially update a shader-constant buffer

                    subregion = new ResourceRegion()
                    {
                        Left   = (int)bufferOffsetInBytes,
                        Right  = (int)(sizeInBytes + bufferOffsetInBytes),
                        Bottom = 1,
                        Back   = 1
                    };
                }

                if (bufferOffsetInBytes == 0)
                {
                    _context.UpdateSubresource(d3dBuffer.Buffer, 0, subregion, source, 0, 0);
                }
                else
                {
                    _context1.UpdateSubresource1(d3dBuffer.Buffer, 0, subregion, source, 0, 0, 0);
                }
            }
        }
示例#4
0
        protected unsafe override void UpdateBufferCore(DeviceBuffer buffer, uint bufferOffsetInBytes, IntPtr source, uint sizeInBytes)
        {
            D3D11Buffer d3dBuffer = Util.AssertSubtype <DeviceBuffer, D3D11Buffer>(buffer);

            if (sizeInBytes == 0)
            {
                return;
            }

            bool useMap = (buffer.Usage & BufferUsage.Dynamic) == BufferUsage.Dynamic ||
                          (buffer.Usage & BufferUsage.Staging) == BufferUsage.Staging;

            if (useMap)
            {
                if (bufferOffsetInBytes != 0)
                {
                    throw new NotImplementedException("bufferOffsetInBytes must be 0 for Dynamic Buffers.");
                }

                MappedResource mr = MapCore(buffer, MapMode.Write, 0);
                if (sizeInBytes < 1024)
                {
                    Unsafe.CopyBlock(mr.Data.ToPointer(), source.ToPointer(), sizeInBytes);
                }
                else
                {
                    System.Buffer.MemoryCopy(source.ToPointer(), mr.Data.ToPointer(), buffer.SizeInBytes, sizeInBytes);
                }
                UnmapCore(buffer, 0);
            }
            else
            {
                ResourceRegion?subregion = null;
                if ((d3dBuffer.Buffer.Description.BindFlags & BindFlags.ConstantBuffer) != BindFlags.ConstantBuffer)
                {
                    // For a shader-constant buffer; set pDstBox to null. It is not possible to use
                    // this method to partially update a shader-constant buffer

                    subregion = new ResourceRegion()
                    {
                        Left   = (int)bufferOffsetInBytes,
                        Right  = (int)(sizeInBytes + bufferOffsetInBytes),
                        Bottom = 1,
                        Back   = 1
                    };
                }
                lock (_immediateContextLock)
                {
                    _immediateContext.UpdateSubresource(d3dBuffer.Buffer, 0, subregion, source, 0, 0);
                }
            }
        }
示例#5
0
        public void CopyRegion(GraphicsResource source, int sourceSubresource, ResourceRegion?sourecRegion, GraphicsResource destination, int destinationSubResource, int dstX = 0, int dstY = 0, int dstZ = 0)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }
            if (destination == null)
            {
                throw new ArgumentNullException("destination");
            }

            var nullableSharpDxRegion = new SharpDX.Direct3D11.ResourceRegion?();

            if (sourecRegion.HasValue)
            {
                var value = sourecRegion.Value;
                nullableSharpDxRegion = new SharpDX.Direct3D11.ResourceRegion(value.Left, value.Top, value.Front, value.Right, value.Bottom, value.Back);
            }

            NativeDeviceContext.CopySubresourceRegion(source.NativeResource, sourceSubresource, nullableSharpDxRegion, destination.NativeResource, destinationSubResource, dstX, dstY, dstZ);
        }
示例#6
0
        public unsafe override void SetData(IntPtr data, int dataSizeInBytes, int destinationOffsetInBytes)
        {
            if (dataSizeInBytes == 0)
            {
                return;
            }

            EnsureBufferSize(dataSizeInBytes + destinationOffsetInBytes);

            if (_resourceUsage == ResourceUsage.Dynamic)
            {
                DataBox db = Device.ImmediateContext.MapSubresource(Buffer, 0, MapMode.WriteNoOverwrite, MapFlags.None);
                {
                    SharpDX.Utilities.CopyMemory(
                        new IntPtr((byte *)db.DataPointer.ToPointer() + destinationOffsetInBytes),
                        new IntPtr((byte *)data),
                        dataSizeInBytes);
                }
                Device.ImmediateContext.UnmapSubresource(Buffer, 0);
            }
            else
            {
                ResourceRegion?subregion = null;
                if ((_bindFlags & BindFlags.ConstantBuffer) != BindFlags.ConstantBuffer)
                {
                    // For a shader-constant buffer; set pDstBox to null. It is not possible to use
                    // this method to partially update a shader-constant buffer

                    subregion = new ResourceRegion()
                    {
                        Left   = destinationOffsetInBytes,
                        Right  = dataSizeInBytes + destinationOffsetInBytes,
                        Bottom = 1,
                        Back   = 1
                    };
                }

                Device.ImmediateContext.UpdateSubresource(Buffer, 0, subregion, data, 0, 0);
            }
        }
示例#7
0
        private static void RenderFrameX(StreamDecoder d, mfxFrameSurface1 surf)
        {
            var m_pDXGIBackBuffer = swapChain.GetBackBuffer <Texture2D>(0);

            if (useSystemMemoryNotVideoMemory)
            {
                Trace.Assert(surf.Data.B != IntPtr.Zero);

                //ResourceRegion? rr = new ResourceRegion(0, 0, 0, 1920, 1080, 1);
                ResourceRegion?rr = null;
                device.ImmediateContext.UpdateSubresource(m_pDXGIBackBuffer, 0, rr, surf.Data.B, surf.Data.Pitch, 0);
            }
            else
            {
                Trace.Assert(surf.Data.MemId != IntPtr.Zero);

                IntPtr dx11frameHandle = d.lowLevelDecoder.videoAccelerationSupport.FrameGetHandle(surf.Data.MemId);
                //  CustomMemId* cm = (CustomMemId*)
                var texture2d = new Texture2D(dx11frameHandle);
                device.ImmediateContext.CopySubresourceRegion(texture2d, 0, null, m_pDXGIBackBuffer, 0);
            }

            swapChain.Present(2, PresentFlags.None);
        }
示例#8
0
        public unsafe override void UpdateBuffer(DeviceBuffer buffer, uint bufferOffsetInBytes, IntPtr source, uint sizeInBytes)
        {
            D3D11Buffer d3dBuffer = Util.AssertSubtype <DeviceBuffer, D3D11Buffer>(buffer);

            if (sizeInBytes == 0)
            {
                return;
            }

            bool isDynamic = (buffer.Usage & BufferUsage.Dynamic) == BufferUsage.Dynamic;
            bool isStaging = (buffer.Usage & BufferUsage.Staging) == BufferUsage.Staging;
            bool useMap    = isDynamic || isStaging;

            if (!useMap)
            {
                ResourceRegion?subregion = null;
                if ((d3dBuffer.Buffer.Description.BindFlags & BindFlags.ConstantBuffer) != BindFlags.ConstantBuffer)
                {
                    // For a shader-constant buffer; set pDstBox to null. It is not possible to use
                    // this method to partially update a shader-constant buffer

                    subregion = new ResourceRegion()
                    {
                        Left   = (int)bufferOffsetInBytes,
                        Right  = (int)(sizeInBytes + bufferOffsetInBytes),
                        Bottom = 1,
                        Back   = 1
                    };
                }

                if (bufferOffsetInBytes == 0)
                {
                    _context.UpdateSubresource(d3dBuffer.Buffer, 0, subregion, source, 0, 0);
                }
                else
                {
                    _context1.UpdateSubresource1(d3dBuffer.Buffer, 0, subregion, source, 0, 0, 0);
                }
            }
            else
            {
                bool updateFullBuffer = bufferOffsetInBytes == 0 && sizeInBytes == buffer.SizeInBytes;
                if (updateFullBuffer && isDynamic)
                {
                    SharpDX.DataBox db = _context.MapSubresource(
                        d3dBuffer.Buffer,
                        0,
                        SharpDX.Direct3D11.MapMode.WriteDiscard,
                        MapFlags.None);
                    if (sizeInBytes < 1024)
                    {
                        Unsafe.CopyBlock(db.DataPointer.ToPointer(), source.ToPointer(), sizeInBytes);
                    }
                    else
                    {
                        System.Buffer.MemoryCopy(source.ToPointer(), db.DataPointer.ToPointer(), buffer.SizeInBytes, sizeInBytes);
                    }
                    _context.UnmapSubresource(d3dBuffer.Buffer, 0);
                }
                else
                {
                    D3D11Buffer staging = GetFreeStagingBuffer(sizeInBytes);
                    _gd.UpdateBuffer(staging, 0, source, sizeInBytes);
                    CopyBuffer(staging, 0, buffer, bufferOffsetInBytes, sizeInBytes);
                    _submittedStagingBuffers.Add(staging);
                }
            }
        }
示例#9
0
        /// <summary>
        /// Copies the content an data on CPU memory to this texture into GPU memory.
        /// </summary>
        /// <param name="device">The <see cref="GraphicsDevice"/>.</param>
        /// <param name="fromData">The data to copy from.</param>
        /// <param name="arraySlice">The array slice index. This value must be set to 0 for Texture 3D.</param>
        /// <param name="mipSlice">The mip slice index.</param>
        /// <param name="region">Destination region</param>
        /// <exception cref="System.ArgumentException">When strides is different from optimal strides, and TData is not the same size as the pixel format, or Width * Height != toData.Length</exception>
        /// <remarks>
        /// See unmanaged documentation for usage and restrictions.
        /// </remarks>
        public unsafe void SetData(GraphicsDevice device, DataPointer fromData, int arraySlice = 0, int mipSlice = 0, ResourceRegion?region = null)
        {
            if (device == null)
            {
                throw new ArgumentNullException("device");
            }
            if (region.HasValue && this.Description.Usage != GraphicsResourceUsage.Default)
            {
                throw new ArgumentException("Region is only supported for textures with ResourceUsage.Default");
            }

            // Get mipmap description for the specified mipSlice
            var mipMapDesc = this.GetMipMapDescription(mipSlice);

            int width  = mipMapDesc.Width;
            int height = mipMapDesc.Height;
            int depth  = mipMapDesc.Depth;

            // If we are using a region, then check that parameters are fine
            if (region.HasValue)
            {
                int newWidth  = region.Value.Right - region.Value.Left;
                int newHeight = region.Value.Bottom - region.Value.Top;
                int newDepth  = region.Value.Back - region.Value.Front;
                if (newWidth > width)
                {
                    throw new ArgumentException(string.Format("Region width [{0}] cannot be greater than mipmap width [{1}]", newWidth, width), "region");
                }
                if (newHeight > height)
                {
                    throw new ArgumentException(string.Format("Region height [{0}] cannot be greater than mipmap height [{1}]", newHeight, height), "region");
                }
                if (newDepth > depth)
                {
                    throw new ArgumentException(string.Format("Region depth [{0}] cannot be greater than mipmap depth [{1}]", newDepth, depth), "region");
                }

                width  = newWidth;
                height = newHeight;
                depth  = newDepth;
            }

            // Size per pixel
            var sizePerElement = Description.Format.SizeInBytes();

            // Calculate depth stride based on mipmap level
            int rowStride;

            // Depth Stride
            int textureDepthStride;

            // Compute Actual pitch
            Image.ComputePitch(this.Description.Format, width, height, out rowStride, out textureDepthStride, out width, out height);

            // Size Of actual texture data
            int sizeOfTextureData = textureDepthStride * depth;

            // Check size validity of data to copy to
            if (fromData.Size != sizeOfTextureData)
            {
                throw new ArgumentException(string.Format("Size of toData ({0} bytes) is not compatible expected size ({1} bytes) : Width * Height * Depth * sizeof(PixelFormat) size in bytes", fromData.Size, sizeOfTextureData));
            }

            // Calculate the subResourceIndex for a Texture
            int subResourceIndex = this.GetSubResourceIndex(arraySlice, mipSlice);

            // If this texture is declared as default usage, we use UpdateSubresource that supports sub resource region.
            if (this.Description.Usage == GraphicsResourceUsage.Default)
            {
                // If using a specific region, we need to handle this case
                if (region.HasValue)
                {
                    var regionValue   = region.Value;
                    var sourceDataPtr = fromData.Pointer;

                    // Workaround when using region with a deferred context and a device that does not support CommandList natively
                    // see http://blogs.msdn.com/b/chuckw/archive/2010/07/28/known-issue-direct3d-11-updatesubresource-and-deferred-contexts.aspx
                    if (device.NeedWorkAroundForUpdateSubResource)
                    {
                        if (IsBlockCompressed)
                        {
                            regionValue.Left   /= 4;
                            regionValue.Right  /= 4;
                            regionValue.Top    /= 4;
                            regionValue.Bottom /= 4;
                        }
                        sourceDataPtr = new IntPtr((byte *)sourceDataPtr - (regionValue.Front * textureDepthStride) - (regionValue.Top * rowStride) - (regionValue.Left * sizePerElement));
                    }
                    device.UpdateSubresource(this, subResourceIndex, new DataBox(sourceDataPtr, rowStride, textureDepthStride), regionValue);
                }
                else
                {
                    device.UpdateSubresource(this, subResourceIndex, new DataBox(fromData.Pointer, rowStride, textureDepthStride));
                }
            }
            else
            {
                var mappedResource = device.MapSubresource(this, subResourceIndex, this.Description.Usage == GraphicsResourceUsage.Dynamic ? MapMode.WriteDiscard : MapMode.Write);
                var box            = mappedResource.DataBox;

                // If depth == 1 (Texture1D, Texture2D or TextureCube), then depthStride is not used
                var boxDepthStride = this.Description.Depth == 1 ? box.SlicePitch : textureDepthStride;

                // The fast way: If same stride, we can directly copy the whole texture in one shot
                if (box.RowPitch == rowStride && boxDepthStride == textureDepthStride)
                {
                    Utilities.CopyMemory(box.DataPointer, fromData.Pointer, sizeOfTextureData);
                }
                else
                {
                    // Otherwise, the long way by copying each scanline
                    var destPerDepthPtr = (byte *)box.DataPointer;
                    var sourcePtr       = (byte *)fromData.Pointer;

                    // Iterate on all depths
                    for (int j = 0; j < depth; j++)
                    {
                        var destPtr = destPerDepthPtr;
                        // Iterate on each line
                        for (int i = 0; i < height; i++)
                        {
                            Utilities.CopyMemory((IntPtr)destPtr, (IntPtr)sourcePtr, rowStride);
                            destPtr   += box.RowPitch;
                            sourcePtr += rowStride;
                        }
                        destPerDepthPtr += box.SlicePitch;
                    }
                }
                device.UnmapSubresource(mappedResource);
            }
        }
示例#10
0
 /// <summary>
 /// Copies the content an array of data on CPU memory to this texture into GPU memory using the specified <see cref="GraphicsDevice"/> (The graphics device could be deffered).
 /// </summary>
 /// <typeparam name="TData">The type of the T data.</typeparam>
 /// <param name="device">The <see cref="GraphicsDevice"/>.</param>
 /// <param name="fromData">The data to copy from.</param>
 /// <param name="arraySlice">The array slice index. This value must be set to 0 for Texture 3D.</param>
 /// <param name="mipSlice">The mip slice index.</param>
 /// <param name="region">Destination region</param>
 /// <exception cref="System.ArgumentException">When strides is different from optimal strides, and TData is not the same size as the pixel format, or Width * Height != toData.Length</exception>
 /// <remarks>
 /// See unmanaged documentation for usage and restrictions.
 /// </remarks>
 public unsafe void SetData <TData>(GraphicsDevice device, TData[] fromData, int arraySlice = 0, int mipSlice = 0, ResourceRegion?region = null) where TData : struct
 {
     SetData(device, new DataPointer((IntPtr)Interop.Fixed(fromData), fromData.Length * Utilities.SizeOf <TData>()), arraySlice, mipSlice, region);
 }
示例#11
0
 /// <summary>
 /// Copies the content an data on CPU memory to this texture into GPU memory using the specified <see cref="GraphicsDevice"/> (The graphics device could be deffered).
 /// </summary>
 /// <param name="fromData">The data to copy from.</param>
 /// <param name="arraySlice">The array slice index. This value must be set to 0 for Texture 3D.</param>
 /// <param name="mipSlice">The mip slice index.</param>
 /// <param name="region">Destination region</param>
 /// <exception cref="System.ArgumentException">When strides is different from optimal strides, and TData is not the same size as the pixel format, or Width * Height != toData.Length</exception>
 /// <remarks>
 /// This method is only working on the main graphics device. Use method with explicit graphics device to set data on a deferred context.
 /// See also unmanaged documentation about Map/UnMap for usage and restrictions.
 /// </remarks>
 public void SetData(DataPointer fromData, int arraySlice = 0, int mipSlice = 0, ResourceRegion?region = null)
 {
     SetData(GraphicsDevice, fromData, arraySlice, mipSlice, region);
 }
示例#12
0
 /// <summary>
 /// Copies the content an array of data on CPU memory to this texture into GPU memory.
 /// </summary>
 /// <typeparam name="TData">The type of the T data.</typeparam>
 /// <param name="fromData">The data to copy from.</param>
 /// <param name="arraySlice">The array slice index. This value must be set to 0 for Texture 3D.</param>
 /// <param name="mipSlice">The mip slice index.</param>
 /// <param name="region">Destination region</param>
 /// <exception cref="System.ArgumentException">When strides is different from optimal strides, and TData is not the same size as the pixel format, or Width * Height != toData.Length</exception>
 /// <remarks>
 /// This method is only working on the main graphics device. Use method with explicit graphics device to set data on a deferred context.
 /// See also unmanaged documentation about Map/UnMap for usage and restrictions.
 /// </remarks>
 public void SetData <TData>(TData[] fromData, int arraySlice = 0, int mipSlice = 0, ResourceRegion?region = null) where TData : struct
 {
     SetData(GraphicsDevice, fromData, arraySlice, mipSlice, region);
 }
 public void UpdateSubresource <T>(T[] data, Resource resource, int subresource = 0, int rowPitch = 0, int depthPitch = 0, ResourceRegion?region = null) where T : unmanaged
 {
     deviceContext.UpdateSubresource(data, resource, subresource, rowPitch, depthPitch, region);
 }
示例#14
0
        /// <summary>
        /// Copies the <paramref name="fromData"/> to the given <paramref name="buffer"/> on GPU memory.
        /// </summary>
        /// <typeparam name="TData">The type of the T data.</typeparam>
        /// <param name="buffer">The <see cref="Buffer"/>.</param>
        /// <param name="commandList">The <see cref="CommandList"/>.</param>
        /// <param name="fromData">The data to copy from.</param>
        /// <param name="offsetInBytes">The offset in bytes to write to.</param>
        /// <exception cref="ArgumentException"></exception>
        /// <remarks>
        /// See the unmanaged documentation about Map/UnMap for usage and restrictions.
        /// </remarks>
        /// <returns>The GPU buffer.</returns>
        public static unsafe Texture SetData <TData>(this Texture texture, CommandList commandList, Spread <TData> fromData, int arraySlice, int mipSlice, ResourceRegion?region) where TData : struct
        {
            var immutableArray = fromData._array;
            var array          = Unsafe.As <ImmutableArray <TData>, TData[]>(ref immutableArray);

            texture.SetData(commandList, array, arraySlice, mipSlice, region);
            return(texture);
        }
示例#15
0
 public void CopySubresourceRegion(Resource source, int sourceSubresource, ResourceRegion?sourceRegion, Resource destination,
                                   int destinationSubResource, int dstX = 0, int dstY = 0, int dstZ = 0)
 {
     deviceContext.CopySubresourceRegion(source, sourceSubresource, sourceRegion, destination, destinationSubResource, dstX, dstY, dstZ);
 }
示例#16
0
 public void UpdateSubresource <T>(ref T data, Resource resource, int subresource = 0, int rowPitch = 0, int depthPitch = 0, ResourceRegion?region = null) where T : struct
 {
     deviceContext.UpdateSubresource(ref data, resource, subresource, rowPitch, depthPitch, region);
 }
示例#17
0
 /// <summary>
 /// Copies data from the CPU to to a non-mappable subresource region.
 /// </summary>
 /// <typeparam name="T">Type of the data to upload</typeparam>
 /// <param name="data">A reference to the data to upload.</param>
 /// <param name="resource">The destination resource.</param>
 /// <param name="subresource">The destination subresource.</param>
 /// <param name="rowPitch">The row pitch.</param>
 /// <param name="depthPitch">The depth pitch.</param>
 /// <param name="region">A region that defines the portion of the destination subresource to copy the resource data into. Coordinates are in bytes for buffers and in texels for textures.</param>
 /// <msdn-id>ff476486</msdn-id>
 ///   <unmanaged>void ID3D11DeviceContext::UpdateSubresource([In] ID3D11Resource* pDstResource,[In] unsigned int DstSubresource,[In, Optional] const D3D11_BOX* pDstBox,[In] const void* pSrcData,[In] unsigned int SrcRowPitch,[In] unsigned int SrcDepthPitch)</unmanaged>
 ///   <unmanaged-short>ID3D11DeviceContext::UpdateSubresource</unmanaged-short>
 /// <remarks>This method is implementing the <a href="http://blogs.msdn.com/b/chuckw/archive/2010/07/28/known-issue-direct3d-11-updatesubresource-and-deferred-contexts.aspx">workaround for deferred context</a>.</remarks>
 public void UpdateSubresource <T>(T[] data, Resource resource, int subresource = 0, int rowPitch = 0, int depthPitch = 0, ResourceRegion?region = null) where T : struct
 {
     unsafe
     {
         UpdateSubresource(resource, subresource, region, (IntPtr)Interop.Fixed(data), rowPitch, depthPitch);
     }
 }
示例#18
0
 internal void CopySubresourceRegion(IResource source, int sourceSubresource, ResourceRegion?sourceRegion,
                                     IResource destination, int destinationSubResource, int dstX = 0, int dstY = 0, int dstZ = 0)
 {
     CopySubresourceRegion(source, sourceSubresource, sourceRegion, destination.Resource, destinationSubResource, dstX, dstY, dstZ);
 }
示例#19
0
 // TODO: Code that uses temporary resources (that calls this method) should be changed to use Managers and their interfaces
 internal void CopySubresourceRegion(IResource source, int sourceSubresource, ResourceRegion?sourceRegion,
                                     Resource destination, int destinationSubResource, int dstX = 0, int dstY = 0, int dstZ = 0)
 {
     m_deviceContext.CopySubresourceRegion(source.Resource, sourceSubresource, sourceRegion, destination, destinationSubResource, dstX, dstY, dstZ);
     CheckErrors();
 }
示例#20
0
 public void CopyRegion(GraphicsResource source, int sourceSubresource, ResourceRegion?sourecRegion, GraphicsResource destination, int destinationSubResource, int dstX = 0, int dstY = 0, int dstZ = 0)
 {
     NullHelper.ToImplement();
 }
示例#21
0
 public void CopyRegion(GraphicsResource source, int sourceSubresource, ResourceRegion?sourecRegion, GraphicsResource destination, int destinationSubResource, int dstX = 0, int dstY = 0, int dstZ = 0)
 {
     throw new NotImplementedException();
 }
示例#22
0
 public void UpdateSubresource(Resource dstResourceRef, int dstSubresource, ResourceRegion?dstBoxRef, System.IntPtr srcDataRef, int srcRowPitch, int srcDepthPitch)
 {
     deviceContext.UpdateSubresource(dstResourceRef, dstSubresource, dstBoxRef, srcDataRef, srcRowPitch, srcDepthPitch);
 }
示例#23
0
        public static unsafe Texture SetDataFromIImage(this Texture texture, CommandList commandList, IImage image, int arraySlice, int mipSlice, ResourceRegion?region)
        {
            using (var data = image.GetData())
            {
                var dp = new DataPointer(data.Pointer, data.Size);
                texture.SetData(commandList, dp, arraySlice, mipSlice, region);
            }

            return(texture);
        }