public static void vkCmdPipelineBarrier(VkCommandBuffer commandBuffer, VkPipelineStageFlagBits srcStageMask, VkPipelineStageFlagBits dstStageMask, int dependencyFlags, int memoryBarrierCount, VkMemoryBarrier[] pMemoryBarriers, int bufferMemoryBarrierCount, VkBufferMemoryBarrier[] pBufferMemoryBarriers, int imageMemoryBarrierCount, VkImageMemoryBarrier[] pImageMemoryBarriers) { bool hasBarrier = false; VkPreconditions.CheckNull(commandBuffer, nameof(commandBuffer)); if (memoryBarrierCount != 0) { hasBarrier = true; VkPreconditions.CheckNull(pMemoryBarriers, nameof(pMemoryBarriers)); VkPreconditions.CheckRange(memoryBarrierCount, 1, pMemoryBarriers.Length, nameof(memoryBarrierCount)); } if (bufferMemoryBarrierCount != 0) { hasBarrier = true; VkPreconditions.CheckNull(pBufferMemoryBarriers, nameof(pBufferMemoryBarriers)); VkPreconditions.CheckRange(bufferMemoryBarrierCount, 1, pBufferMemoryBarriers.Length, nameof(bufferMemoryBarrierCount)); } if (imageMemoryBarrierCount != 0) { hasBarrier = true; VkPreconditions.CheckNull(pImageMemoryBarriers, nameof(pImageMemoryBarriers)); VkPreconditions.CheckRange(imageMemoryBarrierCount, 1, pImageMemoryBarriers.Length, nameof(imageMemoryBarrierCount)); } VkPreconditions.CheckOperation(!hasBarrier, ("At least one type of barrier must be informed on the command")); GetCommandBuffer(commandBuffer).CmdPipelineBarrier(srcStageMask, dstStageMask, dependencyFlags, memoryBarrierCount, pMemoryBarriers, bufferMemoryBarrierCount, pBufferMemoryBarriers, imageMemoryBarrierCount, pImageMemoryBarriers); }
private static double MeasureAction(Action action, int workSize, int minMilliseconds) { VkPreconditions.CheckNull(action, nameof(action)); VkPreconditions.CheckRange(workSize <= 0, nameof(workSize)); VkPreconditions.CheckRange(minMilliseconds <= 0, nameof(minMilliseconds)); return(RunAction(action, workSize, minMilliseconds)); }
public static void Copy(object input, byte[] output, int outputOffset, int length) { if (length == 0) { return; } VkPreconditions.CheckNull(input, nameof(input)); VkPreconditions.CheckNull(output, nameof(output)); VkPreconditions.CheckRange(outputOffset, 0, int.MaxValue, nameof(outputOffset)); VkPreconditions.CheckRange(length, 0, int.MaxValue, nameof(length)); VkPreconditions.CheckRange(outputOffset + length > output.Length, nameof(length)); GCHandle pinned = GCHandle.Alloc(input, GCHandleType.Pinned); try { IntPtr addr = pinned.AddrOfPinnedObject(); Marshal.Copy(addr, output, outputOffset, length); } finally { pinned.Free(); } }
public static void vkCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer, int offset, VkIndexType indexType) { VkPreconditions.CheckNull(commandBuffer, nameof(commandBuffer)); VkPreconditions.CheckNull(buffer, nameof(buffer)); VkPreconditions.CheckRange(offset, 0, int.MaxValue, nameof(offset)); GetCommandBuffer(commandBuffer).CmdBindIndexBuffer(buffer, offset, indexType); }
public static VkResult vkGetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice physicalDevice, int queueFamilyIndex, VkSurfaceKHR surface, out bool pSupported) { VkPreconditions.CheckNull(physicalDevice, nameof(physicalDevice)); VkPreconditions.CheckNull(surface, nameof(surface)); VkPreconditions.CheckRange(queueFamilyIndex, 0, int.MaxValue, nameof(queueFamilyIndex)); return(GetPhysicalDevice(physicalDevice).GetSurfaceSupport(queueFamilyIndex, surface, out pSupported)); }
public static void vkGetDeviceQueue(VkDevice device, int queueFamilyIndex, int queueIndex, out VkQueue pQueue) { VkPreconditions.CheckNull(device, nameof(device)); VkPreconditions.CheckRange(queueFamilyIndex, 0, int.MaxValue, nameof(queueFamilyIndex)); VkPreconditions.CheckRange(queueIndex, 0, int.MaxValue, nameof(queueIndex)); GetDevice(device).GetQueue(queueFamilyIndex, queueIndex, out pQueue); }
public static VkResult vkAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, long timeout, VkSemaphore semaphore, VkFence fence, out int pImageIndex) { VkPreconditions.CheckNull(device, nameof(device)); VkPreconditions.CheckNull(swapchain, nameof(swapchain)); VkPreconditions.CheckRange(timeout, 1, long.MaxValue, nameof(timeout)); return(GetDevice(device).AcquireNextImage(swapchain, timeout, semaphore, fence, out pImageIndex)); }
public static void vkFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, int commandBufferCount, VkCommandBuffer[] pCommandBuffers) { VkPreconditions.CheckNull(device, nameof(device)); VkPreconditions.CheckNull(commandPool, nameof(commandPool)); VkPreconditions.CheckNull(pCommandBuffers, nameof(pCommandBuffers)); VkPreconditions.CheckRange(commandBufferCount, 0, pCommandBuffers.Length, nameof(commandBufferCount)); GetDevice(device).FreeCommandBuffers(commandPool, commandBufferCount, pCommandBuffers); }
public static VkResult vkBindBufferMemory(VkDevice device, VkBuffer buffer, VkDeviceMemory memory, int memoryOffset) { VkPreconditions.CheckNull(device, nameof(device)); VkPreconditions.CheckNull(buffer, nameof(buffer)); VkPreconditions.CheckNull(memory, nameof(memory)); VkPreconditions.CheckRange(memoryOffset, 0, int.MaxValue, nameof(memoryOffset)); return(GetDevice(device).BindBufferMemory(buffer, memory, memoryOffset)); }
public static void vkCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage, VkImageLayout dstImageLayout, int regionCount, VkBufferImageCopy[] pRegions) { VkPreconditions.CheckNull(commandBuffer, nameof(commandBuffer)); VkPreconditions.CheckNull(srcBuffer, nameof(srcBuffer)); VkPreconditions.CheckNull(dstImage, nameof(dstImage)); VkPreconditions.CheckNull(pRegions, nameof(pRegions)); VkPreconditions.CheckRange(regionCount, 1, pRegions.Length, nameof(regionCount)); GetCommandBuffer(commandBuffer).CmdCopyBufferToImage(srcBuffer, dstImage, dstImageLayout, regionCount, pRegions); }
public static void vkCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer, int regionCount, VkBufferCopy[] pRegions) { VkPreconditions.CheckNull(commandBuffer, nameof(commandBuffer)); VkPreconditions.CheckNull(srcBuffer, nameof(srcBuffer)); VkPreconditions.CheckNull(dstBuffer, nameof(dstBuffer)); VkPreconditions.CheckNull(pRegions, nameof(pRegions)); VkPreconditions.CheckRange(regionCount, 1, pRegions.Length, nameof(regionCount)); GetCommandBuffer(commandBuffer).CmdCopyBuffer(srcBuffer, dstBuffer, regionCount, pRegions); }
public static void vkCmdDraw(VkCommandBuffer commandBuffer, int vertexCount, int instanceCount, int firstVertex, int firstInstance) { VkPreconditions.CheckNull(commandBuffer, nameof(commandBuffer)); VkPreconditions.CheckRange(vertexCount, 1, int.MaxValue, nameof(vertexCount)); VkPreconditions.CheckRange(instanceCount, 1, int.MaxValue, nameof(instanceCount)); VkPreconditions.CheckRange(firstVertex, 0, int.MaxValue, nameof(firstVertex)); VkPreconditions.CheckRange(firstInstance, 0, int.MaxValue, nameof(firstInstance)); GetCommandBuffer(commandBuffer).CmdDraw(vertexCount, instanceCount, firstVertex, firstInstance); }
public static VkResult vkQueueSubmit(VkQueue queue, int submitCount, VkSubmitInfo[] pSubmits, VkFence fence) { VkPreconditions.CheckNull(queue, nameof(queue)); VkPreconditions.CheckNull(pSubmits, nameof(pSubmits)); VkPreconditions.CheckRange(submitCount, 1, int.MaxValue, nameof(submitCount)); VkPreconditions.CheckRange(pSubmits.Length < submitCount, nameof(pSubmits.Length)); return(GetQueue(queue).Submit(submitCount, pSubmits, fence)); }
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); }
public static VkResult vkCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, int createInfoCount, VkGraphicsPipelineCreateInfo[] pCreateInfos, VkAllocationCallbacks pAllocator, VkPipeline[] pPipelines) { VkPreconditions.CheckNull(device, nameof(device)); VkPreconditions.CheckNull(device, nameof(pCreateInfos)); VkPreconditions.CheckNull(device, nameof(pPipelines)); VkPreconditions.CheckRange(createInfoCount, 1, int.MaxValue, nameof(createInfoCount)); VkPreconditions.CheckRange(pCreateInfos.Length < createInfoCount, nameof(pCreateInfos.Length)); return(GetDevice(device).CreateGraphicsPipelines(pipelineCache, createInfoCount, pCreateInfos, pPipelines)); }
public static void ReadStructure <T>(byte[] input, int inputOffset, ref T output) where T : struct { VkPreconditions.CheckNull(input, nameof(input)); VkPreconditions.CheckRange(inputOffset, 0, input.Length - 1, nameof(inputOffset)); GCHandle pinned = GCHandle.Alloc(input, GCHandleType.Pinned); try { IntPtr addr = pinned.AddrOfPinnedObject(); output = (T)Marshal.PtrToStructure(addr + inputOffset, typeof(T)); } finally { pinned.Free(); } }
public static double MeasureAction(Action action, int workSize) { VkPreconditions.CheckNull(action, nameof(action)); VkPreconditions.CheckRange(workSize <= 0, nameof(workSize)); return(RunAction(action, workSize)); }