ogl_beamforming

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

Commit: 218fb7e140c058278ee9396b17569571ceb18e9e
Parent: 8a20ea056af8f588c5f76e9df2ece648694953c0
Author: Randy Palamar
Date:   Sat, 17 Jan 2026 22:20:09 -0700

vulkan: set up glslc constraints

Diffstat:
Mexternal/glslang_local/glslang.cpp | 2--
Mvulkan.c | 90++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
2 files changed, 87 insertions(+), 5 deletions(-)

diff --git a/external/glslang_local/glslang.cpp b/external/glslang_local/glslang.cpp @@ -46,8 +46,6 @@ #include "glslang/MachineIndependent/preprocessor/PpTokens.cpp" #include "glslang/MachineIndependent/propagateNoContraction.cpp" #include "glslang/MachineIndependent/reflection.cpp" -#include "glslang/ResourceLimits/ResourceLimits.cpp" -#include "glslang/ResourceLimits/resource_limits_c.cpp" #if OS_WINDOWS // NOTE(rnp): includes windows.h: i.e. it needs its own TU diff --git a/vulkan.c b/vulkan.c @@ -1,7 +1,6 @@ #include "beamformer_internal.h" #include "vulkan.h" #include "external/glslang/glslang/Include/glslang_c_interface.h" -#include "external/glslang/glslang/Public/resource_limits_c.h" #define glslang_info(s) s8("[glslang] " s) #define vulkan_info(s) s8("[vulkan] " s) @@ -120,6 +119,92 @@ VK_REQUIRED_DEVICE_EXTENSIONS_LIST global VulkanContext vulkan_context[1]; +/* NOTE(rnp): the idea here is to set reasonable development constraints. + * They should probably not match one to one with the maximums of the dev + * machine's hardware. Instead these are here to cause compile time failure + * for features which are not expected to work everywhere. */ +global glslang_resource_t glslc_resource_constraints[1] = {{ + .max_compute_work_group_count_x = 65535, + .max_compute_work_group_count_y = 65535, + .max_compute_work_group_count_z = 65535, + .max_compute_work_group_size_x = 1024, + .max_compute_work_group_size_y = 1024, + .max_compute_work_group_size_z = 1024, + + // NOTE: taken from glslang defaults + .max_lights = 32, + .max_clip_planes = 6, + .max_texture_units = 32, + .max_texture_coords = 32, + .max_vertex_attribs = 64, + .max_vertex_uniform_components = 4096, + .max_varying_floats = 64, + .max_vertex_texture_image_units = 32, + .max_combined_texture_image_units = 80, + .max_texture_image_units = 32, + .max_fragment_uniform_components = 4096, + .max_draw_buffers = 32, + .max_vertex_uniform_vectors = 128, + .max_varying_vectors = 8, + .max_fragment_uniform_vectors = 16, + .max_vertex_output_vectors = 16, + .max_fragment_input_vectors = 15, + .min_program_texel_offset = -8, + .max_program_texel_offset = 7, + .max_clip_distances = 8, + .max_compute_uniform_components = 1024, + .max_compute_texture_image_units = 16, + .max_compute_image_uniforms = 8, + .max_compute_atomic_counters = 8, + .max_compute_atomic_counter_buffers = 1, + .max_varying_components = 60, + .max_vertex_output_components = 64, + .max_fragment_input_components = 128, + .max_image_units = 8, + .max_combined_image_units_and_fragment_outputs = 8, + .max_combined_shader_output_resources = 8, + .max_image_samples = 0, + .max_vertex_image_uniforms = 0, + .max_fragment_image_uniforms = 8, + .max_combined_image_uniforms = 8, + .max_viewports = 16, + .max_vertex_atomic_counters = 0, + .max_fragment_atomic_counters = 8, + .max_combined_atomic_counters = 8, + .max_atomic_counter_bindings = 1, + .max_vertex_atomic_counter_buffers = 0, + .max_fragment_atomic_counter_buffers = 1, + .max_combined_atomic_counter_buffers = 1, + .max_atomic_counter_buffer_size = 16384, + .max_transform_feedback_buffers = 4, + .max_transform_feedback_interleaved_components = 64, + .max_cull_distances = 8, + .max_combined_clip_and_cull_distances = 8, + .max_samples = 4, + .max_mesh_output_vertices_ext = 256, + .max_mesh_output_primitives_ext = 256, + .max_mesh_work_group_size_x_ext = 128, + .max_mesh_work_group_size_y_ext = 128, + .max_mesh_work_group_size_z_ext = 128, + .max_task_work_group_size_x_ext = 128, + .max_task_work_group_size_y_ext = 128, + .max_task_work_group_size_z_ext = 128, + .max_mesh_view_count_ext = 4, + .max_dual_source_draw_buffers_ext = 1, + + .limits = { + .non_inductive_for_loops = 1, + .while_loops = 1, + .do_while_loops = 1, + .general_uniform_indexing = 1, + .general_attribute_matrix_vector_indexing = 1, + .general_varying_indexing = 1, + .general_sampler_indexing = 1, + .general_variable_indexing = 1, + .general_constant_matrix_vector_indexing = 1, + }, +}}; + function VulkanEntity * vk_entity_allocate(VulkanEntityKind kind) { @@ -174,8 +259,7 @@ glsl_to_spirv(Arena *arena, u32 kind, s8 shader_text, s8 name) .force_default_version_and_profile = 0, .forward_compatible = 0, .messages = GLSLANG_MSG_DEFAULT_BIT, - // TODO(rnp): fill this in based on the selected GPU. Then remove that junk from the library - .resource = glslang_default_resource(), + .resource = glslc_resource_constraints, }; glslang_shader_t *shader = glslang_shader_create(&input);