Skip to content

Commit

Permalink
Clang tidy cleanup pass
Browse files Browse the repository at this point in the history
  • Loading branch information
Derek Gerstmann committed Nov 26, 2024
1 parent b354b55 commit ca967cc
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 28 deletions.
20 changes: 10 additions & 10 deletions src/runtime/vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ WEAK int halide_vulkan_copy_to_device(void *user_context, halide_buffer_t *halid
nullptr // the semaphores to signal
};

result = vkQueueSubmit(ctx.queue, 1, &submit_info, 0);
result = vkQueueSubmit(ctx.queue, 1, &submit_info, VK_NULL_HANDLE);
if (result != VK_SUCCESS) {
error(user_context) << "Vulkan: vkQueueSubmit returned " << vk_get_error_name(result) << "\n";
return halide_error_code_device_buffer_copy_failed;
Expand Down Expand Up @@ -632,15 +632,15 @@ WEAK int halide_vulkan_copy_to_host(void *user_context, halide_buffer_t *halide_
<< " into halide buffer=" << halide_buffer << "\n";
#endif

VkCommandPool command_pool;
VkCommandPool command_pool = VK_NULL_HANDLE;
int error_code = vk_create_command_pool(user_context, ctx.allocator, ctx.queue_family_index, &command_pool);
if (error_code != halide_error_code_success) {
error(user_context) << "Vulkan: Failed to create command pool!\n";
return error_code;
}

// create a command buffer
VkCommandBuffer command_buffer;
VkCommandBuffer command_buffer = VK_NULL_HANDLE;
error_code = vk_create_command_buffer(user_context, ctx.allocator, command_pool, &command_buffer);
if (error_code != halide_error_code_success) {
error(user_context) << "Vulkan: Failed to create command buffer!\n";
Expand Down Expand Up @@ -703,7 +703,7 @@ WEAK int halide_vulkan_copy_to_host(void *user_context, halide_buffer_t *halide_
nullptr // the semaphores to signal
};

result = vkQueueSubmit(ctx.queue, 1, &submit_info, 0);
result = vkQueueSubmit(ctx.queue, 1, &submit_info, VK_NULL_HANDLE);
if (result != VK_SUCCESS) {
error(user_context) << "Vulkan: vkQueueSubmit returned " << vk_get_error_name(result) << "\n";
return halide_error_code_copy_to_device_failed;
Expand Down Expand Up @@ -1005,7 +1005,7 @@ WEAK int halide_vulkan_buffer_copy(void *user_context, struct halide_buffer_t *s
nullptr // the semaphores to signal
};

result = vkQueueSubmit(ctx.queue, 1, &submit_info, 0);
result = vkQueueSubmit(ctx.queue, 1, &submit_info, VK_NULL_HANDLE);
if (result != VK_SUCCESS) {
error(user_context) << "vkQueueSubmit returned " << vk_get_error_name(result) << "\n";
return result;
Expand Down Expand Up @@ -1224,11 +1224,11 @@ WEAK int halide_vulkan_run(void *user_context,
}

int error_code = halide_error_code_success;
if (shader_module->pipeline_layout == 0) {
if (shader_module->pipeline_layout == VK_NULL_HANDLE) {

// 2a. Create all descriptor set layouts
for (uint32_t n = 0; n < shader_module->shader_count; ++n) {
if (((void *)shader_module->descriptor_set_layouts[n]) == nullptr) {
if (((void *)shader_module->descriptor_set_layouts[n]) == VK_NULL_HANDLE) {
uint32_t uniform_buffer_count = shader_module->shader_bindings[n].uniform_buffer_count;
uint32_t storage_buffer_count = shader_module->shader_bindings[n].storage_buffer_count;
debug(user_context) << " creating descriptor set layout [" << n << "] " << shader_module->shader_bindings[n].entry_point_name << "\n";
Expand Down Expand Up @@ -1267,7 +1267,7 @@ WEAK int halide_vulkan_run(void *user_context,
}

// 2d. Create a descriptor set
if (entry_point_binding->descriptor_set == 0) {
if (entry_point_binding->descriptor_set == VK_NULL_HANDLE) {

// Construct a descriptor pool
//
Expand Down Expand Up @@ -1326,15 +1326,15 @@ WEAK int halide_vulkan_run(void *user_context,
}

// 4a. Create a command pool
VkCommandPool command_pool;
VkCommandPool command_pool= VK_NULL_HANDLE;
error_code = vk_create_command_pool(user_context, ctx.allocator, ctx.queue_family_index, &command_pool);
if (error_code != halide_error_code_success) {
error(user_context) << "Vulkan: Failed to create command pool!\n";
return error_code;
}

// 4b. Create a command buffer from the command pool
VkCommandBuffer command_buffer;
VkCommandBuffer command_buffer = VK_NULL_HANDLE;
error_code = vk_create_command_buffer(user_context, ctx.allocator, command_pool, &command_buffer);
if (error_code != halide_error_code_success) {
error(user_context) << "Vulkan: Failed to create command buffer!\n";
Expand Down
6 changes: 3 additions & 3 deletions src/runtime/vulkan_memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ int VulkanMemoryAllocator::lookup_requirements(void *user_context, size_t size,
0, nullptr};

// Create a buffer to determine alignment requirements
VkBuffer buffer = {0};
VkBuffer buffer = VK_NULL_HANDLE;
VkResult result = vkCreateBuffer(this->device, &create_info, this->alloc_callbacks, &buffer);
if (result != VK_SUCCESS) {
#if defined(HL_VK_DEBUG_MEM)
Expand Down Expand Up @@ -748,7 +748,7 @@ int VulkanMemoryAllocator::allocate_block(void *instance_ptr, MemoryBlock *block

if (selected_type == invalid_memory_type) {
vk_host_free(nullptr, device_memory, instance->alloc_callbacks);
device_memory = nullptr;
device_memory = VK_NULL_HANDLE;
error(user_context) << "VulkanMemoryAllocator: Allocation failed for block (\n"
<< "\tblock=" << (void *)(block) << "\n"
<< "\tsize=" << (uint64_t)block->size << "\n"
Expand Down Expand Up @@ -1470,7 +1470,7 @@ int vk_clear_device_buffer(void *user_context,
nullptr // the semaphores to signal
};

result = vkQueueSubmit(command_queue, 1, &submit_info, 0);
result = vkQueueSubmit(command_queue, 1, &submit_info, VK_NULL_HANDLE);
if (result != VK_SUCCESS) {
error(user_context) << "Vulkan: vkQueueSubmit returned " << vk_get_error_name(result) << "\n";
return halide_error_code_generic_error;
Expand Down
30 changes: 15 additions & 15 deletions src/runtime/vulkan_resources.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ struct VulkanSharedMemoryAllocation {
struct VulkanShaderBinding {
const char *entry_point_name = nullptr;
VulkanDispatchData dispatch_data = {};
VkDescriptorPool descriptor_pool = {0};
VkDescriptorSet descriptor_set = {0};
VkPipeline compute_pipeline = {0};
VkDescriptorPool descriptor_pool = VK_NULL_HANDLE;
VkDescriptorSet descriptor_set = VK_NULL_HANDLE;
VkPipeline compute_pipeline = VK_NULL_HANDLE;
uint32_t uniform_buffer_count = 0;
uint32_t storage_buffer_count = 0;
uint32_t specialization_constants_count = 0;
Expand All @@ -58,9 +58,9 @@ struct VulkanShaderBinding {

// Compiled shader module and associated bindings
struct VulkanCompiledShaderModule {
VkShaderModule shader_module = {0};
VkShaderModule shader_module = VK_NULL_HANDLE;
VkDescriptorSetLayout *descriptor_set_layouts = nullptr;
VkPipelineLayout pipeline_layout = {0};
VkPipelineLayout pipeline_layout = VK_NULL_HANDLE;
uint32_t shader_count = 0;
VulkanShaderBinding *shader_bindings = nullptr;
};
Expand Down Expand Up @@ -241,7 +241,7 @@ int vk_submit_command_buffer(void *user_context, VkQueue queue, VkCommandBuffer
nullptr // the semaphores to signal
};

VkResult result = vkQueueSubmit(queue, 1, &submit_info, 0);
VkResult result = vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE);
if (result != VK_SUCCESS) {
error(user_context) << "Vulkan: vkQueueSubmit returned " << vk_get_error_name(result) << "\n";
return halide_error_code_generic_error;
Expand Down Expand Up @@ -843,11 +843,11 @@ int vk_create_compute_pipeline(void *user_context,
specialization_info, // pointer to VkSpecializationInfo struct
},
pipeline_layout, // pipeline layout
0, // base pipeline handle for derived pipeline
VK_NULL_HANDLE, // base pipeline handle for derived pipeline
0 // base pipeline index for derived pipeline
};

VkResult result = vkCreateComputePipelines(allocator->current_device(), 0, 1, &compute_pipeline_info, allocator->callbacks(), compute_pipeline);
VkResult result = vkCreateComputePipelines(allocator->current_device(), VK_NULL_HANDLE, 1, &compute_pipeline_info, allocator->callbacks(), compute_pipeline);
if (result != VK_SUCCESS) {
error(user_context) << "Vulkan: Failed to create compute pipeline! vkCreateComputePipelines returned " << vk_get_error_name(result) << "\n";
return halide_error_code_generic_error;
Expand Down Expand Up @@ -1024,7 +1024,7 @@ int vk_setup_compute_pipeline(void *user_context,
error(user_context) << "Vulkan: Failed to destroy compute pipeline!\n";
return halide_error_code_generic_error;
}
shader_bindings->compute_pipeline = {0};
shader_bindings->compute_pipeline = VK_NULL_HANDLE;
}

int error_code = vk_create_compute_pipeline(user_context, allocator, entry_point_name, shader_module, pipeline_layout, &specialization_info, &(shader_bindings->compute_pipeline));
Expand All @@ -1036,7 +1036,7 @@ int vk_setup_compute_pipeline(void *user_context,
} else {

// Construct and re-use the fixed pipeline
if (shader_bindings->compute_pipeline == 0) {
if (shader_bindings->compute_pipeline == VK_NULL_HANDLE) {
int error_code = vk_create_compute_pipeline(user_context, allocator, entry_point_name, shader_module, pipeline_layout, nullptr, &(shader_bindings->compute_pipeline));
if (error_code != halide_error_code_success) {
error(user_context) << "Vulkan: Failed to create compute pipeline!\n";
Expand Down Expand Up @@ -1584,15 +1584,15 @@ void vk_destroy_compiled_shader_module(VulkanCompiledShaderModule *shader_module
for (uint32_t n = 0; n < shader_module->shader_count; n++) {
debug(user_context) << " destroying descriptor set layout [" << n << "] " << shader_module->shader_bindings[n].entry_point_name << "\n";
vk_destroy_descriptor_set_layout(user_context, allocator, shader_module->descriptor_set_layouts[n]);
shader_module->descriptor_set_layouts[n] = {0};
shader_module->descriptor_set_layouts[n] = VK_NULL_HANDLE;
}
vk_host_free(user_context, shader_module->descriptor_set_layouts, allocator->callbacks());
shader_module->descriptor_set_layouts = nullptr;
}
if (shader_module->pipeline_layout) {
debug(user_context) << " destroying pipeline layout " << (void *)shader_module->pipeline_layout << "\n";
vk_destroy_pipeline_layout(user_context, allocator, shader_module->pipeline_layout);
shader_module->pipeline_layout = {0};
shader_module->pipeline_layout = VK_NULL_HANDLE;
}

if (shader_module->shader_bindings) {
Expand All @@ -1603,7 +1603,7 @@ void vk_destroy_compiled_shader_module(VulkanCompiledShaderModule *shader_module
}
if (shader_module->shader_bindings[n].descriptor_pool) {
vk_destroy_descriptor_pool(user_context, allocator, shader_module->shader_bindings[n].descriptor_pool);
shader_module->shader_bindings[n].descriptor_pool = {0};
shader_module->shader_bindings[n].descriptor_pool = VK_NULL_HANDLE;
}
if (shader_module->shader_bindings[n].specialization_constants) {
vk_host_free(user_context, shader_module->shader_bindings[n].specialization_constants, allocator->callbacks());
Expand All @@ -1615,7 +1615,7 @@ void vk_destroy_compiled_shader_module(VulkanCompiledShaderModule *shader_module
}
if (shader_module->shader_bindings[n].compute_pipeline) {
vk_destroy_compute_pipeline(user_context, allocator, shader_module->shader_bindings[n].compute_pipeline);
shader_module->shader_bindings[n].compute_pipeline = {0};
shader_module->shader_bindings[n].compute_pipeline = VK_NULL_HANDLE;
}
}
vk_host_free(user_context, shader_module->shader_bindings, allocator->callbacks());
Expand All @@ -1624,7 +1624,7 @@ void vk_destroy_compiled_shader_module(VulkanCompiledShaderModule *shader_module
if (shader_module->shader_module) {
debug(user_context) << " . destroying shader module " << (void *)shader_module->shader_module << "\n";
vkDestroyShaderModule(allocator->current_device(), shader_module->shader_module, allocator->callbacks());
shader_module->shader_module = {0};
shader_module->shader_module = VK_NULL_HANDLE;
}
shader_module->shader_count = 0;
vk_host_free(user_context, shader_module, allocator->callbacks());
Expand Down

0 comments on commit ca967cc

Please sign in to comment.