ogl_beamforming

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

Commit: 43c60fcb546a5ce3a62c07e29a29030e131794e0
Parent: 93a40c67c7a1e37bcf6bb16b301bf4a5504fb70c
Author: Randy Palamar
Date:   Mon, 27 Jul 2026 19:40:27 -0700

build/meta: drop second name field in Bake

no need to over complicate things.

Diffstat:
Mbeamformer.meta | 102++++++++++++++++++++++++++++++++++++++++----------------------------------------
Mbeamformer_core.c | 128++++++++++++++++++++++++++++++++++++++++----------------------------------------
Mbuild.c | 118++++++++++++++++++++++++-------------------------------------------------------
Mgenerated/beamformer.c | 290+++++++++++++++++++++++++++++++------------------------------------------------
Mui.c | 2+-
5 files changed, 264 insertions(+), 376 deletions(-)

diff --git a/beamformer.meta b/beamformer.meta @@ -343,17 +343,17 @@ @Bake { - [UseSharedMemory use_shared_memory B32] - [DecodeMode decode_mode U32] - [OutputChannelStride output_channel_stride U32] - [OutputSampleStride output_sample_stride U32] - [OutputTransmitStride output_transmit_stride U32] - [ToProcess to_process U32] - [TransmitCount transmit_count U32] - [ChunkChannelCount chunk_channel_count U32] - [CooperativeMatrixM cooperative_matrix_m U32] - [CooperativeMatrixN cooperative_matrix_n U32] - [CooperativeMatrixK cooperative_matrix_k U32] + [UseSharedMemory B32] + [DecodeMode U32] + [OutputChannelStride U32] + [OutputSampleStride U32] + [OutputTransmitStride U32] + [ToProcess U32] + [TransmitCount U32] + [ChunkChannelCount U32] + [CooperativeMatrixM U32] + [CooperativeMatrixN U32] + [CooperativeMatrixK U32] } @PushConstants @@ -379,19 +379,18 @@ @Bake { - [DecimationRate decimation_rate U32] - [FilterLength filter_length U32] - [InputChannelStride input_channel_stride U32] - [InputSampleStride input_sample_stride U32] - [InputTransmitStride input_transmit_stride U32] - [OutputChannelStride output_channel_stride U32] - [OutputSampleStride output_sample_stride U32] - [OutputTransmitStride output_transmit_stride U32] - [SampleCount sample_count U32] - [BatchSampleCount batch_sample_count U32] - - [DemodulationFrequency demodulation_frequency F32] - [SamplingFrequency sampling_frequency F32] + [SamplingFrequency F32] + [DemodulationFrequency F32] + [DecimationRate U32] + [FilterLength U32] + [SampleCount U32] + [BatchSampleCount U32] + [InputChannelStride U32] + [InputSampleStride U32] + [InputTransmitStride U32] + [OutputChannelStride U32] + [OutputSampleStride U32] + [OutputTransmitStride U32] } @PushConstants @@ -421,24 +420,25 @@ @Bake { - [SingleFocus single_focus B32] - [SingleOrientation single_orientation B32] - [Sparse sparse B32] - [AcquisitionCount acquisition_count S32] - [AcquisitionKind acquisition_kind U32] - [ChannelCount channel_count S32] - [ChunkChannelCount chunk_channel_count S32] - [InterpolationMode interpolation_mode U32] - [SampleCount sample_count S32] - [TransmitReceiveOrientation transmit_receive_orientation U32] - - [DemodulationFrequency demodulation_frequency F32] - [FNumber f_number F32] - [FocusDepth focus_depth F32] - [SamplingFrequency sampling_frequency F32] - [SpeedOfSound speed_of_sound F32] - [TimeOffset time_offset F32] - [TransmitAngle transmit_angle F32] + [AcquisitionKind U32] + [Sparse B32] + [AcquisitionCount S32] + [ChannelCount S32] + [ChunkChannelCount S32] + [SampleCount S32] + + [SamplingFrequency F32] + [DemodulationFrequency F32] + [SpeedOfSound F32] + [TimeOffset F32] + [InterpolationMode U32] + [FNumber F32] + + [SingleOrientation B32] + [TransmitReceiveOrientation U32] + [SingleFocus B32] + [FocusDepth F32] + [TransmitAngle F32] } @PushConstants @@ -501,15 +501,15 @@ @Bake { - [SizeX size_x U32] - [SizeY size_y U32] - [SizeZ size_z U32] - [InputStrideX input_stride_x U32] - [InputStrideY input_stride_y U32] - [InputStrideZ input_stride_z U32] - [OutputStrideX output_stride_x U32] - [OutputStrideY output_stride_y U32] - [OutputStrideZ output_stride_z U32] + [SizeX U32] + [SizeY U32] + [SizeZ U32] + [InputStrideX U32] + [InputStrideY U32] + [InputStrideZ U32] + [OutputStrideX U32] + [OutputStrideY U32] + [OutputStrideZ U32] } @PushConstants diff --git a/beamformer_core.c b/beamformer_core.c @@ -614,20 +614,20 @@ plan_compute_pipeline(BeamformerComputePlan *cp, BeamformerParameterBlock *pb, A BeamformerDecodeBakeParameters *db = &sd->bake.Decode; u32 decode_sample_count = input_sample_count; - db->decode_mode = pb->parameters.decode_mode; - db->transmit_count = pb->parameters.acquisition_count; - db->chunk_channel_count = chunk_channel_count; + db->DecodeMode = pb->parameters.decode_mode; + db->TransmitCount = pb->parameters.acquisition_count; + db->ChunkChannelCount = chunk_channel_count; // NOTE(rnp): ignored when using coop matrices - db->output_sample_stride = node->output_stride.x; - db->output_channel_stride = node->output_stride.y; - db->output_transmit_stride = node->output_stride.z; + db->OutputSampleStride = node->output_stride.x; + db->OutputChannelStride = node->output_stride.y; + db->OutputTransmitStride = node->output_stride.z; - db->to_process = 1; + db->ToProcess = 1; b32 use_coop_matrix = vk_gpu_info()->cooperative_matrix && node->input_data_kind == BeamformerDataKind_Float16 && - (db->transmit_count % 16 == 0) && + (db->TransmitCount % 16 == 0) && (chunk_channel_count % 16 == 0); if (use_coop_matrix) { // TODO(rnp): shared memory for larger sizes @@ -637,26 +637,26 @@ plan_compute_pipeline(BeamformerComputePlan *cp, BeamformerParameterBlock *pb, A decode_sample_count *= 2; sd->compile_flags |= BeamformerDecodeCompileFlags_CooperativeMatrix; - db->cooperative_matrix_m = 16; - db->cooperative_matrix_n = 16; - db->cooperative_matrix_k = 16; + db->CooperativeMatrixM = 16; + db->CooperativeMatrixN = 16; + db->CooperativeMatrixK = 16; - sd->dispatch.x = db->transmit_count / db->cooperative_matrix_n; - sd->dispatch.y = chunk_channel_count / db->cooperative_matrix_m; + sd->dispatch.x = db->TransmitCount / db->CooperativeMatrixN; + sd->dispatch.y = chunk_channel_count / db->CooperativeMatrixM; sd->dispatch.z = decode_sample_count; - } else if (db->transmit_count > 40) { - db->use_shared_memory = 1; + } else if (db->TransmitCount > 40) { + db->UseSharedMemory = 1; - if (db->transmit_count == 48) - db->to_process = db->transmit_count / 16; + if (db->TransmitCount == 48) + db->ToProcess = db->TransmitCount / 16; - b32 use_16x = db->transmit_count == 48 || db->transmit_count == 80 || - db->transmit_count == 96 || db->transmit_count == 160; + b32 use_16x = db->TransmitCount == 48 || db->TransmitCount == 80 || + db->TransmitCount == 96 || db->TransmitCount == 160; sd->layout.x = use_16x ? 16 : 32; sd->layout.y = 4; sd->layout.z = 1; - sd->dispatch.x = (u32)ceil_f32((f32)pb->parameters.acquisition_count / (f32)sd->layout.x / (f32)db->to_process); + sd->dispatch.x = (u32)ceil_f32((f32)pb->parameters.acquisition_count / (f32)sd->layout.x / (f32)db->ToProcess); sd->dispatch.y = (u32)ceil_f32((f32)chunk_channel_count / (f32)sd->layout.y); sd->dispatch.z = (u32)ceil_f32((f32)decode_sample_count / (f32)sd->layout.z); } else { @@ -682,23 +682,23 @@ plan_compute_pipeline(BeamformerComputePlan *cp, BeamformerParameterBlock *pb, A time_offset += f->time_delay; BeamformerFilterBakeParameters *fb = &sd->bake.Filter; - fb->filter_length = (u32)f->length; + fb->FilterLength = (u32)f->length; - fb->sample_count = input_sample_count; - fb->decimation_rate = demod ? decimation_rate : 1; + fb->SampleCount = input_sample_count; + fb->DecimationRate = demod ? decimation_rate : 1; b32 deinterleave = beamformer_data_kind_complex[node->input_data_kind] && !beamformer_data_kind_complex[node->output_data_kind]; if (deinterleave) - fb->batch_sample_count = chunk_channel_count * input_sample_count * pb->parameters.acquisition_count; + fb->BatchSampleCount = chunk_channel_count * input_sample_count * pb->parameters.acquisition_count; - fb->output_sample_stride = node->output_stride.x; - fb->output_channel_stride = node->output_stride.y; - fb->output_transmit_stride = node->output_stride.z; + fb->OutputSampleStride = node->output_stride.x; + fb->OutputChannelStride = node->output_stride.y; + fb->OutputTransmitStride = node->output_stride.z; - fb->input_sample_stride = node->input_stride.x; - fb->input_channel_stride = node->input_stride.y; - fb->input_transmit_stride = node->input_stride.z; + fb->InputSampleStride = node->input_stride.x; + fb->InputChannelStride = node->input_stride.y; + fb->InputTransmitStride = node->input_stride.z; /* NOTE(rnp): when we are demodulating we pretend that the sampler was alternating * between sampling the I portion and the Q portion of an IQ signal. Therefore there @@ -710,8 +710,8 @@ plan_compute_pipeline(BeamformerComputePlan *cp, BeamformerParameterBlock *pb, A * IQ[n] = I[n] - j*Q[n] */ if (demod) { - fb->demodulation_frequency = pb->parameters.demodulation_frequency; - fb->sampling_frequency = pb->parameters.sampling_frequency / 2; + fb->DemodulationFrequency = pb->parameters.demodulation_frequency; + fb->SamplingFrequency = pb->parameters.sampling_frequency / 2; } sd->layout = (uv3){{subgroup_size, 1, 1}}; @@ -724,20 +724,20 @@ plan_compute_pipeline(BeamformerComputePlan *cp, BeamformerParameterBlock *pb, A cp->first_image_shader_index = cp->pipeline.shader_count; BeamformerDASBakeParameters *db = &sd->bake.DAS; - db->sampling_frequency = sampling_frequency; - db->demodulation_frequency = pb->parameters.demodulation_frequency; - db->speed_of_sound = pb->parameters.speed_of_sound; - db->time_offset = time_offset; - db->f_number = pb->parameters.f_number; - db->acquisition_kind = pb->parameters.acquisition_kind; - db->sample_count = input_sample_count; - db->channel_count = pb->parameters.channel_count; - db->acquisition_count = pb->parameters.acquisition_count; - db->chunk_channel_count = chunk_channel_count; - db->interpolation_mode = pb->parameters.interpolation_mode; - db->transmit_angle = pb->parameters.focal_vector.E[0]; - db->focus_depth = pb->parameters.focal_vector.E[1]; - db->transmit_receive_orientation = pb->parameters.transmit_receive_orientation; + db->SamplingFrequency = sampling_frequency; + db->DemodulationFrequency = pb->parameters.demodulation_frequency; + db->SpeedOfSound = pb->parameters.speed_of_sound; + db->TimeOffset = time_offset; + db->FNumber = pb->parameters.f_number; + db->AcquisitionKind = pb->parameters.acquisition_kind; + db->SampleCount = input_sample_count; + db->ChannelCount = pb->parameters.channel_count; + db->AcquisitionCount = pb->parameters.acquisition_count; + db->ChunkChannelCount = chunk_channel_count; + db->InterpolationMode = pb->parameters.interpolation_mode; + db->TransmitAngle = pb->parameters.focal_vector.E[0]; + db->FocusDepth = pb->parameters.focal_vector.E[1]; + db->TransmitReceiveOrientation = pb->parameters.transmit_receive_orientation; // NOTE(rnp): old gcc will miscompile an assignment memory_copy(cp->xdc_transform.E, pb->parameters.xdc_transform.E, sizeof(cp->xdc_transform)); @@ -751,9 +751,9 @@ plan_compute_pipeline(BeamformerComputePlan *cp, BeamformerParameterBlock *pb, A if (id == BeamformerAcquisitionKind_UFORCES || id == BeamformerAcquisitionKind_FORCES) cp->das_voxel_transform = m4_mul(cp->xdc_transform, cp->das_voxel_transform); - db->sparse = id == BeamformerAcquisitionKind_UFORCES || id == BeamformerAcquisitionKind_UHERCULES; - db->single_focus = pb->parameters.single_focus; - db->single_orientation = pb->parameters.single_orientation; + db->Sparse = id == BeamformerAcquisitionKind_UFORCES || id == BeamformerAcquisitionKind_UHERCULES; + db->SingleFocus = pb->parameters.single_focus; + db->SingleOrientation = pb->parameters.single_orientation; sd->compile_flags |= BeamformerDASCompileFlags_CoherencyWeighting * pb->parameters.coherency_weighting; sd->layout = layout_for_output(cp->output_points); @@ -775,25 +775,25 @@ plan_compute_pipeline(BeamformerComputePlan *cp, BeamformerParameterBlock *pb, A sd->compile_flags |= BeamformerReshapeCompileFlags_Deinterleave * deinterleave; sd->compile_flags |= BeamformerReshapeCompileFlags_Interleave * interleave; - rb->input_stride_x = node->input_stride.x; - rb->input_stride_y = node->input_stride.y; - rb->input_stride_z = node->input_stride.z; - rb->output_stride_x = node->output_stride.x; - rb->output_stride_y = node->output_stride.y; - rb->output_stride_z = node->output_stride.z; + rb->InputStrideX = node->input_stride.x; + rb->InputStrideY = node->input_stride.y; + rb->InputStrideZ = node->input_stride.z; + rb->OutputStrideX = node->output_stride.x; + rb->OutputStrideY = node->output_stride.y; + rb->OutputStrideZ = node->output_stride.z; // NOTE(rnp): order doesn't really matter here but it must match the dispatch layout - rb->size_x = input_sample_count; - rb->size_y = chunk_channel_count; - rb->size_z = acquisition_count; + rb->SizeX = input_sample_count; + rb->SizeY = chunk_channel_count; + rb->SizeZ = acquisition_count; sd->layout.x = 1; - sd->layout.z = Min(subgroup_size, rb->size_z); + sd->layout.z = Min(subgroup_size, rb->SizeZ); sd->layout.y = subgroup_size / sd->layout.z; - sd->dispatch.x = (u32)(ceil_f32((f32)rb->size_x / sd->layout.x)); - sd->dispatch.y = (u32)(ceil_f32((f32)rb->size_y / sd->layout.y)); - sd->dispatch.z = (u32)(ceil_f32((f32)rb->size_z / sd->layout.z)); + sd->dispatch.x = (u32)(ceil_f32((f32)rb->SizeX / sd->layout.x)); + sd->dispatch.y = (u32)(ceil_f32((f32)rb->SizeY / sd->layout.y)); + sd->dispatch.z = (u32)(ceil_f32((f32)rb->SizeZ / sd->layout.z)); }break; default:{}break; @@ -890,7 +890,7 @@ stream_append_shader_header(Stream *s, i32 reloadable_index, BeamformerShaderDes i32 struct_id = beamformer_base_shader_to_bake_struct_id[reloadable_index]; if (struct_id != -1) { - str8 *names = beamformer_shader_bake_parameter_names[reloadable_index]; + str8 *names = meta_struct_member_names_by_id[struct_id]; MetaStructInfo *si = meta_struct_info_by_id + struct_id; MetaStructMember *sm = meta_struct_members_by_id[struct_id]; for (u32 index = 0; index < si->member_count; index++) { @@ -1312,7 +1312,7 @@ do_compute_shader(BeamformerCtx *ctx, VulkanHandle cmd, BeamformerComputePlan *c u64 input_pointer = shader_slot == 0 ? rf_pointer : pp_input_pointer; BeamformerReshapePushConstants pc = { .left_input_buffer = input_pointer, - .right_input_buffer = input_pointer + rb->size_x * rb->size_y * rb->size_z + .right_input_buffer = input_pointer + rb->SizeX * rb->SizeY * rb->SizeZ * beamformer_data_kind_byte_size[input_data_kind], }; diff --git a/build.c b/build.c @@ -1728,15 +1728,6 @@ typedef struct { typedef enum {META_STRUCT_FIELDS} MetaStructFields; #undef X -#define META_BAKE_FIELDS \ - X(NameUpper, name_upper) \ - X(NameLower, name_lower) \ - X(Type, type) \ - -#define X(id, ...) MetaBakeField_##id, -typedef enum {META_BAKE_FIELDS} MetaBakeFields; -#undef X - typedef struct { str8 *fields; str8 **entries; @@ -1788,12 +1779,12 @@ typedef struct { X(Table, 1, 0, 0) \ X(Union, 1, 1, 1) \ -// X(EntityKind, TypeField, ElementsField, NameField, AllowReferences, Emit) +// X(EntityKind, AllowReferences, Emit) #define META_STRUCT_MAP_LIST \ - X(BakeParameters, MetaBakeField_Type, -1, MetaBakeField_NameLower, 0, 1) \ - X(PushConstants, MetaStructField_Type, MetaStructField_Elements, MetaStructField_Name, 0, 1) \ - X(Struct, MetaStructField_Type, MetaStructField_Elements, MetaStructField_Name, 1, 1) \ - X(Union, MetaStructField_Type, MetaStructField_Elements, MetaStructField_Name, 1, 0) \ + X(BakeParameters, 0, 1) \ + X(PushConstants, 0, 1) \ + X(Struct, 1, 1) \ + X(Union, 1, 0) \ typedef enum { @@ -1835,19 +1826,10 @@ read_only global b8 meta_entity_kind_struct_reference_target[] = {META_ENTITY_KI #define X(k, ...) MetaEntityKind_##k, read_only global MetaEntityKind meta_struct_entity_kinds[] = {META_STRUCT_MAP_LIST}; #undef X -#define X(_k, t, ...) t, -read_only global i32 meta_struct_type_field[] = {META_STRUCT_MAP_LIST}; -#undef X -#define X(_k, _t, e, ...) e, -read_only global i32 meta_struct_element_field[] = {META_STRUCT_MAP_LIST}; -#undef X -#define X(_k, _t, _e, n, ...) n, -read_only global i32 meta_struct_name_field[] = {META_STRUCT_MAP_LIST}; -#undef X -#define X(_k, _t, _e, _n, allow, ...) allow, +#define X(_k, allow, ...) allow, read_only global b8 meta_struct_allow_references[] = {META_STRUCT_MAP_LIST}; #undef X -#define X(_k, _t, _e, _n, _a, emit, ...) emit, +#define X(_k, _a, emit, ...) emit, read_only global b8 meta_struct_emit[] = {META_STRUCT_MAP_LIST}; #undef X @@ -2487,16 +2469,6 @@ meta_pack_table_begin(MetaEntry *e, MetaTable *t) { switch (e->kind) { - case MetaEntryKind_Bake: - { - meta_entry_argument_expected_(e, 0, 0); - #define X(_i, name, ...) str8_comp(#name), - read_only local_persist str8 bake_fields[] = {META_BAKE_FIELDS}; - #undef X - t->fields = bake_fields; - t->field_count = countof(bake_fields); - }break; - case MetaEntryKind_Enumeration: case MetaEntryKind_Flags: { @@ -2505,6 +2477,7 @@ meta_pack_table_begin(MetaEntry *e, MetaTable *t) t->field_count = countof(enumeration_fields); }break; + case MetaEntryKind_Bake: case MetaEntryKind_PushConstants: case MetaEntryKind_Struct: case MetaEntryKind_Union: @@ -2549,6 +2522,7 @@ meta_pack_table_entity(MetaContext *ctx, MetaEntry *e, i64 entry_count, str8 nam meta_pack_table_begin(e, t); b32 structure = e->kind == MetaEntryKind_Struct || + e->kind == MetaEntryKind_Bake || e->kind == MetaEntryKind_PushConstants || e->kind == MetaEntryKind_Union; @@ -4228,23 +4202,6 @@ metagen_emit_c_code(MetaContext *ctx, Arena arena) } if (ctx->base_shader_count) - DeferLoop(meta_begin_scope(m, str8("read_only global str8 *" META_NAMESPACE_LOWER "_shader_bake_parameter_names[] = {")), - meta_end_scope(m, str8("};\n"))) - { - for (da_count bs = 0; bs < ctx->base_shader_count; bs++) { - da_count id = ctx->base_shader_ids[bs]; - MetaEntity *e = ctx->entities.data + id; - MetaEntityID bp_id = meta_entity_first_child_of_kind(ctx, e, MetaEntityKind_BakeParameters); - if (bp_id.value != 0) { - MetaEntity *bp = meta_entity(ctx, bp_id); - metagen_emit_c_str8_list(m, bp->table.entries[MetaBakeField_NameUpper], bp->table.entry_count); - } else { - meta_push_line(m, str8("0,")); - } - } - } - - if (ctx->base_shader_count) DeferLoop(meta_begin_scope(m, str8("read_only global i32 " META_NAMESPACE_LOWER "_base_shader_to_bake_struct_id[] = {")), meta_end_scope(m, str8("};\n"))) @@ -4914,7 +4871,7 @@ metagen_load_context(Arena *arena, char *filename) s->info.name = ctx->entity_names.data[entity]; s->info.member_count = e->table.entry_count; s->info.size = (u32)-1; - s->members = e->table.entries[meta_struct_name_field[kind_it]]; + s->members = e->table.entries[MetaStructField_Name]; s->location = e->location; s->entity = (MetaEntityID){entity}; if (meta_struct_entity_kinds[kind_it] == MetaEntityKind_Union) @@ -4935,7 +4892,7 @@ metagen_load_context(Arena *arena, char *filename) MetaEntity *e = ctx->entities.data + entity; MetaStruct *s = ctx->struct_infos + e->table.struct_info_id; - str8 *types = e->table.entries[meta_struct_type_field[kind_it]]; + str8 *types = e->table.entries[MetaStructField_Type]; for EachIndex(s->info.member_count, member) { s->type_ids[member] = meta_lookup_string_slow(meta_kind_meta_types, MetaKind_Count, types[member]); @@ -4969,40 +4926,35 @@ metagen_load_context(Arena *arena, char *filename) MetaEntity *e = ctx->entities.data + entity; MetaStruct *s = ctx->struct_infos + e->table.struct_info_id; - i32 field = meta_struct_element_field[kind_it]; - str8 *elements = field >= 0 ? e->table.entries[field] : 0; + str8 *elements = e->table.entries[MetaStructField_Elements]; for EachIndex(s->info.member_count, member) { - if (elements) { - NumberConversion integer = integer_from_str8(elements[member]); - if (integer.result == NumberConversionResult_Success) { - s->elements[member] = integer.U64; + NumberConversion integer = integer_from_str8(elements[member]); + if (integer.result == NumberConversionResult_Success) { + s->elements[member] = integer.U64; + } else { + str8 ref_name = elements[member]; + if (ref_name.data[0] == '#') { + s->member_flags[member] |= MetaBuildStructMemberFlag_EnumerationCount; + str8_chop(&ref_name, 1); } else { - str8 ref_name = elements[member]; - if (ref_name.data[0] == '#') { - s->member_flags[member] |= MetaBuildStructMemberFlag_EnumerationCount; - str8_chop(&ref_name, 1); - } else { - s->member_flags[member] |= MetaBuildStructMemberFlag_ReferenceElements; - } + s->member_flags[member] |= MetaBuildStructMemberFlag_ReferenceElements; + } - i64 id = meta_lookup_string_slow(ctx->entity_names.data, ctx->entity_names.count, ref_name); - if (id >= 0) { - MetaEntity *ee = ctx->entities.data + id; - b32 valid = ee->kind == MetaEntityKind_Enumeration || - (ee->kind == MetaEntityKind_Constant && ee->constant.kind == MetaConstantKind_Integer); - if (!valid) { - // TODO(rnp): point at correct member - meta_compiler_error(e->location, "struct '%.*s': element count for field '%.*s'" - "references '%.*s' which is not an integer constant\n", - (i32)s->info.name.length, s->info.name.data, - (i32)s->members[member].length, s->members[member].data, - (i32)elements[member].length, elements[member].data); - } - s->elements[member] = id; + i64 id = meta_lookup_string_slow(ctx->entity_names.data, ctx->entity_names.count, ref_name); + if (id >= 0) { + MetaEntity *ee = ctx->entities.data + id; + b32 valid = ee->kind == MetaEntityKind_Enumeration || + (ee->kind == MetaEntityKind_Constant && ee->constant.kind == MetaConstantKind_Integer); + if (!valid) { + // TODO(rnp): point at correct member + meta_compiler_error(e->location, "struct '%.*s': element count for field '%.*s'" + "references '%.*s' which is not an integer constant\n", + (i32)s->info.name.length, s->info.name.data, + (i32)s->members[member].length, s->members[member].data, + (i32)elements[member].length, elements[member].data); } + s->elements[member] = id; } - } else { - s->elements[member] = 1; } if (s->elements[member] == -1) { diff --git a/generated/beamformer.c b/generated/beamformer.c @@ -166,64 +166,64 @@ typedef enum { } BeamformerShaderKind; typedef struct { - b32 use_shared_memory; - u32 decode_mode; - u32 output_channel_stride; - u32 output_sample_stride; - u32 output_transmit_stride; - u32 to_process; - u32 transmit_count; - u32 chunk_channel_count; - u32 cooperative_matrix_m; - u32 cooperative_matrix_n; - u32 cooperative_matrix_k; + b32 UseSharedMemory; + u32 DecodeMode; + u32 OutputChannelStride; + u32 OutputSampleStride; + u32 OutputTransmitStride; + u32 ToProcess; + u32 TransmitCount; + u32 ChunkChannelCount; + u32 CooperativeMatrixM; + u32 CooperativeMatrixN; + u32 CooperativeMatrixK; } BeamformerDecodeBakeParameters; typedef struct { - u32 decimation_rate; - u32 filter_length; - u32 input_channel_stride; - u32 input_sample_stride; - u32 input_transmit_stride; - u32 output_channel_stride; - u32 output_sample_stride; - u32 output_transmit_stride; - u32 sample_count; - u32 batch_sample_count; - f32 demodulation_frequency; - f32 sampling_frequency; + f32 SamplingFrequency; + f32 DemodulationFrequency; + u32 DecimationRate; + u32 FilterLength; + u32 SampleCount; + u32 BatchSampleCount; + u32 InputChannelStride; + u32 InputSampleStride; + u32 InputTransmitStride; + u32 OutputChannelStride; + u32 OutputSampleStride; + u32 OutputTransmitStride; } BeamformerFilterBakeParameters; typedef struct { - b32 single_focus; - b32 single_orientation; - b32 sparse; - i32 acquisition_count; - u32 acquisition_kind; - i32 channel_count; - i32 chunk_channel_count; - u32 interpolation_mode; - i32 sample_count; - u32 transmit_receive_orientation; - f32 demodulation_frequency; - f32 f_number; - f32 focus_depth; - f32 sampling_frequency; - f32 speed_of_sound; - f32 time_offset; - f32 transmit_angle; + u32 AcquisitionKind; + b32 Sparse; + i32 AcquisitionCount; + i32 ChannelCount; + i32 ChunkChannelCount; + i32 SampleCount; + f32 SamplingFrequency; + f32 DemodulationFrequency; + f32 SpeedOfSound; + f32 TimeOffset; + u32 InterpolationMode; + f32 FNumber; + b32 SingleOrientation; + u32 TransmitReceiveOrientation; + b32 SingleFocus; + f32 FocusDepth; + f32 TransmitAngle; } BeamformerDASBakeParameters; typedef struct { - u32 size_x; - u32 size_y; - u32 size_z; - u32 input_stride_x; - u32 input_stride_y; - u32 input_stride_z; - u32 output_stride_x; - u32 output_stride_y; - u32 output_stride_z; + u32 SizeX; + u32 SizeY; + u32 SizeZ; + u32 InputStrideX; + u32 InputStrideY; + u32 InputStrideZ; + u32 OutputStrideX; + u32 OutputStrideY; + u32 OutputStrideZ; } BeamformerReshapeBakeParameters; typedef struct { @@ -598,8 +598,8 @@ read_only global MetaStructMember *meta_struct_members_by_id[] = { {18, 40, 1, 0}, }, (MetaStructMember []){ - {18, 0, 1, 0}, - {18, 4, 1, 0}, + {8, 0, 1, 0}, + {8, 4, 1, 0}, {18, 8, 1, 0}, {18, 12, 1, 0}, {18, 16, 1, 0}, @@ -608,25 +608,25 @@ read_only global MetaStructMember *meta_struct_members_by_id[] = { {18, 28, 1, 0}, {18, 32, 1, 0}, {18, 36, 1, 0}, - {8, 40, 1, 0}, - {8, 44, 1, 0}, + {18, 40, 1, 0}, + {18, 44, 1, 0}, }, (MetaStructMember []){ - {14, 0, 1, 0}, + {18, 0, 1, 0}, {14, 4, 1, 0}, - {14, 8, 1, 0}, + {10, 8, 1, 0}, {10, 12, 1, 0}, - {18, 16, 1, 0}, + {10, 16, 1, 0}, {10, 20, 1, 0}, - {10, 24, 1, 0}, - {18, 28, 1, 0}, - {10, 32, 1, 0}, - {18, 36, 1, 0}, - {8, 40, 1, 0}, + {8, 24, 1, 0}, + {8, 28, 1, 0}, + {8, 32, 1, 0}, + {8, 36, 1, 0}, + {18, 40, 1, 0}, {8, 44, 1, 0}, - {8, 48, 1, 0}, - {8, 52, 1, 0}, - {8, 56, 1, 0}, + {14, 48, 1, 0}, + {18, 52, 1, 0}, + {14, 56, 1, 0}, {8, 60, 1, 0}, {8, 64, 1, 0}, }, @@ -645,61 +645,61 @@ read_only global MetaStructMember *meta_struct_members_by_id[] = { read_only global str8 *meta_struct_member_names_by_id[] = { (str8 []){ - str8_comp("use_shared_memory"), - str8_comp("decode_mode"), - str8_comp("output_channel_stride"), - str8_comp("output_sample_stride"), - str8_comp("output_transmit_stride"), - str8_comp("to_process"), - str8_comp("transmit_count"), - str8_comp("chunk_channel_count"), - str8_comp("cooperative_matrix_m"), - str8_comp("cooperative_matrix_n"), - str8_comp("cooperative_matrix_k"), + str8_comp("UseSharedMemory"), + str8_comp("DecodeMode"), + str8_comp("OutputChannelStride"), + str8_comp("OutputSampleStride"), + str8_comp("OutputTransmitStride"), + str8_comp("ToProcess"), + str8_comp("TransmitCount"), + str8_comp("ChunkChannelCount"), + str8_comp("CooperativeMatrixM"), + str8_comp("CooperativeMatrixN"), + str8_comp("CooperativeMatrixK"), }, (str8 []){ - str8_comp("decimation_rate"), - str8_comp("filter_length"), - str8_comp("input_channel_stride"), - str8_comp("input_sample_stride"), - str8_comp("input_transmit_stride"), - str8_comp("output_channel_stride"), - str8_comp("output_sample_stride"), - str8_comp("output_transmit_stride"), - str8_comp("sample_count"), - str8_comp("batch_sample_count"), - str8_comp("demodulation_frequency"), - str8_comp("sampling_frequency"), + str8_comp("SamplingFrequency"), + str8_comp("DemodulationFrequency"), + str8_comp("DecimationRate"), + str8_comp("FilterLength"), + str8_comp("SampleCount"), + str8_comp("BatchSampleCount"), + str8_comp("InputChannelStride"), + str8_comp("InputSampleStride"), + str8_comp("InputTransmitStride"), + str8_comp("OutputChannelStride"), + str8_comp("OutputSampleStride"), + str8_comp("OutputTransmitStride"), }, (str8 []){ - str8_comp("single_focus"), - str8_comp("single_orientation"), - str8_comp("sparse"), - str8_comp("acquisition_count"), - str8_comp("acquisition_kind"), - str8_comp("channel_count"), - str8_comp("chunk_channel_count"), - str8_comp("interpolation_mode"), - str8_comp("sample_count"), - str8_comp("transmit_receive_orientation"), - str8_comp("demodulation_frequency"), - str8_comp("f_number"), - str8_comp("focus_depth"), - str8_comp("sampling_frequency"), - str8_comp("speed_of_sound"), - str8_comp("time_offset"), - str8_comp("transmit_angle"), + str8_comp("AcquisitionKind"), + str8_comp("Sparse"), + str8_comp("AcquisitionCount"), + str8_comp("ChannelCount"), + str8_comp("ChunkChannelCount"), + str8_comp("SampleCount"), + str8_comp("SamplingFrequency"), + str8_comp("DemodulationFrequency"), + str8_comp("SpeedOfSound"), + str8_comp("TimeOffset"), + str8_comp("InterpolationMode"), + str8_comp("FNumber"), + str8_comp("SingleOrientation"), + str8_comp("TransmitReceiveOrientation"), + str8_comp("SingleFocus"), + str8_comp("FocusDepth"), + str8_comp("TransmitAngle"), }, (str8 []){ - str8_comp("size_x"), - str8_comp("size_y"), - str8_comp("size_z"), - str8_comp("input_stride_x"), - str8_comp("input_stride_y"), - str8_comp("input_stride_z"), - str8_comp("output_stride_x"), - str8_comp("output_stride_y"), - str8_comp("output_stride_z"), + str8_comp("SizeX"), + str8_comp("SizeY"), + str8_comp("SizeZ"), + str8_comp("InputStrideX"), + str8_comp("InputStrideY"), + str8_comp("InputStrideZ"), + str8_comp("OutputStrideX"), + str8_comp("OutputStrideY"), + str8_comp("OutputStrideZ"), }, }; @@ -984,70 +984,6 @@ read_only global u8 beamformer_shader_compile_flag_counts[] = { 0, }; -read_only global str8 *beamformer_shader_bake_parameter_names[] = { - (str8 []){ - str8_comp("UseSharedMemory"), - str8_comp("DecodeMode"), - str8_comp("OutputChannelStride"), - str8_comp("OutputSampleStride"), - str8_comp("OutputTransmitStride"), - str8_comp("ToProcess"), - str8_comp("TransmitCount"), - str8_comp("ChunkChannelCount"), - str8_comp("CooperativeMatrixM"), - str8_comp("CooperativeMatrixN"), - str8_comp("CooperativeMatrixK"), - }, - (str8 []){ - str8_comp("DecimationRate"), - str8_comp("FilterLength"), - str8_comp("InputChannelStride"), - str8_comp("InputSampleStride"), - str8_comp("InputTransmitStride"), - str8_comp("OutputChannelStride"), - str8_comp("OutputSampleStride"), - str8_comp("OutputTransmitStride"), - str8_comp("SampleCount"), - str8_comp("BatchSampleCount"), - str8_comp("DemodulationFrequency"), - str8_comp("SamplingFrequency"), - }, - (str8 []){ - str8_comp("SingleFocus"), - str8_comp("SingleOrientation"), - str8_comp("Sparse"), - str8_comp("AcquisitionCount"), - str8_comp("AcquisitionKind"), - str8_comp("ChannelCount"), - str8_comp("ChunkChannelCount"), - str8_comp("InterpolationMode"), - str8_comp("SampleCount"), - str8_comp("TransmitReceiveOrientation"), - str8_comp("DemodulationFrequency"), - str8_comp("FNumber"), - str8_comp("FocusDepth"), - str8_comp("SamplingFrequency"), - str8_comp("SpeedOfSound"), - str8_comp("TimeOffset"), - str8_comp("TransmitAngle"), - }, - 0, - 0, - 0, - (str8 []){ - str8_comp("SizeX"), - str8_comp("SizeY"), - str8_comp("SizeZ"), - str8_comp("InputStrideX"), - str8_comp("InputStrideY"), - str8_comp("InputStrideZ"), - str8_comp("OutputStrideX"), - str8_comp("OutputStrideY"), - str8_comp("OutputStrideZ"), - }, - 0, -}; - read_only global i32 beamformer_base_shader_to_bake_struct_id[] = { 0, 1, diff --git a/ui.c b/ui.c @@ -3319,7 +3319,7 @@ ui_build_compute_stats(BeamformerComputePlan *cp, f32 broken_shader_t, Beamforme i32 struct_id = beamformer_base_shader_to_bake_struct_id[reloadable_index]; if (struct_id != -1) { - str8 *names = beamformer_shader_bake_parameter_names[reloadable_index]; + str8 *names = meta_struct_member_names_by_id[struct_id]; MetaStructInfo *si = meta_struct_info_by_id + struct_id; MetaStructMember *sm = meta_struct_members_by_id[struct_id]; for EachIndex(si->member_count, member) {