Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        public static void vkGetBufferMemoryRequirements(VkDevice device, VkBuffer buffer, out VkMemoryRequirements pMemoryRequirements)
        {
            VkPreconditions.CheckNull(device, nameof(device));
            VkPreconditions.CheckNull(buffer, nameof(buffer));

            GetDevice(device).GetBufferMemoryRequirements(buffer, out pMemoryRequirements);
        }
Ejemplo n.º 3
0
        public static VkResult vkAllocateCommandBuffers(VkDevice device, VkCommandBufferAllocateInfo allocInfo, VkCommandBuffer[] commandBuffers)
        {
            VkPreconditions.CheckNull(device, nameof(device));
            VkPreconditions.CheckNull(commandBuffers, nameof(commandBuffers));

            return(GetDevice(device).AllocateCommandBuffers(allocInfo, commandBuffers));
        }
Ejemplo n.º 4
0
        public static VkResult vkGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, ref int formatCount, VkSurfaceFormatKHR[] formats)
        {
            VkPreconditions.CheckNull(physicalDevice, nameof(physicalDevice));
            VkPreconditions.CheckNull(surface, nameof(surface));

            return(GetPhysicalDevice(physicalDevice).GetSurfaceFormats(surface, ref formatCount, formats));
        }
Ejemplo n.º 5
0
        public static VkResult vkGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, ref int presentModeCount, VkPresentModeKHR[] presentModes)
        {
            VkPreconditions.CheckNull(physicalDevice, nameof(physicalDevice));
            VkPreconditions.CheckNull(surface, nameof(surface));

            return(GetPhysicalDevice(physicalDevice).GetSurfacePresentModes(surface, ref presentModeCount, presentModes));
        }
Ejemplo n.º 6
0
        public static VkResult vkGetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapChain, ref int imageCount, VkImage[] swapChainImages)
        {
            VkPreconditions.CheckNull(device, nameof(device));
            VkPreconditions.CheckNull(swapChain, nameof(swapChain));

            return(GetDevice(device).GetSwapchainImages(swapChain, ref imageCount, swapChainImages));
        }
Ejemplo n.º 7
0
        public static VkResult vkGetPhysicalDeviceSurfaceCapabilitiesKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, out VkSurfaceCapabilitiesKHR capabilities)
        {
            VkPreconditions.CheckNull(physicalDevice, nameof(physicalDevice));
            VkPreconditions.CheckNull(surface, nameof(surface));

            return(GetPhysicalDevice(physicalDevice).GetSurfaceCapabilities(surface, out capabilities));
        }
Ejemplo n.º 8
0
        public static void vkUnmapMemory(VkDevice device, VkDeviceMemory memory)
        {
            VkPreconditions.CheckNull(device, nameof(device));
            VkPreconditions.CheckNull(memory, nameof(memory));

            GetDevice(device).UnmapMemory(memory);
        }
Ejemplo n.º 9
0
        public static VkResult vkMapMemory(VkDevice device, VkDeviceMemory memory, int offset, int size, int memoryMapFlags, out byte[] ppData)
        {
            VkPreconditions.CheckNull(device, nameof(device));
            VkPreconditions.CheckNull(memory, nameof(memory));

            return(GetDevice(device).MapMemory(memory, offset, size, memoryMapFlags, out ppData));
        }
Ejemplo n.º 10
0
        public static void vkGetImageMemoryRequirements(VkDevice device, VkImage image, out VkMemoryRequirements pMemoryRequirements)
        {
            VkPreconditions.CheckNull(device, nameof(device));
            VkPreconditions.CheckNull(image, nameof(image));

            GetDevice(device).GetImageMemoryRequirements(image, out pMemoryRequirements);
        }
Ejemplo n.º 11
0
 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));
 }
Ejemplo n.º 12
0
        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();
            }
        }
Ejemplo n.º 13
0
        public static void vkCmdBindPipeline(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline)
        {
            VkPreconditions.CheckNull(commandBuffer, nameof(commandBuffer));
            VkPreconditions.CheckNull(pipeline, nameof(pipeline));

            GetCommandBuffer(commandBuffer).CmdBindPipeline(pipelineBindPoint, pipeline);
        }
Ejemplo n.º 14
0
        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));
        }
Ejemplo n.º 15
0
        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);
        }
Ejemplo n.º 16
0
        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);
        }
Ejemplo n.º 17
0
        public static VkResult vkBindImageMemory(VkDevice device, VkImage image, VkDeviceMemory memory, int memoryOffset)
        {
            VkPreconditions.CheckNull(device, nameof(device));
            VkPreconditions.CheckNull(image, nameof(image));
            VkPreconditions.CheckNull(memory, nameof(memory));

            return(GetDevice(device).BindImageMemory(image, memory, memoryOffset));
        }
Ejemplo n.º 18
0
        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));
        }
Ejemplo n.º 19
0
        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);
        }
Ejemplo n.º 20
0
        public static void vkDestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT callback, VkAllocationCallbacks pAllocator)
        {
            VkPreconditions.CheckNull(instance, nameof(instance));

            if (callback != null)
            {
                GetInstance(instance).DestroyDebugReportCallback(callback);
            }
        }
Ejemplo n.º 21
0
        public static void vkDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapChain, VkAllocationCallbacks pAllocator)
        {
            VkPreconditions.CheckNull(device, nameof(device));

            if (swapChain != null)
            {
                GetDevice(device).DestroySwapchainKHR(swapChain);
            }
        }
Ejemplo n.º 22
0
        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));
        }
Ejemplo n.º 23
0
        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));
        }
Ejemplo n.º 24
0
        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);
        }
Ejemplo n.º 25
0
        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);
        }
Ejemplo n.º 26
0
        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);
        }
Ejemplo n.º 27
0
        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));
        }
Ejemplo n.º 28
0
        public static void CopyMemory(IntPtr input, IntPtr output, uint byteCount)
        {
            if (byteCount == 0)
            {
                return;
            }

            VkPreconditions.CheckNull(input == IntPtr.Zero, nameof(input));
            VkPreconditions.CheckNull(output == IntPtr.Zero, nameof(output));

            Msvcrt.memcpy(output, input, (UIntPtr)byteCount);
        }
Ejemplo n.º 29
0
        public static void vkDebugReportMessageEXT(
            VkInstance instance,
            VkDebugReportFlagBitsEXT flags,
            VkDebugReportObjectTypeEXT objectType,
            object obj,
            int location,
            int messageCode,
            string pLayerPrefix,
            string pMessage)
        {
            VkPreconditions.CheckNull(instance, nameof(instance));
            VkPreconditions.CheckString(pMessage, nameof(pMessage));

            GetInstance(instance).DebugReportMessage(flags, objectType, obj, location, messageCode, pLayerPrefix, pMessage);
        }
Ejemplo n.º 30
0
        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();
            }
        }