ogl_beamforming

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

Commit: 9644dbb430f10f15bdd6dc71f3813b7ba7f55d27
Parent: 69849c81bd11647ce32269a181873d06d2647ed4
Author: Randy Palamar
Date:   Wed, 22 Jul 2026 20:15:20 -0700

build/meta: split off some internal meta definitions

we don't want this located in library headers unnecessarily. There
is still some other stuff but that can wait.

Diffstat:
M.gitignore | 2+-
Mbeamformer.meta | 97-------------------------------------------------------------------------------
Abeamformer_core.meta | 94+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mbeamformer_internal.h | 5+++--
Mbuild.c | 191+++++++++++++++++++++++++++++++++++++++++++------------------------------------
Agenerated/beamformer.c | 896+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dgenerated/beamformer.meta.c | 1002-------------------------------------------------------------------------------
Agenerated/beamformer_core.c | 108+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mlib/ogl_beamformer_lib.c | 2+-
9 files changed, 1208 insertions(+), 1189 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -11,4 +11,4 @@ !*.h !*.meta assets/generated -generated/beamformer_shaders.c +generated/beamformer_shader_data.c diff --git a/beamformer.meta b/beamformer.meta @@ -531,100 +531,3 @@ } } } - -//////////////////// -// NOTE: Core Data - -@Flags PanelFlags -{ - List - NeedsFrame - HasSettings -} - -@Struct PanelInfo -{ - [display STR] - [string STR] - [description STR] - [flags PanelFlags] -} - -@Table([name display string list needs_frame has_settings description]) PanelTable -{ - [Nil `` nil 0 0 0 ``] - [Split `` split 0 0 0 ``] - [TabGroup `` group 0 0 0 ``] - - [ComputeBarGraph `Compute Bar Graph` compute_bar_graph 1 0 0 `Bar graph showing portions of compute occupied by each stage.`] - [ComputeStats `Compute Stats` compute_stats 1 0 0 `Average stats about beamforming computations.`] - [FrameViewLive `Frame View` frame_view_live 1 0 1 `Latest frame with selected tag.`] - [FrameViewCopy `Frame View (Copy)` frame_view_copy 0 1 1 `Copy of an old frame. Useful for comparisons.`] - [FrameViewXPlane `3D X-Plane` frame_view_xplane 1 0 1 `3D Cross Plane View.`] - [LiveImagingControls `Live Controls` live_controls 1 0 0 `Imaging system controls.`] - [ParameterListing `Parameter Listing` parameters_listing 1 0 1 `Editable parameter set used for beamforming.`] -} -@Expand(PanelTable) @Enumeration(`$(name)`) PanelKind -@Emit -{ - `read_only global BeamformerPanelInfo beamformer_panel_infos[] = {` - @Expand(PanelTable) ` {str8_comp("$(display)"), str8_comp("$(string)"), str8_comp("$(description)"), ($(list)*BeamformerPanelFlags_List)|($(needs_frame)*BeamformerPanelFlags_NeedsFrame)|($(has_settings)*BeamformerPanelFlags_HasSettings)},` - `};` -} - -@Table ([type name upper]) RegistersTable -{ - [STR string String ] - [U64 tree_node TreeNode ] - [U64 window Window ] - [U64 frame Frame ] - - [U64 frame_view FrameView ] - - // NOTE(rnp): Panel Movement and Splitting - [U64 split_axis SplitAxis ] - [U64 split_left_tree SplitLeftTree ] - [U64 split_right_tree SplitRightTree] - - [U64 drop_target_tree DropTargetTree] - [U64 drop_child_index DropChildIndex] -} -@Expand(RegistersTable) @Struct([`$(name)` `$(type)`]) Registers -@Expand(RegistersTable) @Enumeration(`$(upper)`) RegisterSlot - -@Emit -{ - `#define beamformer_registers_init_literal \` - @Expand(RegistersTable) ` .$(name)$(|)= beamformer_registers()->$(name), \` -} - -@Struct CommandInfo -{ - [string STR] - [display STR] - [description STR] -} - -@Table([kind string display_string description]) CommandTable -{ - // NOTE(rnp): tab commands - [CloseTab `close_tab` `Close Tab` `Closes currently active tab.`] - [FocusTab `focus_tab` `Focus Tab` `Focus the currently selected tab in its group.`] - [MoveTab `move_tab` `Move Tab` `Moves an exisiting tab to a different group/split.`] - [OpenTab `open_tab` `Open Tab` `Opens a new tab with a specified view.`] - [SplitTree `split_tree` `Split Tree` `Splits the UI into two new splits.`] -} - -@Enumeration CommandKind -{ - Nil - @Expand(CommandTable) `$(kind)` -} - -@Emit -{ - `read_only global BeamformerCommandInfo beamformer_command_infos[] = {` - ` {0},` - @Expand(CommandTable) ` {str8_comp("$(string)"), str8_comp("$(display_string)"), str8_comp("$(description)")},` - `};` -} diff --git a/beamformer_core.meta b/beamformer_core.meta @@ -0,0 +1,94 @@ +// See LICENSE for license details. +@Flags PanelFlags +{ + List + NeedsFrame + HasSettings +} + +@Struct PanelInfo +{ + [display STR] + [string STR] + [description STR] + [flags PanelFlags] +} + +@Table([name display string list needs_frame has_settings description]) PanelTable +{ + [Nil `` nil 0 0 0 ``] + [Split `` split 0 0 0 ``] + [TabGroup `` group 0 0 0 ``] + + [ComputeBarGraph `Compute Bar Graph` compute_bar_graph 1 0 0 `Bar graph showing portions of compute occupied by each stage.`] + [ComputeStats `Compute Stats` compute_stats 1 0 0 `Average stats about beamforming computations.`] + [FrameViewLive `Frame View` frame_view_live 1 0 1 `Latest frame with selected tag.`] + [FrameViewCopy `Frame View (Copy)` frame_view_copy 0 1 1 `Copy of an old frame. Useful for comparisons.`] + [FrameViewXPlane `3D X-Plane` frame_view_xplane 1 0 1 `3D Cross Plane View.`] + [LiveImagingControls `Live Controls` live_controls 1 0 0 `Imaging system controls.`] + [ParameterListing `Parameter Listing` parameters_listing 1 0 1 `Editable parameter set used for beamforming.`] +} +@Expand(PanelTable) @Enumeration(`$(name)`) PanelKind +@Emit +{ + `read_only global BeamformerPanelInfo beamformer_panel_infos[] = {` + @Expand(PanelTable) ` {str8_comp("$(display)"), str8_comp("$(string)"), str8_comp("$(description)"), ($(list)*BeamformerPanelFlags_List)|($(needs_frame)*BeamformerPanelFlags_NeedsFrame)|($(has_settings)*BeamformerPanelFlags_HasSettings)},` + `};` +} + +@Table ([type name upper]) RegistersTable +{ + [STR string String ] + [U64 tree_node TreeNode ] + [U64 window Window ] + [U64 frame Frame ] + + [U64 frame_view FrameView ] + + // NOTE(rnp): Panel Movement and Splitting + [U64 split_axis SplitAxis ] + [U64 split_left_tree SplitLeftTree ] + [U64 split_right_tree SplitRightTree] + + [U64 drop_target_tree DropTargetTree] + [U64 drop_child_index DropChildIndex] +} +@Expand(RegistersTable) @Struct([`$(name)` `$(type)`]) Registers +@Expand(RegistersTable) @Enumeration(`$(upper)`) RegisterSlot + +@Emit +{ + `#define beamformer_registers_init_literal \` + @Expand(RegistersTable) ` .$(name)$(|)= beamformer_registers()->$(name), \` +} + +@Struct CommandInfo +{ + [string STR] + [display STR] + [description STR] +} + +@Table([kind string display_string description]) CommandTable +{ + // NOTE(rnp): tab commands + [CloseTab `close_tab` `Close Tab` `Closes currently active tab.`] + [FocusTab `focus_tab` `Focus Tab` `Focus the currently selected tab in its group.`] + [MoveTab `move_tab` `Move Tab` `Moves an exisiting tab to a different group/split.`] + [OpenTab `open_tab` `Open Tab` `Opens a new tab with a specified view.`] + [SplitTree `split_tree` `Split Tree` `Splits the UI into two new splits.`] +} + +@Enumeration CommandKind +{ + Nil + @Expand(CommandTable) `$(kind)` +} + +@Emit +{ + `read_only global BeamformerCommandInfo beamformer_command_infos[] = {` + ` {0},` + @Expand(CommandTable) ` {str8_comp("$(string)"), str8_comp("$(display_string)"), str8_comp("$(description)")},` + `};` +} diff --git a/beamformer_internal.h b/beamformer_internal.h @@ -7,8 +7,9 @@ #include "util.h" #include "opengl.h" -#include "generated/beamformer.meta.c" -#include "generated/beamformer_shaders.c" +#include "generated/beamformer.c" +#include "generated/beamformer_core.c" +#include "generated/beamformer_shader_data.c" #include "external/raylib/src/raylib.h" #include "external/raylib/src/rlgl.h" diff --git a/build.c b/build.c @@ -2,12 +2,6 @@ /* NOTE: inspired by nob: https://github.com/tsoding/nob.h */ /* TODO(rnp): - * [ ]: refactor: unify struct type paths - * - struct printing can do a stack traversal for sub types - * but it should not have other branching - * - basically we should flatten structs into a base type - * similar to ornot where we know the size of everything - * and all names are fully resolved * [ ]: refactor: allow @Expand to come before the table definition * [ ]: cross compile/override baked compiler * [ ]: msvc build doesn't detect out of date files correctly @@ -1001,11 +995,11 @@ meta_push_(MetaprogramContext *m, s8 *items, iz count) #define meta_pad(m, b, n) stream_pad(&(m)->stream, (b), (n)) #define meta_indent(m) meta_pad((m), '\t', (m)->indentation_level) -#define meta_begin_line(m, ...) do { meta_indent(m); meta_push(m, __VA_ARGS__); } while(0) +#define meta_begin_line(m, ...) meta_indent(m), meta_push(m, __VA_ARGS__) #define meta_end_line(m, ...) meta_push(m, ##__VA_ARGS__, s8("\n")) -#define meta_push_line(m, ...) do { meta_indent(m); meta_push(m, ##__VA_ARGS__, s8("\n")); } while(0) -#define meta_begin_scope(m, ...) do { meta_push_line(m, __VA_ARGS__); (m)->indentation_level++; } while(0) -#define meta_end_scope(m, ...) do { (m)->indentation_level--; meta_push_line(m, __VA_ARGS__); } while(0) +#define meta_push_line(m, ...) meta_indent(m), meta_push(m, ##__VA_ARGS__, s8("\n")) +#define meta_begin_scope(m, ...) meta_push_line(m, __VA_ARGS__), (m)->indentation_level++ +#define meta_end_scope(m, ...) (m)->indentation_level--, meta_push_line(m, __VA_ARGS__) #define meta_push_f64(m, n) stream_append_f64(&(m)->stream, (n), 1000000) #define meta_push_u64(m, n) stream_append_u64(&(m)->stream, (n)) #define meta_push_i64(m, n) stream_append_i64(&(m)->stream, (n)) @@ -1942,6 +1936,7 @@ typedef struct { str8 filename; str8 directory; + str8 fullpath; MetaEntityID library_entity; MetaEntityID matlab_entity; @@ -3628,6 +3623,9 @@ meta_push_matlab_properties(MetaprogramContext *m, MetaContext *ctx, MetaStruct function void meta_push_shader_reload_info(MetaprogramContext *m, MetaContext *ctx) { + if (!ctx->base_shader_count) + return; + /////////////////////////////// // NOTE(rnp): reloadable infos meta_begin_scope(m, s8("read_only global " META_NAMESPACE_UPPER "ShaderKind " META_NAMESPACE_LOWER "_reloadable_shader_kinds[] = {")); @@ -3856,8 +3854,29 @@ metagen_emit_c_s8_list(MetaprogramContext *m, s8 *strs, u32 count) function b32 metagen_emit_c_code(MetaContext *ctx, Arena arena) { - os_make_directory("generated"); - char *out_meta = "generated" OS_PATH_SEPARATOR "beamformer.meta.c"; + b32 result = 1; + char *out, *out_shaders; + { + str8 basename; + str8_split(ctx->filename, &basename, 0, '.'); + + Stream sb = arena_stream(arena); + stream_append_s8s(&sb, s8_from_str8(ctx->directory), s8(OS_PATH_SEPARATOR), s8("generated")); + stream_append_byte(&sb, 0); + os_make_directory((c8 *)sb.data); + stream_reset(&sb, sb.widx - 1); + + stream_append_s8s(&sb, s8(OS_PATH_SEPARATOR), s8_from_str8(basename), s8(".c")); + stream_append_byte(&sb, 0); + + out = (c8 *)arena_stream_commit_and_reset(&arena, &sb).data; + + stream_append_s8s(&sb, s8_from_str8(ctx->directory), s8(OS_PATH_SEPARATOR), s8("generated")); + stream_append_s8s(&sb, s8(OS_PATH_SEPARATOR), s8_from_str8(basename), s8("_shader_data.c")); + stream_append_byte(&sb, 0); + + out_shaders = (c8 *)arena_stream_commit(&arena, &sb).data; + } MetaprogramContext m[1] = {{.stream = arena_stream(arena), .scratch = ctx->scratch}}; @@ -3865,12 +3884,9 @@ metagen_emit_c_code(MetaContext *ctx, Arena arena) build_fatal("Failed to generate C Code"); } - b32 result = 1; - //////////////////////////// // NOTE(rnp): shader baking - { - char *out_shaders = "generated" OS_PATH_SEPARATOR "beamformer_shaders.c"; + if (ctx->base_shader_count) { char **deps = push_array(&m->scratch, char *, 2 * ctx->base_shader_count); u32 dep_count = 0; for (da_count bs = 0; bs < ctx->base_shader_count; bs++) { @@ -3879,8 +3895,9 @@ metagen_emit_c_code(MetaContext *ctx, Arena arena) if (s->files[1].len > 0) deps[dep_count++] = (c8 *)push_s8_from_parts(&m->scratch, s8(OS_PATH_SEPARATOR), s8("shaders"), s->files[1]).data; } + if (needs_rebuild_(out_shaders, deps, dep_count)) { - build_log_generate("Bake Shaders"); + build_log_generate("%.*s: baking shaders", (i32)ctx->filename.length, ctx->filename.data); meta_push(m, c_file_header); meta_push_shader_bake(m, ctx); result &= meta_write_and_reset(m, out_shaders); @@ -3888,10 +3905,15 @@ metagen_emit_c_code(MetaContext *ctx, Arena arena) m->scratch = ctx->scratch; } - if (!needs_rebuild(out_meta, "beamformer.meta")) - return result; + { + CommandList deps = meta_extract_emit_file_dependencies(ctx, &m->scratch); + *da_push(&m->scratch, &deps) = (c8 *)ctx->filename.data; + if (!needs_rebuild_(out, deps.data, deps.count)) + return result; + m->scratch = ctx->scratch; + } - build_log_generate("Core C Code"); + build_log_generate("%.*s: C Code", (i32)ctx->filename.length, ctx->filename.data); meta_push(m, c_file_header); @@ -3916,7 +3938,7 @@ metagen_emit_c_code(MetaContext *ctx, Arena arena) u32 row_count; row_count = 0; - meta_push_line(m, s8("// NOTE: Constants (Integer)")); + if (integers) meta_push_line(m, s8("// NOTE: Constants (Integer)")); for (da_count constant = 0; constant < ctx->entity_kind_counts[MetaEntityKind_Constant]; constant++) { da_count id = ctx->entity_kind_ids[MetaEntityKind_Constant][constant]; MetaEntity *e = ctx->entities.data + id; @@ -3932,7 +3954,7 @@ metagen_emit_c_code(MetaContext *ctx, Arena arena) metagen_push_table(m, m->scratch, str8("#define " META_NAMESPACE_UPPER), str8(")"), columns, row_count, 2); row_count = 0; - meta_push_line(m, s8("\n// NOTE: Constants (Float)")); + if (floats) meta_push_line(m, s8("\n// NOTE: Constants (Float)")); for (da_count constant = 0; constant < ctx->entity_kind_counts[MetaEntityKind_Constant]; constant++) { da_count id = ctx->entity_kind_ids[MetaEntityKind_Constant][constant]; MetaEntity *e = ctx->entities.data + id; @@ -3948,8 +3970,9 @@ metagen_emit_c_code(MetaContext *ctx, Arena arena) metagen_push_table(m, m->scratch, str8("#define " META_NAMESPACE_UPPER), str8(")"), columns, row_count, 2); m->scratch = ctx->scratch; + + if (integers || floats) meta_push(m, s8("\n")); } - meta_push(m, s8("\n")); ///////////////////////// // NOTE(rnp): enumerants @@ -3969,7 +3992,8 @@ metagen_emit_c_code(MetaContext *ctx, Arena arena) } } - { + // TODO(rnp): technically this needs to be namespaced to the file they are coming from + if (ctx->entity_kind_counts[MetaEntityKind_Shader]) { s8 kind = s8(META_NAMESPACE_UPPER "ShaderKind"); s8 kind_full = s8(META_NAMESPACE_UPPER "ShaderKind_"); meta_begin_scope(m, s8("typedef enum {")); @@ -4041,7 +4065,9 @@ metagen_emit_c_code(MetaContext *ctx, Arena arena) } // NOTE: shader bake parameter union - meta_begin_scope(m, s8("typedef union {")); + if (ctx->entity_kind_counts[MetaEntityKind_BakeParameters]) + DeferLoop(meta_begin_scope(m, s8("typedef union {")), + meta_end_scope(m, s8("} " META_NAMESPACE_UPPER "ShaderBakeParameters;\n"))) { Arena scratch; DeferLoop(scratch = m->scratch, m->scratch = scratch) @@ -4062,21 +4088,27 @@ metagen_emit_c_code(MetaContext *ctx, Arena arena) metagen_push_table(m, m->scratch, str8(""), str8(";"), columns, ctx->entity_kind_counts[MetaEntityKind_BakeParameters], 2); } - } meta_end_scope(m, s8("} " META_NAMESPACE_UPPER "ShaderBakeParameters;\n")); + } metagen_run_emit_set(m, ctx, ctx->emit_sets + MetaEmitLang_C, (s8 *)meta_kind_c_types); ///////////////////////////////// // NOTE(rnp): shader info tables - meta_begin_scope(m, s8("read_only global s8 " META_NAMESPACE_LOWER "_shader_names[] = {")); - for (da_count shader = 0; shader < ctx->entity_kind_counts[MetaEntityKind_Shader]; shader++) { - da_count id = ctx->entity_kind_ids[MetaEntityKind_Shader][shader]; - meta_push_line(m, s8("s8_comp(\""), ctx->entity_names.data[id], s8("\"),")); - } meta_end_scope(m, s8("};\n")); + if (ctx->entity_kind_counts[MetaEntityKind_Shader]) + DeferLoop(meta_begin_scope(m, s8("read_only global s8 " META_NAMESPACE_LOWER "_shader_names[] = {")), + meta_end_scope(m, s8("};\n"))) + { + for (da_count shader = 0; shader < ctx->entity_kind_counts[MetaEntityKind_Shader]; shader++) { + da_count id = ctx->entity_kind_ids[MetaEntityKind_Shader][shader]; + meta_push_line(m, s8("s8_comp(\""), ctx->entity_names.data[id], s8("\"),")); + } + } meta_push_shader_reload_info(m, ctx); - meta_begin_scope(m, s8("read_only global i32 *" META_NAMESPACE_LOWER "_shader_header_vectors[] = {")); + if (ctx->base_shader_count) + DeferLoop(meta_begin_scope(m, s8("read_only global i32 *" META_NAMESPACE_LOWER "_shader_header_vectors[] = {")), + meta_end_scope(m, s8("};\n"))) { for (da_count bs = 0; bs < ctx->base_shader_count; bs++) { da_count id = ctx->base_shader_ids[bs]; @@ -4095,9 +4127,11 @@ metagen_emit_c_code(MetaContext *ctx, Arena arena) meta_push_line(m, s8("0,")); } } - } meta_end_scope(m, s8("};\n")); + } - meta_begin_scope(m, s8("read_only global i32 " META_NAMESPACE_LOWER "_shader_header_vector_lengths[] = {")); + if (ctx->base_shader_count) + DeferLoop(meta_begin_scope(m, s8("read_only global i32 " META_NAMESPACE_LOWER "_shader_header_vector_lengths[] = {")), + meta_end_scope(m, s8("};\n"))) { for (da_count bs= 0; bs < ctx->base_shader_count; bs++) { da_count id = ctx->base_shader_ids[bs]; @@ -4106,9 +4140,11 @@ metagen_emit_c_code(MetaContext *ctx, Arena arena) meta_push_i64(m, s->entity_reference_ids.count); meta_end_line(m, s8(",")); } - } meta_end_scope(m, s8("};\n")); + } - meta_begin_scope(m, s8("read_only global s8 *" META_NAMESPACE_LOWER "_shader_bake_parameter_names[] = {")); + if (ctx->base_shader_count) + DeferLoop(meta_begin_scope(m, s8("read_only global s8 *" META_NAMESPACE_LOWER "_shader_bake_parameter_names[] = {")), + meta_end_scope(m, s8("};\n"))) { for (da_count bs = 0; bs < ctx->base_shader_count; bs++) { da_count id = ctx->base_shader_ids[bs]; @@ -4121,9 +4157,11 @@ metagen_emit_c_code(MetaContext *ctx, Arena arena) meta_push_line(m, s8("0,")); } } - } meta_end_scope(m, s8("};\n")); + } - meta_begin_scope(m, s8("read_only global u32 " META_NAMESPACE_LOWER "_shader_bake_parameter_float_bits[] = {")); + if (ctx->base_shader_count) + DeferLoop(meta_begin_scope(m, s8("read_only global u32 " META_NAMESPACE_LOWER "_shader_bake_parameter_float_bits[] = {")), + meta_end_scope(m, s8("};\n"))) { for (da_count bs = 0; bs < ctx->base_shader_count; bs++) { da_count id = ctx->base_shader_ids[bs]; @@ -4143,9 +4181,11 @@ metagen_emit_c_code(MetaContext *ctx, Arena arena) meta_push_u64_hex_width(m, hex, 8); meta_end_line(m, s8("UL,")); } - } meta_end_scope(m, s8("};\n")); + } - meta_begin_scope(m, s8("read_only global u8 " META_NAMESPACE_LOWER "_shader_bake_parameter_counts[] = {")); + if (ctx->base_shader_count) + DeferLoop(meta_begin_scope(m, s8("read_only global u8 " META_NAMESPACE_LOWER "_shader_bake_parameter_counts[] = {")), + meta_end_scope(m, s8("};\n"))) { for (da_count bs = 0; bs < ctx->base_shader_count; bs++) { da_count id = ctx->base_shader_ids[bs]; @@ -4158,24 +4198,25 @@ metagen_emit_c_code(MetaContext *ctx, Arena arena) meta_push_u64(m, count); meta_end_line(m, s8(",")); } - } meta_end_scope(m, s8("};\n")); + } - meta_begin_scope(m, s8("read_only global u8 " META_NAMESPACE_LOWER "_shader_push_constant_sizes[] = {")); - 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 pc_id = meta_entity_first_child_of_kind(ctx, e, MetaEntityKind_PushConstants); - if (pc_id.value != 0) { - meta_push_line(m, s8("sizeof(" META_NAMESPACE_UPPER), ctx->entity_names.data[id], s8("PushConstants),")); - } else { - meta_push_line(m, s8("0,")); + if (ctx->base_shader_count) + DeferLoop(meta_begin_scope(m, s8("read_only global u8 " META_NAMESPACE_LOWER "_shader_push_constant_sizes[] = {")), + meta_end_scope(m, s8("};\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 pc_id = meta_entity_first_child_of_kind(ctx, e, MetaEntityKind_PushConstants); + if (pc_id.value != 0) { + meta_push_line(m, s8("sizeof(" META_NAMESPACE_UPPER), ctx->entity_names.data[id], s8("PushConstants),")); + } else { + meta_push_line(m, s8("0,")); + } } } - meta_end_scope(m, s8("};\n")); - //fprintf(stderr, "%.*s\n", (i32)m.stream.widx, m.stream.data); - - result = meta_write_and_reset(m, out_meta); + result = meta_write_and_reset(m, out); return result; } @@ -4663,10 +4704,15 @@ metagen_load_context(Arena *arena, char *filename) MetaContext *result = ctx; - ctx->filename = str8_from_c_str(filename); + ctx->filename = push_str8(ctx->arena, str8_from_c_str(filename)); ctx->directory = str8_chop(&ctx->filename, str8_scan_backwards(ctx->filename, OS_PATH_SEPARATOR_CHAR)); - str8_chop(&ctx->filename, 1); - if (ctx->directory.length <= 0) ctx->directory = str8("."); + ctx->fullpath = str8_from_c_str((c8 *)ctx->directory.data); + if (ctx->directory.length > 0) str8_chop(&ctx->filename, 1); + if (ctx->directory.length <= 0) { + ctx->directory = str8("."); + ctx->fullpath = push_str8_from_parts(ctx->arena, str8(""), ctx->directory, + str8(OS_PATH_SEPARATOR), ctx->filename); + } Arena scratch = ctx->scratch; MetaEntryStack entries = meta_entry_stack_from_file(ctx->arena, filename); @@ -5012,35 +5058,7 @@ function b32 metagen_file_direct(Arena arena, char *filename) { MetaContext *ctx = metagen_load_context(&arena, filename); - if (!ctx) return 0; - - b32 result = 1; - char *out; - { - str8 basename; - str8_split(ctx->filename, &basename, 0, '.'); - - Stream sb = arena_stream(arena); - stream_append_s8s(&sb, s8_from_str8(ctx->directory), s8(OS_PATH_SEPARATOR), s8("generated")); - stream_append_byte(&sb, 0); - os_make_directory((c8 *)sb.data); - stream_reset(&sb, sb.widx - 1); - - stream_append_s8s(&sb, s8(OS_PATH_SEPARATOR), s8_from_str8(basename), s8(".c")); - stream_append_byte(&sb, 0); - - out = (c8 *)arena_stream_commit(&arena, &sb).data; - } - - CommandList deps = meta_extract_emit_file_dependencies(ctx, &arena); - MetaprogramContext m[1] = {{.stream = arena_stream(arena), .scratch = ctx->scratch}}; - if (needs_rebuild_(out, deps.data, deps.count)) { - build_log_generate("%s", out); - meta_push(m, c_file_header); - metagen_run_emit_set(m, ctx, ctx->emit_sets + MetaEmitLang_C, (s8 *)meta_kind_c_types); - result &= meta_write_and_reset(m, out); - } - + b32 result = ctx && metagen_emit_c_code(ctx, arena); return result; } @@ -5057,6 +5075,7 @@ main(i32 argc, char *argv[]) os_make_directory(OUTDIR); result &= metagen_file_direct(arena, "assets" OS_PATH_SEPARATOR "assets.meta"); + result &= metagen_file_direct(arena, "beamformer_core.meta"); MetaContext *meta = metagen_load_context(&arena, "beamformer.meta"); if (!meta) return 1; diff --git a/generated/beamformer.c b/generated/beamformer.c @@ -0,0 +1,896 @@ +/* See LICENSE for license details. */ + +// GENERATED CODE + +// NOTE: Constants (Integer) +#define BeamformerChunkChannelCount (16) +#define BeamformerFilterSlots (4) +#define BeamformerMaxBacklogFrames (4096) +#define BeamformerMaxChannelCount (256) +#define BeamformerMaxEmissionsCount (256) +#define BeamformerMaxComputeShaderStages (16) +#define BeamformerMaxParameterBlocks (16) +#define BeamformerMaxRawDataFramesInFlight (3) + +typedef enum { + BeamformerShaderResourceKind_Buffer = 0, + BeamformerShaderResourceKind_Count, +} BeamformerShaderResourceKind; + +typedef enum { + BeamformerShaderBufferSlot_BeamformedData = 0, + BeamformerShaderBufferSlot_PingPong = 1, + BeamformerShaderBufferSlot_Count, +} BeamformerShaderBufferSlot; + +typedef enum { + BeamformerDecodeMode_None = 0, + BeamformerDecodeMode_Hadamard = 1, + BeamformerDecodeMode_Count, +} BeamformerDecodeMode; + +typedef enum { + BeamformerRCAOrientation_None = 0, + BeamformerRCAOrientation_Rows = 1, + BeamformerRCAOrientation_Columns = 2, + BeamformerRCAOrientation_Count, +} BeamformerRCAOrientation; + +typedef enum { + BeamformerSamplingMode_2X = 0, + BeamformerSamplingMode_4X = 1, + BeamformerSamplingMode_Count, +} BeamformerSamplingMode; + +typedef enum { + BeamformerDataKind_Int16 = 0, + BeamformerDataKind_Int16Complex = 1, + BeamformerDataKind_Float32 = 2, + BeamformerDataKind_Float32Complex = 3, + BeamformerDataKind_Float16 = 4, + BeamformerDataKind_Float16Complex = 5, + BeamformerDataKind_Count, +} BeamformerDataKind; + +typedef enum { + BeamformerContrastMode_None = 0, + BeamformerContrastMode_A1S2 = 1, + BeamformerContrastMode_Count, +} BeamformerContrastMode; + +typedef enum { + BeamformerEmissionKind_Sine = 0, + BeamformerEmissionKind_Chirp = 1, + BeamformerEmissionKind_Count, +} BeamformerEmissionKind; + +typedef enum { + BeamformerInterpolationMode_Nearest = 0, + BeamformerInterpolationMode_Linear = 1, + BeamformerInterpolationMode_Cubic = 2, + BeamformerInterpolationMode_Count, +} BeamformerInterpolationMode; + +typedef enum { + BeamformerViewPlaneTag_XZ = 0, + BeamformerViewPlaneTag_YZ = 1, + BeamformerViewPlaneTag_XY = 2, + BeamformerViewPlaneTag_Arbitrary = 3, + BeamformerViewPlaneTag_Count, +} BeamformerViewPlaneTag; + +typedef enum { + BeamformerAcquisitionKind_FORCES = 0, + BeamformerAcquisitionKind_UFORCES = 1, + BeamformerAcquisitionKind_HERCULES = 2, + BeamformerAcquisitionKind_RCA_VLS = 3, + BeamformerAcquisitionKind_RCA_TPW = 4, + BeamformerAcquisitionKind_UHERCULES = 5, + BeamformerAcquisitionKind_RACES = 6, + BeamformerAcquisitionKind_EPIC_FORCES = 7, + BeamformerAcquisitionKind_EPIC_UFORCES = 8, + BeamformerAcquisitionKind_EPIC_UHERCULES = 9, + BeamformerAcquisitionKind_Flash = 10, + BeamformerAcquisitionKind_HERO_PA = 11, + BeamformerAcquisitionKind_ULM = 12, + BeamformerAcquisitionKind_Count, +} BeamformerAcquisitionKind; + +typedef enum { + BeamformerFilterKind_Kaiser = 0, + BeamformerFilterKind_MatchedChirp = 1, + BeamformerFilterKind_Count, +} BeamformerFilterKind; + +typedef enum { + BeamformerLiveFeedbackFlags_ImagePlaneOffsets = 0, + BeamformerLiveFeedbackFlags_TransmitPower = 1, + BeamformerLiveFeedbackFlags_TGCControlPoints = 2, + BeamformerLiveFeedbackFlags_SaveData = 3, + BeamformerLiveFeedbackFlags_SaveNameTag = 4, + BeamformerLiveFeedbackFlags_StopImaging = 5, + BeamformerLiveFeedbackFlags_AcquisitionKind = 6, + BeamformerLiveFeedbackFlags_Count, +} BeamformerLiveFeedbackFlags; + +typedef enum { + BeamformerLiveImagingDirtyFlags_ImagePlaneOffsets = 1 << 0, + BeamformerLiveImagingDirtyFlags_TransmitPower = 1 << 1, + BeamformerLiveImagingDirtyFlags_TGCControlPoints = 1 << 2, + BeamformerLiveImagingDirtyFlags_SaveData = 1 << 3, + BeamformerLiveImagingDirtyFlags_SaveNameTag = 1 << 4, + BeamformerLiveImagingDirtyFlags_StopImaging = 1 << 5, + BeamformerLiveImagingDirtyFlags_AcquisitionKind = 1 << 6, +} BeamformerLiveImagingDirtyFlags; + +typedef enum { + BeamformerShaderKind_Decode = 0, + BeamformerShaderKind_Filter = 1, + BeamformerShaderKind_Demodulate = 2, + BeamformerShaderKind_DAS = 3, + BeamformerShaderKind_Sum = 4, + BeamformerShaderKind_MinMax = 5, + BeamformerShaderKind_Hilbert = 6, + BeamformerShaderKind_CoherencyWeighting = 7, + BeamformerShaderKind_Reshape = 8, + BeamformerShaderKind_RenderBeamformed = 9, + BeamformerShaderKind_Count, + + BeamformerShaderKind_ComputeFirst = BeamformerShaderKind_Decode, + BeamformerShaderKind_ComputeLast = BeamformerShaderKind_Hilbert, + BeamformerShaderKind_ComputeCount = 7, + BeamformerShaderKind_ComputeHelpersFirst = BeamformerShaderKind_CoherencyWeighting, + BeamformerShaderKind_ComputeHelpersLast = BeamformerShaderKind_Reshape, + BeamformerShaderKind_ComputeHelpersCount = 2, + BeamformerShaderKind_RenderFirst = BeamformerShaderKind_RenderBeamformed, + BeamformerShaderKind_RenderLast = BeamformerShaderKind_RenderBeamformed, + BeamformerShaderKind_RenderCount = 1, +} 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; + b32 cooperative_matrix; + u32 cooperative_matrix_m; + u32 cooperative_matrix_n; + u32 cooperative_matrix_k; +} BeamformerDecodeBakeParameters; + +typedef struct { + u32 demodulate; + u32 complex_filter; + 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; +} BeamformerFilterBakeParameters; + +typedef struct { + u32 coherency_weighting; + u32 single_focus; + u32 single_orientation; + u32 sparse; + u32 acquisition_count; + u32 acquisition_kind; + u32 channel_count; + u32 chunk_channel_count; + u32 interpolation_mode; + u32 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; +} 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; + b32 interleave; + b32 deinterleave; +} BeamformerReshapeBakeParameters; + +typedef struct { + u64 hadamard_buffer; + u64 rf_buffer; + u64 output_buffer; +} BeamformerDecodePushConstants; + +typedef struct { + u64 input_data; + u64 filter_coefficients; + u32 output_element_offset; +} BeamformerFilterPushConstants; + +typedef struct { + m4 xdc_transform; + m4 voxel_transform; + v2 xdc_element_pitch; + u64 array_parameters; + u64 output_frame; + u64 incoherent_frame; + u32 rf_element_offset; + u32 output_size_x; + u32 output_size_y; + u32 output_size_z; + u32 cycle_t; + i32 channel_offset; +} BeamformerDASPushConstants; + +typedef struct { + u64 output_data; + u64 input_data; + u32 image_elements; + f32 scale; +} BeamformerSumPushConstants; + +typedef struct { + u64 left_side_buffer; + u64 right_side_buffer; + f32 scale; + u32 output_size_x; + u32 output_size_y; + u32 output_size_z; +} BeamformerCoherencyWeightingPushConstants; + +typedef struct { + u64 output_buffer; + u64 left_input_buffer; + u64 right_input_buffer; +} BeamformerReshapePushConstants; + +typedef struct { + m4 mvp_matrix; + u64 positions; + u64 normals; + v4 bounding_box_colour; + f32 bounding_box_fraction; + f32 db_cutoff; + f32 threshold; + f32 gamma; + u64 input_data; + u32 input_size_x; + u32 input_size_y; + u32 input_size_z; + u32 data_kind; +} BeamformerRenderBeamformedPushConstants; + +typedef struct { + f32 cycles; + f32 frequency; +} BeamformerSineParameters; + +typedef struct { + f32 duration; + f32 min_frequency; + f32 max_frequency; +} BeamformerChirpParameters; + +typedef struct { + BeamformerEmissionKind kind; + union { + BeamformerSineParameters sine; + BeamformerChirpParameters chirp; + }; +} BeamformerEmissionParameters; + +typedef struct { + f32 cutoff_frequency; + f32 beta; + u32 length; +} BeamformerKaiserFilterParameters; + +typedef struct { + f32 duration; + f32 min_frequency; + f32 max_frequency; +} BeamformerMatchedChirpFilterParameters; + +typedef struct { + BeamformerFilterKind kind; + f32 sampling_frequency; + b32 complex; + union { + BeamformerKaiserFilterParameters kaiser; + BeamformerMatchedChirpFilterParameters matched_chirp; + }; +} BeamformerFilterParameters; + +typedef struct { + m4 das_voxel_transform; + m4 xdc_transform; + v2 xdc_element_pitch; + uv2 raw_data_dimensions; + v2 focal_vector; + u32 transmit_receive_orientation; + u32 sample_count; + u32 channel_count; + u32 acquisition_count; + BeamformerAcquisitionKind acquisition_kind; + BeamformerDecodeMode decode_mode; + BeamformerSamplingMode sampling_mode; + f32 time_offset; + b32 single_focus; + b32 single_orientation; +} BeamformerParametersHead; + +typedef struct { + iv4 output_points; + f32 sampling_frequency; + f32 demodulation_frequency; + f32 speed_of_sound; + f32 f_number; + BeamformerInterpolationMode interpolation_mode; + b32 coherency_weighting; + u32 decimation_rate; +} BeamformerUIParameters; + +typedef struct { + BeamformerContrastMode contrast_mode; + BeamformerEmissionParameters emission_parameters; +} BeamformerExtraParameters; + +typedef struct { + m4 das_voxel_transform; + m4 xdc_transform; + v2 xdc_element_pitch; + uv2 raw_data_dimensions; + v2 focal_vector; + u32 transmit_receive_orientation; + u32 sample_count; + u32 channel_count; + u32 acquisition_count; + BeamformerAcquisitionKind acquisition_kind; + BeamformerDecodeMode decode_mode; + BeamformerSamplingMode sampling_mode; + f32 time_offset; + b32 single_focus; + b32 single_orientation; + iv4 output_points; + f32 sampling_frequency; + f32 demodulation_frequency; + f32 speed_of_sound; + f32 f_number; + BeamformerInterpolationMode interpolation_mode; + b32 coherency_weighting; + u32 decimation_rate; + BeamformerContrastMode contrast_mode; + BeamformerEmissionParameters emission_parameters; +} BeamformerParameters; + +typedef struct { + m4 das_voxel_transform; + m4 xdc_transform; + v2 xdc_element_pitch; + uv2 raw_data_dimensions; + v2 focal_vector; + u32 transmit_receive_orientation; + u32 sample_count; + u32 channel_count; + u32 acquisition_count; + BeamformerAcquisitionKind acquisition_kind; + BeamformerDecodeMode decode_mode; + BeamformerSamplingMode sampling_mode; + f32 time_offset; + b32 single_focus; + b32 single_orientation; + iv4 output_points; + f32 sampling_frequency; + f32 demodulation_frequency; + f32 speed_of_sound; + f32 f_number; + BeamformerInterpolationMode interpolation_mode; + b32 coherency_weighting; + u32 decimation_rate; + BeamformerContrastMode contrast_mode; + BeamformerEmissionParameters emission_parameters; + i16 channel_mapping[BeamformerMaxChannelCount]; + i16 sparse_elements[BeamformerMaxEmissionsCount]; + u8 transmit_receive_orientations[BeamformerMaxEmissionsCount]; + f32 steering_angles[BeamformerMaxEmissionsCount]; + f32 focal_depths[BeamformerMaxEmissionsCount]; + i32 compute_stages[BeamformerMaxComputeShaderStages]; + i32 compute_stage_parameters[BeamformerMaxComputeShaderStages]; + u32 compute_stages_count; + BeamformerDataKind data_kind; +} BeamformerSimpleParameters; + +typedef struct { + u32 active; + u32 save_enabled; + u32 save_active; + u32 acquisition_kind; + u64 acquisition_kind_enabled_flags; + f32 transmit_power; + f32 image_plane_offsets[BeamformerViewPlaneTag_Count]; + f32 tgc_control_points[8]; + i32 save_name_tag_length; + u8 save_name_tag[128]; +} BeamformerLiveImagingParameters; + +typedef struct { + v2 focal_vectors[BeamformerMaxChannelCount]; + i16 sparse_elements[BeamformerMaxChannelCount]; + u16 transmit_receive_orientations[BeamformerMaxChannelCount]; +} BeamformerDASArrayParameters; + +typedef union { + BeamformerDecodeBakeParameters Decode; + BeamformerFilterBakeParameters Filter; + BeamformerDASBakeParameters DAS; + BeamformerReshapeBakeParameters Reshape; +} BeamformerShaderBakeParameters; + +read_only global u8 beamformer_data_kind_element_size[] = { + 2, + 2, + 4, + 4, + 2, + 2, +}; + +read_only global u8 beamformer_data_kind_element_count[] = { + 1, + 2, + 1, + 2, + 1, + 2, +}; + +read_only global u8 beamformer_data_kind_byte_size[] = { + 2 * 1, + 2 * 2, + 4 * 1, + 4 * 2, + 2 * 1, + 2 * 2, +}; + +read_only global b8 beamformer_data_kind_complex[] = { + 0, + 1, + 0, + 1, + 0, + 1, +}; + +read_only global s8 beamformer_data_kind_glsl_type[] = { + s8_comp("int16_t"), + s8_comp("i16vec2"), + s8_comp("float32_t"), + s8_comp("f32vec2"), + s8_comp("float16_t"), + s8_comp("f16vec2"), +}; + +read_only global s8 beamformer_data_kind_s8[] = { + s8_comp("Int16"), + s8_comp("Int16Complex"), + s8_comp("Float32"), + s8_comp("Float32Complex"), + s8_comp("Float16"), + s8_comp("Float16Complex"), +}; + +read_only global u8 beamformer_contrast_mode_samples[] = { + 1, + 3, +}; + +read_only global str8 beamformer_contrast_mode_strings[] = { + str8_comp("None"), + str8_comp("A1S2"), +}; + +read_only global str8 beamformer_view_plane_tag_strings[] = { + str8_comp("XZ"), + str8_comp("YZ"), + str8_comp("XY"), + str8_comp("Arbitrary"), +}; + +read_only global u8 beamformer_acquisition_kind_has_fixed_transmits[] = { + 1, + 0, + 1, + 0, + 0, + 0, + 1, + 1, + 0, + 0, + 0, + 0, + 0, +}; + +read_only global str8 beamformer_acquisition_kind_strings[] = { + str8_comp("FORCES"), + str8_comp("UFORCES"), + str8_comp("HERCULES"), + str8_comp("VLS"), + str8_comp("TPW"), + str8_comp("UHERCULES"), + str8_comp("RACES"), + str8_comp("EPIC-FORCES"), + str8_comp("EPIC-UFORCES"), + str8_comp("EPIC-UHERCULES"), + str8_comp("Flash"), + str8_comp("HERO-PA"), + str8_comp("ULM"), +}; + +read_only global s8 beamformer_filter_kind_strings[] = { + s8_comp("Kaiser"), + s8_comp("MatchedChirp"), +}; + +read_only global s8 beamformer_interpolation_mode_strings[] = { + s8_comp("Nearest"), + s8_comp("Linear"), + s8_comp("Cubic"), +}; + +read_only global s8 beamformer_shader_resource_kind_strings[] = { + s8_comp("Buffer"), +}; + +read_only global s8 beamformer_shader_names[] = { + s8_comp("Decode"), + s8_comp("Filter"), + s8_comp("Demodulate"), + s8_comp("DAS"), + s8_comp("Sum"), + s8_comp("MinMax"), + s8_comp("Hilbert"), + s8_comp("CoherencyWeighting"), + s8_comp("Reshape"), + s8_comp("RenderBeamformed"), +}; + +read_only global BeamformerShaderKind beamformer_reloadable_shader_kinds[] = { + BeamformerShaderKind_Decode, + BeamformerShaderKind_Filter, + BeamformerShaderKind_DAS, + BeamformerShaderKind_Sum, + BeamformerShaderKind_MinMax, + BeamformerShaderKind_CoherencyWeighting, + BeamformerShaderKind_Reshape, + BeamformerShaderKind_RenderBeamformed, +}; + +read_only global s8 *beamformer_reloadable_shader_files[] = { + (s8 []){s8_comp("decode.glsl")}, + (s8 []){s8_comp("filter.glsl")}, + (s8 []){s8_comp("das.glsl")}, + (s8 []){s8_comp("sum.glsl")}, + (s8 []){s8_comp("min_max.glsl")}, + (s8 []){s8_comp("coherency_weighting.glsl")}, + (s8 []){s8_comp("reshape.glsl")}, + (s8 []){s8_comp("render_3d.vert.glsl"), s8_comp("render_3d.frag.glsl")}, +}; + +read_only global i32 beamformer_shader_reloadable_index_by_shader[] = { + 0, + 1, + 1, + 2, + 3, + 4, + -1, + 5, + 6, + 7, +}; + +read_only global i32 beamformer_reloadable_compute_shader_info_indices[] = { + 0, + 1, + 2, + 3, + 4, +}; + +read_only global i32 beamformer_reloadable_compute_helpers_shader_info_indices[] = { + 5, + 6, +}; + +read_only global i32 beamformer_reloadable_render_shader_info_indices[] = { + 7, +}; + +read_only global s8 beamformer_shader_global_header_strings[] = { + s8_comp("" + "#define DecodeMode_None 0\n" + "#define DecodeMode_Hadamard 1\n" + "\n"), + s8_comp("" + "layout(push_constant, std430) uniform PushConstants {\n" + " uint64_t hadamard_buffer;\n" + " uint64_t rf_buffer;\n" + " uint64_t output_buffer;\n" + "};\n" + "\n"), + s8_comp("" + "#define ShaderBufferSlot_BeamformedData 0\n" + "#define ShaderBufferSlot_PingPong 1\n" + "\n"), + s8_comp("" + "#define ShaderResourceKind_Buffer 0\n" + "\n"), + s8_comp("" + "layout(push_constant, std430) uniform PushConstants {\n" + " uint64_t input_data;\n" + " uint64_t filter_coefficients;\n" + " uint32_t output_element_offset;\n" + "};\n" + "\n"), + s8_comp("#define MaxChannelCount (256)\n\n"), + s8_comp("" + "#define AcquisitionKind_FORCES 0\n" + "#define AcquisitionKind_UFORCES 1\n" + "#define AcquisitionKind_HERCULES 2\n" + "#define AcquisitionKind_RCA_VLS 3\n" + "#define AcquisitionKind_RCA_TPW 4\n" + "#define AcquisitionKind_UHERCULES 5\n" + "#define AcquisitionKind_RACES 6\n" + "#define AcquisitionKind_EPIC_FORCES 7\n" + "#define AcquisitionKind_EPIC_UFORCES 8\n" + "#define AcquisitionKind_EPIC_UHERCULES 9\n" + "#define AcquisitionKind_Flash 10\n" + "#define AcquisitionKind_HERO_PA 11\n" + "#define AcquisitionKind_ULM 12\n" + "\n"), + s8_comp("" + "#define InterpolationMode_Nearest 0\n" + "#define InterpolationMode_Linear 1\n" + "#define InterpolationMode_Cubic 2\n" + "\n"), + s8_comp("" + "#define RCAOrientation_None 0\n" + "#define RCAOrientation_Rows 1\n" + "#define RCAOrientation_Columns 2\n" + "\n"), + s8_comp("" + "struct DASArrayParameters {\n" + " f32vec2 focal_vectors[MaxChannelCount];\n" + " int16_t sparse_elements[MaxChannelCount];\n" + " uint16_t transmit_receive_orientations[MaxChannelCount];\n" + "};\n" + "\n"), + s8_comp("" + "layout(push_constant, std430) uniform PushConstants {\n" + " f32mat4 xdc_transform;\n" + " f32mat4 voxel_transform;\n" + " f32vec2 xdc_element_pitch;\n" + " uint64_t array_parameters;\n" + " uint64_t output_frame;\n" + " uint64_t incoherent_frame;\n" + " uint32_t rf_element_offset;\n" + " uint32_t output_size_x;\n" + " uint32_t output_size_y;\n" + " uint32_t output_size_z;\n" + " uint32_t cycle_t;\n" + " int32_t channel_offset;\n" + "};\n" + "\n"), + s8_comp("" + "layout(push_constant, std430) uniform PushConstants {\n" + " uint64_t output_data;\n" + " uint64_t input_data;\n" + " uint32_t image_elements;\n" + " float32_t scale;\n" + "};\n" + "\n"), + s8_comp("" + "layout(push_constant, std430) uniform PushConstants {\n" + " uint64_t left_side_buffer;\n" + " uint64_t right_side_buffer;\n" + " float32_t scale;\n" + " uint32_t output_size_x;\n" + " uint32_t output_size_y;\n" + " uint32_t output_size_z;\n" + "};\n" + "\n"), + s8_comp("" + "layout(push_constant, std430) uniform PushConstants {\n" + " uint64_t output_buffer;\n" + " uint64_t left_input_buffer;\n" + " uint64_t right_input_buffer;\n" + "};\n" + "\n"), + s8_comp("" + "layout(push_constant, std430) uniform PushConstants {\n" + " f32mat4 mvp_matrix;\n" + " uint64_t positions;\n" + " uint64_t normals;\n" + " f32vec4 bounding_box_colour;\n" + " float32_t bounding_box_fraction;\n" + " float32_t db_cutoff;\n" + " float32_t threshold;\n" + " float32_t gamma;\n" + " uint64_t input_data;\n" + " uint32_t input_size_x;\n" + " uint32_t input_size_y;\n" + " uint32_t input_size_z;\n" + " uint32_t data_kind;\n" + "};\n" + "\n"), +}; + +read_only global b8 beamformer_shader_has_primitive[] = { + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, +}; + +read_only global b8 beamformer_shader_primitive_is_vertex[] = { + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, +}; + +read_only global i32 *beamformer_shader_header_vectors[] = { + (i32 []){0, 1}, + (i32 []){2, 3, 4}, + (i32 []){5, 6, 7, 8, 2, 3, 9, 10}, + (i32 []){11}, + 0, + (i32 []){12}, + (i32 []){13}, + (i32 []){14}, +}; + +read_only global i32 beamformer_shader_header_vector_lengths[] = { + 2, + 3, + 8, + 1, + 0, + 1, + 1, + 1, +}; + +read_only global s8 *beamformer_shader_bake_parameter_names[] = { + (s8 []){ + s8_comp("UseSharedMemory"), + s8_comp("DecodeMode"), + s8_comp("OutputChannelStride"), + s8_comp("OutputSampleStride"), + s8_comp("OutputTransmitStride"), + s8_comp("ToProcess"), + s8_comp("TransmitCount"), + s8_comp("ChunkChannelCount"), + s8_comp("CooperativeMatrix"), + s8_comp("CooperativeMatrixM"), + s8_comp("CooperativeMatrixN"), + s8_comp("CooperativeMatrixK"), + }, + (s8 []){ + s8_comp("Demodulate"), + s8_comp("ComplexFilter"), + s8_comp("DecimationRate"), + s8_comp("FilterLength"), + s8_comp("InputChannelStride"), + s8_comp("InputSampleStride"), + s8_comp("InputTransmitStride"), + s8_comp("OutputChannelStride"), + s8_comp("OutputSampleStride"), + s8_comp("OutputTransmitStride"), + s8_comp("SampleCount"), + s8_comp("BatchSampleCount"), + s8_comp("DemodulationFrequency"), + s8_comp("SamplingFrequency"), + }, + (s8 []){ + s8_comp("CoherencyWeighting"), + s8_comp("SingleFocus"), + s8_comp("SingleOrientation"), + s8_comp("Sparse"), + s8_comp("AcquisitionCount"), + s8_comp("AcquisitionKind"), + s8_comp("ChannelCount"), + s8_comp("ChunkChannelCount"), + s8_comp("InterpolationMode"), + s8_comp("SampleCount"), + s8_comp("TransmitReceiveOrientation"), + s8_comp("DemodulationFrequency"), + s8_comp("FNumber"), + s8_comp("FocusDepth"), + s8_comp("SamplingFrequency"), + s8_comp("SpeedOfSound"), + s8_comp("TimeOffset"), + s8_comp("TransmitAngle"), + }, + 0, + 0, + 0, + (s8 []){ + s8_comp("SizeX"), + s8_comp("SizeY"), + s8_comp("SizeZ"), + s8_comp("InputStrideX"), + s8_comp("InputStrideY"), + s8_comp("InputStrideZ"), + s8_comp("OutputStrideX"), + s8_comp("OutputStrideY"), + s8_comp("OutputStrideZ"), + s8_comp("Interleave"), + s8_comp("Deinterleave"), + }, + 0, +}; + +read_only global u32 beamformer_shader_bake_parameter_float_bits[] = { + 0x00000000UL, + 0x00003000UL, + 0x0003f800UL, + 0x00000000UL, + 0x00000000UL, + 0x00000000UL, + 0x00000000UL, + 0x00000000UL, +}; + +read_only global u8 beamformer_shader_bake_parameter_counts[] = { + 12, + 14, + 18, + 0, + 0, + 0, + 11, + 0, +}; + +read_only global u8 beamformer_shader_push_constant_sizes[] = { + sizeof(BeamformerDecodePushConstants), + sizeof(BeamformerFilterPushConstants), + sizeof(BeamformerDASPushConstants), + sizeof(BeamformerSumPushConstants), + 0, + sizeof(BeamformerCoherencyWeightingPushConstants), + sizeof(BeamformerReshapePushConstants), + sizeof(BeamformerRenderBeamformedPushConstants), +}; + diff --git a/generated/beamformer.meta.c b/generated/beamformer.meta.c @@ -1,1002 +0,0 @@ -/* See LICENSE for license details. */ - -// GENERATED CODE - -// NOTE: Constants (Integer) -#define BeamformerChunkChannelCount (16) -#define BeamformerFilterSlots (4) -#define BeamformerMaxBacklogFrames (4096) -#define BeamformerMaxChannelCount (256) -#define BeamformerMaxEmissionsCount (256) -#define BeamformerMaxComputeShaderStages (16) -#define BeamformerMaxParameterBlocks (16) -#define BeamformerMaxRawDataFramesInFlight (3) - -// NOTE: Constants (Float) - -typedef enum { - BeamformerShaderResourceKind_Buffer = 0, - BeamformerShaderResourceKind_Count, -} BeamformerShaderResourceKind; - -typedef enum { - BeamformerShaderBufferSlot_BeamformedData = 0, - BeamformerShaderBufferSlot_PingPong = 1, - BeamformerShaderBufferSlot_Count, -} BeamformerShaderBufferSlot; - -typedef enum { - BeamformerDecodeMode_None = 0, - BeamformerDecodeMode_Hadamard = 1, - BeamformerDecodeMode_Count, -} BeamformerDecodeMode; - -typedef enum { - BeamformerRCAOrientation_None = 0, - BeamformerRCAOrientation_Rows = 1, - BeamformerRCAOrientation_Columns = 2, - BeamformerRCAOrientation_Count, -} BeamformerRCAOrientation; - -typedef enum { - BeamformerSamplingMode_2X = 0, - BeamformerSamplingMode_4X = 1, - BeamformerSamplingMode_Count, -} BeamformerSamplingMode; - -typedef enum { - BeamformerDataKind_Int16 = 0, - BeamformerDataKind_Int16Complex = 1, - BeamformerDataKind_Float32 = 2, - BeamformerDataKind_Float32Complex = 3, - BeamformerDataKind_Float16 = 4, - BeamformerDataKind_Float16Complex = 5, - BeamformerDataKind_Count, -} BeamformerDataKind; - -typedef enum { - BeamformerContrastMode_None = 0, - BeamformerContrastMode_A1S2 = 1, - BeamformerContrastMode_Count, -} BeamformerContrastMode; - -typedef enum { - BeamformerEmissionKind_Sine = 0, - BeamformerEmissionKind_Chirp = 1, - BeamformerEmissionKind_Count, -} BeamformerEmissionKind; - -typedef enum { - BeamformerInterpolationMode_Nearest = 0, - BeamformerInterpolationMode_Linear = 1, - BeamformerInterpolationMode_Cubic = 2, - BeamformerInterpolationMode_Count, -} BeamformerInterpolationMode; - -typedef enum { - BeamformerViewPlaneTag_XZ = 0, - BeamformerViewPlaneTag_YZ = 1, - BeamformerViewPlaneTag_XY = 2, - BeamformerViewPlaneTag_Arbitrary = 3, - BeamformerViewPlaneTag_Count, -} BeamformerViewPlaneTag; - -typedef enum { - BeamformerAcquisitionKind_FORCES = 0, - BeamformerAcquisitionKind_UFORCES = 1, - BeamformerAcquisitionKind_HERCULES = 2, - BeamformerAcquisitionKind_RCA_VLS = 3, - BeamformerAcquisitionKind_RCA_TPW = 4, - BeamformerAcquisitionKind_UHERCULES = 5, - BeamformerAcquisitionKind_RACES = 6, - BeamformerAcquisitionKind_EPIC_FORCES = 7, - BeamformerAcquisitionKind_EPIC_UFORCES = 8, - BeamformerAcquisitionKind_EPIC_UHERCULES = 9, - BeamformerAcquisitionKind_Flash = 10, - BeamformerAcquisitionKind_HERO_PA = 11, - BeamformerAcquisitionKind_ULM = 12, - BeamformerAcquisitionKind_Count, -} BeamformerAcquisitionKind; - -typedef enum { - BeamformerFilterKind_Kaiser = 0, - BeamformerFilterKind_MatchedChirp = 1, - BeamformerFilterKind_Count, -} BeamformerFilterKind; - -typedef enum { - BeamformerLiveFeedbackFlags_ImagePlaneOffsets = 0, - BeamformerLiveFeedbackFlags_TransmitPower = 1, - BeamformerLiveFeedbackFlags_TGCControlPoints = 2, - BeamformerLiveFeedbackFlags_SaveData = 3, - BeamformerLiveFeedbackFlags_SaveNameTag = 4, - BeamformerLiveFeedbackFlags_StopImaging = 5, - BeamformerLiveFeedbackFlags_AcquisitionKind = 6, - BeamformerLiveFeedbackFlags_Count, -} BeamformerLiveFeedbackFlags; - -typedef enum { - BeamformerPanelKind_Nil = 0, - BeamformerPanelKind_Split = 1, - BeamformerPanelKind_TabGroup = 2, - BeamformerPanelKind_ComputeBarGraph = 3, - BeamformerPanelKind_ComputeStats = 4, - BeamformerPanelKind_FrameViewLive = 5, - BeamformerPanelKind_FrameViewCopy = 6, - BeamformerPanelKind_FrameViewXPlane = 7, - BeamformerPanelKind_LiveImagingControls = 8, - BeamformerPanelKind_ParameterListing = 9, - BeamformerPanelKind_Count, -} BeamformerPanelKind; - -typedef enum { - BeamformerRegisterSlot_String = 0, - BeamformerRegisterSlot_TreeNode = 1, - BeamformerRegisterSlot_Window = 2, - BeamformerRegisterSlot_Frame = 3, - BeamformerRegisterSlot_FrameView = 4, - BeamformerRegisterSlot_SplitAxis = 5, - BeamformerRegisterSlot_SplitLeftTree = 6, - BeamformerRegisterSlot_SplitRightTree = 7, - BeamformerRegisterSlot_DropTargetTree = 8, - BeamformerRegisterSlot_DropChildIndex = 9, - BeamformerRegisterSlot_Count, -} BeamformerRegisterSlot; - -typedef enum { - BeamformerCommandKind_Nil = 0, - BeamformerCommandKind_CloseTab = 1, - BeamformerCommandKind_FocusTab = 2, - BeamformerCommandKind_MoveTab = 3, - BeamformerCommandKind_OpenTab = 4, - BeamformerCommandKind_SplitTree = 5, - BeamformerCommandKind_Count, -} BeamformerCommandKind; - -typedef enum { - BeamformerLiveImagingDirtyFlags_ImagePlaneOffsets = 1 << 0, - BeamformerLiveImagingDirtyFlags_TransmitPower = 1 << 1, - BeamformerLiveImagingDirtyFlags_TGCControlPoints = 1 << 2, - BeamformerLiveImagingDirtyFlags_SaveData = 1 << 3, - BeamformerLiveImagingDirtyFlags_SaveNameTag = 1 << 4, - BeamformerLiveImagingDirtyFlags_StopImaging = 1 << 5, - BeamformerLiveImagingDirtyFlags_AcquisitionKind = 1 << 6, -} BeamformerLiveImagingDirtyFlags; - -typedef enum { - BeamformerPanelFlags_List = 1 << 0, - BeamformerPanelFlags_NeedsFrame = 1 << 1, - BeamformerPanelFlags_HasSettings = 1 << 2, -} BeamformerPanelFlags; - -typedef enum { - BeamformerShaderKind_Decode = 0, - BeamformerShaderKind_Filter = 1, - BeamformerShaderKind_Demodulate = 2, - BeamformerShaderKind_DAS = 3, - BeamformerShaderKind_Sum = 4, - BeamformerShaderKind_MinMax = 5, - BeamformerShaderKind_Hilbert = 6, - BeamformerShaderKind_CoherencyWeighting = 7, - BeamformerShaderKind_Reshape = 8, - BeamformerShaderKind_RenderBeamformed = 9, - BeamformerShaderKind_Count, - - BeamformerShaderKind_ComputeFirst = BeamformerShaderKind_Decode, - BeamformerShaderKind_ComputeLast = BeamformerShaderKind_Hilbert, - BeamformerShaderKind_ComputeCount = 7, - BeamformerShaderKind_ComputeHelpersFirst = BeamformerShaderKind_CoherencyWeighting, - BeamformerShaderKind_ComputeHelpersLast = BeamformerShaderKind_Reshape, - BeamformerShaderKind_ComputeHelpersCount = 2, - BeamformerShaderKind_RenderFirst = BeamformerShaderKind_RenderBeamformed, - BeamformerShaderKind_RenderLast = BeamformerShaderKind_RenderBeamformed, - BeamformerShaderKind_RenderCount = 1, -} 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; - b32 cooperative_matrix; - u32 cooperative_matrix_m; - u32 cooperative_matrix_n; - u32 cooperative_matrix_k; -} BeamformerDecodeBakeParameters; - -typedef struct { - u32 demodulate; - u32 complex_filter; - 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; -} BeamformerFilterBakeParameters; - -typedef struct { - u32 coherency_weighting; - u32 single_focus; - u32 single_orientation; - u32 sparse; - u32 acquisition_count; - u32 acquisition_kind; - u32 channel_count; - u32 chunk_channel_count; - u32 interpolation_mode; - u32 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; -} 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; - b32 interleave; - b32 deinterleave; -} BeamformerReshapeBakeParameters; - -typedef struct { - u64 hadamard_buffer; - u64 rf_buffer; - u64 output_buffer; -} BeamformerDecodePushConstants; - -typedef struct { - u64 input_data; - u64 filter_coefficients; - u32 output_element_offset; -} BeamformerFilterPushConstants; - -typedef struct { - m4 xdc_transform; - m4 voxel_transform; - v2 xdc_element_pitch; - u64 array_parameters; - u64 output_frame; - u64 incoherent_frame; - u32 rf_element_offset; - u32 output_size_x; - u32 output_size_y; - u32 output_size_z; - u32 cycle_t; - i32 channel_offset; -} BeamformerDASPushConstants; - -typedef struct { - u64 output_data; - u64 input_data; - u32 image_elements; - f32 scale; -} BeamformerSumPushConstants; - -typedef struct { - u64 left_side_buffer; - u64 right_side_buffer; - f32 scale; - u32 output_size_x; - u32 output_size_y; - u32 output_size_z; -} BeamformerCoherencyWeightingPushConstants; - -typedef struct { - u64 output_buffer; - u64 left_input_buffer; - u64 right_input_buffer; -} BeamformerReshapePushConstants; - -typedef struct { - m4 mvp_matrix; - u64 positions; - u64 normals; - v4 bounding_box_colour; - f32 bounding_box_fraction; - f32 db_cutoff; - f32 threshold; - f32 gamma; - u64 input_data; - u32 input_size_x; - u32 input_size_y; - u32 input_size_z; - u32 data_kind; -} BeamformerRenderBeamformedPushConstants; - -typedef struct { - f32 cycles; - f32 frequency; -} BeamformerSineParameters; - -typedef struct { - f32 duration; - f32 min_frequency; - f32 max_frequency; -} BeamformerChirpParameters; - -typedef struct { - BeamformerEmissionKind kind; - union { - BeamformerSineParameters sine; - BeamformerChirpParameters chirp; - }; -} BeamformerEmissionParameters; - -typedef struct { - f32 cutoff_frequency; - f32 beta; - u32 length; -} BeamformerKaiserFilterParameters; - -typedef struct { - f32 duration; - f32 min_frequency; - f32 max_frequency; -} BeamformerMatchedChirpFilterParameters; - -typedef struct { - BeamformerFilterKind kind; - f32 sampling_frequency; - b32 complex; - union { - BeamformerKaiserFilterParameters kaiser; - BeamformerMatchedChirpFilterParameters matched_chirp; - }; -} BeamformerFilterParameters; - -typedef struct { - m4 das_voxel_transform; - m4 xdc_transform; - v2 xdc_element_pitch; - uv2 raw_data_dimensions; - v2 focal_vector; - u32 transmit_receive_orientation; - u32 sample_count; - u32 channel_count; - u32 acquisition_count; - BeamformerAcquisitionKind acquisition_kind; - BeamformerDecodeMode decode_mode; - BeamformerSamplingMode sampling_mode; - f32 time_offset; - b32 single_focus; - b32 single_orientation; -} BeamformerParametersHead; - -typedef struct { - iv4 output_points; - f32 sampling_frequency; - f32 demodulation_frequency; - f32 speed_of_sound; - f32 f_number; - BeamformerInterpolationMode interpolation_mode; - b32 coherency_weighting; - u32 decimation_rate; -} BeamformerUIParameters; - -typedef struct { - BeamformerContrastMode contrast_mode; - BeamformerEmissionParameters emission_parameters; -} BeamformerExtraParameters; - -typedef struct { - m4 das_voxel_transform; - m4 xdc_transform; - v2 xdc_element_pitch; - uv2 raw_data_dimensions; - v2 focal_vector; - u32 transmit_receive_orientation; - u32 sample_count; - u32 channel_count; - u32 acquisition_count; - BeamformerAcquisitionKind acquisition_kind; - BeamformerDecodeMode decode_mode; - BeamformerSamplingMode sampling_mode; - f32 time_offset; - b32 single_focus; - b32 single_orientation; - iv4 output_points; - f32 sampling_frequency; - f32 demodulation_frequency; - f32 speed_of_sound; - f32 f_number; - BeamformerInterpolationMode interpolation_mode; - b32 coherency_weighting; - u32 decimation_rate; - BeamformerContrastMode contrast_mode; - BeamformerEmissionParameters emission_parameters; -} BeamformerParameters; - -typedef struct { - m4 das_voxel_transform; - m4 xdc_transform; - v2 xdc_element_pitch; - uv2 raw_data_dimensions; - v2 focal_vector; - u32 transmit_receive_orientation; - u32 sample_count; - u32 channel_count; - u32 acquisition_count; - BeamformerAcquisitionKind acquisition_kind; - BeamformerDecodeMode decode_mode; - BeamformerSamplingMode sampling_mode; - f32 time_offset; - b32 single_focus; - b32 single_orientation; - iv4 output_points; - f32 sampling_frequency; - f32 demodulation_frequency; - f32 speed_of_sound; - f32 f_number; - BeamformerInterpolationMode interpolation_mode; - b32 coherency_weighting; - u32 decimation_rate; - BeamformerContrastMode contrast_mode; - BeamformerEmissionParameters emission_parameters; - i16 channel_mapping[BeamformerMaxChannelCount]; - i16 sparse_elements[BeamformerMaxEmissionsCount]; - u8 transmit_receive_orientations[BeamformerMaxEmissionsCount]; - f32 steering_angles[BeamformerMaxEmissionsCount]; - f32 focal_depths[BeamformerMaxEmissionsCount]; - i32 compute_stages[BeamformerMaxComputeShaderStages]; - i32 compute_stage_parameters[BeamformerMaxComputeShaderStages]; - u32 compute_stages_count; - BeamformerDataKind data_kind; -} BeamformerSimpleParameters; - -typedef struct { - u32 active; - u32 save_enabled; - u32 save_active; - u32 acquisition_kind; - u64 acquisition_kind_enabled_flags; - f32 transmit_power; - f32 image_plane_offsets[BeamformerViewPlaneTag_Count]; - f32 tgc_control_points[8]; - i32 save_name_tag_length; - u8 save_name_tag[128]; -} BeamformerLiveImagingParameters; - -typedef struct { - v2 focal_vectors[BeamformerMaxChannelCount]; - i16 sparse_elements[BeamformerMaxChannelCount]; - u16 transmit_receive_orientations[BeamformerMaxChannelCount]; -} BeamformerDASArrayParameters; - -typedef struct { - str8 display; - str8 string; - str8 description; - BeamformerPanelFlags flags; -} BeamformerPanelInfo; - -typedef struct { - str8 string; - u64 tree_node; - u64 window; - u64 frame; - u64 frame_view; - u64 split_axis; - u64 split_left_tree; - u64 split_right_tree; - u64 drop_target_tree; - u64 drop_child_index; -} BeamformerRegisters; - -typedef struct { - str8 string; - str8 display; - str8 description; -} BeamformerCommandInfo; - -typedef union { - BeamformerDecodeBakeParameters Decode; - BeamformerFilterBakeParameters Filter; - BeamformerDASBakeParameters DAS; - BeamformerReshapeBakeParameters Reshape; -} BeamformerShaderBakeParameters; - -read_only global u8 beamformer_data_kind_element_size[] = { - 2, - 2, - 4, - 4, - 2, - 2, -}; - -read_only global u8 beamformer_data_kind_element_count[] = { - 1, - 2, - 1, - 2, - 1, - 2, -}; - -read_only global u8 beamformer_data_kind_byte_size[] = { - 2 * 1, - 2 * 2, - 4 * 1, - 4 * 2, - 2 * 1, - 2 * 2, -}; - -read_only global b8 beamformer_data_kind_complex[] = { - 0, - 1, - 0, - 1, - 0, - 1, -}; - -read_only global s8 beamformer_data_kind_glsl_type[] = { - s8_comp("int16_t"), - s8_comp("i16vec2"), - s8_comp("float32_t"), - s8_comp("f32vec2"), - s8_comp("float16_t"), - s8_comp("f16vec2"), -}; - -read_only global s8 beamformer_data_kind_s8[] = { - s8_comp("Int16"), - s8_comp("Int16Complex"), - s8_comp("Float32"), - s8_comp("Float32Complex"), - s8_comp("Float16"), - s8_comp("Float16Complex"), -}; - -read_only global u8 beamformer_contrast_mode_samples[] = { - 1, - 3, -}; - -read_only global str8 beamformer_contrast_mode_strings[] = { - str8_comp("None"), - str8_comp("A1S2"), -}; - -read_only global str8 beamformer_view_plane_tag_strings[] = { - str8_comp("XZ"), - str8_comp("YZ"), - str8_comp("XY"), - str8_comp("Arbitrary"), -}; - -read_only global u8 beamformer_acquisition_kind_has_fixed_transmits[] = { - 1, - 0, - 1, - 0, - 0, - 0, - 1, - 1, - 0, - 0, - 0, - 0, - 0, -}; - -read_only global str8 beamformer_acquisition_kind_strings[] = { - str8_comp("FORCES"), - str8_comp("UFORCES"), - str8_comp("HERCULES"), - str8_comp("VLS"), - str8_comp("TPW"), - str8_comp("UHERCULES"), - str8_comp("RACES"), - str8_comp("EPIC-FORCES"), - str8_comp("EPIC-UFORCES"), - str8_comp("EPIC-UHERCULES"), - str8_comp("Flash"), - str8_comp("HERO-PA"), - str8_comp("ULM"), -}; - -read_only global s8 beamformer_filter_kind_strings[] = { - s8_comp("Kaiser"), - s8_comp("MatchedChirp"), -}; - -read_only global s8 beamformer_interpolation_mode_strings[] = { - s8_comp("Nearest"), - s8_comp("Linear"), - s8_comp("Cubic"), -}; - -read_only global s8 beamformer_shader_resource_kind_strings[] = { - s8_comp("Buffer"), -}; - -read_only global BeamformerPanelInfo beamformer_panel_infos[] = { - {str8_comp(""), str8_comp("nil"), str8_comp(""), (0*BeamformerPanelFlags_List)|(0*BeamformerPanelFlags_NeedsFrame)|(0*BeamformerPanelFlags_HasSettings)}, - {str8_comp(""), str8_comp("split"), str8_comp(""), (0*BeamformerPanelFlags_List)|(0*BeamformerPanelFlags_NeedsFrame)|(0*BeamformerPanelFlags_HasSettings)}, - {str8_comp(""), str8_comp("group"), str8_comp(""), (0*BeamformerPanelFlags_List)|(0*BeamformerPanelFlags_NeedsFrame)|(0*BeamformerPanelFlags_HasSettings)}, - {str8_comp("Compute Bar Graph"), str8_comp("compute_bar_graph"), str8_comp("Bar graph showing portions of compute occupied by each stage."), (1*BeamformerPanelFlags_List)|(0*BeamformerPanelFlags_NeedsFrame)|(0*BeamformerPanelFlags_HasSettings)}, - {str8_comp("Compute Stats"), str8_comp("compute_stats"), str8_comp("Average stats about beamforming computations."), (1*BeamformerPanelFlags_List)|(0*BeamformerPanelFlags_NeedsFrame)|(0*BeamformerPanelFlags_HasSettings)}, - {str8_comp("Frame View"), str8_comp("frame_view_live"), str8_comp("Latest frame with selected tag."), (1*BeamformerPanelFlags_List)|(0*BeamformerPanelFlags_NeedsFrame)|(1*BeamformerPanelFlags_HasSettings)}, - {str8_comp("Frame View (Copy)"), str8_comp("frame_view_copy"), str8_comp("Copy of an old frame. Useful for comparisons."), (0*BeamformerPanelFlags_List)|(1*BeamformerPanelFlags_NeedsFrame)|(1*BeamformerPanelFlags_HasSettings)}, - {str8_comp("3D X-Plane"), str8_comp("frame_view_xplane"), str8_comp("3D Cross Plane View."), (1*BeamformerPanelFlags_List)|(0*BeamformerPanelFlags_NeedsFrame)|(1*BeamformerPanelFlags_HasSettings)}, - {str8_comp("Live Controls"), str8_comp("live_controls"), str8_comp("Imaging system controls."), (1*BeamformerPanelFlags_List)|(0*BeamformerPanelFlags_NeedsFrame)|(0*BeamformerPanelFlags_HasSettings)}, - {str8_comp("Parameter Listing"), str8_comp("parameters_listing"), str8_comp("Editable parameter set used for beamforming."), (1*BeamformerPanelFlags_List)|(0*BeamformerPanelFlags_NeedsFrame)|(1*BeamformerPanelFlags_HasSettings)}, -}; - -#define beamformer_registers_init_literal \ - .string = beamformer_registers()->string, \ - .tree_node = beamformer_registers()->tree_node, \ - .window = beamformer_registers()->window, \ - .frame = beamformer_registers()->frame, \ - .frame_view = beamformer_registers()->frame_view, \ - .split_axis = beamformer_registers()->split_axis, \ - .split_left_tree = beamformer_registers()->split_left_tree, \ - .split_right_tree = beamformer_registers()->split_right_tree, \ - .drop_target_tree = beamformer_registers()->drop_target_tree, \ - .drop_child_index = beamformer_registers()->drop_child_index, \ - -read_only global BeamformerCommandInfo beamformer_command_infos[] = { - {0}, - {str8_comp("close_tab"), str8_comp("Close Tab"), str8_comp("Closes currently active tab.")}, - {str8_comp("focus_tab"), str8_comp("Focus Tab"), str8_comp("Focus the currently selected tab in its group.")}, - {str8_comp("move_tab"), str8_comp("Move Tab"), str8_comp("Moves an exisiting tab to a different group/split.")}, - {str8_comp("open_tab"), str8_comp("Open Tab"), str8_comp("Opens a new tab with a specified view.")}, - {str8_comp("split_tree"), str8_comp("Split Tree"), str8_comp("Splits the UI into two new splits.")}, -}; - -read_only global s8 beamformer_shader_names[] = { - s8_comp("Decode"), - s8_comp("Filter"), - s8_comp("Demodulate"), - s8_comp("DAS"), - s8_comp("Sum"), - s8_comp("MinMax"), - s8_comp("Hilbert"), - s8_comp("CoherencyWeighting"), - s8_comp("Reshape"), - s8_comp("RenderBeamformed"), -}; - -read_only global BeamformerShaderKind beamformer_reloadable_shader_kinds[] = { - BeamformerShaderKind_Decode, - BeamformerShaderKind_Filter, - BeamformerShaderKind_DAS, - BeamformerShaderKind_Sum, - BeamformerShaderKind_MinMax, - BeamformerShaderKind_CoherencyWeighting, - BeamformerShaderKind_Reshape, - BeamformerShaderKind_RenderBeamformed, -}; - -read_only global s8 *beamformer_reloadable_shader_files[] = { - (s8 []){s8_comp("decode.glsl")}, - (s8 []){s8_comp("filter.glsl")}, - (s8 []){s8_comp("das.glsl")}, - (s8 []){s8_comp("sum.glsl")}, - (s8 []){s8_comp("min_max.glsl")}, - (s8 []){s8_comp("coherency_weighting.glsl")}, - (s8 []){s8_comp("reshape.glsl")}, - (s8 []){s8_comp("render_3d.vert.glsl"), s8_comp("render_3d.frag.glsl")}, -}; - -read_only global i32 beamformer_shader_reloadable_index_by_shader[] = { - 0, - 1, - 1, - 2, - 3, - 4, - -1, - 5, - 6, - 7, -}; - -read_only global i32 beamformer_reloadable_compute_shader_info_indices[] = { - 0, - 1, - 2, - 3, - 4, -}; - -read_only global i32 beamformer_reloadable_compute_helpers_shader_info_indices[] = { - 5, - 6, -}; - -read_only global i32 beamformer_reloadable_render_shader_info_indices[] = { - 7, -}; - -read_only global s8 beamformer_shader_global_header_strings[] = { - s8_comp("" - "#define DecodeMode_None 0\n" - "#define DecodeMode_Hadamard 1\n" - "\n"), - s8_comp("" - "layout(push_constant, std430) uniform PushConstants {\n" - " uint64_t hadamard_buffer;\n" - " uint64_t rf_buffer;\n" - " uint64_t output_buffer;\n" - "};\n" - "\n"), - s8_comp("" - "#define ShaderBufferSlot_BeamformedData 0\n" - "#define ShaderBufferSlot_PingPong 1\n" - "\n"), - s8_comp("" - "#define ShaderResourceKind_Buffer 0\n" - "\n"), - s8_comp("" - "layout(push_constant, std430) uniform PushConstants {\n" - " uint64_t input_data;\n" - " uint64_t filter_coefficients;\n" - " uint32_t output_element_offset;\n" - "};\n" - "\n"), - s8_comp("#define MaxChannelCount (256)\n\n"), - s8_comp("" - "#define AcquisitionKind_FORCES 0\n" - "#define AcquisitionKind_UFORCES 1\n" - "#define AcquisitionKind_HERCULES 2\n" - "#define AcquisitionKind_RCA_VLS 3\n" - "#define AcquisitionKind_RCA_TPW 4\n" - "#define AcquisitionKind_UHERCULES 5\n" - "#define AcquisitionKind_RACES 6\n" - "#define AcquisitionKind_EPIC_FORCES 7\n" - "#define AcquisitionKind_EPIC_UFORCES 8\n" - "#define AcquisitionKind_EPIC_UHERCULES 9\n" - "#define AcquisitionKind_Flash 10\n" - "#define AcquisitionKind_HERO_PA 11\n" - "#define AcquisitionKind_ULM 12\n" - "\n"), - s8_comp("" - "#define InterpolationMode_Nearest 0\n" - "#define InterpolationMode_Linear 1\n" - "#define InterpolationMode_Cubic 2\n" - "\n"), - s8_comp("" - "#define RCAOrientation_None 0\n" - "#define RCAOrientation_Rows 1\n" - "#define RCAOrientation_Columns 2\n" - "\n"), - s8_comp("" - "struct DASArrayParameters {\n" - " f32vec2 focal_vectors[MaxChannelCount];\n" - " int16_t sparse_elements[MaxChannelCount];\n" - " uint16_t transmit_receive_orientations[MaxChannelCount];\n" - "};\n" - "\n"), - s8_comp("" - "layout(push_constant, std430) uniform PushConstants {\n" - " f32mat4 xdc_transform;\n" - " f32mat4 voxel_transform;\n" - " f32vec2 xdc_element_pitch;\n" - " uint64_t array_parameters;\n" - " uint64_t output_frame;\n" - " uint64_t incoherent_frame;\n" - " uint32_t rf_element_offset;\n" - " uint32_t output_size_x;\n" - " uint32_t output_size_y;\n" - " uint32_t output_size_z;\n" - " uint32_t cycle_t;\n" - " int32_t channel_offset;\n" - "};\n" - "\n"), - s8_comp("" - "layout(push_constant, std430) uniform PushConstants {\n" - " uint64_t output_data;\n" - " uint64_t input_data;\n" - " uint32_t image_elements;\n" - " float32_t scale;\n" - "};\n" - "\n"), - s8_comp("" - "layout(push_constant, std430) uniform PushConstants {\n" - " uint64_t left_side_buffer;\n" - " uint64_t right_side_buffer;\n" - " float32_t scale;\n" - " uint32_t output_size_x;\n" - " uint32_t output_size_y;\n" - " uint32_t output_size_z;\n" - "};\n" - "\n"), - s8_comp("" - "layout(push_constant, std430) uniform PushConstants {\n" - " uint64_t output_buffer;\n" - " uint64_t left_input_buffer;\n" - " uint64_t right_input_buffer;\n" - "};\n" - "\n"), - s8_comp("" - "layout(push_constant, std430) uniform PushConstants {\n" - " f32mat4 mvp_matrix;\n" - " uint64_t positions;\n" - " uint64_t normals;\n" - " f32vec4 bounding_box_colour;\n" - " float32_t bounding_box_fraction;\n" - " float32_t db_cutoff;\n" - " float32_t threshold;\n" - " float32_t gamma;\n" - " uint64_t input_data;\n" - " uint32_t input_size_x;\n" - " uint32_t input_size_y;\n" - " uint32_t input_size_z;\n" - " uint32_t data_kind;\n" - "};\n" - "\n"), -}; - -read_only global b8 beamformer_shader_has_primitive[] = { - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 1, -}; - -read_only global b8 beamformer_shader_primitive_is_vertex[] = { - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 1, -}; - -read_only global i32 *beamformer_shader_header_vectors[] = { - (i32 []){0, 1}, - (i32 []){2, 3, 4}, - (i32 []){5, 6, 7, 8, 2, 3, 9, 10}, - (i32 []){11}, - 0, - (i32 []){12}, - (i32 []){13}, - (i32 []){14}, -}; - -read_only global i32 beamformer_shader_header_vector_lengths[] = { - 2, - 3, - 8, - 1, - 0, - 1, - 1, - 1, -}; - -read_only global s8 *beamformer_shader_bake_parameter_names[] = { - (s8 []){ - s8_comp("UseSharedMemory"), - s8_comp("DecodeMode"), - s8_comp("OutputChannelStride"), - s8_comp("OutputSampleStride"), - s8_comp("OutputTransmitStride"), - s8_comp("ToProcess"), - s8_comp("TransmitCount"), - s8_comp("ChunkChannelCount"), - s8_comp("CooperativeMatrix"), - s8_comp("CooperativeMatrixM"), - s8_comp("CooperativeMatrixN"), - s8_comp("CooperativeMatrixK"), - }, - (s8 []){ - s8_comp("Demodulate"), - s8_comp("ComplexFilter"), - s8_comp("DecimationRate"), - s8_comp("FilterLength"), - s8_comp("InputChannelStride"), - s8_comp("InputSampleStride"), - s8_comp("InputTransmitStride"), - s8_comp("OutputChannelStride"), - s8_comp("OutputSampleStride"), - s8_comp("OutputTransmitStride"), - s8_comp("SampleCount"), - s8_comp("BatchSampleCount"), - s8_comp("DemodulationFrequency"), - s8_comp("SamplingFrequency"), - }, - (s8 []){ - s8_comp("CoherencyWeighting"), - s8_comp("SingleFocus"), - s8_comp("SingleOrientation"), - s8_comp("Sparse"), - s8_comp("AcquisitionCount"), - s8_comp("AcquisitionKind"), - s8_comp("ChannelCount"), - s8_comp("ChunkChannelCount"), - s8_comp("InterpolationMode"), - s8_comp("SampleCount"), - s8_comp("TransmitReceiveOrientation"), - s8_comp("DemodulationFrequency"), - s8_comp("FNumber"), - s8_comp("FocusDepth"), - s8_comp("SamplingFrequency"), - s8_comp("SpeedOfSound"), - s8_comp("TimeOffset"), - s8_comp("TransmitAngle"), - }, - 0, - 0, - 0, - (s8 []){ - s8_comp("SizeX"), - s8_comp("SizeY"), - s8_comp("SizeZ"), - s8_comp("InputStrideX"), - s8_comp("InputStrideY"), - s8_comp("InputStrideZ"), - s8_comp("OutputStrideX"), - s8_comp("OutputStrideY"), - s8_comp("OutputStrideZ"), - s8_comp("Interleave"), - s8_comp("Deinterleave"), - }, - 0, -}; - -read_only global u32 beamformer_shader_bake_parameter_float_bits[] = { - 0x00000000UL, - 0x00003000UL, - 0x0003f800UL, - 0x00000000UL, - 0x00000000UL, - 0x00000000UL, - 0x00000000UL, - 0x00000000UL, -}; - -read_only global u8 beamformer_shader_bake_parameter_counts[] = { - 12, - 14, - 18, - 0, - 0, - 0, - 11, - 0, -}; - -read_only global u8 beamformer_shader_push_constant_sizes[] = { - sizeof(BeamformerDecodePushConstants), - sizeof(BeamformerFilterPushConstants), - sizeof(BeamformerDASPushConstants), - sizeof(BeamformerSumPushConstants), - 0, - sizeof(BeamformerCoherencyWeightingPushConstants), - sizeof(BeamformerReshapePushConstants), - sizeof(BeamformerRenderBeamformedPushConstants), -}; - diff --git a/generated/beamformer_core.c b/generated/beamformer_core.c @@ -0,0 +1,108 @@ +/* See LICENSE for license details. */ + +// GENERATED CODE + +typedef enum { + BeamformerPanelKind_Nil = 0, + BeamformerPanelKind_Split = 1, + BeamformerPanelKind_TabGroup = 2, + BeamformerPanelKind_ComputeBarGraph = 3, + BeamformerPanelKind_ComputeStats = 4, + BeamformerPanelKind_FrameViewLive = 5, + BeamformerPanelKind_FrameViewCopy = 6, + BeamformerPanelKind_FrameViewXPlane = 7, + BeamformerPanelKind_LiveImagingControls = 8, + BeamformerPanelKind_ParameterListing = 9, + BeamformerPanelKind_Count, +} BeamformerPanelKind; + +typedef enum { + BeamformerRegisterSlot_String = 0, + BeamformerRegisterSlot_TreeNode = 1, + BeamformerRegisterSlot_Window = 2, + BeamformerRegisterSlot_Frame = 3, + BeamformerRegisterSlot_FrameView = 4, + BeamformerRegisterSlot_SplitAxis = 5, + BeamformerRegisterSlot_SplitLeftTree = 6, + BeamformerRegisterSlot_SplitRightTree = 7, + BeamformerRegisterSlot_DropTargetTree = 8, + BeamformerRegisterSlot_DropChildIndex = 9, + BeamformerRegisterSlot_Count, +} BeamformerRegisterSlot; + +typedef enum { + BeamformerCommandKind_Nil = 0, + BeamformerCommandKind_CloseTab = 1, + BeamformerCommandKind_FocusTab = 2, + BeamformerCommandKind_MoveTab = 3, + BeamformerCommandKind_OpenTab = 4, + BeamformerCommandKind_SplitTree = 5, + BeamformerCommandKind_Count, +} BeamformerCommandKind; + +typedef enum { + BeamformerPanelFlags_List = 1 << 0, + BeamformerPanelFlags_NeedsFrame = 1 << 1, + BeamformerPanelFlags_HasSettings = 1 << 2, +} BeamformerPanelFlags; + +typedef struct { + str8 display; + str8 string; + str8 description; + BeamformerPanelFlags flags; +} BeamformerPanelInfo; + +typedef struct { + str8 string; + u64 tree_node; + u64 window; + u64 frame; + u64 frame_view; + u64 split_axis; + u64 split_left_tree; + u64 split_right_tree; + u64 drop_target_tree; + u64 drop_child_index; +} BeamformerRegisters; + +typedef struct { + str8 string; + str8 display; + str8 description; +} BeamformerCommandInfo; + +read_only global BeamformerPanelInfo beamformer_panel_infos[] = { + {str8_comp(""), str8_comp("nil"), str8_comp(""), (0*BeamformerPanelFlags_List)|(0*BeamformerPanelFlags_NeedsFrame)|(0*BeamformerPanelFlags_HasSettings)}, + {str8_comp(""), str8_comp("split"), str8_comp(""), (0*BeamformerPanelFlags_List)|(0*BeamformerPanelFlags_NeedsFrame)|(0*BeamformerPanelFlags_HasSettings)}, + {str8_comp(""), str8_comp("group"), str8_comp(""), (0*BeamformerPanelFlags_List)|(0*BeamformerPanelFlags_NeedsFrame)|(0*BeamformerPanelFlags_HasSettings)}, + {str8_comp("Compute Bar Graph"), str8_comp("compute_bar_graph"), str8_comp("Bar graph showing portions of compute occupied by each stage."), (1*BeamformerPanelFlags_List)|(0*BeamformerPanelFlags_NeedsFrame)|(0*BeamformerPanelFlags_HasSettings)}, + {str8_comp("Compute Stats"), str8_comp("compute_stats"), str8_comp("Average stats about beamforming computations."), (1*BeamformerPanelFlags_List)|(0*BeamformerPanelFlags_NeedsFrame)|(0*BeamformerPanelFlags_HasSettings)}, + {str8_comp("Frame View"), str8_comp("frame_view_live"), str8_comp("Latest frame with selected tag."), (1*BeamformerPanelFlags_List)|(0*BeamformerPanelFlags_NeedsFrame)|(1*BeamformerPanelFlags_HasSettings)}, + {str8_comp("Frame View (Copy)"), str8_comp("frame_view_copy"), str8_comp("Copy of an old frame. Useful for comparisons."), (0*BeamformerPanelFlags_List)|(1*BeamformerPanelFlags_NeedsFrame)|(1*BeamformerPanelFlags_HasSettings)}, + {str8_comp("3D X-Plane"), str8_comp("frame_view_xplane"), str8_comp("3D Cross Plane View."), (1*BeamformerPanelFlags_List)|(0*BeamformerPanelFlags_NeedsFrame)|(1*BeamformerPanelFlags_HasSettings)}, + {str8_comp("Live Controls"), str8_comp("live_controls"), str8_comp("Imaging system controls."), (1*BeamformerPanelFlags_List)|(0*BeamformerPanelFlags_NeedsFrame)|(0*BeamformerPanelFlags_HasSettings)}, + {str8_comp("Parameter Listing"), str8_comp("parameters_listing"), str8_comp("Editable parameter set used for beamforming."), (1*BeamformerPanelFlags_List)|(0*BeamformerPanelFlags_NeedsFrame)|(1*BeamformerPanelFlags_HasSettings)}, +}; + +#define beamformer_registers_init_literal \ + .string = beamformer_registers()->string, \ + .tree_node = beamformer_registers()->tree_node, \ + .window = beamformer_registers()->window, \ + .frame = beamformer_registers()->frame, \ + .frame_view = beamformer_registers()->frame_view, \ + .split_axis = beamformer_registers()->split_axis, \ + .split_left_tree = beamformer_registers()->split_left_tree, \ + .split_right_tree = beamformer_registers()->split_right_tree, \ + .drop_target_tree = beamformer_registers()->drop_target_tree, \ + .drop_child_index = beamformer_registers()->drop_child_index, \ + +read_only global BeamformerCommandInfo beamformer_command_infos[] = { + {0}, + {str8_comp("close_tab"), str8_comp("Close Tab"), str8_comp("Closes currently active tab.")}, + {str8_comp("focus_tab"), str8_comp("Focus Tab"), str8_comp("Focus the currently selected tab in its group.")}, + {str8_comp("move_tab"), str8_comp("Move Tab"), str8_comp("Moves an exisiting tab to a different group/split.")}, + {str8_comp("open_tab"), str8_comp("Open Tab"), str8_comp("Opens a new tab with a specified view.")}, + {str8_comp("split_tree"), str8_comp("Split Tree"), str8_comp("Splits the UI into two new splits.")}, +}; + diff --git a/lib/ogl_beamformer_lib.c b/lib/ogl_beamformer_lib.c @@ -7,7 +7,7 @@ #include "../util.h" -#include "../generated/beamformer.meta.c" +#include "../generated/beamformer.c" #include "ogl_beamformer_lib_base.h" #if OS_LINUX