ogl_beamforming

Ultrasound Beamforming Implemented with OpenGL
git clone anongit@rnpnr.xyz:ogl_beamforming.git
Log | Files | Refs | Feed | Submodules | README | LICENSE

Commit: e76ab3de660a7e5b78b62ef106e2f863a20aaa88
Parent: f1cf968138c9e14e4053a73639708c76a59b3349
Author: Randy Palamar
Date:   Wed, 19 Aug 2026 20:40:30 -0700

vulkan: gpu_buffer_allocate: don't assert on size 0

This function behaves like realloc but need not repeat the
terrible API design from there. A size of 0 means free and don't
realloc.

Diffstat:
Mvulkan.c | 48+++++++++++++++++++++++++-----------------------
1 file changed, 25 insertions(+), 23 deletions(-)

diff --git a/vulkan.c b/vulkan.c @@ -1986,33 +1986,35 @@ gpu_buffer_allocate(GPUBuffer *b, GPUBufferAllocateInfo *info) gpu_buffer_release(b); - assert(info->size > 0); - - VulkanEntity *e = vk_entity_allocate(VulkanEntityKind_Buffer); - VulkanBufferAllocateInfo vulkan_buffer_allocate_info = { - .gpu_buffer = b, - .size = (u64)info->size, - .flags = info->flags, - .index_type = VK_INDEX_TYPE_NONE_KHR, - .label = info->label, - .export = info->export, - }; + assert(info->size >= 0); + + if (info->size > 0) { + VulkanEntity *e = vk_entity_allocate(VulkanEntityKind_Buffer); + VulkanBufferAllocateInfo vulkan_buffer_allocate_info = { + .gpu_buffer = b, + .size = (u64)info->size, + .flags = info->flags, + .index_type = VK_INDEX_TYPE_NONE_KHR, + .label = info->label, + .export = info->export, + }; - u32 queue_index_hit_count[VulkanQueueKind_Count] = {0}; - for (u32 it = 0; it < info->timeline_count; it++) - queue_index_hit_count[vk->queue_indices[info->timelines_used[it]]]++; + u32 queue_index_hit_count[VulkanQueueKind_Count] = {0}; + for (u32 it = 0; it < info->timeline_count; it++) + queue_index_hit_count[vk->queue_indices[info->timelines_used[it]]]++; - for EachElement(queue_index_hit_count, it) { - if (queue_index_hit_count[it] > 0) { - u32 index = vulkan_buffer_allocate_info.queue_family_count++; - vulkan_buffer_allocate_info.queue_family_indices[index] = vk->queues[vk->queue_indices[it]]->queue_family; + for EachElement(queue_index_hit_count, it) { + if (queue_index_hit_count[it] > 0) { + u32 index = vulkan_buffer_allocate_info.queue_family_count++; + vulkan_buffer_allocate_info.queue_family_indices[index] = vk->queues[vk->queue_indices[it]]->queue_family; + } } - } - if (vk_buffer_allocate_common(&e->as.buffer, &vulkan_buffer_allocate_info)) { - b->handle.value = (u64)e; - } else { - vk_entity_release(e); + if (vk_buffer_allocate_common(&e->as.buffer, &vulkan_buffer_allocate_info)) { + b->handle.value = (u64)e; + } else { + vk_entity_release(e); + } } }