Skip to content

Commit

Permalink
Clang tidy fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Derek Gerstmann committed Jan 8, 2025
1 parent 505ae8a commit f57ea54
Showing 1 changed file with 27 additions and 28 deletions.
55 changes: 27 additions & 28 deletions src/runtime/vulkan_resources.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,9 @@ int vk_fill_command_buffer_with_dispatch_call(void *user_context,
<< "blocks: " << blocksX << ", " << blocksY << ", " << blocksZ << ")\n";
#endif

// vkCmdBindPipeline(command_buffer, VK_PIPELINE_BIND_POINT_COMPUTE, compute_pipeline);
// vkCmdBindDescriptorSets(command_buffer, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline_layout,
// descriptor_set_index, 1, &descriptor_set, 0, nullptr);
// vkCmdBindPipeline(command_buffer, VK_PIPELINE_BIND_POINT_COMPUTE, compute_pipeline);
// vkCmdBindDescriptorSets(command_buffer, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline_layout,
// descriptor_set_index, 1, &descriptor_set, 0, nullptr);
vkCmdDispatch(command_buffer, blocksX, blocksY, blocksZ);
return halide_error_code_success;
}
Expand Down Expand Up @@ -443,8 +443,8 @@ int vk_create_descriptor_set_layout(void *user_context,
for (uint32_t n = 0; n < uniform_buffer_count; ++n) {
// Params will be passed as UNIFORM_BUFFERs
VkDescriptorSetLayoutBinding uniform_buffer_layout_binding{};
uniform_buffer_layout_binding.binding = (uint32_t)layout_bindings.size(), // binding index
uniform_buffer_layout_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
uniform_buffer_layout_binding.binding = (uint32_t)layout_bindings.size(), // binding index
uniform_buffer_layout_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
uniform_buffer_layout_binding.descriptorCount = 1;
uniform_buffer_layout_binding.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT;
#ifdef DEBUG_RUNTIME
Expand All @@ -458,8 +458,8 @@ int vk_create_descriptor_set_layout(void *user_context,
for (uint32_t n = 0; n < storage_buffer_count; ++n) {
// halide buffers will be passed as STORAGE_BUFFERs
VkDescriptorSetLayoutBinding storage_buffer_layout_binding{};
storage_buffer_layout_binding.binding = (uint32_t)layout_bindings.size(), // binding index
storage_buffer_layout_binding.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER;
storage_buffer_layout_binding.binding = (uint32_t)layout_bindings.size(), // binding index
storage_buffer_layout_binding.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER;
storage_buffer_layout_binding.descriptorCount = 1;
storage_buffer_layout_binding.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT;
#ifdef DEBUG_RUNTIME
Expand Down Expand Up @@ -544,15 +544,15 @@ int vk_create_descriptor_set(void *user_context,
}

int vk_get_descriptor_buffer_info(void *user_context,
VulkanMemoryAllocator *allocator,
VkDescriptorSet descriptor_set,
VkBuffer *scalar_args_buffer,
size_t uniform_buffer_count,
size_t storage_buffer_count,
size_t arg_sizes[],
void *args[],
int8_t arg_is_buffer[],
BlockStorage *descriptor_buffer_info_result) {
VulkanMemoryAllocator *allocator,
VkDescriptorSet descriptor_set,
VkBuffer *scalar_args_buffer,
size_t uniform_buffer_count,
size_t storage_buffer_count,
size_t arg_sizes[],
void *args[],
int8_t arg_is_buffer[],
BlockStorage *descriptor_buffer_info_result) {
#ifdef DEBUG_RUNTIME
debug(user_context)
<< " vk_get_descriptor_buffer_info (user_context: " << user_context << ", "
Expand Down Expand Up @@ -667,7 +667,7 @@ int vk_get_write_descriptor_set_info(void *user_context,

// First binding will be the scalar args buffer (if needed) passed as a UNIFORM BUFFER
size_t index = 0;
if (scalar_args_buffer != nullptr && descriptor_buffer_info->size()) {
if ((scalar_args_buffer != nullptr) && (!descriptor_buffer_info->empty())) {
VkWriteDescriptorSet uniform_buffer_write_entry{};
uniform_buffer_write_entry.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
uniform_buffer_write_entry.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
Expand Down Expand Up @@ -733,7 +733,8 @@ int vk_update_descriptor_set(void *user_context,
arg_sizes,
args,
arg_is_buffer,
&descriptor_buffer_info);
&descriptor_buffer_info
);

if (error_code) {
error(user_context) << "Vulkan: Failed to update descriptor set ... get descriptor buffer info failed!\n";
Expand All @@ -751,7 +752,8 @@ int vk_update_descriptor_set(void *user_context,
&descriptor_buffer_info,
descriptor_set,
scalar_args_buffer,
&write_descriptor_set);
&write_descriptor_set
);

if (error_code) {
error(user_context) << "Vulkan: Failed to update descriptor set ... write descriptor set creation failed!\n";
Expand All @@ -760,7 +762,7 @@ int vk_update_descriptor_set(void *user_context,

// issue the update call to populate the descriptor set
uint32_t update_size = (uint32_t)write_descriptor_set.size();
const VkWriteDescriptorSet *update_data = (const VkWriteDescriptorSet *)write_descriptor_set.data();
const VkWriteDescriptorSet * update_data = (const VkWriteDescriptorSet *)write_descriptor_set.data();
vkUpdateDescriptorSets(allocator->current_device(), update_size, update_data, 0, nullptr);
return halide_error_code_success;
}
Expand Down Expand Up @@ -809,11 +811,6 @@ int vk_push_descriptor_set(void *user_context,
return halide_error_code_generic_error;
}

if (allocator == nullptr) {
error(user_context) << "Vulkan: Failed to update descriptor set ... invalid allocator pointer!\n";
return halide_error_code_generic_error;
}

BlockStorage::Config dbi_config;
dbi_config.minimum_capacity = storage_buffer_count + uniform_buffer_count;
dbi_config.entry_size = sizeof(VkDescriptorBufferInfo);
Expand All @@ -829,7 +826,8 @@ int vk_push_descriptor_set(void *user_context,
arg_sizes,
args,
arg_is_buffer,
&descriptor_buffer_info);
&descriptor_buffer_info
);

if (error_code) {
error(user_context) << "Vulkan: Failed to update descriptor set ... get descriptor buffer info failed!\n";
Expand All @@ -847,7 +845,8 @@ int vk_push_descriptor_set(void *user_context,
&descriptor_buffer_info,
descriptor_set,
scalar_args_buffer,
&write_descriptor_set);
&write_descriptor_set
);

if (error_code) {
error(user_context) << "Vulkan: Failed to update descriptor set ... write descriptor set creation failed!\n";
Expand All @@ -856,7 +855,7 @@ int vk_push_descriptor_set(void *user_context,

// issue the update call to populate the descriptor set
uint32_t update_size = (uint32_t)write_descriptor_set.size();
const VkWriteDescriptorSet *update_data = (const VkWriteDescriptorSet *)write_descriptor_set.data();
const VkWriteDescriptorSet * update_data = (const VkWriteDescriptorSet *)write_descriptor_set.data();
vkCmdPushDescriptorSetKHR(command_buffer, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline_layout, 0, update_size, update_data);
return halide_error_code_success;
}
Expand Down

0 comments on commit f57ea54

Please sign in to comment.