@@ -184,25 +184,30 @@ inline vk::Format choose_blendable_format(vk::PhysicalDevice gpu, const std::vec
184184}
185185
186186// helper functions not backed by vk_common.h
187- inline vk::CommandBuffer allocate_command_buffer (vk::Device device, vk::CommandPool command_pool, vk::CommandBufferLevel level = vk::CommandBufferLevel::ePrimary)
187+ inline vk::CommandBuffer
188+ allocate_command_buffer (vk::Device device, vk::CommandPool command_pool, vk::CommandBufferLevel level = vk::CommandBufferLevel::ePrimary)
188189{
189- vk::CommandBufferAllocateInfo command_buffer_allocate_info ( command_pool, level, 1 ) ;
190+ vk::CommandBufferAllocateInfo command_buffer_allocate_info{. commandPool = command_pool, . level = level, . commandBufferCount = 1 } ;
190191 return device.allocateCommandBuffers (command_buffer_allocate_info).front ();
191192}
192193
193194inline vk::DescriptorSet allocate_descriptor_set (vk::Device device, vk::DescriptorPool descriptor_pool, vk::DescriptorSetLayout descriptor_set_layout)
194195{
195- #if defined(ANDROID)
196- vk::DescriptorSetAllocateInfo descriptor_set_allocate_info (descriptor_pool, 1 , &descriptor_set_layout);
197- #else
198- vk::DescriptorSetAllocateInfo descriptor_set_allocate_info (descriptor_pool, descriptor_set_layout);
199- #endif
196+ vk::DescriptorSetAllocateInfo descriptor_set_allocate_info{.descriptorPool = descriptor_pool,
197+ .descriptorSetCount = 1 ,
198+ .pSetLayouts = &descriptor_set_layout};
200199 return device.allocateDescriptorSets (descriptor_set_allocate_info).front ();
201200}
202201
203- inline vk::Framebuffer create_framebuffer (vk::Device device, vk::RenderPass render_pass, std::vector<vk::ImageView> const &attachments, vk::Extent2D const &extent)
202+ inline vk::Framebuffer
203+ create_framebuffer (vk::Device device, vk::RenderPass render_pass, std::vector<vk::ImageView> const &attachments, vk::Extent2D const &extent)
204204{
205- vk::FramebufferCreateInfo framebuffer_create_info ({}, render_pass, attachments, extent.width , extent.height , 1 );
205+ vk::FramebufferCreateInfo framebuffer_create_info{.renderPass = render_pass,
206+ .attachmentCount = static_cast <uint32_t >(attachments.size ()),
207+ .pAttachments = attachments.data (),
208+ .width = extent.width ,
209+ .height = extent.height ,
210+ .layers = 1 };
206211 return device.createFramebuffer (framebuffer_create_info);
207212}
208213
@@ -220,42 +225,39 @@ inline vk::Pipeline create_graphics_pipeline(vk::Device
220225 vk::PipelineLayout pipeline_layout,
221226 vk::RenderPass render_pass)
222227{
223- vk::PipelineInputAssemblyStateCreateInfo input_assembly_state ({}, primitive_topology, false ) ;
228+ vk::PipelineInputAssemblyStateCreateInfo input_assembly_state{. topology = primitive_topology} ;
224229
225- vk::PipelineTessellationStateCreateInfo tessellation_state ({}, patch_control_points) ;
230+ vk::PipelineTessellationStateCreateInfo tessellation_state{. patchControlPoints = patch_control_points} ;
226231
227- vk::PipelineViewportStateCreateInfo viewport_state ({}, 1 , nullptr , 1 , nullptr ) ;
232+ vk::PipelineViewportStateCreateInfo viewport_state{. viewportCount = 1 , . scissorCount = 1 } ;
228233
229- vk::PipelineRasterizationStateCreateInfo rasterization_state;
230- rasterization_state.polygonMode = polygon_mode;
231- rasterization_state.cullMode = cull_mode;
232- rasterization_state.frontFace = front_face;
233- rasterization_state.lineWidth = 1 .0f ;
234+ vk::PipelineRasterizationStateCreateInfo rasterization_state{
235+ .polygonMode = polygon_mode, .cullMode = cull_mode, .frontFace = front_face, .lineWidth = 1 .0f };
234236
235- vk::PipelineMultisampleStateCreateInfo multisample_state ({}, vk::SampleCountFlagBits::e1 ) ;
237+ vk::PipelineMultisampleStateCreateInfo multisample_state{. rasterizationSamples = vk::SampleCountFlagBits::e1 } ;
236238
237- vk::PipelineColorBlendStateCreateInfo color_blend_state ({}, false , {}, blend_attachment_states);
239+ vk::PipelineColorBlendStateCreateInfo color_blend_state{.attachmentCount = static_cast <uint32_t >(blend_attachment_states.size ()),
240+ .pAttachments = blend_attachment_states.data ()};
238241
239242 std::array<vk::DynamicState, 2 > dynamic_state_enables = {vk::DynamicState::eViewport, vk::DynamicState::eScissor};
240- vk::PipelineDynamicStateCreateInfo dynamic_state ({}, dynamic_state_enables);
243+ vk::PipelineDynamicStateCreateInfo dynamic_state{.dynamicStateCount = static_cast <uint32_t >(dynamic_state_enables.size ()),
244+ .pDynamicStates = dynamic_state_enables.data ()};
241245
242246 // Final fullscreen composition pass pipeline
243- vk::GraphicsPipelineCreateInfo pipeline_create_info ({},
244- shader_stages,
245- &vertex_input_state,
246- &input_assembly_state,
247- &tessellation_state,
248- &viewport_state,
249- &rasterization_state,
250- &multisample_state,
251- &depth_stencil_state,
252- &color_blend_state,
253- &dynamic_state,
254- pipeline_layout,
255- render_pass,
256- {},
257- {},
258- -1 );
247+ vk::GraphicsPipelineCreateInfo pipeline_create_info{.stageCount = static_cast <uint32_t >(shader_stages.size ()),
248+ .pStages = shader_stages.data (),
249+ .pVertexInputState = &vertex_input_state,
250+ .pInputAssemblyState = &input_assembly_state,
251+ .pTessellationState = &tessellation_state,
252+ .pViewportState = &viewport_state,
253+ .pRasterizationState = &rasterization_state,
254+ .pMultisampleState = &multisample_state,
255+ .pDepthStencilState = &depth_stencil_state,
256+ .pColorBlendState = &color_blend_state,
257+ .pDynamicState = &dynamic_state,
258+ .layout = pipeline_layout,
259+ .renderPass = render_pass,
260+ .basePipelineIndex = -1 };
259261
260262 vk::Result result;
261263 vk::Pipeline pipeline;
@@ -274,24 +276,20 @@ inline vk::ImageView create_image_view(vk::Device device,
274276 uint32_t base_array_layer = 0 ,
275277 uint32_t layer_count = 1 )
276278{
277- vk::ImageViewCreateInfo image_view_create_info;
278- image_view_create_info.image = image;
279- image_view_create_info.viewType = view_type;
280- image_view_create_info.format = format;
281- image_view_create_info.subresourceRange .aspectMask = aspect_mask;
282- image_view_create_info.subresourceRange .baseMipLevel = base_mip_level;
283- image_view_create_info.subresourceRange .levelCount = level_count;
284- image_view_create_info.subresourceRange .baseArrayLayer = base_array_layer;
285- image_view_create_info.subresourceRange .layerCount = layer_count;
279+ vk::ImageViewCreateInfo image_view_create_info{.image = image,
280+ .viewType = view_type,
281+ .format = format,
282+ .subresourceRange = {.aspectMask = aspect_mask,
283+ .baseMipLevel = base_mip_level,
284+ .levelCount = level_count,
285+ .baseArrayLayer = base_array_layer,
286+ .layerCount = layer_count}};
286287 return device.createImageView (image_view_create_info);
287288}
288289
289290inline vk::QueryPool create_query_pool (vk::Device device, vk::QueryType query_type, uint32_t query_count, vk::QueryPipelineStatisticFlags pipeline_statistics = {})
290291{
291- vk::QueryPoolCreateInfo query_pool_create_info;
292- query_pool_create_info.queryType = query_type;
293- query_pool_create_info.queryCount = query_count;
294- query_pool_create_info.pipelineStatistics = pipeline_statistics;
292+ vk::QueryPoolCreateInfo query_pool_create_info{.queryType = query_type, .queryCount = query_count, .pipelineStatistics = pipeline_statistics};
295293 return device.createQueryPool (query_pool_create_info);
296294}
297295
@@ -303,21 +301,18 @@ inline vk::Sampler create_sampler(vk::Device device,
303301 float max_anisotropy,
304302 float max_LOD)
305303{
306- vk::SamplerCreateInfo sampler_create_info ({},
307- mag_filter,
308- min_filter,
309- mipmap_mode,
310- sampler_address_mode,
311- sampler_address_mode,
312- sampler_address_mode,
313- 0 .0f ,
314- (1 .0f < max_anisotropy),
315- max_anisotropy,
316- false ,
317- vk::CompareOp::eNever,
318- 0 .0f ,
319- max_LOD,
320- vk::BorderColor::eFloatOpaqueWhite);
304+ vk::SamplerCreateInfo sampler_create_info{.magFilter = mag_filter,
305+ .minFilter = min_filter,
306+ .mipmapMode = mipmap_mode,
307+ .addressModeU = sampler_address_mode,
308+ .addressModeV = sampler_address_mode,
309+ .addressModeW = sampler_address_mode,
310+ .anisotropyEnable = (1 .0f < max_anisotropy),
311+ .maxAnisotropy = max_anisotropy,
312+ .compareOp = vk::CompareOp::eNever,
313+ .minLod = 0 .0f ,
314+ .maxLod = max_LOD,
315+ .borderColor = vk::BorderColor::eFloatOpaqueWhite};
321316 return device.createSampler (sampler_create_info);
322317}
323318
@@ -371,7 +366,10 @@ inline vk::ImageAspectFlags get_image_aspect_flags(vk::ImageUsageFlagBits usage,
371366inline void submit_and_wait (vk::Device device, vk::Queue queue, std::vector<vk::CommandBuffer> command_buffers, std::vector<vk::Semaphore> semaphores = {})
372367{
373368 // Submit command_buffer
374- vk::SubmitInfo submit_info (nullptr , {}, command_buffers, semaphores);
369+ vk::SubmitInfo submit_info{.commandBufferCount = static_cast <uint32_t >(command_buffers.size ()),
370+ .pCommandBuffers = command_buffers.data (),
371+ .signalSemaphoreCount = static_cast <uint32_t >(semaphores.size ()),
372+ .pSignalSemaphores = semaphores.data ()};
375373
376374 // Create fence to ensure that command_buffer has finished executing
377375 vk::Fence fence = device.createFence ({});
0 commit comments