Do not hardcode counts for structs

This commit is contained in:
Przemyslaw Gasinski 2024-07-16 22:23:48 +02:00
parent c391c53eea
commit 99cfb4cfb1

View file

@ -362,7 +362,7 @@ pub const VulkanRenderer = struct {
}; };
swapchain_create_info.image_sharing_mode = .concurrent; swapchain_create_info.image_sharing_mode = .concurrent;
swapchain_create_info.queue_family_index_count = 2; // Number of queues to share images between swapchain_create_info.queue_family_index_count = @intCast(qfi.len); // Number of queues to share images between
swapchain_create_info.p_queue_family_indices = &qfi; swapchain_create_info.p_queue_family_indices = &qfi;
} }
@ -558,14 +558,14 @@ pub const VulkanRenderer = struct {
const dynamic_states = [_]vk.DynamicState{ .viewport, .scissor }; const dynamic_states = [_]vk.DynamicState{ .viewport, .scissor };
const dynamic_state_create_info: vk.PipelineDynamicStateCreateInfo = .{ const dynamic_state_create_info: vk.PipelineDynamicStateCreateInfo = .{
.dynamic_state_count = 2, .dynamic_state_count = @intCast(dynamic_states.len),
.p_dynamic_states = &dynamic_states, .p_dynamic_states = &dynamic_states,
}; };
// -- Rasterizer -- // -- Rasterizer --
const rasterizer_create_info: vk.PipelineRasterizationStateCreateInfo = .{ const rasterizer_create_info: vk.PipelineRasterizationStateCreateInfo = .{
.depth_clamp_enable = vk.FALSE, // Change if fragments beyond near/far planes are clipped (default) or clamped to planed .depth_clamp_enable = vk.FALSE, // Change if fragments beyond near/far planes are clipped (default) or clamped to plane
.rasterizer_discard_enable = vk.FALSE, // Whether to discard data and skip rasterizer (never creates fragments) .rasterizer_discard_enable = vk.FALSE, // Whether to discard data and skip rasterizer (never creates fragments)
.polygon_mode = .fill, // How to handle filling points between vertices .polygon_mode = .fill, // How to handle filling points between vertices
.line_width = 1.0, // How thick the lines should be when drawn .line_width = 1.0, // How thick the lines should be when drawn
@ -601,7 +601,6 @@ pub const VulkanRenderer = struct {
.alpha_blend_op = vk.BlendOp.add, .alpha_blend_op = vk.BlendOp.add,
// Summary (1 * new alpha) + (0 * old alpha) = new alpha // Summary (1 * new alpha) + (0 * old alpha) = new alpha
}; };
// Blending uses equation: (srcColorBlendFactor * new colour) colorBlendOp (dstColorBlendFactor * old colour) // Blending uses equation: (srcColorBlendFactor * new colour) colorBlendOp (dstColorBlendFactor * old colour)
const colour_blending_create_info: vk.PipelineColorBlendStateCreateInfo = .{ const colour_blending_create_info: vk.PipelineColorBlendStateCreateInfo = .{
@ -622,7 +621,7 @@ pub const VulkanRenderer = struct {
// -- Graphics pipeline creation -- // -- Graphics pipeline creation --
const pipeline_create_info: vk.GraphicsPipelineCreateInfo = .{ const pipeline_create_info: vk.GraphicsPipelineCreateInfo = .{
.stage_count = 2, // Number of shader stages .stage_count = @intCast(shader_create_infos.len), // Number of shader stages
.p_stages = &shader_create_infos, // List of shader stages .p_stages = &shader_create_infos, // List of shader stages
.p_vertex_input_state = &vertex_input_create_info, .p_vertex_input_state = &vertex_input_create_info,
.p_input_assembly_state = &assembly_create_info, .p_input_assembly_state = &assembly_create_info,
@ -732,7 +731,7 @@ pub const VulkanRenderer = struct {
.extent = self.extent, // Size of region to run render pass on (starting at offset) .extent = self.extent, // Size of region to run render pass on (starting at offset)
}, },
.p_clear_values = &clear_values, // List of clear values (TODO: Depth attachment clear value) .p_clear_values = &clear_values, // List of clear values (TODO: Depth attachment clear value)
.clear_value_count = 1, .clear_value_count = @intCast(clear_values.len),
.framebuffer = undefined, .framebuffer = undefined,
}; };