public CommandBuffer(VkCommandBuffer cmd, VkCommandBufferLevel level, CommandPool src, bool transient) { Cmd = cmd; Level = level; SourcePool = src; Transient = transient; }
internal CommandBuffer(Device device, CommandPool pool, VkCommandBuffer commandBuffer, VkCommandBufferLevel level) { Device = device; Pool = pool; this.commandBuffer = commandBuffer; Level = level; }
public CommandBuffer[] Allocate(VkCommandBufferLevel level, int count) { var info = new VkCommandBufferAllocateInfo(); info.sType = VkStructureType.CommandBufferAllocateInfo; info.level = level; info.commandPool = commandPool; info.commandBufferCount = (uint)count; using (var commandBuffersMarshalled = new NativeArray <VkCommandBuffer>(count)) { CommandBuffer[] commandBuffers = new CommandBuffer[count]; var result = Device.Commands.allocateCommandBuffers(Device.Native, ref info, commandBuffersMarshalled.Address); if (result != VkResult.Success) { throw new CommandPoolException(string.Format("Error allocating command buffers: {0}", result)); } for (int i = 0; i < count; i++) { commandBuffers[i] = new CommandBuffer(Device, this, commandBuffersMarshalled[i], level); } return(commandBuffers); } }
private void GrowBuffers(VkCommandBufferLevel level, uint numBuffers) { NativeList <VkCommandBuffer> buffers = level == VkCommandBufferLevel.Primary ? primaryCmdBuffers : secondaryCmdBuffers; uint oldBuffers = buffers.Count; if (numBuffers <= oldBuffers) { return; } // Create one command buffer for each swap chain image and reuse for rendering buffers.Resize(numBuffers); buffers.Count = numBuffers; if (buffers.Count > MAX_BUFFERS) { throw new InvalidOperationException("Hit max buffer amount. Please check if buffers are not being reused correctly."); } VkCommandBufferAllocateInfo cmdBufAllocateInfo = Initializers.CommandBufferAllocateInfo(vkCmdPool, level, buffers.Count - oldBuffers); Util.CheckResult(vkAllocateCommandBuffers(device.device, ref cmdBufAllocateInfo, (VkCommandBuffer *)buffers.GetAddress(oldBuffers))); var queue = level == VkCommandBufferLevel.Primary ? freePrimaryBuffers : freeSecondaryBuffers; for (uint i = oldBuffers; i < buffers.Count; i++) { queue.Enqueue(buffers[i]); } }
public CommandBuffer Rent(VkCommandBufferLevel level = VkCommandBufferLevel.Primary) { if (level == VkCommandBufferLevel.Primary) { if (freePrimaryBuffers.TryDequeue(out var result)) { return(new CommandBuffer(result, this, level)); } else { GrowBuffers(level, primaryCmdBuffers.Count + 10); result = freePrimaryBuffers.Dequeue(); return(new CommandBuffer(result, this, level)); } } else { if (freeSecondaryBuffers.TryDequeue(out var result)) { return(new CommandBuffer(result, this, level)); } else { GrowBuffers(level, secondaryCmdBuffers.Count + 10); result = freeSecondaryBuffers.Dequeue(); return(new CommandBuffer(result, this, level)); } } }
public CommandBuffer AllocateAndStart(VkCommandBufferUsageFlags usage = 0, VkCommandBufferLevel level = VkCommandBufferLevel.Primary) { CommandBuffer cmd = AllocateCommandBuffer(level); cmd.Start(usage); return(cmd); }
public unsafe CommandBuffer AllocateCommandBuffer(VkCommandBufferLevel commandBufferLevel) { VkCommandBuffer cmdBuffer; Device.AllocateCommandBuffers(cmdPool, commandBufferLevel, 1, &cmdBuffer); return(new CommandBuffer(cmdBuffer)); }
public unsafe CommandBuffer( CommandPool commandPool, VkCommandBufferLevel level = VkCommandBufferLevel.Primary, bool isFenceSignaled = false ) { _commandPool = commandPool; _level = level; var allocateInfo = new VkCommandBufferAllocateInfo { sType = VkStructureType.CommandBufferAllocateInfo, commandPool = commandPool.Handle, level = level, commandBufferCount = 1 }; VkCommandBuffer commandBuffer; if (VulkanNative.vkAllocateCommandBuffers( commandPool.Device.Handle, &allocateInfo, &commandBuffer ) != VkResult.Success) { throw new Exception("failed to allocate command buffers"); } _handle = commandBuffer; _fence = new Fence(commandPool.Device, isFenceSignaled); }
public VkCommandBuffer[] AllocateCommandBuffers(VkCommandBufferLevel level, UInt32 commandBufferCount) { VkCommandBufferAllocateInfo commandBufferAllocateInfo = new VkCommandBufferAllocateInfo(); commandBufferAllocateInfo.commandBufferCount = commandBufferCount; commandBufferAllocateInfo.level = level; return(AllocateCommandBuffers(ref commandBufferAllocateInfo)); }
public CommandBuffer(VkCommandBuffer internalBuffer, CommandPool pool, VkCommandBufferLevel level) { vkCmd = internalBuffer; this.pool = pool; this.level = level; begun = false; inRenderPass = false; ended = false; renderPassUseSecondaryBuffers = false; }
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)); }
public CommandBuffer AllocateCommandBuffer(VkCommandBufferLevel level = VkCommandBufferLevel.Primary) { VkCommandBuffer buff; VkCommandBufferAllocateInfo infos = VkCommandBufferAllocateInfo.New(); infos.commandPool = handle; infos.level = level; infos.commandBufferCount = 1; Utils.CheckResult(vkAllocateCommandBuffers(Dev.VkDev, ref infos, out buff)); return(new CommandBuffer(Dev.VkDev, this, buff)); }
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 unsafe void Allocate(VkCommandBufferLevel commandBufferLevel, uint count) { if (cmdBuffers.Count > 0) { Free(); } cmdBuffers.Resize(count); Device.AllocateCommandBuffers(cmdPool, commandBufferLevel, count, (VkCommandBuffer *)cmdBuffers.Data); CommandBuffers = new CommandBuffer[count]; for (int i = 0; i < count; i++) { CommandBuffers[i] = new CommandBuffer(cmdBuffers[i]); } }
protected VkCommandBuffer createCommandBuffer(VkCommandBufferLevel level, bool begin) { VkCommandBuffer cmdBuffer; VkCommandBufferAllocateInfo cmdBufAllocateInfo = Initializers.CommandBufferAllocateInfo(cmdPool, level, 1); Util.CheckResult(vkAllocateCommandBuffers(device, &cmdBufAllocateInfo, out cmdBuffer)); // If requested, also start the new command buffer if (begin) { VkCommandBufferBeginInfo cmdBufInfo = Initializers.commandBufferBeginInfo(); Util.CheckResult(vkBeginCommandBuffer(cmdBuffer, &cmdBufInfo)); } return(cmdBuffer); }
public CommandBuffer[] AllocateCommandBuffer(uint count, VkCommandBufferLevel level = VkCommandBufferLevel.Primary) { VkCommandBufferAllocateInfo infos = VkCommandBufferAllocateInfo.New(); infos.commandPool = handle; infos.level = level; infos.commandBufferCount = count; VkCommandBuffer[] buffs = new VkCommandBuffer[count]; Utils.CheckResult(vkAllocateCommandBuffers(Dev.VkDev, ref infos, buffs.Pin())); buffs.Unpin(); CommandBuffer[] cmds = new CommandBuffer[count]; for (int i = 0; i < count; i++) { cmds[i] = new CommandBuffer(Dev.VkDev, this, buffs[i]); } return(cmds); }
public CommandBuffer(CommandPool pool, VkCommandBufferLevel level) { CommandPool = pool; unsafe { VkCommandBuffer handle = VkCommandBuffer.Null; VkCommandBufferAllocateInfo info = new VkCommandBufferAllocateInfo() { SType = VkStructureType.CommandBufferAllocateInfo, PNext = IntPtr.Zero, CommandPool = pool.Handle, CommandBufferCount = 1, Level = level }; VkException.Check(VkDevice.vkAllocateCommandBuffers(Device.Handle, &info, &handle)); Debug.Assert(handle != VkCommandBuffer.Null); Handle = handle; _state = State.Allocated; } }
public CommandBuffer Allocate(VkCommandBufferLevel level) { var info = new VkCommandBufferAllocateInfo(); info.sType = VkStructureType.CommandBufferAllocateInfo; info.level = level; info.commandPool = commandPool; info.commandBufferCount = 1; using (var commandBufferMarshalled = new Native <VkCommandBuffer>()) { var result = Device.Commands.allocateCommandBuffers(Device.Native, ref info, commandBufferMarshalled.Address); if (result != VkResult.Success) { throw new CommandPoolException(string.Format("Error allocating command buffer: {0}", result)); } CommandBuffer commandBuffer = new CommandBuffer(Device, this, commandBufferMarshalled.Value, level); return(commandBuffer); } }
public VkCommandBuffer createCommandBuffer(VkCommandBufferLevel level, bool begin = false) { VkCommandBufferAllocateInfo cmdBufAllocateInfo = VkCommandBufferAllocateInfo.New(); cmdBufAllocateInfo.commandPool = CommandPool; cmdBufAllocateInfo.level = level; cmdBufAllocateInfo.commandBufferCount = 1; VkCommandBuffer cmdBuffer; Util.CheckResult(vkAllocateCommandBuffers(_logicalDevice, ref cmdBufAllocateInfo, out cmdBuffer)); // If requested, also start recording for the new command buffer if (begin) { VkCommandBufferBeginInfo cmdBufInfo = VkCommandBufferBeginInfo.New(); Util.CheckResult(vkBeginCommandBuffer(cmdBuffer, ref cmdBufInfo)); } return(cmdBuffer); }
protected VkCommandBuffer createCommandBuffer(VkCommandBufferLevel level, bool begin) { VkCommandBuffer cmdBuffer; VkCommandBufferAllocateInfo cmdBufAllocateInfo = new VkCommandBufferAllocateInfo(); cmdBufAllocateInfo.sType = CommandBufferAllocateInfo; cmdBufAllocateInfo.commandPool = cmdPool; cmdBufAllocateInfo.level = level; cmdBufAllocateInfo.commandBufferCount = 1; vkAllocateCommandBuffers(device, &cmdBufAllocateInfo, &cmdBuffer); // If requested, also start the new command buffer if (begin) { VkCommandBufferBeginInfo cmdBufInfo = new VkCommandBufferBeginInfo(); cmdBufInfo.sType = CommandBufferBeginInfo; vkBeginCommandBuffer(cmdBuffer, &cmdBufInfo); } return(cmdBuffer); }
public VkCommandBuffer createCommandBuffer(VkCommandBufferLevel level, bool begin = false) { VkCommandBufferAllocateInfo cmdBufAllocateInfo = new VkCommandBufferAllocateInfo(); cmdBufAllocateInfo.sType = CommandBufferAllocateInfo; cmdBufAllocateInfo.commandPool = CommandPool; cmdBufAllocateInfo.level = level; cmdBufAllocateInfo.commandBufferCount = 1; VkCommandBuffer cmdBuffer; vkAllocateCommandBuffers(_logicalDevice, &cmdBufAllocateInfo, &cmdBuffer); // If requested, also start recording for the new command buffer if (begin) { VkCommandBufferBeginInfo cmdBufInfo = new VkCommandBufferBeginInfo(); cmdBufInfo.sType = CommandBufferBeginInfo; vkBeginCommandBuffer(cmdBuffer, &cmdBufInfo); } return(cmdBuffer); }
public CommandBuffer BuildCommandBuffer(VkCommandBufferLevel level) { return(new CommandBuffer(this, level)); }
public VkCommandBuffer AllocateCommandBuffer(VkCommandBufferLevel level) { return(AllocateCommandBuffers(level, 1)[0]); }