Commit: 40c417baa84aaaac992fa0c0ac6c8aa75b02ee9a
Parent: 8abf3591606238d6cff40e3e64163174f8e69b38
Author: Randy Palamar
Date: Sat, 28 Jun 2025 19:37:25 -0600
core: naming cleanup
Diffstat:
6 files changed, 75 insertions(+), 64 deletions(-)
diff --git a/beamformer.c b/beamformer.c
@@ -160,7 +160,7 @@ push_compute_timing_info(ComputeTimingTable *t, ComputeTimingInfo info)
}
function b32
-fill_frame_compute_work(BeamformerCtx *ctx, BeamformWork *work, ImagePlaneTag plane)
+fill_frame_compute_work(BeamformerCtx *ctx, BeamformWork *work, BeamformerViewPlaneTag plane)
{
b32 result = 0;
if (work) {
@@ -171,8 +171,8 @@ fill_frame_compute_work(BeamformerCtx *ctx, BeamformWork *work, ImagePlaneTag pl
work->lock = BeamformerSharedMemoryLockKind_DispatchCompute;
work->frame = ctx->beamform_frames + frame_index;
work->frame->ready_to_present = 0;
- work->frame->frame.id = frame_id;
- work->frame->image_plane_tag = plane;
+ work->frame->view_plane_tag = plane;
+ work->frame->frame.id = frame_id;
}
return result;
}
@@ -186,7 +186,7 @@ do_sum_shader(ComputeShaderCtx *cs, u32 *in_textures, u32 in_texture_count, f32
glMemoryBarrier(GL_TEXTURE_UPDATE_BARRIER_BIT);
glBindImageTexture(0, out_texture, 0, GL_TRUE, 0, GL_READ_WRITE, GL_RG32F);
- glProgramUniform1f(cs->programs[BeamformerShaderKind_Sum], CS_SUM_PRESCALE_UNIFORM_LOC, in_scale);
+ glProgramUniform1f(cs->programs[BeamformerShaderKind_Sum], SUM_PRESCALE_UNIFORM_LOC, in_scale);
for (u32 i = 0; i < in_texture_count; i++) {
glBindImageTexture(1, in_textures[i], 0, GL_TRUE, 0, GL_READ_ONLY, GL_RG32F);
glDispatchCompute(ORONE(out_data_dim.x / 32),
@@ -325,7 +325,7 @@ do_compute_shader(BeamformerCtx *ctx, Arena arena, BeamformComputeFrame *frame,
for (u32 i = 1; i < frame->frame.mips; i++) {
glBindImageTexture(0, texture, i - 1, GL_TRUE, 0, GL_READ_ONLY, GL_RG32F);
glBindImageTexture(1, texture, i - 0, GL_TRUE, 0, GL_WRITE_ONLY, GL_RG32F);
- glProgramUniform1i(csctx->programs[shader], CS_MIN_MAX_MIPS_LEVEL_UNIFORM_LOC, i);
+ glProgramUniform1i(csctx->programs[shader], MIN_MAX_MIPS_LEVEL_UNIFORM_LOC, i);
u32 width = frame->frame.dim.x >> i;
u32 height = frame->frame.dim.y >> i;
@@ -440,11 +440,11 @@ shader_text_with_header(ShaderReloadContext *ctx, OS *os, Arena *arena)
#undef X
}break;
case BeamformerShaderKind_MinMax:{
- stream_append_s8(&sb, s8("layout(location = " str(CS_MIN_MAX_MIPS_LEVEL_UNIFORM_LOC)
+ stream_append_s8(&sb, s8("layout(location = " str(MIN_MAX_MIPS_LEVEL_UNIFORM_LOC)
") uniform int u_mip_map;\n\n"));
}break;
case BeamformerShaderKind_Sum:{
- stream_append_s8(&sb, s8("layout(location = " str(CS_SUM_PRESCALE_UNIFORM_LOC)
+ stream_append_s8(&sb, s8("layout(location = " str(SUM_PRESCALE_UNIFORM_LOC)
") uniform float u_sum_prescale = 1.0;\n\n"));
}break;
default:{}break;
@@ -530,7 +530,7 @@ complete_queue(BeamformerCtx *ctx, BeamformWorkQueue *q, Arena arena, iptr gl_co
if (success && ctx->csctx.raw_data_ssbo) {
/* TODO(rnp): this check seems off */
can_commit = 0;
- fill_frame_compute_work(ctx, work, ctx->latest_frame->image_plane_tag);
+ fill_frame_compute_work(ctx, work, ctx->latest_frame->view_plane_tag);
}
}break;
case BeamformerWorkKind_ExportBuffer:{
@@ -686,7 +686,7 @@ complete_queue(BeamformerCtx *ctx, BeamformWorkQueue *q, Arena arena, iptr gl_co
frame->ready_to_present = 1;
if (did_sum_shader) {
u32 aframe_index = (ctx->averaged_frame_index % countof(ctx->averaged_frames));
- ctx->averaged_frames[aframe_index].image_plane_tag = frame->image_plane_tag;
+ ctx->averaged_frames[aframe_index].view_plane_tag = frame->view_plane_tag;
ctx->averaged_frames[aframe_index].ready_to_present = 1;
atomic_add_u32(&ctx->averaged_frame_index, 1);
atomic_store_u64((u64 *)&ctx->latest_frame, (u64)(ctx->averaged_frames + aframe_index));
@@ -831,7 +831,7 @@ DEBUG_EXPORT BEAMFORMER_FRAME_STEP_FN(beamformer_frame_step)
if (sm->locks[BeamformerSharedMemoryLockKind_DispatchCompute] && ctx->os.compute_worker.asleep) {
if (sm->start_compute_from_main) {
BeamformWork *work = beamform_work_queue_push(ctx->beamform_work_queue);
- ImagePlaneTag tag = ctx->latest_frame->image_plane_tag;
+ BeamformerViewPlaneTag tag = ctx->latest_frame->view_plane_tag;
if (fill_frame_compute_work(ctx, work, tag))
beamform_work_queue_push_commit(ctx->beamform_work_queue);
atomic_store_u32(&sm->start_compute_from_main, 0);
@@ -840,7 +840,7 @@ DEBUG_EXPORT BEAMFORMER_FRAME_STEP_FN(beamformer_frame_step)
}
draw_ui(ctx, input, ctx->latest_frame->ready_to_present ? &ctx->latest_frame->frame : 0,
- ctx->latest_frame->image_plane_tag);
+ ctx->latest_frame->view_plane_tag);
ctx->frame_view_render_context.updated = 0;
diff --git a/beamformer.h b/beamformer.h
@@ -73,8 +73,6 @@ typedef struct {
#include "beamformer_parameters.h"
#include "beamformer_work_queue.h"
-#define CS_MIN_MAX_MIPS_LEVEL_UNIFORM_LOC 1
-#define CS_SUM_PRESCALE_UNIFORM_LOC 1
typedef struct {
u32 programs[BeamformerShaderKind_ComputeCount];
@@ -163,8 +161,8 @@ typedef struct BeamformFrame {
struct BeamformComputeFrame {
BeamformFrame frame;
- ImagePlaneTag image_plane_tag;
b32 ready_to_present;
+ BeamformerViewPlaneTag view_plane_tag;
};
#define GL_PARAMETERS \
diff --git a/beamformer_parameters.h b/beamformer_parameters.h
@@ -42,18 +42,18 @@ typedef struct {
X(HADAMARD, 1, "Hadamard")
/* X(type, id, pretty name) */
-#define IMAGE_PLANE_TAGS \
+#define BEAMFORMER_VIEW_PLANE_TAG_LIST \
X(XZ, 0, "XZ") \
X(YZ, 1, "YZ") \
X(XY, 2, "XY") \
- X(ARBITRARY, 3, "Arbitrary")
+ X(Arbitrary, 3, "Arbitrary")
typedef enum {
- #define X(type, id, pretty) IPT_ ##type = id,
- IMAGE_PLANE_TAGS
+ #define X(type, id, pretty) BeamformerViewPlaneTag_##type = id,
+ BEAMFORMER_VIEW_PLANE_TAG_LIST
#undef X
- IPT_LAST
-} ImagePlaneTag;
+ BeamformerViewPlaneTag_Count,
+} BeamformerViewPlaneTag;
/* X(type, id, pretty name, fixed transmits) */
#define DAS_TYPES \
@@ -82,6 +82,9 @@ typedef enum {
#define DAS_VOXEL_OFFSET_UNIFORM_LOC 2
#define DAS_CYCLE_T_UNIFORM_LOC 3
+#define MIN_MAX_MIPS_LEVEL_UNIFORM_LOC 1
+#define SUM_PRESCALE_UNIFORM_LOC 1
+
#define MAX_BEAMFORMED_SAVED_FRAMES 16
#define MAX_COMPUTE_SHADER_STAGES 16
diff --git a/beamformer_work_queue.h b/beamformer_work_queue.h
@@ -62,7 +62,7 @@ typedef struct {
BeamformerUploadContext upload_context;
BeamformerExportContext export_context;
ShaderReloadContext *shader_reload_context;
- ImagePlaneTag compute_indirect_plane;
+ BeamformerViewPlaneTag compute_indirect_plane;
void *generic;
};
BeamformerSharedMemoryLockKind lock;
diff --git a/helpers/ogl_beamformer_lib.c b/helpers/ogl_beamformer_lib.c
@@ -264,7 +264,7 @@ beamformer_push_data_with_compute(void *data, u32 data_size, u32 image_plane_tag
{
b32 result = beamformer_push_data_base(data, data_size, timeout_ms, 0);
if (result) {
- result = image_plane_tag < IPT_LAST;
+ result = image_plane_tag < BeamformerViewPlaneTag_Count;
if (result) {
BeamformWork *work = try_push_work_queue();
result = work != 0;
diff --git a/ui.c b/ui.c
@@ -261,10 +261,11 @@ struct Variable {
};
typedef enum {
- FVT_LATEST,
- FVT_INDEXED,
- FVT_COPY,
-} BeamformerFrameViewType;
+ BeamformerFrameViewKind_Latest,
+ BeamformerFrameViewKind_Indexed,
+ BeamformerFrameViewKind_Copy,
+ BeamformerFrameViewKind_3DXPlane,
+} BeamformerFrameViewKind;
typedef struct BeamformerFrameView {
Variable lateral_scale_bar;
@@ -297,7 +298,7 @@ typedef struct BeamformerFrameView {
u32 texture_mipmaps;
u32 texture;
- BeamformerFrameViewType type;
+ BeamformerFrameViewKind kind;
b32 needs_update;
} BeamformerFrameView;
@@ -348,7 +349,7 @@ struct BeamformerUI {
v2_sll *scale_bar_savepoint_freelist;
- BeamformFrame *latest_plane[IPT_LAST + 1];
+ BeamformFrame *latest_plane[BeamformerViewPlaneTag_Count + 1];
BeamformerUIParameters params;
b32 flush_params;
@@ -785,7 +786,7 @@ ui_variable_free(BeamformerUI *ui, Variable *var)
if (var->type == VT_BEAMFORMER_FRAME_VIEW) {
/* TODO(rnp): instead there should be a way of linking these up */
BeamformerFrameView *bv = var->generic;
- if (bv->type == FVT_COPY) {
+ if (bv->kind == BeamformerFrameViewKind_Copy) {
glDeleteTextures(1, &bv->frame->texture);
bv->frame->texture = 0;
SLLPush(bv->frame, ui->frame_freelist);
@@ -1035,7 +1036,7 @@ add_beamformer_parameters_view(Variable *parent, BeamformerCtx *ctx)
function Variable *
add_beamformer_frame_view(BeamformerUI *ui, Variable *parent, Arena *arena,
- BeamformerFrameViewType type, b32 closable)
+ BeamformerFrameViewKind kind, b32 closable)
{
/* TODO(rnp): this can be always closable once we have a way of opening new views */
Variable *result = add_ui_view(ui, parent, arena, s8(""), UIViewFlag_CustomText, 1, closable);
@@ -1048,7 +1049,7 @@ add_beamformer_frame_view(BeamformerUI *ui, Variable *parent, Arena *arena,
DLLPushDown(bv, ui->views);
var->generic = bv;
- bv->type = type;
+ bv->kind = kind;
fill_variable(&bv->dynamic_range, var, s8("Dynamic Range:"), V_INPUT|V_TEXT|V_UPDATE_VIEW,
VT_F32, ui->small_font);
@@ -1080,20 +1081,20 @@ add_beamformer_frame_view(BeamformerUI *ui, Variable *parent, Arena *arena,
FRAME_VIEW_BUTTONS
#undef X
- switch (type) {
- case FVT_LATEST: {
+ switch (kind) {
+ case BeamformerFrameViewKind_Latest:{
#define X(_type, _id, pretty) s8_comp(pretty),
- read_only local_persist s8 labels[] = {IMAGE_PLANE_TAGS s8_comp("Any")};
+ read_only local_persist s8 labels[] = {BEAMFORMER_VIEW_PLANE_TAG_LIST s8_comp("Any")};
#undef X
bv->cycler = add_variable_cycler(ui, menu, arena, 0, ui->small_font, s8("Live:"),
&bv->cycler_state, labels, countof(labels));
- bv->cycler_state = IPT_LAST;
- } break;
- case FVT_INDEXED: {
+ bv->cycler_state = BeamformerViewPlaneTag_Count;
+ }break;
+ case BeamformerFrameViewKind_Indexed:{
bv->cycler = add_variable_cycler(ui, menu, arena, 0, ui->small_font, s8("Index:"),
&bv->cycler_state, 0, MAX_BEAMFORMED_SAVED_FRAMES);
- } break;
- default: break;
+ }break;
+ default:{}break;
}
bv->log_scale = add_variable(ui, menu, arena, s8("Log Scale"),
@@ -1181,11 +1182,12 @@ function void
ui_add_live_frame_view(BeamformerUI *ui, Variable *view, RegionSplitDirection direction)
{
Variable *region = view->parent;
- ASSERT(region->type == VT_UI_REGION_SPLIT);
- ASSERT(view->type == VT_UI_VIEW);
+ assert(region->type == VT_UI_REGION_SPLIT);
+ assert(view->type == VT_UI_VIEW);
Variable *new_region = ui_split_region(ui, region, view, direction);
- new_region->region_split.right = add_beamformer_frame_view(ui, new_region, &ui->arena, FVT_LATEST, 1);
+ new_region->region_split.right = add_beamformer_frame_view(ui, new_region, &ui->arena,
+ BeamformerFrameViewKind_Latest, 1);
ui_fill_live_frame_view(ui, new_region->region_split.right->group.first->generic);
}
@@ -1194,8 +1196,8 @@ function void
ui_copy_frame(BeamformerUI *ui, Variable *view, RegionSplitDirection direction)
{
Variable *region = view->parent;
- ASSERT(region->type == VT_UI_REGION_SPLIT);
- ASSERT(view->type == VT_UI_VIEW);
+ assert(region->type == VT_UI_REGION_SPLIT);
+ assert(view->type == VT_UI_VIEW);
BeamformerFrameView *old = view->group.first->generic;
/* TODO(rnp): hack; it would be better if this was unreachable with a 0 old->frame */
@@ -1203,7 +1205,8 @@ ui_copy_frame(BeamformerUI *ui, Variable *view, RegionSplitDirection direction)
return;
Variable *new_region = ui_split_region(ui, region, view, direction);
- new_region->region_split.right = add_beamformer_frame_view(ui, new_region, &ui->arena, FVT_COPY, 1);
+ new_region->region_split.right = add_beamformer_frame_view(ui, new_region, &ui->arena,
+ BeamformerFrameViewKind_Copy, 1);
BeamformerFrameView *bv = new_region->region_split.right->group.first->generic;
ScaleBar *lateral = &bv->lateral_scale_bar.scale_bar;
@@ -1241,7 +1244,7 @@ ui_copy_frame(BeamformerUI *ui, Variable *view, RegionSplitDirection direction)
function b32
view_update(BeamformerUI *ui, BeamformerFrameView *view)
{
- if (view->type == FVT_LATEST) {
+ if (view->kind == BeamformerFrameViewKind_Latest) {
u32 index = *view->cycler->cycler.state;
view->needs_update |= view->frame != ui->latest_plane[index];
view->frame = ui->latest_plane[index];
@@ -1255,7 +1258,7 @@ view_update(BeamformerUI *ui, BeamformerFrameView *view)
/* TODO(rnp): add method of setting a target size in frame view */
uv2 current = view->texture_dim;
uv2 target = {.w = ui->params.output_points[0], .h = ui->params.output_points[2]};
- if (view->type != FVT_COPY && !uv2_equal(current, target) && !uv2_equal(target, (uv2){0})) {
+ if (view->kind != BeamformerFrameViewKind_Copy && !uv2_equal(current, target) && !uv2_equal(target, (uv2){0})) {
resize_frame_view(view, target);
view->needs_update = 1;
}
@@ -1362,27 +1365,33 @@ push_custom_view_title(Stream *s, Variable *var)
stream_append_f64(s, 100 * *var->compute_progress_bar.progress, 100);
stream_append_byte(s, '%');
} break;
- case VT_BEAMFORMER_FRAME_VIEW: {
+ case VT_BEAMFORMER_FRAME_VIEW:{
BeamformerFrameView *bv = var->generic;
stream_append_s8(s, s8("Frame View"));
- switch (bv->type) {
- case FVT_COPY: stream_append_s8(s, s8(": Copy [")); break;
- case FVT_LATEST: {
+ switch (bv->kind) {
+ case BeamformerFrameViewKind_Copy:{ stream_append_s8(s, s8(": Copy [")); }break;
+ case BeamformerFrameViewKind_Latest:{
#define X(plane, id, pretty) s8_comp(": " pretty " ["),
- read_only local_persist s8 labels[IPT_LAST + 1] = {IMAGE_PLANE_TAGS s8_comp(": Live [")};
+ read_only local_persist s8 labels[BeamformerViewPlaneTag_Count + 1] = {
+ BEAMFORMER_VIEW_PLANE_TAG_LIST
+ s8_comp(": Live [")
+ };
#undef X
- stream_append_s8(s, labels[*bv->cycler->cycler.state % (IPT_LAST + 1)]);
- } break;
- case FVT_INDEXED: {
+ stream_append_s8(s, labels[*bv->cycler->cycler.state % (BeamformerViewPlaneTag_Count + 1)]);
+ }break;
+ case BeamformerFrameViewKind_Indexed:{
stream_append_s8(s, s8(": Index {"));
stream_append_u64(s, *bv->cycler->cycler.state % MAX_BEAMFORMED_SAVED_FRAMES);
stream_append_s8(s, s8("} ["));
- } break;
+ }break;
+ case BeamformerFrameViewKind_3DXPlane:{ stream_append_s8(s, s8(": 3D X-Plane")); }break;
}
- stream_append_hex_u64(s, bv->frame? bv->frame->id : 0);
- stream_append_byte(s, ']');
- } break;
- default: INVALID_CODE_PATH;
+ if (bv->kind != BeamformerFrameViewKind_3DXPlane) {
+ stream_append_hex_u64(s, bv->frame? bv->frame->id : 0);
+ stream_append_byte(s, ']');
+ }
+ }break;
+ InvalidDefaultCase;
}
return stream_to_s8(s);
}
@@ -3096,7 +3105,8 @@ ui_init(BeamformerCtx *ctx, Arena store)
RSD_HORIZONTAL, ui->font);
split->region_split.left = add_ui_split(ui, split, &ui->arena, s8(""), 0.475,
RSD_VERTICAL, ui->font);
- split->region_split.right = add_beamformer_frame_view(ui, split, &ui->arena, FVT_LATEST, 0);
+ split->region_split.right = add_beamformer_frame_view(ui, split, &ui->arena,
+ BeamformerFrameViewKind_Latest, 0);
ui_fill_live_frame_view(ui, split->region_split.right->view.child->generic);
@@ -3125,13 +3135,13 @@ validate_ui_parameters(BeamformerUIParameters *p)
}
function void
-draw_ui(BeamformerCtx *ctx, BeamformerInput *input, BeamformFrame *frame_to_draw, ImagePlaneTag frame_plane)
+draw_ui(BeamformerCtx *ctx, BeamformerInput *input, BeamformFrame *frame_to_draw, BeamformerViewPlaneTag frame_plane)
{
BeamformerUI *ui = ctx->ui;
BeamformerSharedMemory *sm = ctx->shared_memory.region;
- ui->latest_plane[IPT_LAST] = frame_to_draw;
- ui->latest_plane[frame_plane] = frame_to_draw;
+ ui->latest_plane[BeamformerViewPlaneTag_Count] = frame_to_draw;
+ ui->latest_plane[frame_plane] = frame_to_draw;
/* TODO(rnp): there should be a better way of detecting this */
if (ctx->ui_read_params) {