Example #1
0
 int IInternalTexture.Write(HostBuffer buffer, long offset)
 {
     if (buffer == null)
     {
         throw new ArgumentNullException(nameof(buffer));
     }
     return(buffer.Write(pixels, offset));
 }
Example #2
0
        void IInternalTexture.Upload(
            HostBuffer stagingBuffer,
            TransientExecutor executor,
            Image image,
            ImageAspects aspects)
        {
            if (stagingBuffer == null)
            {
                throw new ArgumentNullException(nameof(stagingBuffer));
            }
            if (executor == null)
            {
                throw new ArgumentNullException(nameof(executor));
            }

            //Write to the staging buffer
            stagingBuffer.Write(pixels, offset: 0);

            //Copy the staging buffer to the image
            executor.ExecuteBlocking(commandBuffer =>
            {
                commandBuffer.CmdCopyBufferToImage(
                    srcBuffer: stagingBuffer.VulkanBuffer,
                    dstImage: image,
                    dstImageLayout: ImageLayout.TransferDstOptimal,
                    regions: new BufferImageCopy {
                    BufferOffset      = 0,
                    BufferRowLength   = 0,
                    BufferImageHeight = 0,
                    ImageSubresource  = new ImageSubresourceLayers(
                        aspectMask: aspects, mipLevel: 0, baseArrayLayer: 0, layerCount: 1),
                    ImageOffset = new Offset3D(x: 0, y: 0, z: 0),
                    ImageExtent = new Extent3D(
                        width: size.X,
                        height: size.Y,
                        depth: 1)
                });
            });
        }