Esempio n. 1
0
        internal void CopyBufferToImage(VkBuffer srcBuffer, VkImageLayout dstImageLayout, int regionCount, VkBufferImageCopy[] pRegions)
        {
            int                  dstPixelSize   = 4;
            SoftwareBuffer       softwareBuffer = (SoftwareBuffer)srcBuffer;
            SoftwareDeviceMemory sdm            = softwareBuffer.m_deviceMemory;

            int dstLineStride  = m_imageExtent.width * dstPixelSize;
            int dstDepthStride = m_imageExtent.width * m_imageExtent.height * dstPixelSize;

            for (int nRegion = 0; nRegion < regionCount; nRegion++)
            {
                var region        = pRegions[nRegion];
                int regLineStride = region.imageExtent.width * dstPixelSize;

                for (int z = 0; z < region.imageExtent.depth; z++)
                {
                    int bufferOffset      = region.bufferOffset;
                    int bufferImageHeight = region.bufferImageHeight;
                    int bufferRowLength   = region.bufferRowLength;
                    if (bufferImageHeight == 0 || bufferRowLength == 0)
                    {
                        bufferImageHeight = m_imageExtent.height;
                        bufferRowLength   = m_imageExtent.width * dstPixelSize;
                    }

                    int srcLineStride  = bufferRowLength;
                    int srcDepthStride = bufferImageHeight * bufferRowLength;

                    int srcOffset = (z * srcDepthStride) + bufferOffset + softwareBuffer.m_memoryOffset;
                    int dstOffset = ((region.imageOffset.z + z) * dstDepthStride) + (region.imageOffset.y * dstLineStride) + (region.imageOffset.x * dstPixelSize);

                    for (int y = 0; y < region.imageExtent.height; y++)
                    {
                        int imgOffs = dstOffset + (y * dstLineStride);
                        int bufOffs = srcOffset + (y * srcLineStride);
                        Buffer.BlockCopy(sdm.m_bytes, bufOffs, m_imageData, imgOffs, regLineStride);
                    }
                }
            }
        }
Esempio n. 2
0
 public override VkResult CreateBuffer(VkBufferCreateInfo pCreateInfo, out VkBuffer pBuffer)
 {
     pBuffer = new SoftwareBuffer(this, pCreateInfo);
     return(VkResult.VK_SUCCESS);
 }