Skip to content

Commit 97546f1

Browse files
committed
port createCommandPool function
1 parent 1c2424d commit 97546f1

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/main.zig

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ var renderPass: c.VkRenderPass = undefined;
3131
var pipelineLayout: c.VkPipelineLayout = undefined;
3232
var graphicsPipeline: c.VkPipeline = undefined;
3333
var swapChainFramebuffers: []c.VkFramebuffer = undefined;
34+
var commandPool: c.VkCommandPool = undefined;
3435

3536
const QueueFamilyIndices = struct {
3637
graphicsFamily: ?u32,
@@ -103,12 +104,26 @@ fn initVulkan(allocator: *Allocator, window: *c.GLFWwindow) !void {
103104
try createRenderPass();
104105
try createGraphicsPipeline(allocator);
105106
try createFramebuffers(allocator);
107+
try createCommandPool(allocator);
106108
// TODO
107-
//createCommandPool();
108109
//createCommandBuffers();
109110
//createSyncObjects();
110111
}
111112

113+
fn createCommandPool(allocator: *Allocator) !void {
114+
const queueFamilyIndices = try findQueueFamilies(allocator, physicalDevice);
115+
116+
const poolInfo = c.VkCommandPoolCreateInfo{
117+
.sType = c.VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
118+
.queueFamilyIndex = queueFamilyIndices.graphicsFamily.?,
119+
120+
.pNext = null,
121+
.flags = 0,
122+
};
123+
124+
try checkSuccess(c.vkCreateCommandPool(global_device, &poolInfo, null, &commandPool));
125+
}
126+
112127
fn createFramebuffers(allocator: *Allocator) !void {
113128
swapChainFramebuffers = try allocator.alloc(c.VkFramebuffer, swapChainImageViews.len);
114129

src/vulkan.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4036,7 +4036,7 @@ pub extern fn vkDestroyFramebuffer(device: VkDevice, framebuffer: VkFramebuffer,
40364036
pub extern fn vkCreateRenderPass(device: VkDevice, pCreateInfo: *const VkRenderPassCreateInfo, pAllocator: ?[*]const VkAllocationCallbacks, pRenderPass: *VkRenderPass) VkResult;
40374037
pub extern fn vkDestroyRenderPass(device: VkDevice, renderPass: VkRenderPass, pAllocator: ?[*]const VkAllocationCallbacks) void;
40384038
pub extern fn vkGetRenderAreaGranularity(device: VkDevice, renderPass: VkRenderPass, pGranularity: ?[*]VkExtent2D) void;
4039-
pub extern fn vkCreateCommandPool(device: VkDevice, pCreateInfo: ?[*]const VkCommandPoolCreateInfo, pAllocator: ?[*]const VkAllocationCallbacks, pCommandPool: ?[*]VkCommandPool) VkResult;
4039+
pub extern fn vkCreateCommandPool(device: VkDevice, pCreateInfo: *const VkCommandPoolCreateInfo, pAllocator: ?[*]const VkAllocationCallbacks, pCommandPool: *VkCommandPool) VkResult;
40404040
pub extern fn vkDestroyCommandPool(device: VkDevice, commandPool: VkCommandPool, pAllocator: ?[*]const VkAllocationCallbacks) void;
40414041
pub extern fn vkResetCommandPool(device: VkDevice, commandPool: VkCommandPool, flags: VkCommandPoolResetFlags) VkResult;
40424042
pub extern fn vkAllocateCommandBuffers(device: VkDevice, pAllocateInfo: ?[*]const VkCommandBufferAllocateInfo, pCommandBuffers: ?[*]VkCommandBuffer) VkResult;

0 commit comments

Comments
 (0)