public void Recreate() { // TODO: Reuse the same VkCommandPool only for transfer, compute and graphics use an independent one per thread switch (Type) { case CommandBufferType.Generic: cmd_command_pool = NativeDevice.create_command_pool(NativeDevice.GraphicsFamily); break; case CommandBufferType.AsyncGraphics: cmd_command_pool = NativeDevice.create_command_pool(NativeDevice.GraphicsFamily); break; case CommandBufferType.AsyncCompute: cmd_command_pool = NativeDevice.create_command_pool(NativeDevice.ComputeFamily); break; case CommandBufferType.AsyncTransfer: cmd_command_pool = NativeDevice.transfer_cmd_pool; break; case CommandBufferType.Count: cmd_command_pool = NativeDevice.create_command_pool(NativeDevice.GraphicsFamily); break; } handle = NativeDevice.create_command_buffer_primary(cmd_command_pool); }
public TransferManager(GraphicsDevice graphics) { Graphics = graphics; Buffer = new((ulong)INITIAL_HOST_SIZE.B); Buffer.CanDestroyImmediately = true; // Safe to do since all operations with this are synchronous // Create command objects VkCommandPoolCreateInfo cpci = new(VkCommandPoolCreateFlags.Transient, Graphics.GraphicsQueue.FamilyIndex); VulkanHandle <VkCommandPool> poolHandle; Graphics.VkDevice.CreateCommandPool(&cpci, null, &poolHandle) .Throw("Failed to create command pool for transfer"); _pool = new(poolHandle, Graphics.VkDevice); VkCommandBufferAllocateInfo cbai = new(_pool, VkCommandBufferLevel.Primary, 1); VulkanHandle <VkCommandBuffer> cmdHandle; Graphics.VkDevice.AllocateCommandBuffers(&cbai, &cmdHandle) .Throw("Failed to allocate command buffer for transfer"); _cmd = new(cmdHandle, _pool); VkFenceCreateInfo fci = new(VkFenceCreateFlags.NoFlags); VulkanHandle <VkFence> fenceHandle; Graphics.VkDevice.CreateFence(&fci, null, &fenceHandle) .Throw("Failed to create fence for transfer"); _fence = new(fenceHandle, Graphics.VkDevice); }
private VulkanBuffer(VkDevice device, VkCommandPool commandPool, VkBuffer buffer, VkDeviceMemory memory, int count) { Buffer = buffer; Memory = memory; Count = count; this.device = device; this.commandPool = commandPool; }
void CreateCommandPool() { var info = new VkCommandPoolCreateInfo(); info.queueFamilyIndex = graphicsIndex; commandPool = new VkCommandPool(device, info); }
void CreateCommandPool() { var info = new VkCommandPoolCreateInfo(); info.queueFamilyIndex = graphicsIndex; info.flags = VkCommandPoolCreateFlags.ResetCommandBufferBit; commandPool = new VkCommandPool(device, info); }
private void DisposeVulkanCommandPool(VkCommandPool vulkanCommandPool) { _state.AssertDisposing(); if (vulkanCommandPool != VK_NULL_HANDLE) { vkDestroyCommandPool(VulkanGraphicsDevice.VulkanDevice, vulkanCommandPool, pAllocator: null); } }
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); }
private void CreateCommandPool() { VkCommandPoolCreateInfo cmdPoolInfo = new VkCommandPoolCreateInfo(); cmdPoolInfo.sType = CommandPoolCreateInfo; cmdPoolInfo.queueFamilyIndex = Swapchain.QueueNodeIndex; cmdPoolInfo.flags = VkCommandPoolCreateFlagBits.ResetCommandBuffer; VkCommandPool pool; vkCreateCommandPool(device, &cmdPoolInfo, null, &pool); this._cmdPool = pool; }
public static VkCommandBufferAllocateInfo CommandBufferAllocateInfo( VkCommandPool commandPool, VkCommandBufferLevel level, uint bufferCount) { VkCommandBufferAllocateInfo commandBufferAllocateInfo = new VkCommandBufferAllocateInfo(); commandBufferAllocateInfo.sType = VkStructureType.CommandBufferAllocateInfo; commandBufferAllocateInfo.commandPool = commandPool; commandBufferAllocateInfo.level = level; commandBufferAllocateInfo.commandBufferCount = bufferCount; return(commandBufferAllocateInfo); }
public static void AllocateCommandBuffers(VkCommandPool cmdPool, VkCommandBufferLevel level, uint count, VkCommandBuffer *cmdBuffers) { VkCommandBufferAllocateInfo cmdBufAllocateInfo = new VkCommandBufferAllocateInfo { sType = VkStructureType.CommandBufferAllocateInfo }; cmdBufAllocateInfo.commandPool = cmdPool; cmdBufAllocateInfo.level = level; cmdBufAllocateInfo.commandBufferCount = count; VulkanUtil.CheckResult(vkAllocateCommandBuffers(device, &cmdBufAllocateInfo, cmdBuffers)); }
private void CreateCommandPool() { var indices = new QueueFamilyIndices(vkPhysicalDevice, vkSurface); var poolInfo = new VkCommandPoolCreateInfo() { sType = VkStructureType.VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, queueFamilyIndex = (uint)indices.GraphicsFamily, flags = 0, }; VkCommandPool newCommandPool; var result = VulkanNative.vkCreateCommandPool(vkDevice, &poolInfo, null, &newCommandPool); vkCommandPool = newCommandPool; Helpers.CheckErrors(result); }
public static int CreateCommandPool(VkCommandPoolCreateFlags flags) { VkCommandPoolCreateInfo createInfo = VkCommandPoolCreateInfo.New(); createInfo.flags = flags; createInfo.queueFamilyIndex = graphicsQueueFamily; VkCommandPool pool = VkCommandPool.Null; if (vkCreateCommandPool(device, &createInfo, null, &pool) != VkResult.Success) { throw new System.Exception("Failed to create commandpool"); } Guid guid = Guid.NewGuid(); int id = guid.GetHashCode(); pools[id] = pool; return(id); }
public void Recreate() { QueueFamilyProperties = new List <VkQueueFamilyProperties>(); InitializePlatformDevice(); NativeSwapChain = new GraphicsSwapChain(this); NativeCommandPool = CreateCommandPool(); NativeCommandBufferPrimary = CreateCommandBufferPrimary(); NativeCommandList = new CommandList(this); NativeCommandBufferSecondary = CreateCommandBufferSecondary(); }
public unsafe CommandPool(QueueFamily queueFamily) { _queueFamily = queueFamily; _device = queueFamily.Device; var createInfo = new VkCommandPoolCreateInfo { sType = VkStructureType.CommandPoolCreateInfo, flags = VkCommandPoolCreateFlags.ResetCommandBuffer, queueFamilyIndex = queueFamily.Index }; VkCommandPool commandPool; if (VulkanNative.vkCreateCommandPool( queueFamily.Device.Handle, &createInfo, null, &commandPool ) != VkResult.Success) { throw new System.Exception("failed to create command pool on device"); } _handle = commandPool; }
public static void vkFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, VkCommandBuffer commandBuffer) { vkFreeCommandBuffers(device, commandPool, 1u, &commandBuffer); }
public abstract void DestroyCommandPool(VkCommandPool commandPool);
public abstract VkResult CreateCommandPool(VkCommandPoolCreateInfo commandPoolCreateInfo, out VkCommandPool commandPool);
public abstract void FreeCommandBuffers(VkCommandPool commandPool, int commandBufferCount, VkCommandBuffer[] pCommandBuffers);
public static VkResult vkCreateCommandPool(VkDevice device, VkCommandPoolCreateInfo poolCreateInfo, VkAllocationCallbacks pAllocator, out VkCommandPool commandPool) { VkPreconditions.CheckNull(device, nameof(device)); return(GetDevice(device).CreateCommandPool(poolCreateInfo, out commandPool)); }
public static extern void FreeCommandBuffers( VkDevice device, VkCommandPool commandPool, uint commandBufferCount, IntPtr pCommandBuffers );
public static void vkDestroyCommandPool(VkDevice device, VkCommandPool commandPool, VkAllocationCallbacks pAllocator) { VkPreconditions.CheckNull(device, nameof(device)); GetDevice(device).DestroyCommandPool(commandPool); }
public static extern void DestroyCommandPool( VkDevice device, VkCommandPool commandPool, IntPtr pAllocator );
public static extern VkResult ResetCommandPool( VkDevice device, VkCommandPool commandPool, VkCommandPoolResetFlags flags );
public Triangle() { InitializeComponent(); InitializeVulkan(); _Bitmap = new Bitmap(640, 480); _Framebuffer = new Framebuffer(_Device, 640, 480); VkPipelineLayout dummyLayout = _Device.CreatePipelineLayout(VkPipelineLayoutCreateFlag.NONE, null, null); _VertexShader = _Device.CreateShaderModule(VkShaderModuleCreateFlag.NONE, System.IO.File.ReadAllBytes("./Shaders/vertexShader.spv")); _FramgemtShader = _Device.CreateShaderModule(VkShaderModuleCreateFlag.NONE, System.IO.File.ReadAllBytes("./Shaders/fragmentShader.spv")); _GraphicsPipeline = new Pipeline(_Framebuffer, dummyLayout, _VertexShader, "main", _FramgemtShader, "main"); // Finally we will need a fence for our submission in order to wait on it _Fence = _Device.CreateFence(VkFenceCreateFlag.NONE); // VkBuffer indexBuffer = _Device.CreateBuffer(0, 3 * sizeof(Int32), VkBufferUsageFlag.VK_BUFFER_USAGE_INDEX_BUFFER, VkSharingMode.VK_SHARING_MODE_CONCURRENT, new VkQueueFamilyProperties[] { _Queue.Family }); // VkBuffer vertexBuffer = _Device.CreateBuffer(0, 3 * sizeof(float), VkBufferUsageFlag.VK_BUFFER_USAGE_VERTEX_BUFFER, VkSharingMode.VK_SHARING_MODE_CONCURRENT, new VkQueueFamilyProperties[] { _Queue.Family }); // Now we need to create a command buffer and we will fill it with a single command: // Fill the image with the color (0.1f, 0.75f, 1.0f, 1.0f) which is a Sky blue. VkClearValue.VkClearColorValue.Float color = new VkClearValue.VkClearColorValue.Float(); color.float32[0] = 0.1f; color.float32[1] = 0.75f; color.float32[2] = 1.0f; color.float32[3] = 1.0f; VkCommandPool Pool = _Device.CreateCommandPool(VkCommandPoolCreateFlag.NONE, _Queue.Family); _CommandBuffer = Pool.AllocateCommandBuffer(VkCommandBufferLevel.VK_COMMAND_BUFFER_LEVEL_PRIMARY); _CommandBuffer.Begin(VkCommandBufferUsageFlag.NONE); _CommandBuffer.CmdBeginRenderPass(_Framebuffer.RenderPass, new VkRect2D(0, 0, (uint)640, (uint)480), _Framebuffer.GetFramebuffer(), new VkClearValue[] { color }, VkSubpassContents.VK_SUBPASS_CONTENTS_INLINE); _GraphicsPipeline.BindPipeline(_CommandBuffer); _CommandBuffer.CmdDraw(3, 1, 0, 0); _CommandBuffer.CmdEndRenderPass(); _CommandBuffer.cmdCopyImageToBuffer(_Framebuffer.FrameBufferColor, VkImageLayout.VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, _Framebuffer._TransferBuffer, new VkBufferImageCopy[] { new VkBufferImageCopy() { bufferImageHeight = (uint)_Framebuffer.Height, bufferOffset = 0, bufferRowLength = (uint)_Framebuffer.Width, imageExtent = new VkExtent3D() { depth = 1, width = (uint)_Framebuffer.Width, height = (uint)_Framebuffer.Height }, imageSubresource = new VkImageSubresourceLayers() { aspectMask = VkImageAspectFlag.VK_IMAGE_ASPECT_COLOR_BIT, baseArrayLayer = 0, layerCount = 1, mipLevel = 0 } } }); _CommandBuffer.End(); }
public static extern VkResult CreateCommandPool( VkDevice device, ref VkCommandPoolCreateInfo pCreateInfo, IntPtr pAllocator, out VkCommandPool pCommandPool );
public override VkResult CreateCommandPool(VkCommandPoolCreateInfo commandPoolCreateInfo, out VkCommandPool commandPool) { throw new NotImplementedException(); }
public override void FreeCommandBuffers(VkCommandPool commandPool, int commandBufferCount, VkCommandBuffer[] pCommandBuffers) { throw new NotImplementedException(); }
public override void DestroyCommandPool(VkCommandPool commandPool) { throw new NotImplementedException(); }
public CommandBufferPool(uint queue, VkCommandPoolCreateFlags commandPoolCreateFlags) { QueueIndex = queue; cmdPool = Device.CreateCommandPool(queue, commandPoolCreateFlags); }
public static VkResult vkCreateCommandPool(VkDevice device, VkCommandPoolCreateFlags flags, uint queueFamilyIndex, out VkCommandPool commandPool) { VkCommandPoolCreateInfo createInfo = new VkCommandPoolCreateInfo { sType = VkStructureType.CommandPoolCreateInfo, flags = flags, queueFamilyIndex = queueFamilyIndex }; return(vkCreateCommandPool(device, &createInfo, null, out commandPool)); }