internal VkResult BindMemory(SoftwareDeviceMemory memory, int memoryOffset) { // TODO: SoftwareImage.BindMemory() this.m_memory = memory; this.m_memoryOffset = memoryOffset; return(VkResult.VK_SUCCESS); }
public void BindMemory(SoftwareDeviceMemory memory, int memoryOffset) { this.m_deviceMemory = memory; this.m_memoryOffset = memoryOffset; if (createInfo.usage.HasFlag(VkBufferUsageFlagBits.VK_BUFFER_USAGE_VERTEX_BUFFER_BIT)) { m_VertexBufferCache = new VertexBufferCache(memory.m_bytes, memoryOffset); } }
public override void FreeMemory(VkDeviceMemory memory) { SoftwareDeviceMemory mem = (SoftwareDeviceMemory)memory; if (mem != null) { m_DeviceMemory.Remove(mem); mem.Destroy(); } }
public override VkResult AllocateMemory(VkMemoryAllocateInfo pAllocateInfo, out VkDeviceMemory pMemory) { VkPreconditions.CheckRange(pAllocateInfo.allocationSize, 1, int.MaxValue, nameof(pAllocateInfo.allocationSize)); VkPreconditions.CheckRange(pAllocateInfo.memoryTypeIndex != 0, nameof(pAllocateInfo.memoryTypeIndex)); var ret = new SoftwareDeviceMemory(this, pAllocateInfo); m_DeviceMemory.Add(ret); pMemory = ret; return(VkResult.VK_SUCCESS); }
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); } } } }
public override void UnmapMemory(VkDeviceMemory memory) { SoftwareDeviceMemory mem = (SoftwareDeviceMemory)memory; mem.UnmapMemory(); }
public override VkResult MapMemory(VkDeviceMemory memory, int offset, int size, int memoryMapFlags, out byte[] ppData) { SoftwareDeviceMemory mem = (SoftwareDeviceMemory)memory; return(mem.MapMemory(offset, size, memoryMapFlags, out ppData)); }