Commit: 4c026672a45a3742cdc02269e2939b62d930fa49
Parent: ccc040d84f9fda1e93ef10f71b56b55c34afb78a
Author: Randy Palamar
Date: Fri, 11 Jul 2025 20:56:09 -0600
build: enable more warnings and fix them
some of these were valid but mostly its just a bunch of compiler yapping
Diffstat:
21 files changed, 483 insertions(+), 475 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
@@ -30,8 +30,8 @@ jobs:
fail-fast: false
matrix:
include:
- - { sys: ucrt64, env: ucrt-x86_64, cc: "gcc" }
- - { sys: clang64, env: clang-x86_64, cc: "clang" }
+ - { sys: ucrt64, env: ucrt-x86_64, cc: "gcc", extra: "" }
+ - { sys: clang64, env: clang-x86_64, cc: "clang", extra: "-fms-extensions" }
defaults:
run:
shell: msys2 {0}
@@ -47,6 +47,6 @@ jobs:
- name: Build
run: |
- ${{matrix.cc}} -march=native -O3 build.c -Iexternal/include -o build && \
+ ${{matrix.cc}} -march=native -O3 ${{matrix.extra}} build.c -Iexternal/include -o build && \
./build --tests && \
./build --debug
diff --git a/.gitignore b/.gitignore
@@ -1,4 +1,5 @@
*
+!.github
!tests
!external
!helpers
diff --git a/beamformer.c b/beamformer.c
@@ -42,10 +42,10 @@ typedef struct {
u32 needed_frames;
} ComputeFrameIterator;
-function uv3
-make_valid_test_dim(u32 in[3])
+function iv3
+make_valid_test_dim(i32 in[3])
{
- uv3 result;
+ iv3 result;
result.E[0] = MAX(in[0], 1);
result.E[1] = MAX(in[1], 1);
result.E[2] = MAX(in[2], 1);
@@ -78,7 +78,7 @@ frame_next(ComputeFrameIterator *bfi)
}
function void
-alloc_beamform_frame(GLParams *gp, BeamformerFrame *out, uv3 out_dim, s8 name, Arena arena)
+alloc_beamform_frame(GLParams *gp, BeamformerFrame *out, iv3 out_dim, s8 name, Arena arena)
{
out->dim.x = MAX(1, out_dim.x);
out->dim.y = MAX(1, out_dim.y);
@@ -92,8 +92,8 @@ alloc_beamform_frame(GLParams *gp, BeamformerFrame *out, uv3 out_dim, s8 name, A
/* NOTE: allocate storage for beamformed output data;
* this is shared between compute and fragment shaders */
- u32 max_dim = MAX(out->dim.x, MAX(out->dim.y, out->dim.z));
- out->mips = ctz_u32(round_up_power_of_2(max_dim)) + 1;
+ u32 max_dim = (u32)MAX(out->dim.x, MAX(out->dim.y, out->dim.z));
+ out->mips = (i32)ctz_u32(round_up_power_of_2(max_dim)) + 1;
Stream label = arena_stream(arena);
stream_append_s8(&label, name);
@@ -123,19 +123,19 @@ alloc_shader_storage(BeamformerCtx *ctx, u32 rf_raw_size, Arena a)
glDeleteBuffers(ARRAY_COUNT(cs->rf_data_ssbos), cs->rf_data_ssbos);
glCreateBuffers(ARRAY_COUNT(cs->rf_data_ssbos), cs->rf_data_ssbos);
- i32 storage_flags = GL_DYNAMIC_STORAGE_BIT;
+ u32 storage_flags = GL_DYNAMIC_STORAGE_BIT;
glDeleteBuffers(1, &cs->raw_data_ssbo);
glCreateBuffers(1, &cs->raw_data_ssbo);
glNamedBufferStorage(cs->raw_data_ssbo, 2 * rf_raw_size, 0, storage_flags);
LABEL_GL_OBJECT(GL_BUFFER, cs->raw_data_ssbo, s8("Raw_RF_SSBO"));
- iz rf_decoded_size = 2 * sizeof(f32) * cs->dec_data_dim.x * cs->dec_data_dim.y * cs->dec_data_dim.z;
+ uz rf_decoded_size = 2 * sizeof(f32) * cs->dec_data_dim.x * cs->dec_data_dim.y * cs->dec_data_dim.z;
Stream label = arena_stream(a);
stream_append_s8(&label, s8("Decoded_RF_SSBO_"));
- u32 s_widx = label.widx;
- for (u32 i = 0; i < ARRAY_COUNT(cs->rf_data_ssbos); i++) {
- glNamedBufferStorage(cs->rf_data_ssbos[i], rf_decoded_size, 0, 0);
- stream_append_u64(&label, i);
+ i32 s_widx = label.widx;
+ for (i32 i = 0; i < countof(cs->rf_data_ssbos); i++) {
+ glNamedBufferStorage(cs->rf_data_ssbos[i], (iz)rf_decoded_size, 0, 0);
+ stream_append_i64(&label, i);
LABEL_GL_OBJECT(GL_BUFFER, cs->rf_data_ssbos[i], stream_to_s8(&label));
stream_reset(&label, s_widx);
}
@@ -144,7 +144,7 @@ alloc_shader_storage(BeamformerCtx *ctx, u32 rf_raw_size, Arena a)
ctx->cuda_lib.register_buffers(cs->rf_data_ssbos, countof(cs->rf_data_ssbos), cs->raw_data_ssbo);
ctx->cuda_lib.init(bp->rf_raw_dim, bp->dec_data_dim);
- u32 order = cs->dec_data_dim.z;
+ i32 order = (i32)cs->dec_data_dim.z;
i32 *hadamard = make_hadamard_transpose(&a, order);
if (hadamard) {
glDeleteTextures(1, &cs->hadamard_texture);
@@ -183,7 +183,7 @@ fill_frame_compute_work(BeamformerCtx *ctx, BeamformWork *work, BeamformerViewPl
function void
do_sum_shader(ComputeShaderCtx *cs, u32 *in_textures, u32 in_texture_count, f32 in_scale,
- u32 out_texture, uv3 out_data_dim)
+ u32 out_texture, iv3 out_data_dim)
{
/* NOTE: zero output before summing */
glClearTexImage(out_texture, 0, GL_RED, GL_FLOAT, 0);
@@ -193,16 +193,16 @@ do_sum_shader(ComputeShaderCtx *cs, u32 *in_textures, u32 in_texture_count, f32
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),
- ORONE(out_data_dim.y),
- ORONE(out_data_dim.z / 32));
+ glDispatchCompute(ORONE((u32)out_data_dim.x / 32u),
+ ORONE((u32)out_data_dim.y),
+ ORONE((u32)out_data_dim.z / 32u));
glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
}
}
struct compute_cursor {
iv3 cursor;
- iv3 dispatch;
+ uv3 dispatch;
iv3 target;
u32 points_per_dispatch;
u32 completed_points;
@@ -210,28 +210,28 @@ struct compute_cursor {
};
function struct compute_cursor
-start_compute_cursor(uv3 dim, u32 max_points)
+start_compute_cursor(iv3 dim, u32 max_points)
{
struct compute_cursor result = {0};
u32 invocations_per_dispatch = DAS_LOCAL_SIZE_X * DAS_LOCAL_SIZE_Y * DAS_LOCAL_SIZE_Z;
- result.dispatch.y = MIN(max_points / invocations_per_dispatch, ceil_f32((f32)dim.y / DAS_LOCAL_SIZE_Y));
+ result.dispatch.y = MIN(max_points / invocations_per_dispatch, (u32)ceil_f32((f32)dim.y / DAS_LOCAL_SIZE_Y));
u32 remaining = max_points / result.dispatch.y;
- result.dispatch.x = MIN(remaining / invocations_per_dispatch, ceil_f32((f32)dim.x / DAS_LOCAL_SIZE_X));
+ result.dispatch.x = MIN(remaining / invocations_per_dispatch, (u32)ceil_f32((f32)dim.x / DAS_LOCAL_SIZE_X));
result.dispatch.z = MIN(remaining / (invocations_per_dispatch * result.dispatch.x),
- ceil_f32((f32)dim.z / DAS_LOCAL_SIZE_Z));
+ (u32)ceil_f32((f32)dim.z / DAS_LOCAL_SIZE_Z));
- result.target.x = MAX(dim.x / result.dispatch.x / DAS_LOCAL_SIZE_X, 1);
- result.target.y = MAX(dim.y / result.dispatch.y / DAS_LOCAL_SIZE_Y, 1);
- result.target.z = MAX(dim.z / result.dispatch.z / DAS_LOCAL_SIZE_Z, 1);
+ result.target.x = MAX(dim.x / (i32)result.dispatch.x / DAS_LOCAL_SIZE_X, 1);
+ result.target.y = MAX(dim.y / (i32)result.dispatch.y / DAS_LOCAL_SIZE_Y, 1);
+ result.target.z = MAX(dim.z / (i32)result.dispatch.z / DAS_LOCAL_SIZE_Z, 1);
result.points_per_dispatch = 1;
result.points_per_dispatch *= result.dispatch.x * DAS_LOCAL_SIZE_X;
result.points_per_dispatch *= result.dispatch.y * DAS_LOCAL_SIZE_Y;
result.points_per_dispatch *= result.dispatch.z * DAS_LOCAL_SIZE_Z;
- result.total_points = dim.x * dim.y * dim.z;
+ result.total_points = (u32)(dim.x * dim.y * dim.z);
return result;
}
@@ -252,9 +252,9 @@ step_compute_cursor(struct compute_cursor *cursor)
cursor->completed_points += cursor->points_per_dispatch;
iv3 result = cursor->cursor;
- result.x *= cursor->dispatch.x * DAS_LOCAL_SIZE_X;
- result.y *= cursor->dispatch.y * DAS_LOCAL_SIZE_Y;
- result.z *= cursor->dispatch.z * DAS_LOCAL_SIZE_Z;
+ result.x *= (i32)cursor->dispatch.x * DAS_LOCAL_SIZE_X;
+ result.y *= (i32)cursor->dispatch.y * DAS_LOCAL_SIZE_Y;
+ result.z *= (i32)cursor->dispatch.z * DAS_LOCAL_SIZE_Z;
return result;
}
@@ -286,7 +286,7 @@ do_compute_shader(BeamformerCtx *ctx, Arena arena, BeamformerComputeFrame *frame
glBindImageTexture(1, csctx->channel_mapping_texture, 0, GL_FALSE, 0, GL_READ_ONLY, GL_R16I);
/* NOTE(rnp): decode 2 samples per dispatch when data is i16 */
- i32 local_size_x = DECODE_LOCAL_SIZE_X;
+ f32 local_size_x = (f32)DECODE_LOCAL_SIZE_X;
if (shader == BeamformerShaderKind_Decode)
local_size_x *= 2;
@@ -294,17 +294,17 @@ do_compute_shader(BeamformerCtx *ctx, Arena arena, BeamformerComputeFrame *frame
glProgramUniform1ui(csctx->programs[shader], DECODE_FIRST_PASS_UNIFORM_LOC, 1);
glBindBufferRange(GL_SHADER_STORAGE_BUFFER, 1, csctx->raw_data_ssbo, 0, raw_size);
glBindBufferRange(GL_SHADER_STORAGE_BUFFER, 2, csctx->raw_data_ssbo, raw_size, raw_size);
- glDispatchCompute(ceil_f32((f32)csctx->dec_data_dim.x / local_size_x),
- ceil_f32((f32)csctx->dec_data_dim.y / DECODE_LOCAL_SIZE_Y),
- ceil_f32((f32)csctx->dec_data_dim.z / DECODE_LOCAL_SIZE_Z));
+ glDispatchCompute((u32)ceil_f32((f32)csctx->dec_data_dim.x / local_size_x),
+ (u32)ceil_f32((f32)csctx->dec_data_dim.y / DECODE_LOCAL_SIZE_Y),
+ (u32)ceil_f32((f32)csctx->dec_data_dim.z / DECODE_LOCAL_SIZE_Z));
glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT);
glProgramUniform1ui(csctx->programs[shader], DECODE_FIRST_PASS_UNIFORM_LOC, 0);
glBindBufferRange(GL_SHADER_STORAGE_BUFFER, 1, csctx->raw_data_ssbo, raw_size, raw_size);
- glDispatchCompute(ceil_f32((f32)csctx->dec_data_dim.x / local_size_x),
- ceil_f32((f32)csctx->dec_data_dim.y / DECODE_LOCAL_SIZE_Y),
- ceil_f32((f32)csctx->dec_data_dim.z / DECODE_LOCAL_SIZE_Z));
+ glDispatchCompute((u32)ceil_f32((f32)csctx->dec_data_dim.x / local_size_x),
+ (u32)ceil_f32((f32)csctx->dec_data_dim.y / DECODE_LOCAL_SIZE_Y),
+ (u32)ceil_f32((f32)csctx->dec_data_dim.z / DECODE_LOCAL_SIZE_Z));
csctx->last_output_ssbo_index = !csctx->last_output_ssbo_index;
}break;
@@ -326,14 +326,14 @@ do_compute_shader(BeamformerCtx *ctx, Arena arena, BeamformerComputeFrame *frame
}break;
case BeamformerShaderKind_MinMax:{
u32 texture = frame->frame.texture;
- for (u32 i = 1; i < frame->frame.mips; i++) {
+ for (i32 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], MIN_MAX_MIPS_LEVEL_UNIFORM_LOC, i);
- u32 width = frame->frame.dim.x >> i;
- u32 height = frame->frame.dim.y >> i;
- u32 depth = frame->frame.dim.z >> i;
+ u32 width = (u32)frame->frame.dim.x >> i;
+ u32 height = (u32)frame->frame.dim.y >> i;
+ u32 depth = (u32)frame->frame.dim.z >> i;
glDispatchCompute(ORONE(width / 32), ORONE(height), ORONE(depth / 32));
glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
}
@@ -368,10 +368,11 @@ do_compute_shader(BeamformerCtx *ctx, Arena arena, BeamformerComputeFrame *frame
/* NOTE(rnp): use this for testing tiling code. The performance of the above path
* should be the same as this path if everything is working correctly */
iv3 compute_dim_offset = {0};
- glUniform3iv(csctx->voxel_offset_id, 1, compute_dim_offset.E);
- glDispatchCompute(ORONE(frame->frame.dim.x / 32),
- ORONE(frame->frame.dim.y),
- ORONE(frame->frame.dim.z / 32));
+ glProgramUniform3iv(csctx->programs[shader], DAS_VOXEL_OFFSET_UNIFORM_LOC,
+ 1, compute_dim_offset.E);
+ glDispatchCompute((u32)ceil_f32((f32)frame->frame.dim.x / DAS_LOCAL_SIZE_X),
+ (u32)ceil_f32((f32)frame->frame.dim.y / DAS_LOCAL_SIZE_Y),
+ (u32)ceil_f32((f32)frame->frame.dim.z / DAS_LOCAL_SIZE_Z));
#endif
glMemoryBarrier(GL_TEXTURE_UPDATE_BARRIER_BIT|GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
}break;
@@ -385,7 +386,7 @@ do_compute_shader(BeamformerCtx *ctx, Arena arena, BeamformerComputeFrame *frame
assert(frame >= ctx->beamform_frames);
assert(frame < ctx->beamform_frames + countof(ctx->beamform_frames));
u32 base_index = (u32)(frame - ctx->beamform_frames);
- u32 to_average = sm->parameters.output_points[3];
+ u32 to_average = (u32)sm->parameters.output_points[3];
u32 frame_count = 0;
u32 *in_textures = push_array(&arena, u32, MAX_BEAMFORMED_SAVED_FRAMES);
ComputeFrameIterator cfi = compute_frame_iterator(ctx, 1 + base_index - to_average,
@@ -476,7 +477,7 @@ DEBUG_EXPORT BEAMFORMER_RELOAD_SHADER_FN(beamformer_reload_shader)
i32 index = 0;
do {
- shader_texts[index] = shader_text_with_header(link, &ctx->os, &arena);
+ shader_texts[index] = shader_text_with_header(link, os, &arena);
shader_types[index] = link->gl_type;
index++;
link = link->link;
@@ -497,7 +498,7 @@ reload_compute_shader(BeamformerCtx *ctx, ShaderReloadContext *src, s8 name_extr
Stream sb = arena_stream(arena);
stream_append_s8s(&sb, src->name, name_extra);
s8 name = arena_stream_commit(&arena, &sb);
- b32 result = beamformer_reload_shader(ctx, src, arena, name);
+ b32 result = beamformer_reload_shader(&ctx->os, ctx, src, arena, name);
if (result) {
glUseProgram(*src->shader);
glBindBufferBase(GL_UNIFORM_BUFFER, 0, ctx->csctx.shared_ubo);
@@ -541,17 +542,17 @@ complete_queue(BeamformerCtx *ctx, BeamformWorkQueue *q, Arena arena, iptr gl_co
/* TODO(rnp): better way of handling DispatchCompute barrier */
post_sync_barrier(&ctx->shared_memory, BeamformerSharedMemoryLockKind_DispatchCompute,
sm->locks, ctx->os.shared_memory_region_unlock);
- ctx->os.shared_memory_region_lock(&ctx->shared_memory, sm->locks, (i32)work->lock, -1);
+ ctx->os.shared_memory_region_lock(&ctx->shared_memory, sm->locks, (i32)work->lock, (u32)-1);
BeamformerExportContext *ec = &work->export_context;
switch (ec->kind) {
case BeamformerExportKind_BeamformedData:{
BeamformerComputeFrame *frame = ctx->latest_frame;
assert(frame->ready_to_present);
u32 texture = frame->frame.texture;
- uv3 dim = frame->frame.dim;
- iz out_size = dim.x * dim.y * dim.z * 2 * sizeof(f32);
+ iv3 dim = frame->frame.dim;
+ u32 out_size = (u32)dim.x * (u32)dim.y * (u32)dim.z * 2 * sizeof(f32);
if (out_size <= ec->size) {
- glGetTextureImage(texture, 0, GL_RG, GL_FLOAT, out_size,
+ glGetTextureImage(texture, 0, GL_RG, GL_FLOAT, (i32)out_size,
(u8 *)sm + BEAMFORMER_SCRATCH_OFF);
}
}break;
@@ -570,28 +571,29 @@ complete_queue(BeamformerCtx *ctx, BeamformWorkQueue *q, Arena arena, iptr gl_co
ctx->os.shared_memory_region_unlock);
}break;
case BeamformerWorkKind_UploadBuffer:{
- ctx->os.shared_memory_region_lock(&ctx->shared_memory, sm->locks, (i32)work->lock, -1);
+ ctx->os.shared_memory_region_lock(&ctx->shared_memory, sm->locks, (i32)work->lock, (u32)-1);
BeamformerUploadContext *uc = &work->upload_context;
- u32 tex_type, tex_format, tex_element_count, tex_1d = 0, buffer = 0;
+ u32 tex_type, tex_format, tex_1d = 0, buffer = 0;
+ i32 tex_element_count;
switch (uc->kind) {
case BU_KIND_CHANNEL_MAPPING: {
tex_1d = cs->channel_mapping_texture;
tex_type = GL_SHORT;
tex_format = GL_RED_INTEGER;
- tex_element_count = ARRAY_COUNT(sm->channel_mapping);
+ tex_element_count = countof(sm->channel_mapping);
ctx->cuda_lib.set_channel_mapping(sm->channel_mapping);
} break;
case BU_KIND_FOCAL_VECTORS: {
tex_1d = cs->focal_vectors_texture;
tex_type = GL_FLOAT;
tex_format = GL_RG;
- tex_element_count = ARRAY_COUNT(sm->focal_vectors);
+ tex_element_count = countof(sm->focal_vectors);
} break;
case BU_KIND_SPARSE_ELEMENTS: {
tex_1d = cs->sparse_elements_texture;
tex_type = GL_SHORT;
tex_format = GL_RED_INTEGER;
- tex_element_count = ARRAY_COUNT(sm->sparse_elements);
+ tex_element_count = countof(sm->sparse_elements);
} break;
case BU_KIND_PARAMETERS: {
ctx->ui_read_params = ctx->beamform_work_queue != q;
@@ -621,7 +623,7 @@ complete_queue(BeamformerCtx *ctx, BeamformWorkQueue *q, Arena arena, iptr gl_co
}
if (buffer) {
- glNamedBufferSubData(buffer, 0, uc->size,
+ glNamedBufferSubData(buffer, 0, (i32)uc->size,
(u8 *)sm + uc->shared_memory_offset);
}
@@ -639,7 +641,7 @@ complete_queue(BeamformerCtx *ctx, BeamformWorkQueue *q, Arena arena, iptr gl_co
push_compute_timing_info(ctx->compute_timing_table,
(ComputeTimingInfo){.kind = ComputeTimingInfoKind_ComputeFrameBegin});
- i32 mask = 1 << (BeamformerSharedMemoryLockKind_Parameters - 1);
+ u32 mask = 1 << (BeamformerSharedMemoryLockKind_Parameters - 1);
if (sm->dirty_regions & mask) {
glNamedBufferSubData(cs->shared_ubo, 0, sizeof(sm->parameters), &sm->parameters);
atomic_and_u32(&sm->dirty_regions, ~mask);
@@ -649,12 +651,12 @@ complete_queue(BeamformerCtx *ctx, BeamformWorkQueue *q, Arena arena, iptr gl_co
start_renderdoc_capture(gl_context);
BeamformerComputeFrame *frame = work->frame;
- uv3 try_dim = make_valid_test_dim(bp->output_points);
- if (!uv3_equal(try_dim, frame->frame.dim))
+ iv3 try_dim = make_valid_test_dim(bp->output_points);
+ if (!iv3_equal(try_dim, frame->frame.dim))
alloc_beamform_frame(&ctx->gl, &frame->frame, try_dim, s8("Beamformed_Data"), arena);
if (bp->output_points[3] > 1) {
- if (!uv3_equal(try_dim, ctx->averaged_frames[0].frame.dim)) {
+ if (!iv3_equal(try_dim, ctx->averaged_frames[0].frame.dim)) {
alloc_beamform_frame(&ctx->gl, &ctx->averaged_frames[0].frame,
try_dim, s8("Averaged Frame"), arena);
alloc_beamform_frame(&ctx->gl, &ctx->averaged_frames[1].frame,
@@ -742,12 +744,12 @@ coalesce_timing_table(ComputeTimingTable *t, ComputeShaderStats *stats)
stats_index = (stats_index + 1) % countof(stats->table.times);
}break;
case ComputeTimingInfoKind_Shader:{
- stats->table.times[stats_index][info.shader] += (f32)info.timer_count / 1.0e9;
+ stats->table.times[stats_index][info.shader] += (f32)info.timer_count / 1.0e9f;
seen_info_test |= (1 << info.shader);
}break;
case ComputeTimingInfoKind_RF_Data:{
stats->latest_rf_index = (stats->latest_rf_index + 1) % countof(stats->table.rf_time_deltas);
- f32 delta = (f32)(info.timer_count - stats->last_rf_timer_count) / 1.0e9;
+ f32 delta = (f32)(info.timer_count - stats->last_rf_timer_count) / 1.0e9f;
stats->table.rf_time_deltas[stats->latest_rf_index] = delta;
stats->last_rf_timer_count = info.timer_count;
seen_info_test |= (1 << BeamformerShaderKind_Count);
diff --git a/beamformer.h b/beamformer.h
@@ -163,7 +163,7 @@ typedef struct {
typedef struct BeamformerFrame BeamformerFrame;
struct BeamformerFrame {
- uv3 dim;
+ iv3 dim;
u32 texture;
/* NOTE: for use when displaying either prebeamformed frames or on the current frame
@@ -171,7 +171,7 @@ struct BeamformerFrame {
v4 min_coordinate;
v4 max_coordinate;
- u32 mips;
+ i32 mips;
DASShaderKind das_shader_kind;
u32 compound_count;
u32 id;
@@ -206,7 +206,7 @@ typedef struct {
typedef struct {
GLParams gl;
- uv2 window_size;
+ iv2 window_size;
b32 should_exit;
Arena ui_backing_store;
@@ -252,18 +252,17 @@ struct ShaderReloadContext {
BeamformerShaderKind kind;
};
-#define BEAMFORMER_FRAME_STEP_FN(name) void name(BeamformerCtx *ctx, Arena *arena, \
- BeamformerInput *input)
+#define BEAMFORMER_FRAME_STEP_FN(name) void name(BeamformerCtx *ctx, BeamformerInput *input)
typedef BEAMFORMER_FRAME_STEP_FN(beamformer_frame_step_fn);
-#define BEAMFORMER_COMPUTE_SETUP_FN(name) void name(iptr user_context, Arena arena, iptr gl_context)
+#define BEAMFORMER_COMPUTE_SETUP_FN(name) void name(iptr user_context)
typedef BEAMFORMER_COMPUTE_SETUP_FN(beamformer_compute_setup_fn);
#define BEAMFORMER_COMPLETE_COMPUTE_FN(name) void name(iptr user_context, Arena arena, iptr gl_context)
typedef BEAMFORMER_COMPLETE_COMPUTE_FN(beamformer_complete_compute_fn);
-#define BEAMFORMER_RELOAD_SHADER_FN(name) b32 name(BeamformerCtx *ctx, ShaderReloadContext *src, \
- Arena arena, s8 shader_name)
+#define BEAMFORMER_RELOAD_SHADER_FN(name) b32 name(OS *os, BeamformerCtx *ctx, \
+ ShaderReloadContext *src, Arena arena, s8 shader_name)
typedef BEAMFORMER_RELOAD_SHADER_FN(beamformer_reload_shader_fn);
#endif /*_BEAMFORMER_H_ */
diff --git a/beamformer_parameters.h b/beamformer_parameters.h
@@ -96,7 +96,7 @@ typedef enum {
#define BEAMFORMER_UI_PARAMS \
X(output_min_coordinate, float, [4], vec4, , "/* [m] Back-Top-Left corner of output region */") \
X(output_max_coordinate, float, [4], vec4, , "/* [m] Front-Bottom-Right corner of output region */") \
- X(output_points, uint32_t, [4], uvec4, , "/* Width * Height * Depth * (Frame Average Count) */") \
+ X(output_points, int32_t, [4], uvec4, , "/* Width * Height * Depth * (Frame Average Count) */") \
X(sampling_frequency, float, , float, , "/* [Hz] */") \
X(center_frequency, float, , float, , "/* [Hz] */") \
X(speed_of_sound, float, , float, , "/* [m/s] */") \
diff --git a/beamformer_work_queue.c b/beamformer_work_queue.c
@@ -9,8 +9,8 @@ beamform_work_queue_pop(BeamformWorkQueue *q)
static_assert(ISPOWEROF2(countof(q->work_items)), "queue capacity must be a power of 2");
u64 val = atomic_load_u64(&q->queue);
u64 mask = countof(q->work_items) - 1;
- u32 widx = val & mask;
- u32 ridx = val >> 32 & mask;
+ u64 widx = val & mask;
+ u64 ridx = val >> 32 & mask;
if (ridx != widx)
result = q->work_items + ridx;
@@ -31,9 +31,9 @@ DEBUG_EXPORT BEAMFORM_WORK_QUEUE_PUSH_FN(beamform_work_queue_push)
static_assert(ISPOWEROF2(countof(q->work_items)), "queue capacity must be a power of 2");
u64 val = atomic_load_u64(&q->queue);
u64 mask = countof(q->work_items) - 1;
- u32 widx = val & mask;
- u32 ridx = val >> 32 & mask;
- u32 next = (widx + 1) & mask;
+ u64 widx = val & mask;
+ u64 ridx = val >> 32 & mask;
+ u64 next = (widx + 1) & mask;
if (val & 0x80000000)
atomic_and_u64(&q->queue, ~0x80000000);
@@ -53,11 +53,11 @@ DEBUG_EXPORT BEAMFORM_WORK_QUEUE_PUSH_COMMIT_FN(beamform_work_queue_push_commit)
function void
post_sync_barrier(SharedMemoryRegion *sm, BeamformerSharedMemoryLockKind lock, i32 *locks,
- os_shared_memory_region_unlock_fn *os_shared_memory_region_unlock)
+ os_shared_memory_region_unlock_fn *shared_memory_region_unlock)
{
/* NOTE(rnp): debug: here it is not a bug to release the lock if it
* isn't held but elswhere it is */
DEBUG_DECL(if (locks[lock])) {
- os_shared_memory_region_unlock(sm, locks, lock);
+ shared_memory_region_unlock(sm, locks, (i32)lock);
}
}
diff --git a/beamformer_work_queue.h b/beamformer_work_queue.h
@@ -27,7 +27,7 @@ typedef enum {
typedef struct {
BeamformerUploadKind kind;
- i32 size;
+ u32 size;
i32 shared_memory_offset;
} BeamformerUploadContext;
@@ -38,7 +38,7 @@ typedef enum {
typedef struct {
BeamformerExportKind kind;
- i32 size;
+ u32 size;
} BeamformerExportContext;
#define BEAMFORMER_SHARED_MEMORY_LOCKS \
diff --git a/build.c b/build.c
@@ -24,10 +24,13 @@
#define COMMON_FLAGS "-nologo", "-std:c11", "-Fo:" OUTDIR "\\", "-Z7", "-Zo"
#define DEBUG_FLAGS "-Od", "-D_DEBUG"
#define OPTIMIZED_FLAGS "-O2"
+ #define EXTRA_FLAGS ""
#else
#define COMMON_FLAGS "-std=c11", "-pipe", "-Wall"
#define DEBUG_FLAGS "-O0", "-D_DEBUG", "-Wno-unused-function"
#define OPTIMIZED_FLAGS "-O3"
+ #define EXTRA_FLAGS "-Werror", "-Wextra", "-Wshadow", "-Wconversion", "-Wno-unused-parameter", \
+ "-Wno-error=unused-function", "-ffast-math"
#endif
#define is_aarch64 ARCH_ARM64
@@ -96,14 +99,14 @@
#define shift(list, count) ((count)--, *(list)++)
#define da_append_count(a, s, items, item_count) do { \
- da_reserve((a), (s), (s)->count + (item_count)); \
- mem_copy((s)->data + (s)->count, (items), sizeof(*(items)) * (item_count)); \
- (s)->count += (item_count); \
+ da_reserve((a), (s), (s)->count + (item_count)); \
+ mem_copy((s)->data + (s)->count, (items), sizeof(*(items)) * (uz)(item_count)); \
+ (s)->count += (item_count); \
} while (0)
#define cmd_append_count da_append_count
#define cmd_append(a, s, ...) da_append_count(a, s, ((char *[]){__VA_ARGS__}), \
- (sizeof((char *[]){__VA_ARGS__}) / sizeof(char *)))
+ (iz)(sizeof((char *[]){__VA_ARGS__}) / sizeof(char *)))
typedef struct {
char **data;
@@ -219,7 +222,7 @@ os_get_filetime(char *file)
struct stat sb;
u64 result = (u64)-1;
if (stat(file, &sb) != -1)
- result = sb.st_mtim.tv_sec;
+ result = (u64)sb.st_mtim.tv_sec;
return result;
}
@@ -244,7 +247,7 @@ os_wait_close_process(iptr handle)
b32 result = 0;
for (;;) {
i32 status;
- iptr wait_pid = (iptr)waitpid(handle, &status, 0);
+ iptr wait_pid = (iptr)waitpid((i32)handle, &status, 0);
if (wait_pid == -1)
build_fatal("failed to wait on child process: %s", strerror(errno));
if (wait_pid == handle) {
@@ -436,6 +439,7 @@ check_rebuild_self(Arena arena, i32 argc, char *argv[])
Options options = {0};
CommandList c = cmd_base(&arena, &options);
+ cmd_append(&arena, &c, EXTRA_FLAGS);
if (!is_msvc) cmd_append(&arena, &c, "-Wno-unused-function");
cmd_append(&arena, &c, __FILE__, OUTPUT_EXE(binary));
if (is_msvc) cmd_append(&arena, &c, "/link", "-incremental:no", "-opt:ref");
@@ -758,9 +762,14 @@ main(i32 argc, char *argv[])
CommandList c = cmd_base(&arena, &options);
if (!check_build_raylib(arena, c, options.debug)) return 1;
+ /////////////////////////////////////
+ // extra flags (unusable for raylib)
+ cmd_append(&arena, &c, EXTRA_FLAGS);
+
+ /////////////////
+ // helpers/tests
result &= build_matlab_bindings(arena);
result &= build_helper_library(arena, c);
-
if (options.tests) result &= build_tests(arena, c);
//////////////////
@@ -802,7 +811,7 @@ main(i32 argc, char *argv[])
}
if (options.time) {
- f64 seconds = (f64)(os_get_timer_counter() - start_time) / os_get_timer_frequency();
+ f64 seconds = (f64)(os_get_timer_counter() - start_time) / (f64)os_get_timer_frequency();
build_log_info("took %0.03f [s]", seconds);
}
diff --git a/helpers/ogl_beamformer_lib.c b/helpers/ogl_beamformer_lib.c
@@ -106,7 +106,7 @@ try_push_work_queue(void)
function b32
lib_try_lock(BeamformerSharedMemoryLockKind lock, i32 timeout_ms)
{
- b32 result = os_shared_memory_region_lock(&g_shared_memory, g_bp->locks, (i32)lock, timeout_ms);
+ b32 result = os_shared_memory_region_lock(&g_shared_memory, g_bp->locks, (i32)lock, (u32)timeout_ms);
if (!result) g_lib_last_error = BF_LIB_ERR_KIND_SYNC_VARIABLE;
return result;
}
@@ -154,15 +154,15 @@ beamformer_get_last_error_string(void)
}
b32
-set_beamformer_pipeline(i32 *stages, i32 stages_count)
+set_beamformer_pipeline(i32 *stages, u32 stages_count)
{
b32 result = 0;
if (stages_count <= countof(g_bp->compute_stages)) {
if (check_shared_memory()) {
g_bp->compute_stages_count = 0;
- for (i32 i = 0; i < stages_count; i++) {
+ for (u32 i = 0; i < stages_count; i++) {
if (BETWEEN(stages[i], 0, BeamformerShaderKind_ComputeCount)) {
- g_bp->compute_stages[g_bp->compute_stages_count++] = stages[i];
+ g_bp->compute_stages[g_bp->compute_stages_count++] = (BeamformerShaderKind)stages[i];
}
}
result = g_bp->compute_stages_count == stages_count;
@@ -180,7 +180,7 @@ set_beamformer_pipeline(i32 *stages, i32 stages_count)
b32
beamformer_start_compute(i32 timeout_ms)
{
- i32 lock = BeamformerSharedMemoryLockKind_DispatchCompute;
+ u32 lock = BeamformerSharedMemoryLockKind_DispatchCompute;
b32 result = check_shared_memory() && lib_try_lock(lock, timeout_ms);
return result;
}
@@ -188,7 +188,7 @@ beamformer_start_compute(i32 timeout_ms)
b32
beamformer_wait_for_compute_dispatch(i32 timeout_ms)
{
- i32 lock = BeamformerSharedMemoryLockKind_DispatchCompute;
+ u32 lock = BeamformerSharedMemoryLockKind_DispatchCompute;
b32 result = check_shared_memory() && lib_try_lock(lock, timeout_ms);
/* NOTE(rnp): if you are calling this function you are probably about
* to start some other work and it might be better to not do this... */
@@ -366,7 +366,7 @@ beamformer_export_buffer(BeamformerExportContext export_context)
}
function b32
-beamformer_read_output(void *out, iz size, i32 timeout_ms)
+beamformer_read_output(void *out, uz size, i32 timeout_ms)
{
b32 result = 0;
if (try_wait_sync(BeamformerSharedMemoryLockKind_ExportSync, timeout_ms)) {
@@ -380,7 +380,7 @@ beamformer_read_output(void *out, iz size, i32 timeout_ms)
}
b32
-beamform_data_synchronized(void *data, u32 data_size, u32 output_points[3], f32 *out_data, i32 timeout_ms)
+beamform_data_synchronized(void *data, u32 data_size, i32 output_points[3], f32 *out_data, i32 timeout_ms)
{
b32 result = 0;
if (check_shared_memory()) {
@@ -392,13 +392,13 @@ beamform_data_synchronized(void *data, u32 data_size, u32 output_points[3], f32
g_bp->parameters.output_points[1] = output_points[1];
g_bp->parameters.output_points[2] = output_points[2];
- iz output_size = output_points[0] * output_points[1] * output_points[2] * sizeof(f32) * 2;
+ uz output_size = (u32)output_points[0] * (u32)output_points[1] * (u32)output_points[2] * sizeof(f32) * 2;
if (output_size <= BEAMFORMER_SCRATCH_SIZE &&
beamformer_push_data_with_compute(data, data_size, 0, 0))
{
BeamformerExportContext export;
export.kind = BeamformerExportKind_BeamformedData;
- export.size = output_size;
+ export.size = (u32)output_size;
if (beamformer_export_buffer(export) && beamformer_start_compute(0))
result = beamformer_read_output(out_data, output_size, timeout_ms);
} else {
@@ -431,7 +431,7 @@ beamformer_live_parameters_get_dirty_flag(void)
u32 flag = ctz_u32(g_bp->live_imaging_dirty_flags);
if (flag != 32) {
atomic_and_u32(&g_bp->live_imaging_dirty_flags, ~(1 << flag));
- result = flag;
+ result = (i32)flag;
}
}
return result;
diff --git a/helpers/ogl_beamformer_lib_base.h b/helpers/ogl_beamformer_lib_base.h
@@ -33,11 +33,11 @@ LIB_FN const char *beamformer_error_string(BeamformerLibErrorKind kind);
/* IMPORTANT: timeout of -1 will block forever */
LIB_FN uint32_t set_beamformer_parameters(BeamformerParametersV0 *);
-LIB_FN uint32_t set_beamformer_pipeline(int32_t *stages, int32_t stages_count);
+LIB_FN uint32_t set_beamformer_pipeline(int32_t *stages, uint32_t stages_count);
LIB_FN uint32_t send_data(void *data, uint32_t data_size);
/* NOTE: sends data and waits for (complex) beamformed data to be returned.
* out_data: must be allocated by the caller as 2 floats per output point. */
-LIB_FN uint32_t beamform_data_synchronized(void *data, uint32_t data_size, uint32_t output_points[3],
+LIB_FN uint32_t beamform_data_synchronized(void *data, uint32_t data_size, int32_t output_points[3],
float *out_data, int32_t timeout_ms);
/* NOTE: downloads the last 32 frames worth of compute timings into output */
diff --git a/intrinsics.c b/intrinsics.c
@@ -113,7 +113,7 @@ function force_inline u32
clz_u32(u32 a)
{
u32 result = 32;
- if (a) result = __builtin_clz(a);
+ if (a) result = (u32)__builtin_clz(a);
return result;
}
@@ -121,7 +121,7 @@ function force_inline u32
ctz_u32(u32 a)
{
u32 result = 32;
- if (a) result = __builtin_ctz(a);
+ if (a) result = (u32)__builtin_ctz(a);
return result;
}
diff --git a/main_linux.c b/main_linux.c
@@ -43,7 +43,7 @@ dispatch_file_watch_events(OS *os, Arena arena)
struct inotify_event *event;
iz rlen;
- while ((rlen = read(fwctx->handle, mem, 4096)) > 0) {
+ while ((rlen = read((i32)fwctx->handle, mem, 4096)) > 0) {
for (u8 *data = mem; data < mem + rlen; data += sizeof(*event) + event->len) {
event = (struct inotify_event *)data;
for (u32 i = 0; i < fwctx->count; i++) {
@@ -53,8 +53,8 @@ dispatch_file_watch_events(OS *os, Arena arena)
s8 file = c_str_to_s8(event->name);
u64 hash = s8_hash(file);
- for (u32 i = 0; i < dir->count; i++) {
- FileWatch *fw = dir->data + i;
+ for (u32 j = 0; j < dir->count; j++) {
+ FileWatch *fw = dir->data + j;
if (fw->hash == hash) {
stream_append_s8s(&path, dir->name, s8("/"), file);
stream_append_byte(&path, 0);
@@ -93,7 +93,7 @@ main(void)
os_wake_waiters(&ctx.os.compute_worker.sync_variable);
struct pollfd fds[1] = {{0}};
- fds[0].fd = ctx.os.file_watch_context.handle;
+ fds[0].fd = (i32)ctx.os.file_watch_context.handle;
fds[0].events = POLLIN;
u64 last_time = os_get_timer_counter();
@@ -105,10 +105,10 @@ main(void)
u64 now = os_get_timer_counter();
input.last_mouse = input.mouse;
input.mouse.rl = GetMousePosition();
- input.dt = (f64)(now - last_time) / os_get_timer_frequency();
+ input.dt = (f32)((f64)(now - last_time) / (f64)os_get_timer_frequency());
last_time = now;
- beamformer_frame_step(&ctx, &temp_memory, &input);
+ beamformer_frame_step(&ctx, &input);
input.executable_reloaded = 0;
}
diff --git a/main_w32.c b/main_w32.c
@@ -132,10 +132,10 @@ main(void)
u64 now = os_get_timer_counter();
input.last_mouse = input.mouse;
input.mouse.rl = GetMousePosition();
- input.dt = (f64)(now - last_time) / w32_ctx.timer_frequency;
+ input.dt = (f32)((f64)(now - last_time) / (f64)w32_ctx.timer_frequency);
last_time = now;
- beamformer_frame_step(&ctx, &temp_memory, &input);
+ beamformer_frame_step(&ctx, &input);
input.executable_reloaded = 0;
}
diff --git a/math.c b/math.c
@@ -1,9 +1,9 @@
function void
-fill_kronecker_sub_matrix(i32 *out, i32 out_stride, i32 scale, i32 *b, uv2 b_dim)
+fill_kronecker_sub_matrix(i32 *out, i32 out_stride, i32 scale, i32 *b, iv2 b_dim)
{
- f32x4 vscale = dup_f32x4(scale);
- for (u32 i = 0; i < b_dim.y; i++) {
- for (u32 j = 0; j < b_dim.x; j += 4, b += 4) {
+ f32x4 vscale = dup_f32x4((f32)scale);
+ for (i32 i = 0; i < b_dim.y; i++) {
+ for (i32 j = 0; j < b_dim.x; j += 4, b += 4) {
f32x4 vb = cvt_i32x4_f32x4(load_i32x4(b));
store_i32x4(out + j, cvt_f32x4_i32x4(mul_f32x4(vscale, vb)));
}
@@ -13,13 +13,13 @@ fill_kronecker_sub_matrix(i32 *out, i32 out_stride, i32 scale, i32 *b, uv2 b_dim
/* NOTE: this won't check for valid space/etc and assumes row major order */
function void
-kronecker_product(i32 *out, i32 *a, uv2 a_dim, i32 *b, uv2 b_dim)
+kronecker_product(i32 *out, i32 *a, iv2 a_dim, i32 *b, iv2 b_dim)
{
- uv2 out_dim = {.x = a_dim.x * b_dim.x, .y = a_dim.y * b_dim.y};
- ASSERT(out_dim.y % 4 == 0);
- for (u32 i = 0; i < a_dim.y; i++) {
+ iv2 out_dim = {{a_dim.x * b_dim.x, a_dim.y * b_dim.y}};
+ assert(out_dim.y % 4 == 0);
+ for (i32 i = 0; i < a_dim.y; i++) {
i32 *vout = out;
- for (u32 j = 0; j < a_dim.x; j++, a++) {
+ for (i32 j = 0; j < a_dim.x; j++, a++) {
fill_kronecker_sub_matrix(vout, out_dim.y, *a, b, b_dim);
vout += b_dim.y;
}
@@ -29,7 +29,7 @@ kronecker_product(i32 *out, i32 *a, uv2 a_dim, i32 *b, uv2 b_dim)
/* NOTE/TODO: to support even more hadamard sizes use the Paley construction */
function i32 *
-make_hadamard_transpose(Arena *a, u32 dim)
+make_hadamard_transpose(Arena *a, i32 dim)
{
read_only local_persist i32 hadamard_12_12_transpose[] = {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -76,7 +76,7 @@ make_hadamard_transpose(Arena *a, u32 dim)
b32 multiple_of_20 = dim % 20 == 0;
iz elements = dim * dim;
- u32 base_dim = 0;
+ i32 base_dim = 0;
if (power_of_2) {
base_dim = dim;
} else if (multiple_of_20 && ISPOWEROF2(dim / 20)) {
@@ -95,9 +95,9 @@ make_hadamard_transpose(Arena *a, u32 dim)
#define IND(i, j) ((i) * dim + (j))
m[0] = 1;
- for (u32 k = 1; k < dim; k *= 2) {
- for (u32 i = 0; i < k; i++) {
- for (u32 j = 0; j < k; j++) {
+ for (i32 k = 1; k < dim; k *= 2) {
+ for (i32 i = 0; i < k; i++) {
+ for (i32 j = 0; j < k; j++) {
i32 val = m[IND(i, j)];
m[IND(i + k, j)] = val;
m[IND(i, j + k)] = val;
@@ -108,27 +108,29 @@ make_hadamard_transpose(Arena *a, u32 dim)
#undef IND
i32 *m2 = 0;
- uv2 m2_dim;
+ iv2 m2_dim;
switch (base_dim) {
- case 12:{ m2 = hadamard_12_12_transpose; m2_dim = (uv2){{12, 12}}; }break;
- case 20:{ m2 = hadamard_20_20_transpose; m2_dim = (uv2){{20, 20}}; }break;
+ case 12:{ m2 = hadamard_12_12_transpose; m2_dim = (iv2){{12, 12}}; }break;
+ case 20:{ m2 = hadamard_20_20_transpose; m2_dim = (iv2){{20, 20}}; }break;
}
- if (m2) kronecker_product(result, m, (uv2){{dim, dim}}, m2, m2_dim);
+ if (m2) kronecker_product(result, m, (iv2){{dim, dim}}, m2, m2_dim);
}
return result;
}
function b32
-uv2_equal(uv2 a, uv2 b)
+iv2_equal(iv2 a, iv2 b)
{
- return a.x == b.x && a.y == b.y;
+ b32 result = a.x == b.x && a.y == b.y;
+ return result;
}
function b32
-uv3_equal(uv3 a, uv3 b)
+iv3_equal(iv3 a, iv3 b)
{
- return a.x == b.x && a.y == b.y && a.z == b.z;
+ b32 result = a.x == b.x && a.y == b.y && a.z == b.z;
+ return result;
}
function v2
@@ -187,8 +189,8 @@ function v2
v2_floor(v2 a)
{
v2 result;
- result.x = (i32)a.x;
- result.y = (i32)a.y;
+ result.x = (f32)((i32)a.x);
+ result.y = (f32)((i32)a.y);
return result;
}
@@ -371,9 +373,7 @@ m4_mul(m4 a, m4 b)
for (u32 i = 0; i < countof(result.E); i++) {
u32 base = i / 4;
u32 sub = i % 4;
- v4 v1 = m4_row(a, base);
- v4 v2 = m4_column(b, sub);
- result.E[i] = v4_dot(v1, v2);
+ result.E[i] = v4_dot(m4_row(a, base), m4_column(b, sub));
}
return result;
}
@@ -518,18 +518,18 @@ camera_look_at(v3 camera, v3 point)
/* NOTE(rnp): adapted from "Essential Mathematics for Games and Interactive Applications" (Verth, Bishop) */
function f32
-obb_raycast(m4 obb_orientation, v3 obb_size, v3 obb_center, ray ray)
+obb_raycast(m4 obb_orientation, v3 obb_size, v3 obb_center, ray r)
{
- v3 p = v3_sub(obb_center, ray.origin);
+ v3 p = v3_sub(obb_center, r.origin);
v3 X = obb_orientation.c[0].xyz;
v3 Y = obb_orientation.c[1].xyz;
v3 Z = obb_orientation.c[2].xyz;
/* NOTE(rnp): projects direction vector onto OBB axis */
v3 f;
- f.x = v3_dot(X, ray.direction);
- f.y = v3_dot(Y, ray.direction);
- f.z = v3_dot(Z, ray.direction);
+ f.x = v3_dot(X, r.direction);
+ f.y = v3_dot(Y, r.direction);
+ f.z = v3_dot(Z, r.direction);
/* NOTE(rnp): projects relative vector onto OBB axis */
v3 e;
diff --git a/os_linux.c b/os_linux.c
@@ -44,8 +44,8 @@ os_get_module(char *name, Stream *e)
function OS_WRITE_FILE_FN(os_write_file)
{
- while (raw.len) {
- iz r = write(file, raw.data, raw.len);
+ while (raw.len > 0) {
+ iz r = write((i32)file, raw.data, (uz)raw.len);
if (r < 0) return 0;
raw = s8_cut_head(raw, r);
}
@@ -78,7 +78,7 @@ os_get_timer_counter(void)
{
struct timespec time = {0};
clock_gettime(CLOCK_MONOTONIC, &time);
- u64 result = time.tv_sec * 1000000000ULL + time.tv_nsec;
+ u64 result = (u64)time.tv_sec * 1000000000ULL + (u64)time.tv_nsec;
return result;
}
@@ -93,7 +93,7 @@ function OS_ALLOC_ARENA_FN(os_alloc_arena)
{
Arena result = {0};
capacity = os_round_up_to_page_size(capacity);
- result.beg = mmap(0, capacity, PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
+ result.beg = mmap(0, (uz)capacity, PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
if (result.beg == MAP_FAILED)
os_fatal(s8("os_alloc_arena: couldn't allocate memory\n"));
result.end = result.beg + capacity;
@@ -108,7 +108,7 @@ function OS_READ_WHOLE_FILE_FN(os_read_whole_file)
i32 fd = open(file, O_RDONLY);
if (fd >= 0 && fstat(fd, &sb) >= 0) {
result = s8_alloc(arena, sb.st_size);
- iz rlen = read(fd, result.data, result.len);
+ iz rlen = read(fd, result.data, (uz)result.len);
if (rlen != result.len)
result = s8("");
}
@@ -119,12 +119,13 @@ function OS_READ_WHOLE_FILE_FN(os_read_whole_file)
function OS_WRITE_NEW_FILE_FN(os_write_new_file)
{
- iptr fd = open(fname, O_WRONLY|O_TRUNC|O_CREAT, 0600);
- if (fd == INVALID_FILE)
- return 0;
- b32 ret = os_write_file(fd, raw);
- close(fd);
- return ret;
+ b32 result = 0;
+ i32 fd = open(fname, O_WRONLY|O_TRUNC|O_CREAT, 0600);
+ if (fd != INVALID_FILE) {
+ result = os_write_file(fd, raw);
+ close(fd);
+ }
+ return result;
}
function b32
@@ -142,7 +143,7 @@ os_create_shared_memory_area(Arena *arena, char *name, i32 lock_count, iz reques
SharedMemoryRegion result = {0};
i32 fd = shm_open(name, O_CREAT|O_RDWR, S_IRUSR|S_IWUSR);
if (fd > 0 && ftruncate(fd, capacity) != -1) {
- void *new = mmap(0, capacity, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
+ void *new = mmap(0, (uz)capacity, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
if (new != MAP_FAILED) result.region = new;
}
if (fd > 0) close(fd);
@@ -164,7 +165,7 @@ os_copy_file(char *name, char *new)
while (copied != sb.st_size) {
iz r = read(fd_old, buf, countof(buf));
if (r < 0) break;
- iz w = write(fd_new, buf, r);
+ iz w = write(fd_new, buf, (uz)r);
if (w < 0) break;
copied += w;
}
@@ -232,8 +233,8 @@ function OS_ADD_FILE_WATCH_FN(os_add_file_watch)
dir = da_push(a, fwctx);
dir->hash = hash;
dir->name = push_s8_zero(a, directory);
- i32 mask = IN_MOVED_TO|IN_CLOSE_WRITE;
- dir->handle = inotify_add_watch(fwctx->handle, (c8 *)dir->name.data, mask);
+ u32 mask = IN_MOVED_TO|IN_CLOSE_WRITE;
+ dir->handle = inotify_add_watch((i32)fwctx->handle, (c8 *)dir->name.data, mask);
}
FileWatch *fw = da_push(a, dir);
@@ -247,7 +248,7 @@ function iptr
os_create_thread(Arena arena, iptr user_context, s8 name, os_thread_entry_point_fn *fn)
{
pthread_t result;
- pthread_create(&result, 0, (void *(*)(void *))fn, (void *)user_context);
+ pthread_create(&result, 0, (void *)fn, (void *)user_context);
pthread_setname_np(result, (char *)name.data);
return (iptr)result;
}
diff --git a/os_win32.c b/os_win32.c
@@ -136,7 +136,7 @@ os_get_module(char *name, Stream *e)
function OS_WRITE_FILE_FN(os_write_file)
{
i32 wlen = 0;
- if (raw.len > 0 && raw.len <= U32_MAX) WriteFile(file, raw.data, raw.len, &wlen, 0);
+ if (raw.len > 0 && raw.len <= U32_MAX) WriteFile(file, raw.data, (i32)raw.len, &wlen, 0);
return raw.len == wlen;
}
@@ -212,13 +212,12 @@ function OS_READ_WHOLE_FILE_FN(os_read_whole_file)
if (h >= 0 && GetFileInformationByHandle(h, &fileinfo)) {
iz filesize = (iz)fileinfo.nFileSizeHigh << 32;
filesize |= (iz)fileinfo.nFileSizeLow;
- result = s8_alloc(arena, filesize);
-
- ASSERT(filesize <= (iz)U32_MAX);
-
- i32 rlen;
- if (!ReadFile(h, result.data, result.len, &rlen, 0) || rlen != result.len)
- result = s8("");
+ if (filesize <= U32_MAX) {
+ result = s8_alloc(arena, filesize);
+ i32 rlen;
+ if (!ReadFile(h, result.data, (i32)result.len, &rlen, 0) || rlen != result.len)
+ result = s8("");
+ }
}
if (h >= 0) CloseHandle(h);
@@ -253,10 +252,11 @@ function SharedMemoryRegion
os_create_shared_memory_area(Arena *arena, char *name, i32 lock_count, iz requested_capacity)
{
iz capacity = os_round_up_to_page_size(requested_capacity);
+ assert(capacity <= (iz)U32_MAX);
SharedMemoryRegion result = {0};
- iptr h = CreateFileMappingA(-1, 0, PAGE_READWRITE, 0, capacity, name);
+ iptr h = CreateFileMappingA(-1, 0, PAGE_READWRITE, 0, (u32)capacity, name);
if (h != INVALID_FILE) {
- void *new = MapViewOfFile(h, FILE_MAP_ALL_ACCESS, 0, 0, capacity);
+ void *new = MapViewOfFile(h, FILE_MAP_ALL_ACCESS, 0, 0, (u32)capacity);
if (new) {
w32_shared_memory_context *ctx = push_struct(arena, typeof(*ctx));
ctx->semaphores = push_array(arena, typeof(*ctx->semaphores), lock_count);
diff --git a/static.c b/static.c
@@ -79,8 +79,6 @@ struct gl_debug_ctx {
function void
gl_debug_logger(u32 src, u32 type, u32 id, u32 lvl, i32 len, const char *msg, const void *userctx)
{
- (void)src; (void)type; (void)id;
-
struct gl_debug_ctx *ctx = (struct gl_debug_ctx *)userctx;
Stream *e = &ctx->stream;
stream_append_s8s(e, s8("[OpenGL] "), (s8){.len = len, .data = (u8 *)msg}, s8("\n"));
@@ -120,7 +118,7 @@ validate_gl_requirements(GLParams *gl, Arena a)
{
Stream s = arena_stream(a);
- if (gl->max_ubo_size < sizeof(BeamformerParameters)) {
+ if (gl->max_ubo_size < (i32)sizeof(BeamformerParameters)) {
stream_append_s8(&s, s8("GPU must support UBOs of at least "));
stream_append_i64(&s, sizeof(BeamformerParameters));
stream_append_s8(&s, s8(" bytes!\n"));
@@ -136,18 +134,17 @@ validate_gl_requirements(GLParams *gl, Arena a)
function void
dump_gl_params(GLParams *gl, Arena a, OS *os)
{
- (void)gl; (void)a;
#ifdef _DEBUG
s8 vendor = s8("vendor:");
- iz max_width = vendor.len;
- #define X(glname, name, suffix) if (s8(#name).len > max_width) max_width = s8(#name ":").len;
+ i32 max_width = (i32)vendor.len;
+ #define X(glname, name, suffix) if (s8(#name).len > max_width) max_width = (i32)s8(#name ":").len;
GL_PARAMETERS
#undef X
max_width++;
Stream s = arena_stream(a);
stream_append_s8s(&s, s8("---- GL Parameters ----\n"), vendor);
- stream_pad(&s, ' ', max_width - vendor.len);
+ stream_pad(&s, ' ', max_width - (i32)vendor.len);
switch (gl->vendor_id) {
case GL_VENDOR_AMD: stream_append_s8(&s, s8("AMD\n")); break;
case GL_VENDOR_ARM: stream_append_s8(&s, s8("ARM\n")); break;
@@ -156,10 +153,10 @@ dump_gl_params(GLParams *gl, Arena a, OS *os)
}
#define X(glname, name, suffix) \
- stream_append_s8(&s, s8(#name ":")); \
- stream_pad(&s, ' ', max_width - s8(#name ":").len); \
- stream_append_i64(&s, gl->name); \
- stream_append_s8(&s, s8(suffix)); \
+ stream_append_s8(&s, s8(#name ":")); \
+ stream_pad(&s, ' ', max_width - (i32)s8(#name ":").len); \
+ stream_append_i64(&s, gl->name); \
+ stream_append_s8(&s, s8(suffix)); \
stream_append_byte(&s, '\n');
GL_PARAMETERS
#undef X
@@ -171,7 +168,7 @@ dump_gl_params(GLParams *gl, Arena a, OS *os)
function FILE_WATCH_CALLBACK_FN(reload_shader)
{
ShaderReloadContext *ctx = (typeof(ctx))user_data;
- return beamformer_reload_shader(ctx->beamformer_context, ctx, arena, ctx->name);
+ return beamformer_reload_shader(os, ctx->beamformer_context, ctx, arena, ctx->name);
}
function FILE_WATCH_CALLBACK_FN(reload_shader_indirect)
@@ -213,13 +210,13 @@ function FILE_WATCH_CALLBACK_FN(load_cuda_lib)
}
function BeamformerRenderModel
-render_model_from_arrays(f32 *vertices, f32 *normals, u32 vertices_size, u16 *indices, u32 index_count)
+render_model_from_arrays(f32 *vertices, f32 *normals, i32 vertices_size, u16 *indices, i32 index_count)
{
BeamformerRenderModel result = {0};
- i32 buffer_size = vertices_size * 2 + index_count * sizeof(u16);
+ i32 buffer_size = vertices_size * 2 + index_count * (i32)sizeof(u16);
i32 indices_offset = vertices_size * 2;
- i32 indices_size = index_count * sizeof(u16);
+ i32 indices_size = index_count * (i32)sizeof(u16);
result.elements = index_count;
result.elements_offset = indices_offset;
@@ -239,7 +236,7 @@ render_model_from_arrays(f32 *vertices, f32 *normals, u32 vertices_size, u16 *in
glEnableVertexArrayAttrib(result.vao, 1);
glVertexArrayAttribFormat(result.vao, 0, 3, GL_FLOAT, 0, 0);
- glVertexArrayAttribFormat(result.vao, 1, 3, GL_FLOAT, 0, vertices_size);
+ glVertexArrayAttribFormat(result.vao, 1, 3, GL_FLOAT, 0, (u32)vertices_size);
glVertexArrayAttribBinding(result.vao, 0, 0);
glVertexArrayAttribBinding(result.vao, 1, 0);
@@ -259,7 +256,7 @@ function OS_THREAD_ENTRY_POINT_FN(compute_worker_thread_entry_point)
glfwMakeContextCurrent(ctx->window_handle);
ctx->gl_context = os_get_native_gl_context(ctx->window_handle);
- beamformer_compute_setup(ctx->user_context, ctx->arena, ctx->gl_context);
+ beamformer_compute_setup(ctx->user_context);
for (;;) {
for (;;) {
@@ -268,7 +265,7 @@ function OS_THREAD_ENTRY_POINT_FN(compute_worker_thread_entry_point)
break;
atomic_store_u32(&ctx->asleep, 1);
- os_wait_on_value(&ctx->sync_variable, 1, -1);
+ os_wait_on_value(&ctx->sync_variable, 1, (u32)-1);
atomic_store_u32(&ctx->asleep, 0);
}
beamformer_complete_compute(ctx->user_context, ctx->arena, ctx->gl_context);
@@ -284,7 +281,7 @@ setup_beamformer(BeamformerCtx *ctx, BeamformerInput *input, Arena *memory)
{
debug_init(&ctx->os, (iptr)input, memory);
- ctx->window_size = (uv2){.w = 1280, .h = 840};
+ ctx->window_size = (iv2){{1280, 840}};
SetConfigFlags(FLAG_VSYNC_HINT|FLAG_WINDOW_ALWAYS_RUN);
InitWindow(ctx->window_size.w, ctx->window_size.h, "OGL Beamformer");
@@ -531,7 +528,7 @@ beamformer_invalidate_shared_memory(BeamformerCtx *ctx)
atomic_store_u32(&sm->invalid, 1);
atomic_store_u32(&sm->external_work_queue.ridx, sm->external_work_queue.widx);
DEBUG_DECL(if (sm->locks[lock])) {
- os_shared_memory_region_unlock(&ctx->shared_memory, sm->locks, lock);
+ os_shared_memory_region_unlock(&ctx->shared_memory, sm->locks, (i32)lock);
}
atomic_or_u32(&sm->live_imaging_dirty_flags, BeamformerLiveImagingDirtyFlags_StopImaging);
diff --git a/tests/throughput.c b/tests/throughput.c
@@ -14,10 +14,10 @@
#include <stdlib.h>
#include <zstd.h>
-global u32 g_output_points[4] = {512, 1, 1024, 1};
-global v2 g_axial_extent = {{ 10e-3, 165e-3}};
-global v2 g_lateral_extent = {{-60e-3, 60e-3}};
-global f32 g_f_number = 0.5;
+global i32 g_output_points[4] = {512, 1, 1024, 1};
+global v2 g_axial_extent = {{ 10e-3f, 165e-3f}};
+global v2 g_lateral_extent = {{-60e-3f, 60e-3f}};
+global f32 g_f_number = 0.5f;
typedef struct {
b32 loop;
@@ -79,7 +79,7 @@ function void os_init_timer(void) { }
function f64
os_get_time(void)
{
- f64 result = (f64)os_get_timer_counter() / os_get_timer_frequency();
+ f64 result = (f64)os_get_timer_counter() / (f64)os_get_timer_frequency();
return result;
}
@@ -96,11 +96,11 @@ os_read_file_simp(char *fname)
die("couldn't stat file\n");
result.len = st.st_size;
- result.data = malloc(st.st_size);
+ result.data = malloc((uz)st.st_size);
if (!result.data)
die("couldn't alloc space for reading\n");
- iz rlen = read(fd, result.data, st.st_size);
+ iz rlen = read(fd, result.data, (u32)st.st_size);
close(fd);
if (rlen != st.st_size)
@@ -122,7 +122,7 @@ os_init_timer(void)
function f64
os_get_time(void)
{
- f64 result = (f64)os_get_timer_counter() / os_context.timer_frequency;
+ f64 result = (f64)os_get_timer_counter() / (f64)os_context.timer_frequency;
return result;
}
@@ -144,7 +144,7 @@ os_read_file_simp(char *fname)
die("couldn't alloc space for reading\n");
i32 rlen = 0;
- if (!ReadFile(h, result.data, fileinfo.nFileSizeLow, &rlen, 0) && rlen != fileinfo.nFileSizeLow)
+ if (!ReadFile(h, result.data, (i32)fileinfo.nFileSizeLow, &rlen, 0) && rlen != (i32)fileinfo.nFileSizeLow)
die("couldn't read file: %s\n", fname);
CloseHandle(h);
@@ -168,28 +168,13 @@ stream_ensure_termination(Stream *s, u8 byte)
}
}
-function void
-stream_append_u64_width(Stream *s, u64 n, u64 min_width)
-{
- u8 tmp[64];
- u8 *end = tmp + sizeof(tmp);
- u8 *beg = end;
- min_width = MIN(sizeof(tmp), min_width);
-
- do { *--beg = '0' + (n % 10); } while (n /= 10);
- while (end - beg > 0 && end - beg < min_width)
- *--beg = '0';
-
- stream_append(s, beg, end - beg);
-}
-
function void *
decompress_zstd_data(s8 raw)
{
- iz requested_size = ZSTD_getFrameContentSize(raw.data, raw.len);
+ uz requested_size = ZSTD_getFrameContentSize(raw.data, (uz)raw.len);
void *out = malloc(requested_size);
if (out) {
- iz decompressed = ZSTD_decompress(out, requested_size, raw.data, raw.len);
+ uz decompressed = ZSTD_decompress(out, requested_size, raw.data, (uz)raw.len);
if (decompressed != requested_size) {
free(out);
out = 0;
@@ -218,7 +203,7 @@ fill_beamformer_parameters_from_zemp_bp_v1(zemp_bp_v1 *zbp, BeamformerParameters
mem_copy(out->xdc_element_pitch, zbp->xdc_element_pitch, sizeof(out->xdc_element_pitch));
mem_copy(out->rf_raw_dim, zbp->raw_data_dim, sizeof(out->rf_raw_dim));
- out->transmit_mode = zbp->transmit_mode;
+ out->transmit_mode = (i32)zbp->transmit_mode;
out->decode = zbp->decode_mode;
out->das_shader_id = zbp->beamform_mode;
out->time_offset = zbp->time_offset;
@@ -269,7 +254,7 @@ parse_argv(i32 argc, char *argv[])
} else if (s8_equal(arg, s8("--frame"))) {
shift(argv, argc);
if (argc) {
- result.frame_number = atoi(*argv);
+ result.frame_number = (u32)atoi(*argv);
shift(argv, argc);
}
} else if (arg.len > 0 && arg.data[0] == '-') {
@@ -322,7 +307,7 @@ execute_study(s8 study, Arena arena, Stream path, Options *options)
stream_append_s8(&path, study);
stream_ensure_termination(&path, OS_PATH_SEPARATOR_CHAR);
stream_append_s8(&path, study);
- iz path_work_index = path.widx;
+ i32 path_work_index = path.widx;
stream_append_s8(&path, s8(".bp"));
stream_ensure_termination(&path, 0);
@@ -351,7 +336,7 @@ execute_study(s8 study, Arena arena, Stream path, Options *options)
bp.interpolate = 0;
if (zbp->sparse_elements[0] == -1) {
- for (u32 i = 0; i < countof(zbp->sparse_elements); i++)
+ for (i16 i = 0; i < countof(zbp->sparse_elements); i++)
zbp->sparse_elements[i] = i;
}
@@ -369,7 +354,7 @@ execute_study(s8 study, Arena arena, Stream path, Options *options)
free(zbp);
i32 shader_stages[16];
- i32 shader_stage_count = 0;
+ u32 shader_stage_count = 0;
if (options->cuda) shader_stages[shader_stage_count++] = BeamformerShaderKind_CudaDecode;
else shader_stages[shader_stage_count++] = BeamformerShaderKind_Decode;
shader_stages[shader_stage_count++] = BeamformerShaderKind_DASCompute;
@@ -382,12 +367,12 @@ execute_study(s8 study, Arena arena, Stream path, Options *options)
if (options->loop) {
u32 frame = 0;
f32 times[32] = {0};
- f32 data_size = bp.rf_raw_dim[0] * bp.rf_raw_dim[1] * sizeof(*data);
+ f32 data_size = (f32)(bp.rf_raw_dim[0] * bp.rf_raw_dim[1] * sizeof(*data));
f64 start = os_get_time();
for (;!g_should_exit;) {
if (send_frame(data, &bp)) {
f64 now = os_get_time();
- f32 delta = now - start;
+ f32 delta = (f32)(now - start);
start = now;
if ((frame % 16) == 0) {
diff --git a/ui.c b/ui.c
@@ -26,23 +26,23 @@
* [ ]: refactor: better method of grouping variables for views such as FrameView/ComputeStatsView
*/
-#define BG_COLOUR (v4){.r = 0.15, .g = 0.12, .b = 0.13, .a = 1.0}
-#define FG_COLOUR (v4){.r = 0.92, .g = 0.88, .b = 0.78, .a = 1.0}
-#define FOCUSED_COLOUR (v4){.r = 0.86, .g = 0.28, .b = 0.21, .a = 1.0}
-#define HOVERED_COLOUR (v4){.r = 0.11, .g = 0.50, .b = 0.59, .a = 1.0}
-#define RULER_COLOUR (v4){.r = 1.00, .g = 0.70, .b = 0.00, .a = 1.0}
-#define BORDER_COLOUR v4_lerp(FG_COLOUR, BG_COLOUR, 0.85)
-
-#define MENU_PLUS_COLOUR (v4){.r = 0.33, .g = 0.42, .b = 1.00, .a = 1.0}
+#define BG_COLOUR (v4){{0.15f, 0.12f, 0.13f, 1.0f}}
+#define FG_COLOUR (v4){{0.92f, 0.88f, 0.78f, 1.0f}}
+#define FOCUSED_COLOUR (v4){{0.86f, 0.28f, 0.21f, 1.0f}}
+#define HOVERED_COLOUR (v4){{0.11f, 0.50f, 0.59f, 1.0f}}
+#define RULER_COLOUR (v4){{1.00f, 0.70f, 0.00f, 1.0f}}
+#define BORDER_COLOUR v4_lerp(FG_COLOUR, BG_COLOUR, 0.85f)
+
+#define MENU_PLUS_COLOUR (v4){{0.33f, 0.42f, 1.00f, 1.00f}}
#define MENU_CLOSE_COLOUR FOCUSED_COLOUR
read_only global v4 g_colour_palette[] = {
- {{0.32, 0.20, 0.50, 1.00}},
- {{0.14, 0.39, 0.61, 1.00}},
- {{0.61, 0.14, 0.25, 1.00}},
- {{0.20, 0.60, 0.24, 1.00}},
- {{0.80, 0.60, 0.20, 1.00}},
- {{0.15, 0.51, 0.74, 1.00}},
+ {{0.32f, 0.20f, 0.50f, 1.00f}},
+ {{0.14f, 0.39f, 0.61f, 1.00f}},
+ {{0.61f, 0.14f, 0.25f, 1.00f}},
+ {{0.20f, 0.60f, 0.24f, 1.00f}},
+ {{0.80f, 0.60f, 0.20f, 1.00f}},
+ {{0.15f, 0.51f, 0.74f, 1.00f}},
};
#define HOVER_SPEED 5.0f
@@ -288,9 +288,9 @@ struct BeamformerFrameView {
BeamformerFrame *frame;
BeamformerFrameView *prev, *next;
- uv2 texture_dim;
+ iv2 texture_dim;
u32 textures[2];
- u32 texture_mipmaps;
+ i32 texture_mipmaps;
/* NOTE(rnp): any pointers to variables are added to the menu and will
* be put onto the freelist if the view is closed. */
@@ -508,19 +508,19 @@ typedef struct {
function v2
measure_glyph(Font font, u32 glyph)
{
- ASSERT(glyph >= 0x20);
- v2 result = {.y = font.baseSize};
+ assert(glyph >= 0x20);
+ v2 result = {.y = (f32)font.baseSize};
/* NOTE: assumes font glyphs are ordered ASCII */
- result.x = font.glyphs[glyph - 0x20].advanceX;
+ result.x = (f32)font.glyphs[glyph - 0x20].advanceX;
if (result.x == 0)
- result.x = (font.recs[glyph - 0x20].width + font.glyphs[glyph - 0x20].offsetX);
+ result.x = (font.recs[glyph - 0x20].width + (f32)font.glyphs[glyph - 0x20].offsetX);
return result;
}
function v2
measure_text(Font font, s8 text)
{
- v2 result = {.y = font.baseSize};
+ v2 result = {.y = (f32)font.baseSize};
for (iz i = 0; i < text.len; i++)
result.x += measure_glyph(font, text.data[i]).x;
return result;
@@ -682,14 +682,14 @@ table_new_(Arena *a, i32 initial_capacity, TextAlignment *alignment, i32 columns
result->alignment = push_array(a, TextAlignment, columns);
result->widths = push_array(a, f32, columns);
result->cell_pad = (v2){{TABLE_CELL_PAD_WIDTH, TABLE_CELL_PAD_HEIGHT}};
- mem_copy(result->alignment, alignment, sizeof(*alignment) * columns);
+ mem_copy(result->alignment, alignment, sizeof(*alignment) * (u32)columns);
return result;
}
function i32
table_skip_rows(Table *t, f32 draw_height, f32 text_height)
{
- i32 max_rows = draw_height / (text_height + t->cell_pad.h);
+ i32 max_rows = (i32)(draw_height / (text_height + t->cell_pad.h));
i32 result = t->rows - MIN(t->rows, max_rows);
return result;
}
@@ -702,9 +702,9 @@ table_iterator_new(Table *table, TableIteratorKind kind, Arena *a, i32 starting_
result->frame.table = table;
result->frame.row_index = starting_row;
result->start_x = at.x;
- result->cell_rect.size.h = font->baseSize;
- result->cell_rect.pos = v2_add(at, v2_scale(table->cell_pad, 0.5));
- result->cell_rect.pos.y += (starting_row - 1) * (result->cell_rect.size.h + table->cell_pad.h + table->row_border_thick);
+ result->cell_rect.size.h = (f32)font->baseSize;
+ result->cell_rect.pos = v2_add(at, v2_scale(table->cell_pad, 0.5f));
+ result->cell_rect.pos.y += (f32)(starting_row - 1) * (result->cell_rect.size.h + table->cell_pad.h + table->row_border_thick);
da_reserve(a, &result->stack, 4);
return result;
}
@@ -765,8 +765,8 @@ table_width(Table *t)
result += t->widths[i];
if (t->widths[i] > 0) valid++;
}
- result += t->cell_pad.w * valid;
- result += MAX(0, (valid - 1)) * t->column_border_thick;
+ result += t->cell_pad.w * (f32)valid;
+ result += MAX(0, ((f32)valid - 1)) * t->column_border_thick;
return result;
}
@@ -781,7 +781,7 @@ table_extent(Table *t, Arena arena, Font *font)
for (i32 i = 0; i < it->frame.table->columns; i++) {
TableCell *cell = (TableCell *)row->data + i;
if (!cell->text.len && cell->var && cell->var->flags & V_RADIO_BUTTON) {
- cell->width = font->baseSize;
+ cell->width = (f32)font->baseSize;
} else {
cell->width = measure_text(*font, cell->text).w;
}
@@ -865,13 +865,13 @@ table_end_subtable(Table *table)
}
function void
-resize_frame_view(BeamformerFrameView *view, uv2 dim, b32 depth)
+resize_frame_view(BeamformerFrameView *view, iv2 dim, b32 depth)
{
glDeleteTextures(countof(view->textures), view->textures);
glCreateTextures(GL_TEXTURE_2D, countof(view->textures) - !!depth, view->textures);
view->texture_dim = dim;
- view->texture_mipmaps = ctz_u32(MAX(dim.x, dim.y)) + 1;
+ view->texture_mipmaps = (i32)ctz_u32((u32)MAX(dim.x, dim.y)) + 1;
glTextureStorage2D(view->textures[0], view->texture_mipmaps, GL_RGBA8, dim.x, dim.y);
if (depth) glTextureStorage2D(view->textures[1], 1, GL_DEPTH_COMPONENT24, dim.x, dim.y);
@@ -1121,25 +1121,25 @@ add_beamformer_parameters_view(Variable *parent, BeamformerCtx *ctx)
VT_GROUP, ui->font);
add_beamformer_variable(ui, group, &ui->arena, s8("Sampling Frequency:"), s8("[MHz]"),
- &bp->sampling_frequency, (v2){0}, 1e-6, 0, 0, ui->font);
+ &bp->sampling_frequency, (v2){0}, 1e-6f, 0, 0, ui->font);
add_beamformer_variable(ui, group, &ui->arena, s8("Center Frequency:"), s8("[MHz]"),
- &bp->center_frequency, (v2){.y = 100e-6}, 1e-6, 1e5,
+ &bp->center_frequency, (v2){.y = 100e-6f}, 1e-6f, 1e5f,
V_INPUT|V_TEXT|V_CAUSES_COMPUTE, ui->font);
add_beamformer_variable(ui, group, &ui->arena, s8("Speed of Sound:"), s8("[m/s]"),
- &bp->speed_of_sound, (v2){.y = 1e6}, 1, 10,
+ &bp->speed_of_sound, (v2){.y = 1e6f}, 1.0f, 10.0f,
V_INPUT|V_TEXT|V_CAUSES_COMPUTE, ui->font);
group = add_variable_group(ui, group, &ui->arena, s8("Lateral Extent:"),
VariableGroupKind_Vector, ui->font);
{
add_beamformer_variable(ui, group, &ui->arena, s8("Min:"), s8("[mm]"),
- bp->output_min_coordinate + 0, v2_inf, 1e3, 0.5e-3,
+ bp->output_min_coordinate + 0, v2_inf, 1e3f, 0.5e-3f,
V_INPUT|V_TEXT|V_CAUSES_COMPUTE, ui->font);
add_beamformer_variable(ui, group, &ui->arena, s8("Max:"), s8("[mm]"),
- bp->output_max_coordinate + 0, v2_inf, 1e3, 0.5e-3,
+ bp->output_max_coordinate + 0, v2_inf, 1e3f, 0.5e-3f,
V_INPUT|V_TEXT|V_CAUSES_COMPUTE, ui->font);
}
group = end_variable_group(group);
@@ -1148,25 +1148,25 @@ add_beamformer_parameters_view(Variable *parent, BeamformerCtx *ctx)
VariableGroupKind_Vector, ui->font);
{
add_beamformer_variable(ui, group, &ui->arena, s8("Min:"), s8("[mm]"),
- bp->output_min_coordinate + 2, v2_inf, 1e3, 0.5e-3,
+ bp->output_min_coordinate + 2, v2_inf, 1e3f, 0.5e-3f,
V_INPUT|V_TEXT|V_CAUSES_COMPUTE, ui->font);
add_beamformer_variable(ui, group, &ui->arena, s8("Max:"), s8("[mm]"),
- bp->output_max_coordinate + 2, v2_inf, 1e3, 0.5e-3,
+ bp->output_max_coordinate + 2, v2_inf, 1e3f, 0.5e-3f,
V_INPUT|V_TEXT|V_CAUSES_COMPUTE, ui->font);
}
group = end_variable_group(group);
add_beamformer_variable(ui, group, &ui->arena, s8("Off Axis Position:"), s8("[mm]"),
- &bp->off_axis_pos, (v2){.x = -1e3, .y = 1e3}, 0.25e3, 0.5e-3,
+ &bp->off_axis_pos, (v2){{-1e3f, 1e3f}}, 0.25e3f, 0.5e-3f,
V_INPUT|V_TEXT|V_CAUSES_COMPUTE, ui->font);
read_only local_persist s8 beamform_plane_labels[] = {s8_comp("XZ"), s8_comp("YZ")};
add_variable_cycler(ui, group, &ui->arena, V_CAUSES_COMPUTE, ui->font, s8("Beamform Plane:"),
(u32 *)&bp->beamform_plane, beamform_plane_labels, countof(beamform_plane_labels));
- add_beamformer_variable(ui, group, &ui->arena, s8("F#:"), s8(""), &bp->f_number, (v2){.y = 1e3},
- 1, 0.1, V_INPUT|V_TEXT|V_CAUSES_COMPUTE, ui->font);
+ add_beamformer_variable(ui, group, &ui->arena, s8("F#:"), s8(""), &bp->f_number, (v2){.y = 1e3f},
+ 1, 0.1f, V_INPUT|V_TEXT|V_CAUSES_COMPUTE, ui->font);
read_only local_persist s8 true_false_labels[] = {s8_comp("False"), s8_comp("True")};
add_variable_cycler(ui, group, &ui->arena, V_CAUSES_COMPUTE, ui->font, s8("Interpolate:"),
@@ -1212,7 +1212,7 @@ ui_beamformer_frame_view_convert(BeamformerUI *ui, Arena *arena, Variable *view,
switch (kind) {
case BeamformerFrameViewKind_3DXPlane:{
view->flags |= V_HIDES_CURSOR;
- resize_frame_view(bv, (uv2){{FRAME_VIEW_RENDER_TARGET_SIZE}}, 0);
+ resize_frame_view(bv, (iv2){{FRAME_VIEW_RENDER_TARGET_SIZE}}, 0);
glTextureParameteri(bv->textures[0], GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTextureParameteri(bv->textures[0], GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
fill_variable(bv->x_plane_shifts + 0, view, s8("XZ Shift"), V_INPUT|V_HIDES_CURSOR,
@@ -1222,15 +1222,15 @@ ui_beamformer_frame_view_convert(BeamformerUI *ui, Arena *arena, Variable *view,
bv->demo = add_variable(ui, menu, arena, s8("Demo Mode"), V_INPUT|V_RADIO_BUTTON, VT_B32, ui->small_font);
}break;
default:{
- view->flags &= ~V_HIDES_CURSOR;
+ view->flags &= ~(u32)V_HIDES_CURSOR;
fill_variable(&bv->lateral_scale_bar, view, s8(""), V_INPUT, VT_SCALE_BAR, ui->small_font);
fill_variable(&bv->axial_scale_bar, view, s8(""), V_INPUT, VT_SCALE_BAR, ui->small_font);
ScaleBar *lateral = &bv->lateral_scale_bar.scale_bar;
ScaleBar *axial = &bv->axial_scale_bar.scale_bar;
lateral->direction = SB_LATERAL;
axial->direction = SB_AXIAL;
- lateral->scroll_scale = (v2){{-0.5e-3, 0.5e-3}};
- axial->scroll_scale = (v2){{ 0, 1.0e-3}};
+ lateral->scroll_scale = (v2){{-0.5e-3f, 0.5e-3f}};
+ axial->scroll_scale = (v2){{ 0, 1.0e-3f}};
lateral->zoom_starting_coord = F32_INFINITY;
axial->zoom_starting_coord = F32_INFINITY;
@@ -1360,12 +1360,12 @@ add_live_controls_view(BeamformerUI *ui, Variable *parent, Arena *arena)
fill_variable(&lv->transmit_power, view, s8(""), V_INPUT|V_LIVE_CONTROL,
VT_BEAMFORMER_VARIABLE, ui->small_font);
- fill_beamformer_variable(&lv->transmit_power, s8(""), &lip->transmit_power, (v2){{0, 1}}, 100, 0.05);
+ fill_beamformer_variable(&lv->transmit_power, s8(""), &lip->transmit_power, (v2){{0, 1.0f}}, 100.0f, 0.05f);
for (u32 i = 0; i < countof(lv->tgc_control_points); i++) {
Variable *v = lv->tgc_control_points + i;
fill_variable(v, view, s8(""), V_INPUT|V_LIVE_CONTROL, VT_BEAMFORMER_VARIABLE, ui->small_font);
- fill_beamformer_variable(v, s8(""), lip->tgc_control_points + i, (v2){{0, 1}}, 0, 0.05);
+ fill_beamformer_variable(v, s8(""), lip->tgc_control_points + i, (v2){{0, 1.0f}}, 0, 0.05f);
}
fill_variable(&lv->stop_button, view, s8("Stop Imaging"), V_INPUT|V_LIVE_CONTROL,
@@ -1421,7 +1421,7 @@ ui_beamformer_frame_view_copy_frame(BeamformerUI *ui, BeamformerFrameView *new,
new->frame->dim.x, new->frame->dim.y, new->frame->dim.z);
glMemoryBarrier(GL_TEXTURE_UPDATE_BARRIER_BIT);
/* TODO(rnp): x vs y here */
- resize_frame_view(new, (uv2){.x = new->frame->dim.x, .y = new->frame->dim.z}, 1);
+ resize_frame_view(new, (iv2){{new->frame->dim.x, new->frame->dim.z}}, 1);
}
function void
@@ -1453,9 +1453,9 @@ beamformer_frame_view_plane_size(BeamformerUI *ui, BeamformerFrameView *view)
v3 max = v4_from_f32_array(ui->params.output_max_coordinate).xyz;
result = v3_sub(max, min);
swap(result.y, result.z);
- result.x = MAX(1e-3, result.x);
- result.y = MAX(1e-3, result.y);
- result.z = MAX(1e-3, result.z);
+ result.x = MAX(1e-3f, result.x);
+ result.y = MAX(1e-3f, result.y);
+ result.z = MAX(1e-3f, result.z);
} else {
v2 size = v2_sub(XZ(view->max_coordinate), XZ(view->min_coordinate));
result = (v3){.x = size.x, .y = size.y};
@@ -1524,8 +1524,8 @@ function m4
projection_matrix_for_x_plane_view(BeamformerFrameView *view)
{
assert(view->kind == BeamformerFrameViewKind_3DXPlane);
- f32 aspect = (f32)view->texture_dim.w / view->texture_dim.h;
- m4 result = perspective_projection(10e-3, 500e-3, 45.0f * PI / 180.0f, aspect);
+ f32 aspect = (f32)view->texture_dim.w / (f32)view->texture_dim.h;
+ m4 result = perspective_projection(10e-3f, 500e-3f, 45.0f * PI / 180.0f, aspect);
return result;
}
@@ -1618,7 +1618,7 @@ render_3D_xplane(BeamformerUI *ui, BeamformerFrameView *view, u32 program)
x_plane_rotation_for_view_plane(view, BeamformerViewPlaneTag_XZ),
model_translate, BeamformerViewPlaneTag_XZ);
model_translate = offset_x_plane_position(ui, view, BeamformerViewPlaneTag_YZ);
- model_translate.y -= 0.0001;
+ model_translate.y -= 0.0001f;
render_single_xplane(ui, view, view->x_plane_shifts + 1, program,
x_plane_rotation_for_view_plane(view, BeamformerViewPlaneTag_YZ),
model_translate, BeamformerViewPlaneTag_YZ);
@@ -1645,7 +1645,7 @@ render_2D_plane(BeamformerUI *ui, BeamformerFrameView *view, u32 program)
function b32
frame_view_ready_to_present(BeamformerUI *ui, BeamformerFrameView *view)
{
- b32 result = !uv2_equal((uv2){0}, view->texture_dim) && view->frame;
+ b32 result = !iv2_equal((iv2){0}, view->texture_dim) && view->frame;
result |= view->kind == BeamformerFrameViewKind_3DXPlane &&
ui->latest_plane[BeamformerViewPlaneTag_Count];
return result;
@@ -1666,11 +1666,11 @@ view_update(BeamformerUI *ui, BeamformerFrameView *view)
/* TODO(rnp): x-z or y-z */
/* 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]};
+ iv2 current = view->texture_dim;
+ iv2 target = {.w = (i32)ui->params.output_points[0], .h = (i32)ui->params.output_points[2]};
if (view->kind != BeamformerFrameViewKind_Copy &&
view->kind != BeamformerFrameViewKind_3DXPlane &&
- !uv2_equal(current, target) && !uv2_equal(target, (uv2){0}))
+ !iv2_equal(current, target) && !iv2_equal(target, (iv2){0}))
{
resize_frame_view(view, target, 1);
view->dirty = 1;
@@ -1728,7 +1728,7 @@ update_frame_views(BeamformerUI *ui, Rect window)
}
if (fbo_bound) {
glBindFramebuffer(GL_FRAMEBUFFER, 0);
- glViewport(window.pos.x, window.pos.y, window.size.w, window.size.h);
+ glViewport((i32)window.pos.x, (i32)window.pos.y, (i32)window.size.w, (i32)window.size.h);
/* NOTE(rnp): I don't trust raylib to not mess with us */
glBindVertexArray(0);
glDisable(GL_DEPTH_TEST);
@@ -1738,8 +1738,9 @@ update_frame_views(BeamformerUI *ui, Rect window)
function Color
colour_from_normalized(v4 rgba)
{
- return (Color){.r = rgba.r * 255.0f, .g = rgba.g * 255.0f,
- .b = rgba.b * 255.0f, .a = rgba.a * 255.0f};
+ Color result = {.r = (u8)(rgba.r * 255.0f), .g = (u8)(rgba.g * 255.0f),
+ .b = (u8)(rgba.b * 255.0f), .a = (u8)(rgba.a * 255.0f)};
+ return result;
}
function Color
@@ -1753,28 +1754,29 @@ function v2
draw_text_base(Font font, s8 text, v2 pos, Color colour)
{
v2 off = v2_floor(pos);
+ f32 glyph_pad = (f32)font.glyphPadding;
for (iz i = 0; i < text.len; i++) {
/* NOTE: assumes font glyphs are ordered ASCII */
i32 idx = text.data[i] - 0x20;
Rectangle dst = {
- off.x + font.glyphs[idx].offsetX - font.glyphPadding,
- off.y + font.glyphs[idx].offsetY - font.glyphPadding,
- font.recs[idx].width + 2.0f * font.glyphPadding,
- font.recs[idx].height + 2.0f * font.glyphPadding
+ off.x + (f32)font.glyphs[idx].offsetX - glyph_pad,
+ off.y + (f32)font.glyphs[idx].offsetY - glyph_pad,
+ font.recs[idx].width + 2.0f * glyph_pad,
+ font.recs[idx].height + 2.0f * glyph_pad
};
Rectangle src = {
- font.recs[idx].x - font.glyphPadding,
- font.recs[idx].y - font.glyphPadding,
- font.recs[idx].width + 2.0f * font.glyphPadding,
- font.recs[idx].height + 2.0f * font.glyphPadding
+ font.recs[idx].x - glyph_pad,
+ font.recs[idx].y - glyph_pad,
+ font.recs[idx].width + 2.0f * glyph_pad,
+ font.recs[idx].height + 2.0f * glyph_pad
};
DrawTexturePro(font.texture, src, dst, (Vector2){0}, 0, colour);
- off.x += font.glyphs[idx].advanceX;
+ off.x += (f32)font.glyphs[idx].advanceX;
if (font.glyphs[idx].advanceX == 0)
off.x += font.recs[idx].width;
}
- v2 result = {.x = off.x - pos.x, .y = font.baseSize};
+ v2 result = {{off.x - pos.x, (f32)font.baseSize}};
return result;
}
@@ -1952,19 +1954,19 @@ draw_title_bar(BeamformerUI *ui, Arena arena, Variable *ui_view, Rect r, v2 mous
}
Rect result, title_rect;
- cut_rect_vertical(r, ui->small_font.baseSize + TITLE_BAR_PAD, &title_rect, &result);
+ cut_rect_vertical(r, (f32)ui->small_font.baseSize + TITLE_BAR_PAD, &title_rect, &result);
cut_rect_vertical(result, LISTING_LINE_PAD, 0, &result);
DrawRectangleRec(title_rect.rl, BLACK);
- title_rect = shrink_rect_centered(title_rect, (v2){.x = 1.5 * TITLE_BAR_PAD});
- DrawRectangleRounded(title_rect.rl, 0.5, 0, fade(colour_from_normalized(BG_COLOUR), 0.55));
- title_rect = shrink_rect_centered(title_rect, (v2){.x = 3 * TITLE_BAR_PAD});
+ title_rect = shrink_rect_centered(title_rect, (v2){.x = 1.5f * TITLE_BAR_PAD});
+ DrawRectangleRounded(title_rect.rl, 0.5f, 0, fade(colour_from_normalized(BG_COLOUR), 0.55f));
+ title_rect = shrink_rect_centered(title_rect, (v2){.x = 3.0f * TITLE_BAR_PAD});
if (view->close) {
Rect close;
cut_rect_horizontal(title_rect, title_rect.size.w - title_rect.size.h, &title_rect, &close);
- draw_close_button(ui, view->close, mouse, close, (v2){{.4, .4}});
+ draw_close_button(ui, view->close, mouse, close, (v2){{0.4f, 0.4f}});
}
if (view->menu) {
@@ -1974,7 +1976,7 @@ draw_title_bar(BeamformerUI *ui, Arena arena, Variable *ui_view, Rect r, v2 mous
hover_interaction(ui, mouse, interaction);
Color colour = colour_from_normalized(v4_lerp(MENU_PLUS_COLOUR, FG_COLOUR, view->menu->hover_t));
- menu = shrink_rect_centered(menu, (v2){.x = 14, .y = 14});
+ menu = shrink_rect_centered(menu, (v2){{14.0f, 14.0f}});
DrawLineEx(v2_add(menu.pos, (v2){.x = menu.size.w / 2}).rl,
v2_add(menu.pos, (v2){.x = menu.size.w / 2, .y = menu.size.h}).rl, 4, colour);
DrawLineEx(v2_add(menu.pos, (v2){.y = menu.size.h / 2}).rl,
@@ -1982,7 +1984,7 @@ draw_title_bar(BeamformerUI *ui, Arena arena, Variable *ui_view, Rect r, v2 mous
}
v2 title_pos = title_rect.pos;
- title_pos.y += 0.5 * TITLE_BAR_PAD;
+ title_pos.y += 0.5f * TITLE_BAR_PAD;
TextSpec text_spec = {.font = &ui->small_font, .flags = TF_LIMITED, .colour = FG_COLOUR,
.limits.size = title_rect.size};
draw_text(title, title_pos, &text_spec);
@@ -2006,14 +2008,14 @@ draw_ruler(BeamformerUI *ui, Arena arena, v2 start_point, v2 end_point,
rlTranslatef(start_point.x, start_point.y, 0);
rlRotatef(rotation, 0, 0, 1);
- f32 inc = v2_magnitude(end_point) / segments;
- f32 value_inc = (end_value - start_value) / segments;
+ f32 inc = v2_magnitude(end_point) / (f32)segments;
+ f32 value_inc = (end_value - start_value) / (f32)segments;
f32 value = start_value;
Stream buf = arena_stream(arena);
v2 sp = {0}, ep = {.y = RULER_TICK_LENGTH};
- v2 tp = {.x = ui->small_font.baseSize / 2, .y = ep.y + RULER_TEXT_PAD};
- TextSpec text_spec = {.font = &ui->small_font, .rotation = 90, .colour = txt_colour, .flags = TF_ROTATED};
+ v2 tp = {{(f32)ui->small_font.baseSize / 2.0f, ep.y + RULER_TEXT_PAD}};
+ TextSpec text_spec = {.font = &ui->small_font, .rotation = 90.0f, .colour = txt_colour, .flags = TF_ROTATED};
Color rl_txt_colour = colour_from_normalized(txt_colour);
for (u32 j = 0; j <= segments; j++) {
DrawLineEx(sp.rl, ep.rl, 3, rl_txt_colour);
@@ -2068,13 +2070,13 @@ do_scale_bar(BeamformerUI *ui, Arena arena, Variable *scale_bar, v2 mouse, Rect
u32 tick_count;
if (sb->direction == SB_AXIAL) {
tick_rect.size.x = RULER_TEXT_PAD + RULER_TICK_LENGTH + txt_s.x;
- tick_count = tick_rect.size.y / (1.5 * ui->small_font.baseSize);
+ tick_count = (u32)(tick_rect.size.y / (1.5f * (f32)ui->small_font.baseSize));
start_pos.y += tick_rect.size.y;
markers[0] = tick_rect.size.y - screen_zoom_point.y;
markers[1] = tick_rect.size.y - relative_mouse.y;
} else {
tick_rect.size.y = RULER_TEXT_PAD + RULER_TICK_LENGTH + txt_s.x;
- tick_count = tick_rect.size.x / (1.5 * ui->small_font.baseSize);
+ tick_count = (u32)(tick_rect.size.x / (1.5f * (f32)ui->small_font.baseSize));
end_pos.x += tick_rect.size.x;
markers[0] = screen_zoom_point.x;
markers[1] = relative_mouse.x;
@@ -2098,10 +2100,10 @@ draw_radio_button(BeamformerUI *ui, Variable *var, v2 at, v2 mouse, v4 base_colo
hover_rect.pos.y += 1;
hover_interaction(ui, mouse, auto_interaction(hover_rect, var));
- hover_rect = shrink_rect_centered(hover_rect, (v2){.x = 8, .y = 8});
- Rect inner = shrink_rect_centered(hover_rect, (v2){.x = 4, .y = 4});
+ hover_rect = shrink_rect_centered(hover_rect, (v2){{8.0f, 8.0f}});
+ Rect inner = shrink_rect_centered(hover_rect, (v2){{4.0f, 4.0f}});
v4 fill = v4_lerp(value? base_colour : (v4){0}, HOVERED_COLOUR, var->hover_t);
- DrawRectangleRoundedLinesEx(hover_rect.rl, 0.2, 0, 2, colour_from_normalized(base_colour));
+ DrawRectangleRoundedLinesEx(hover_rect.rl, 0.2f, 0, 2, colour_from_normalized(base_colour));
DrawRectangleRec(inner.rl, colour_from_normalized(fill));
return result;
@@ -2110,25 +2112,25 @@ draw_radio_button(BeamformerUI *ui, Variable *var, v2 at, v2 mouse, v4 base_colo
function f32
draw_variable_slider(BeamformerUI *ui, Variable *var, Rect r, f32 fill, v4 fill_colour, v2 mouse)
{
- f32 border_thick = 3;
- f32 bar_height_frac = 0.8;
- v2 bar_size = {{6, bar_height_frac * r.size.y}};
+ f32 border_thick = 3.0f;
+ f32 bar_height_frac = 0.8f;
+ v2 bar_size = {{6.0f, bar_height_frac * r.size.y}};
- Rect inner = shrink_rect_centered(r, (v2){{2 * border_thick, // NOTE(rnp): raylib jank
- MAX(0, 2 * (r.size.y - bar_size.y))}});
+ Rect inner = shrink_rect_centered(r, (v2){{2.0f * border_thick, // NOTE(rnp): raylib jank
+ MAX(0, 2.0f * (r.size.y - bar_size.y))}});
Rect filled = inner;
filled.size.w *= fill;
Rect bar;
- bar.pos = v2_add(r.pos, (v2){{fill * (r.size.w - bar_size.w), (1 - bar_height_frac) * 0.5 * r.size.y}});
+ bar.pos = v2_add(r.pos, (v2){{fill * (r.size.w - bar_size.w), (1 - bar_height_frac) * 0.5f * r.size.y}});
bar.size = bar_size;
v4 bar_colour = v4_lerp(FG_COLOUR, FOCUSED_COLOUR, var->hover_t);
hover_interaction(ui, mouse, auto_interaction(inner, var));
DrawRectangleRec(filled.rl, colour_from_normalized(fill_colour));
- DrawRectangleRoundedLinesEx(inner.rl, 0.2, 0, border_thick, BLACK);
- DrawRectangleRounded(bar.rl, 0.6, 1, colour_from_normalized(bar_colour));
+ DrawRectangleRoundedLinesEx(inner.rl, 0.2f, 0, border_thick, BLACK);
+ DrawRectangleRounded(bar.rl, 0.6f, 1, colour_from_normalized(bar_colour));
return r.size.y;
}
@@ -2136,12 +2138,12 @@ draw_variable_slider(BeamformerUI *ui, Variable *var, Rect r, f32 fill, v4 fill_
function v2
draw_fancy_button(BeamformerUI *ui, Variable *var, s8 label, Rect r, v4 border_colour, v2 mouse, TextSpec ts)
{
- assert(ts.font->baseSize <= r.size.h * 0.8);
- f32 pad = 0.1 * r.size.h;
+ assert((f32)ts.font->baseSize <= r.size.h * 0.8f);
+ f32 pad = 0.1f * r.size.h;
- v2 shadow_off = {{2.5, 3}};
- f32 border_thick = 3;
- v2 border_size = v2_add((v2){{pad + 2 * border_thick, pad}}, shadow_off);
+ v2 shadow_off = {{2.5f, 3.0f}};
+ f32 border_thick = 3.0f;
+ v2 border_size = v2_add((v2){{pad + 2.0f * border_thick, pad}}, shadow_off);
Rect border = shrink_rect_centered(r, border_size);
Rect inner = shrink_rect_centered(border, (v2){{pad, pad}});
@@ -2151,19 +2153,19 @@ draw_fancy_button(BeamformerUI *ui, Variable *var, s8 label, Rect r, v4 border_c
border.pos = v2_add(border.pos, shadow_off);
- DrawRectangleRoundedLinesEx(border.rl, 0.6, 0, border_thick, fade(BLACK, 0.8));
+ DrawRectangleRoundedLinesEx(border.rl, 0.6f, 0, border_thick, fade(BLACK, 0.8f));
border.pos = v2_sub(border.pos, shadow_off);
- DrawRectangleRounded(border.rl, 0.6, 1, colour_from_normalized(BG_COLOUR));
- DrawRectangleRoundedLinesEx(border.rl, 0.6, 0, border_thick, colour_from_normalized(border_colour));
+ DrawRectangleRounded(border.rl, 0.6f, 1, colour_from_normalized(BG_COLOUR));
+ DrawRectangleRoundedLinesEx(border.rl, 0.6f, 0, border_thick, colour_from_normalized(border_colour));
/* TODO(rnp): teach draw_text() about alignment */
v2 at = align_text_in_rect(label, inner, *ts.font);
- at = v2_add(at, (v2){{3, 3}});
+ at = v2_add(at, (v2){{3.0f, 3.0f}});
v4 base_colour = ts.colour;
- ts.colour = (v4){{0, 0, 0, 0.8}};
+ ts.colour = (v4){{0, 0, 0, 0.8f}};
draw_text(label, at, &ts);
- at = v2_sub(at, (v2){{3, 3}});
+ at = v2_sub(at, (v2){{3.0f, 3.0f}});
ts.colour = v4_lerp(base_colour, HOVERED_COLOUR, var->hover_t);
draw_text(label, at, &ts);
@@ -2176,7 +2178,7 @@ draw_variable(BeamformerUI *ui, Arena arena, Variable *var, v2 at, v2 mouse, v4
{
v2 result;
if (var->flags & V_RADIO_BUTTON) {
- result = draw_radio_button(ui, var, at, mouse, base_colour, text_spec.font->baseSize);
+ result = draw_radio_button(ui, var, at, mouse, base_colour, (f32)text_spec.font->baseSize);
} else {
Stream buf = arena_stream(arena);
stream_append_variable(&buf, var);
@@ -2249,7 +2251,7 @@ draw_table_borders(Table *t, Rect r, f32 line_height)
start.x += dx;
end.x += dx;
if (t->widths[i + 1] > 0)
- DrawLineEx(start.rl, end.rl, t->column_border_thick, fade(BLACK, 0.8));
+ DrawLineEx(start.rl, end.rl, t->column_border_thick, fade(BLACK, 0.8f));
}
}
@@ -2261,7 +2263,7 @@ draw_table_borders(Table *t, Rect r, f32 line_height)
f32 dy = line_height + t->cell_pad.y + t->row_border_thick;
start.y += dy;
end.y += dy;
- DrawLineEx(start.rl, end.rl, t->row_border_thick, fade(BLACK, 0.8));
+ DrawLineEx(start.rl, end.rl, t->row_border_thick, fade(BLACK, 0.8f));
}
}
}
@@ -2272,7 +2274,7 @@ draw_table(BeamformerUI *ui, Arena arena, Table *table, Rect draw_rect, TextSpec
ts.flags |= TF_LIMITED;
v2 result = {.x = table_width(table)};
- i32 row_index = skip_rows? table_skip_rows(table, draw_rect.size.h, ts.font->baseSize) : 0;
+ i32 row_index = skip_rows? table_skip_rows(table, draw_rect.size.h, (f32)ts.font->baseSize) : 0;
TableIterator *it = table_iterator_new(table, TIK_CELLS, &arena, row_index, draw_rect.pos, ts.font);
for (TableCell *cell = table_iterator_next(it, &arena);
cell;
@@ -2281,8 +2283,8 @@ draw_table(BeamformerUI *ui, Arena arena, Table *table, Rect draw_rect, TextSpec
ts.limits.size.w = draw_rect.size.w - (it->cell_rect.pos.x - it->start_x);
draw_table_cell(ui, arena, cell, it->cell_rect, it->alignment, ts, mouse);
}
- draw_table_borders(table, draw_rect, ts.font->baseSize);
- result.y = it->cell_rect.pos.y - draw_rect.pos.y - table->cell_pad.h / 2;
+ draw_table_borders(table, draw_rect, (f32)ts.font->baseSize);
+ result.y = it->cell_rect.pos.y - draw_rect.pos.y - table->cell_pad.h / 2.0f;
return result;
}
@@ -2386,15 +2388,15 @@ draw_3D_xplane_frame_view(BeamformerUI *ui, Arena arena, Variable *var, Rect dis
}
for (i32 i = 0; i < countof(view->x_plane_shifts); i++) {
- Variable *var = view->x_plane_shifts + i;
- Interaction interaction = auto_interaction(vr, var);
+ Variable *it = view->x_plane_shifts + i;
+ Interaction interaction = auto_interaction(vr, it);
if (id == i) ui->next_interaction = interaction;
- if (interaction_is_hot(ui, interaction)) var->hover_t += HOVER_SPEED * dt_for_frame;
- else var->hover_t -= HOVER_SPEED * dt_for_frame;
- var->hover_t = CLAMP01(var->hover_t);
+ if (interaction_is_hot(ui, interaction)) it->hover_t += HOVER_SPEED * dt_for_frame;
+ else it->hover_t -= HOVER_SPEED * dt_for_frame;
+ it->hover_t = CLAMP01(it->hover_t);
}
- Rectangle tex_r = {0, 0, view->texture_dim.w, view->texture_dim.h};
+ Rectangle tex_r = {0, 0, (f32)view->texture_dim.w, (f32)view->texture_dim.h};
NPatchInfo tex_np = {tex_r, 0, 0, 0, 0, NPATCH_NINE_PATCH};
DrawTextureNPatch(make_raylib_texture(view), tex_np, vr.rl, (Vector2){0}, 0, WHITE);
@@ -2408,8 +2410,8 @@ draw_beamformer_frame_view(BeamformerUI *ui, Arena a, Variable *var, Rect displa
BeamformerFrameView *view = var->generic;
BeamformerFrame *frame = view->frame;
- v2 txt_s = measure_text(ui->small_font, s8("-288.8 mm"));
- f32 scale_bar_size = 1.2 * txt_s.x + RULER_TICK_LENGTH;
+ f32 txt_w = measure_text(ui->small_font, s8("-288.8 mm")).w;
+ f32 scale_bar_size = 1.2f * txt_w + RULER_TICK_LENGTH;
v3 min = view->min_coordinate;
v3 max = view->max_coordinate;
@@ -2419,14 +2421,14 @@ draw_beamformer_frame_view(BeamformerUI *ui, Arena a, Variable *var, Rect displa
Rect vr = display_rect;
v2 scale_bar_area = {0};
if (view->axial_scale_bar_active->bool32) {
- vr.pos.y += 0.5 * ui->small_font.baseSize;
+ vr.pos.y += 0.5f * (f32)ui->small_font.baseSize;
scale_bar_area.x += scale_bar_size;
- scale_bar_area.y += ui->small_font.baseSize;
+ scale_bar_area.y += (f32)ui->small_font.baseSize;
}
if (view->lateral_scale_bar_active->bool32) {
- vr.pos.x += 0.5 * ui->small_font.baseSize;
- scale_bar_area.x += ui->small_font.baseSize;
+ vr.pos.x += 0.5f * (f32)ui->small_font.baseSize;
+ scale_bar_area.x += (f32)ui->small_font.baseSize;
scale_bar_area.y += scale_bar_size;
}
@@ -2457,7 +2459,7 @@ draw_beamformer_frame_view(BeamformerUI *ui, Arena a, Variable *var, Rect displa
v2 texture_points = v2_mul(pixels_per_meter, requested_dim);
/* TODO(rnp): this also depends on x-y, y-z, x-z */
v2 texture_start = {
- .x = pixels_per_meter.x * 0.5 * (output_dim.x - requested_dim.x),
+ .x = pixels_per_meter.x * 0.5f * (output_dim.x - requested_dim.x),
.y = pixels_per_meter.y * (frame->max_coordinate.z - max.z),
};
@@ -2471,8 +2473,8 @@ draw_beamformer_frame_view(BeamformerUI *ui, Arena a, Variable *var, Rect displa
if (vr.size.w > 0 && view->lateral_scale_bar_active->bool32) {
do_scale_bar(ui, a, &view->lateral_scale_bar, mouse,
(Rect){.pos = start_pos, .size = vr.size},
- *view->lateral_scale_bar.scale_bar.min_value * 1e3,
- *view->lateral_scale_bar.scale_bar.max_value * 1e3, s8(" mm"));
+ *view->lateral_scale_bar.scale_bar.min_value * 1e3f,
+ *view->lateral_scale_bar.scale_bar.max_value * 1e3f, s8(" mm"));
}
start_pos = vr.pos;
@@ -2481,8 +2483,8 @@ draw_beamformer_frame_view(BeamformerUI *ui, Arena a, Variable *var, Rect displa
if (vr.size.h > 0 && view->axial_scale_bar_active->bool32) {
do_scale_bar(ui, a, &view->axial_scale_bar, mouse,
(Rect){.pos = start_pos, .size = vr.size},
- *view->axial_scale_bar.scale_bar.max_value * 1e3,
- *view->axial_scale_bar.scale_bar.min_value * 1e3, s8(" mm"));
+ *view->axial_scale_bar.scale_bar.max_value * 1e3f,
+ *view->axial_scale_bar.scale_bar.min_value * 1e3f, s8(" mm"));
}
TextSpec text_spec = {.font = &ui->small_font, .flags = TF_LIMITED|TF_OUTLINED,
@@ -2499,17 +2501,17 @@ draw_beamformer_frame_view(BeamformerUI *ui, Arena a, Variable *var, Rect displa
XZ(view->min_coordinate),
XZ(view->max_coordinate));
Stream buf = arena_stream(a);
- stream_append_v2(&buf, v2_scale(world, 1e3));
+ stream_append_v2(&buf, v2_scale(world, 1e3f));
- text_spec.limits.size.w -= 4;
+ text_spec.limits.size.w -= 4.0f;
v2 txt_s = measure_text(*text_spec.font, stream_to_s8(&buf));
v2 txt_p = {
- .x = vr.pos.x + vr.size.w - txt_s.w - 4,
- .y = vr.pos.y + vr.size.h - txt_s.h - 4,
+ .x = vr.pos.x + vr.size.w - txt_s.w - 4.0f,
+ .y = vr.pos.y + vr.size.h - txt_s.h - 4.0f,
};
txt_p.x = MAX(vr.pos.x, txt_p.x);
draw_table_width -= draw_text(stream_to_s8(&buf), txt_p, &text_spec).w;
- text_spec.limits.size.w += 4;
+ text_spec.limits.size.w += 4.0f;
}
{
@@ -2517,7 +2519,7 @@ draw_beamformer_frame_view(BeamformerUI *ui, Arena a, Variable *var, Rect displa
s8 shader = push_das_shader_kind(&buf, frame->das_shader_kind, frame->compound_count);
text_spec.font = &ui->font;
text_spec.limits.size.w -= 16;
- v2 txt_s = measure_text(*text_spec.font, shader);
+ v2 txt_s = measure_text(*text_spec.font, shader);
v2 txt_p = {
.x = vr.pos.x + vr.size.w - txt_s.w - 16,
.y = vr.pos.y + 4,
@@ -2535,26 +2537,26 @@ draw_beamformer_frame_view(BeamformerUI *ui, Arena a, Variable *var, Rect displa
}
function v2
-draw_compute_progress_bar(BeamformerUI *ui, Arena arena, ComputeProgressBar *state, Rect r)
+draw_compute_progress_bar(BeamformerUI *ui, ComputeProgressBar *state, Rect r)
{
- if (*state->processing) state->display_t_velocity += 65 * dt_for_frame;
- else state->display_t_velocity -= 45 * dt_for_frame;
+ if (*state->processing) state->display_t_velocity += 65.0f * dt_for_frame;
+ else state->display_t_velocity -= 45.0f * dt_for_frame;
- state->display_t_velocity = CLAMP(state->display_t_velocity, -10, 10);
+ state->display_t_velocity = CLAMP(state->display_t_velocity, -10.0f, 10.0f);
state->display_t += state->display_t_velocity * dt_for_frame;
state->display_t = CLAMP01(state->display_t);
- if (state->display_t > (1.0 / 255.0)) {
- Rect outline = {.pos = r.pos, .size = {.w = r.size.w, .h = ui->font.baseSize}};
- outline = scale_rect_centered(outline, (v2){.x = 0.96, .y = 0.7});
+ if (state->display_t > (1.0f / 255.0f)) {
+ Rect outline = {.pos = r.pos, .size = {{r.size.w, (f32)ui->font.baseSize}}};
+ outline = scale_rect_centered(outline, (v2){{0.96f, 0.7f}});
Rect filled = outline;
filled.size.w *= *state->progress;
- DrawRectangleRounded(filled.rl, 2, 0, fade(colour_from_normalized(HOVERED_COLOUR),
+ DrawRectangleRounded(filled.rl, 2.0f, 0, fade(colour_from_normalized(HOVERED_COLOUR),
state->display_t));
- DrawRectangleRoundedLinesEx(outline.rl, 2, 0, 3, fade(BLACK, state->display_t));
+ DrawRectangleRoundedLinesEx(outline.rl, 2.0f, 0, 3, fade(BLACK, state->display_t));
}
- v2 result = {.x = r.size.w, .y = ui->font.baseSize};
+ v2 result = {{r.size.w, (f32)ui->font.baseSize}};
return result;
}
@@ -2593,7 +2595,7 @@ draw_compute_stats_bar_view(BeamformerUI *ui, Arena arena, ComputeShaderStats *s
v2 result = table_extent(table, arena, ts.font);
f32 remaining_width = r.size.w - result.w - table->cell_pad.w;
- f32 average_width = 0.8 * remaining_width;
+ f32 average_width = 0.8f * remaining_width;
s8 mouse_text = s8("");
v2 text_pos;
@@ -2612,8 +2614,8 @@ draw_compute_stats_bar_view(BeamformerUI *ui, Arena arena, ComputeShaderStats *s
u32 frame_index = (stats->latest_frame_index - row_index) % countof(stats->table.times);
f32 total_width = average_width * total_times[row_index] / compute_time_sum;
Rect rect;
- rect.pos = v2_add(cr.pos, (v2){.x = cr.size.w + table->cell_pad.w , .y = cr.size.h * 0.15});
- rect.size = (v2){.y = 0.7 * cr.size.h};
+ rect.pos = v2_add(cr.pos, (v2){{cr.size.w + table->cell_pad.w , cr.size.h * 0.15f}});
+ rect.size = (v2){.y = 0.7f * cr.size.h};
for (u32 i = 0; i < stages_count; i++) {
rect.size.w = total_width * stats->table.times[frame_index][stages[i]] / total_times[row_index];
Color color = colour_from_normalized(g_colour_palette[stages[i] % countof(g_colour_palette)]);
@@ -2634,8 +2636,8 @@ draw_compute_stats_bar_view(BeamformerUI *ui, Arena arena, ComputeShaderStats *s
if (mouse_text.len) {
ts.font = &ui->small_font;
- ts.flags &= ~TF_LIMITED;
- ts.flags |= TF_OUTLINED;
+ ts.flags &= ~(u32)TF_LIMITED;
+ ts.flags |= (u32)TF_OUTLINED;
ts.outline_colour = (v4){.a = 1};
ts.outline_thick = 1;
draw_text(mouse_text, text_pos, &ts);
@@ -2709,7 +2711,7 @@ draw_compute_stats_view(BeamformerUI *ui, Arena arena, Variable *view, Rect r, v
}
function v2
-draw_live_controls_view(BeamformerUI *ui, Arena arena, Variable *var, Rect r, v2 mouse)
+draw_live_controls_view(BeamformerUI *ui, Variable *var, Rect r, v2 mouse)
{
BeamformerSharedMemory *sm = ui->shared_memory.region;
BeamformerLiveImagingParameters *lip = &sm->live_imaging_parameters;
@@ -2718,16 +2720,16 @@ draw_live_controls_view(BeamformerUI *ui, Arena arena, Variable *var, Rect r, v2
TextSpec text_spec = {.font = &ui->font, .colour = FG_COLOUR, .flags = TF_LIMITED};
text_spec.limits.size.w = r.size.w;
- v2 slider_size = {{MIN(140.0f, r.size.w), ui->font.baseSize}};
- v2 button_size = {{MIN(r.size.w, slider_size.x + ui->font.baseSize), ui->font.baseSize * 1.5}};
+ v2 slider_size = {{MIN(140.0f, r.size.w), (f32)ui->font.baseSize}};
+ v2 button_size = {{MIN(r.size.w, slider_size.x + (f32)ui->font.baseSize), (f32)ui->font.baseSize * 1.5f}};
- f32 text_off = r.pos.x + 0.5 * MAX(0, (r.size.w - slider_size.w - ui->font.baseSize));
- f32 slider_off = r.pos.x + 0.5 * (r.size.w - slider_size.w);
- f32 button_off = r.pos.x + 0.5 * (r.size.w - button_size.w);
+ f32 text_off = r.pos.x + 0.5f * MAX(0, (r.size.w - slider_size.w - (f32)ui->font.baseSize));
+ f32 slider_off = r.pos.x + 0.5f * (r.size.w - slider_size.w);
+ f32 button_off = r.pos.x + 0.5f * (r.size.w - button_size.w);
v2 at = {{text_off, r.pos.y}};
- v4 hsv_power_slider = {{0.35 * ease_cubic(1.0f - lip->transmit_power), 0.65f, 0.65f, 1}};
+ v4 hsv_power_slider = {{0.35f * ease_cubic(1.0f - lip->transmit_power), 0.65f, 0.65f, 1}};
at.y += draw_text(s8("Power:"), at, &text_spec).y;
at.x = slider_off;
at.y += draw_variable_slider(ui, &lv->transmit_power, (Rect){.pos = at, .size = slider_size},
@@ -2746,7 +2748,7 @@ draw_live_controls_view(BeamformerUI *ui, Arena arena, Variable *var, Rect r, v2
}
at.x = button_off;
- at.y += ui->font.baseSize * 0.5;
+ at.y += (f32)ui->font.baseSize * 0.5f;
at.y += draw_fancy_button(ui, &lv->stop_button, lv->stop_button.name,
(Rect){.pos = at, .size = button_size},
BORDER_COLOUR, mouse, text_spec).y;
@@ -2762,7 +2764,7 @@ draw_live_controls_view(BeamformerUI *ui, Arena arena, Variable *var, Rect r, v2
v4 border_colour = BORDER_COLOUR;
if (active) border_colour = v4_lerp(border_colour, FOCUSED_COLOUR, ease_cubic(lv->save_button_blink_t));
- at.y += ui->font.baseSize * 0.25;
+ at.y += (f32)ui->font.baseSize * 0.25f;
at.y += draw_fancy_button(ui, &lv->save_button, label, (Rect){.pos = at, .size = button_size},
border_colour, mouse, text_spec).y;
@@ -2899,9 +2901,9 @@ draw_ui_view_container(BeamformerUI *ui, Variable *var, v2 mouse, Rect bounds)
UIView *fw = &var->view;
Rect result = fw->rect;
if (fw->rect.size.x > 0 && fw->rect.size.y > 0) {
- f32 line_height = ui->small_font.baseSize;
+ f32 line_height = (f32)ui->small_font.baseSize;
- f32 pad = MAX(line_height + 5, UI_REGION_PAD);
+ f32 pad = MAX(line_height + 5.0f, UI_REGION_PAD);
if (fw->rect.pos.y < pad)
fw->rect.pos.y += pad - fw->rect.pos.y;
result = fw->rect;
@@ -2921,14 +2923,14 @@ draw_ui_view_container(BeamformerUI *ui, Variable *var, v2 mouse, Rect bounds)
hover_interaction(ui, mouse, auto_interaction(container, var));
cut_rect_horizontal(handle, handle.size.w - handle.size.h - 6, 0, &close);
close.size.w = close.size.h;
- DrawRectangleRounded(handle.rl, 0.1, 0, colour_from_normalized(BG_COLOUR));
- DrawRectangleRoundedLinesEx(handle.rl, 0.2, 0, 2, BLACK);
- draw_close_button(ui, fw->close, mouse, close, (v2){{0.45, 0.45}});
+ DrawRectangleRounded(handle.rl, 0.1f, 0, colour_from_normalized(BG_COLOUR));
+ DrawRectangleRoundedLinesEx(handle.rl, 0.2f, 0, 2, BLACK);
+ draw_close_button(ui, fw->close, mouse, close, (v2){{0.45f, 0.45f}});
} else {
hover_interaction(ui, mouse, auto_interaction(container, var));
}
f32 roundness = 12.0f / fw->rect.size.y;
- DrawRectangleRounded(result.rl, roundness / 2, 0, colour_from_normalized(BG_COLOUR));
+ DrawRectangleRounded(result.rl, roundness / 2.0f, 0, colour_from_normalized(BG_COLOUR));
DrawRectangleRoundedLinesEx(result.rl, roundness, 0, 2, BLACK);
}
return result;
@@ -2974,15 +2976,15 @@ draw_ui_view(BeamformerUI *ui, Variable *ui_view, Rect r, v2 mouse, TextSpec tex
}
} break;
case VT_COMPUTE_PROGRESS_BAR: {
- size = draw_compute_progress_bar(ui, ui->arena, &var->compute_progress_bar, r);
+ size = draw_compute_progress_bar(ui, &var->compute_progress_bar, r);
} break;
case VT_COMPUTE_STATS_VIEW:{ size = draw_compute_stats_view(ui, ui->arena, var, r, mouse); }break;
case VT_LIVE_CONTROLS_VIEW:{
if (view->rect.size.h - r.size.h < 0)
- r.pos.y += 0.5 * (r.size.h - view->rect.size.h);
+ r.pos.y += 0.5f * (r.size.h - view->rect.size.h);
BeamformerSharedMemory *sm = ui->shared_memory.region;
if (sm->live_imaging_parameters.active)
- size = draw_live_controls_view(ui, ui->arena, var, r, mouse);
+ size = draw_live_controls_view(ui, var, r, mouse);
}break;
InvalidDefaultCase;
}
@@ -2997,7 +2999,7 @@ draw_layout_variable(BeamformerUI *ui, Variable *var, Rect draw_rect, v2 mouse)
v2 shrink = {.x = UI_REGION_PAD, .y = UI_REGION_PAD};
draw_rect = shrink_rect_centered(draw_rect, shrink);
draw_rect.size = v2_floor(draw_rect.size);
- BeginScissorMode(draw_rect.pos.x, draw_rect.pos.y, draw_rect.size.w, draw_rect.size.h);
+ BeginScissorMode((i32)draw_rect.pos.x, (i32)draw_rect.pos.y, (i32)draw_rect.size.w, (i32)draw_rect.size.h);
draw_rect = draw_title_bar(ui, ui->arena, var, draw_rect, mouse);
EndScissorMode();
}
@@ -3007,7 +3009,7 @@ draw_layout_variable(BeamformerUI *ui, Variable *var, Rect draw_rect, v2 mouse)
mouse = (v2){.x = F32_INFINITY, .y = F32_INFINITY};
draw_rect.size = v2_floor(draw_rect.size);
- BeginScissorMode(draw_rect.pos.x, draw_rect.pos.y, draw_rect.size.w, draw_rect.size.h);
+ BeginScissorMode((i32)draw_rect.pos.x, (i32)draw_rect.pos.y, (i32)draw_rect.size.w, (i32)draw_rect.size.h);
switch (var->type) {
case VT_UI_VIEW: {
hover_interaction(ui, mouse, auto_interaction(draw_rect, var));
@@ -3025,7 +3027,7 @@ draw_layout_variable(BeamformerUI *ui, Variable *var, Rect draw_rect, v2 mouse)
split.pos.y -= UI_SPLIT_HANDLE_THICK / 2;
split.size.h = UI_SPLIT_HANDLE_THICK;
split.size.w -= 2 * UI_REGION_PAD;
- hover = extend_rect_centered(split, (v2){.y = 0.75 * UI_REGION_PAD});
+ hover = extend_rect_centered(split, (v2){.y = 0.75f * UI_REGION_PAD});
} break;
case RSD_HORIZONTAL: {
split_rect_horizontal(draw_rect, rs->fraction, 0, &split);
@@ -3033,7 +3035,7 @@ draw_layout_variable(BeamformerUI *ui, Variable *var, Rect draw_rect, v2 mouse)
split.pos.y += UI_REGION_PAD;
split.size.w = UI_SPLIT_HANDLE_THICK;
split.size.h -= 2 * UI_REGION_PAD;
- hover = extend_rect_centered(split, (v2){.x = 0.75 * UI_REGION_PAD});
+ hover = extend_rect_centered(split, (v2){.x = 0.75f * UI_REGION_PAD});
} break;
}
@@ -3042,7 +3044,7 @@ draw_layout_variable(BeamformerUI *ui, Variable *var, Rect draw_rect, v2 mouse)
v4 colour = HOVERED_COLOUR;
colour.a = var->hover_t;
- DrawRectangleRounded(split.rl, 0.6, 0, colour_from_normalized(colour));
+ DrawRectangleRounded(split.rl, 0.6f, 0, colour_from_normalized(colour));
} break;
InvalidDefaultCase;
}
@@ -3106,7 +3108,7 @@ draw_floating_widgets(BeamformerUI *ui, Rect window_rect, v2 mouse)
draw_ui_view_container(ui, var, mouse, fw->rect);
- f32 cursor_width = (is->cursor == is->count) ? 0.55 * is->font->baseSize : 4;
+ f32 cursor_width = (is->cursor == is->count) ? 0.55f * (f32)is->font->baseSize : 4.0f;
s8 text = {.len = is->count, .data = is->buf};
v2 text_size = measure_text(*is->font, text);
@@ -3126,8 +3128,8 @@ draw_floating_widgets(BeamformerUI *ui, Rect window_rect, v2 mouse)
cursor_colour.a = CLAMP01(is->cursor_blink_t);
v4 text_colour = v4_lerp(FG_COLOUR, HOVERED_COLOUR, fw->child->hover_t);
- TextSpec text_spec = {.font = is->font, .colour = text_colour};
- draw_text(text, text_position, &text_spec);
+ TextSpec input_text_spec = {.font = is->font, .colour = text_colour};
+ draw_text(text, text_position, &input_text_spec);
DrawRectanglePro(cursor.rl, (Vector2){0}, 0, colour_from_normalized(cursor_colour));
} else {
draw_ui_view(ui, var, window_rect, mouse, text_spec);
@@ -3141,8 +3143,7 @@ scroll_interaction(Variable *var, f32 delta)
switch (var->type) {
case VT_B32:{ var->bool32 = !var->bool32; }break;
case VT_F32:{ var->real32 += delta; }break;
- case VT_I32:{ var->signed32 += delta; }break;
- case VT_U32:{ var->unsigned32 += delta; }break;
+ case VT_I32:{ var->signed32 += (i32)delta; }break;
case VT_SCALED_F32:{ var->scaled_real32.val += delta * var->scaled_real32.scale; }break;
case VT_BEAMFORMER_FRAME_VIEW:{
BeamformerFrameView *bv = var->generic;
@@ -3155,7 +3156,8 @@ scroll_interaction(Variable *var, f32 delta)
*bv->store = CLAMP(value, bv->limits.x, bv->limits.y);
}break;
case VT_CYCLER:{
- *var->cycler.state += delta > 0? 1 : -1;
+ if (delta > 0) *var->cycler.state += 1;
+ else *var->cycler.state -= 1;
*var->cycler.state %= var->cycler.cycle_length;
}break;
case VT_UI_VIEW:{
@@ -3177,14 +3179,14 @@ begin_text_input(InputState *is, Rect r, Variable *container, v2 mouse)
is->container = container;
/* NOTE: extra offset to help with putting a cursor at idx 0 */
- #define TEXT_HALF_CHAR_WIDTH 10
+ f32 text_half_char_width = 10.0f;
f32 hover_p = CLAMP01((mouse.x - r.pos.x) / r.size.w);
- f32 x_off = TEXT_HALF_CHAR_WIDTH, x_bounds = r.size.w * hover_p;
i32 i;
+ f32 x_off = text_half_char_width, x_bounds = r.size.w * hover_p;
for (i = 0; i < is->count && x_off < x_bounds; i++) {
/* NOTE: assumes font glyphs are ordered ASCII */
i32 idx = is->buf[i] - 0x20;
- x_off += font->glyphs[idx].advanceX;
+ x_off += (f32)font->glyphs[idx].advanceX;
if (font->glyphs[idx].advanceX == 0)
x_off += font->recs[idx].width;
}
@@ -3194,7 +3196,7 @@ begin_text_input(InputState *is, Rect r, Variable *container, v2 mouse)
function void
end_text_input(InputState *is, Variable *var)
{
- f64 value = parse_f64((s8){.len = is->count, .data = is->buf});
+ f32 value = (f32)parse_f64((s8){.len = is->count, .data = is->buf});
switch (var->type) {
case VT_SCALED_F32:{ var->scaled_real32.val = value; }break;
@@ -3230,8 +3232,8 @@ update_text_input(InputState *is, Variable *var)
if (allow_key) {
mem_move(is->buf + is->cursor + 1,
is->buf + is->cursor,
- is->count - is->cursor);
- is->buf[is->cursor++] = key;
+ (uz)(is->count - is->cursor));
+ is->buf[is->cursor++] = (u8)key;
is->count++;
}
}
@@ -3244,7 +3246,7 @@ update_text_input(InputState *is, Variable *var)
if (is->cursor < countof(is->buf) - 1) {
mem_move(is->buf + is->cursor,
is->buf + is->cursor + 1,
- is->count - is->cursor - 1);
+ (uz)(is->count - is->cursor - 1));
}
is->count--;
}
@@ -3252,7 +3254,7 @@ update_text_input(InputState *is, Variable *var)
if ((IsKeyPressed(KEY_DELETE) || IsKeyPressedRepeat(KEY_DELETE)) && is->cursor < is->count) {
mem_move(is->buf + is->cursor,
is->buf + is->cursor + 1,
- is->count - is->cursor - 1);
+ (uz)(is->count - is->cursor - 1));
is->count--;
}
@@ -3310,7 +3312,7 @@ scale_bar_interaction(BeamformerUI *ui, ScaleBar *sb, v2 mouse)
sb->zoom_starting_coord = F32_INFINITY;
}
- if (mouse_wheel) {
+ if (mouse_wheel != 0) {
*sb->min_value += mouse_wheel * sb->scroll_scale.x;
*sb->max_value += mouse_wheel * sb->scroll_scale.y;
}
@@ -3492,7 +3494,7 @@ ui_begin_interact(BeamformerUI *ui, BeamformerInput *input, b32 scroll)
HideCursor();
DisableCursor();
/* wtf raylib */
- SetMousePosition(input->mouse.x, input->mouse.y);
+ SetMousePosition((i32)input->mouse.x, (i32)input->mouse.y);
}
} else {
ui->interaction.kind = InteractionKind_Nop;
@@ -3575,7 +3577,9 @@ ui_end_interact(BeamformerUI *ui, v2 mouse)
case VT_GROUP:{ it->var->group.expanded = !it->var->group.expanded; }break;
case VT_SCALE_BAR:{ scale_bar_interaction(ui, &it->var->scale_bar, mouse); }break;
case VT_CYCLER:{
- *it->var->cycler.state += 1;
+ b32 right = IsMouseButtonPressed(MOUSE_BUTTON_RIGHT);
+ if (right) *it->var->cycler.state -= 1;
+ else *it->var->cycler.state += 1;
*it->var->cycler.state %= it->var->cycler.cycle_length;
}break;
InvalidDefaultCase;
@@ -3723,11 +3727,11 @@ ui_interact(BeamformerUI *ui, BeamformerInput *input, Rect window_rect)
RegionSplit *rs = &ui->interaction.var->region_split;
switch (rs->direction) {
case RSD_VERTICAL: {
- min_fraction = (UI_SPLIT_HANDLE_THICK + 0.5 * UI_REGION_PAD) / ws.h;
+ min_fraction = (UI_SPLIT_HANDLE_THICK + 0.5f * UI_REGION_PAD) / ws.h;
rs->fraction += dMouse.y;
} break;
case RSD_HORIZONTAL: {
- min_fraction = (UI_SPLIT_HANDLE_THICK + 0.5 * UI_REGION_PAD) / ws.w;
+ min_fraction = (UI_SPLIT_HANDLE_THICK + 0.5f * UI_REGION_PAD) / ws.w;
rs->fraction += dMouse.x;
} break;
}
@@ -3765,12 +3769,12 @@ ui_init(BeamformerCtx *ctx, Arena store)
ui->floating_widget_sentinal.parent = &ui->floating_widget_sentinal;
ui->floating_widget_sentinal.next = &ui->floating_widget_sentinal;
- Variable *split = ui->regions = add_ui_split(ui, 0, &ui->arena, s8("UI Root"), 0.36,
+ Variable *split = ui->regions = add_ui_split(ui, 0, &ui->arena, s8("UI Root"), 0.36f,
RSD_HORIZONTAL, ui->font);
- split->region_split.left = add_ui_split(ui, split, &ui->arena, s8(""), 0.475,
+ split->region_split.left = add_ui_split(ui, split, &ui->arena, s8(""), 0.475f,
RSD_VERTICAL, ui->font);
- split = split->region_split.right = add_ui_split(ui, split, &ui->arena, s8(""), 0.70,
+ split = split->region_split.right = add_ui_split(ui, split, &ui->arena, s8(""), 0.70f,
RSD_HORIZONTAL, ui->font);
{
split->region_split.left = add_beamformer_frame_view(ui, split, &ui->arena,
@@ -3781,7 +3785,7 @@ ui_init(BeamformerCtx *ctx, Arena store)
split = split->region_split.left;
split->region_split.left = add_beamformer_parameters_view(split, ctx);
- split->region_split.right = add_ui_split(ui, split, &ui->arena, s8(""), 0.22,
+ split->region_split.right = add_ui_split(ui, split, &ui->arena, s8(""), 0.22f,
RSD_VERTICAL, ui->font);
split = split->region_split.right;
@@ -3791,7 +3795,7 @@ ui_init(BeamformerCtx *ctx, Arena store)
ctx->ui_read_params = 1;
/* NOTE(rnp): shrink variable size once this fires */
- assert(ui->arena.beg - (u8 *)ui < KB(64));
+ assert((uz)(ui->arena.beg - (u8 *)ui) < KB(64));
}
}
@@ -3822,7 +3826,7 @@ draw_ui(BeamformerCtx *ctx, BeamformerInput *input, BeamformerFrame *frame_to_dr
/* NOTE: process interactions first because the user interacted with
* the ui that was presented last frame */
- Rect window_rect = {.size = {.w = ctx->window_size.w, .h = ctx->window_size.h}};
+ Rect window_rect = {.size = {{(f32)ctx->window_size.w, (f32)ctx->window_size.h}}};
ui_interact(ui, input, window_rect);
if (ui->flush_params) {
diff --git a/util.c b/util.c
@@ -16,7 +16,7 @@ mem_copy(void *restrict dest, void *restrict src, uz n)
}
function void
-mem_move(u8 *dest, u8 *src, iz n)
+mem_move(u8 *dest, u8 *src, uz n)
{
if (dest < src) mem_copy(dest, src, n);
else while (n) { n--; dest[n] = src[n]; }
@@ -40,28 +40,27 @@ arena_pop(Arena *a, iz length)
#define push_array(a, t, n) (t *)arena_alloc(a, sizeof(t), _Alignof(t), n)
#define push_struct(a, t) (t *)arena_alloc(a, sizeof(t), _Alignof(t), 1)
function void *
-arena_alloc(Arena *a, iz len, iz align, iz count)
+arena_alloc(Arena *a, iz len, uz align, iz count)
{
/* NOTE: special case 0 arena */
if (a->beg == 0)
return 0;
- iz padding = -(uintptr_t)a->beg & (align - 1);
- iz available = a->end - a->beg - padding;
- if (available < 0 || count > available / len)
- ASSERT(0 && "arena OOM\n");
+ uz padding = -(uintptr_t)a->beg & (align - 1);
+ iz available = a->end - a->beg - (iz)padding;
+ assert((available >= 0 && count <= available / len));
void *p = a->beg + padding;
- a->beg += padding + count * len;
+ a->beg += (iz)padding + count * len;
/* TODO: Performance? */
return mem_clear(p, 0, count * len);
}
#define arena_capacity(a, t) arena_capacity_(a, sizeof(t), _Alignof(t))
function iz
-arena_capacity_(Arena *a, iz size, iz alignment)
+arena_capacity_(Arena *a, iz size, uz alignment)
{
- iz padding = -(uintptr_t)a->beg & (alignment - 1);
- iz available = a->end - a->beg - padding;
+ uz padding = -(uintptr_t)a->beg & (alignment - 1);
+ iz available = a->end - a->beg - (iz)padding;
iz result = available / size;
return result;
}
@@ -78,7 +77,7 @@ enum { DA_INITIAL_CAP = 4 };
: (s)->data + (s)->count++)
function void *
-da_reserve_(Arena *a, void *data, iz *capacity, iz needed, iz align, iz size)
+da_reserve_(Arena *a, void *data, iz *capacity, iz needed, uz align, iz size)
{
iz cap = *capacity;
@@ -86,7 +85,7 @@ da_reserve_(Arena *a, void *data, iz *capacity, iz needed, iz align, iz size)
* on the stack or someone allocated something in the middle of the arena during usage) */
if (!data || a->beg != (u8 *)data + cap * size) {
void *copy = arena_alloc(a, size, align, cap);
- if (data) mem_copy(copy, data, cap * size);
+ if (data) mem_copy(copy, data, (uz)(cap * size));
data = copy;
}
@@ -98,14 +97,14 @@ da_reserve_(Arena *a, void *data, iz *capacity, iz needed, iz align, iz size)
}
function Arena
-sub_arena(Arena *a, iz len, iz align)
+sub_arena(Arena *a, iz len, uz align)
{
Arena result = {0};
- iz padding = -(uintptr_t)a->beg & (align - 1);
+ uz padding = -(uintptr_t)a->beg & (align - 1);
result.beg = a->beg + padding;
result.end = result.beg + len;
- arena_commit(a, len + padding);
+ arena_commit(a, len + (iz)padding);
return result;
}
@@ -161,11 +160,11 @@ utf16_decode(u16 *data, iz length)
if (length) {
result.consumed = 1;
result.cp = data[0];
- if (length > 1 && BETWEEN(data[0], 0xD800, 0xDBFF)
- && BETWEEN(data[1], 0xDC00, 0xDFFF))
+ if (length > 1 && BETWEEN(data[0], 0xD800u, 0xDBFFu)
+ && BETWEEN(data[1], 0xDC00u, 0xDFFFu))
{
result.consumed = 2;
- result.cp = ((data[0] - 0xD800) << 10) | ((data[1] - 0xDC00) + 0x10000);
+ result.cp = ((data[0] - 0xD800u) << 10u) | ((data[1] - 0xDC00u) + 0x10000u);
}
}
return result;
@@ -177,19 +176,19 @@ utf16_encode(u16 *out, u32 cp)
u32 result = 1;
if (cp == U32_MAX) {
out[0] = '?';
- } else if (cp < 0x10000) {
- out[0] = cp;
+ } else if (cp < 0x10000u) {
+ out[0] = (u16)cp;
} else {
- u32 value = cp - 0x10000;
- out[0] = 0xD800 + (value >> 10u);
- out[1] = 0xDC00 + (value & 0x3FFu);
+ u32 value = cp - 0x10000u;
+ out[0] = (u16)(0xD800u + (value >> 10u));
+ out[1] = (u16)(0xDC00u + (value & 0x3FFu));
result = 2;
}
return result;
}
function Stream
-stream_alloc(Arena *a, iz cap)
+stream_alloc(Arena *a, i32 cap)
{
Stream result = {.cap = cap};
result.data = push_array(a, u8, cap);
@@ -205,7 +204,7 @@ stream_to_s8(Stream *s)
}
function void
-stream_reset(Stream *s, iz index)
+stream_reset(Stream *s, i32 index)
{
s->errors = s->cap <= index;
if (!s->errors)
@@ -213,7 +212,7 @@ stream_reset(Stream *s, iz index)
}
function void
-stream_commit(Stream *s, iz count)
+stream_commit(Stream *s, i32 count)
{
s->errors |= !BETWEEN(s->widx + count, 0, s->cap);
if (!s->errors)
@@ -225,8 +224,8 @@ stream_append(Stream *s, void *data, iz count)
{
s->errors |= (s->cap - s->widx) < count;
if (!s->errors) {
- mem_copy(s->data + s->widx, data, count);
- s->widx += count;
+ mem_copy(s->data + s->widx, data, (uz)count);
+ s->widx += (i32)count;
}
}
@@ -257,16 +256,27 @@ stream_append_s8s_(Stream *s, s8 *strs, iz count)
}
function void
-stream_append_u64(Stream *s, u64 n)
+stream_append_u64_width(Stream *s, u64 n, u64 min_width)
{
u8 tmp[64];
u8 *end = tmp + sizeof(tmp);
u8 *beg = end;
- do { *--beg = '0' + (n % 10); } while (n /= 10);
+ min_width = MIN(sizeof(tmp), min_width);
+
+ do { *--beg = (u8)('0' + (n % 10)); } while (n /= 10);
+ while (end - beg > 0 && (uz)(end - beg) < min_width)
+ *--beg = '0';
+
stream_append(s, beg, end - beg);
}
function void
+stream_append_u64(Stream *s, u64 n)
+{
+ stream_append_u64_width(s, n, 0);
+}
+
+function void
stream_append_hex_u64(Stream *s, u64 n)
{
if (!s->errors) {
@@ -274,7 +284,7 @@ stream_append_hex_u64(Stream *s, u64 n)
u8 *end = buf + sizeof(buf);
u8 *beg = end;
while (n) {
- *--beg = "0123456789abcdef"[n & 0x0F];
+ *--beg = (u8)"0123456789abcdef"[n & 0x0F];
n >>= 4;
}
while (end - beg < 2)
@@ -290,11 +300,11 @@ stream_append_i64(Stream *s, i64 n)
stream_append_byte(s, '-');
n *= -1;
}
- stream_append_u64(s, n);
+ stream_append_u64(s, (u64)n);
}
function void
-stream_append_f64(Stream *s, f64 f, i64 prec)
+stream_append_f64(Stream *s, f64 f, u64 prec)
{
if (f < 0) {
stream_append_byte(s, '-');
@@ -302,16 +312,16 @@ stream_append_f64(Stream *s, f64 f, i64 prec)
}
/* NOTE: round last digit */
- f += 0.5f / prec;
+ f += 0.5f / (f64)prec;
if (f >= (f64)(-1UL >> 1)) {
stream_append_s8(s, s8("inf"));
} else {
- u64 integral = f;
- u64 fraction = (f - integral) * prec;
+ u64 integral = (u64)f;
+ u64 fraction = (u64)((f - (f64)integral) * (f64)prec);
stream_append_u64(s, integral);
stream_append_byte(s, '.');
- for (i64 i = prec / 10; i > 1; i /= 10) {
+ for (u64 i = prec / 10; i > 1; i /= 10) {
if (i > fraction)
stream_append_byte(s, '0');
}
@@ -346,13 +356,13 @@ stream_append_f64_e(Stream *s, f64 f)
}
#endif
- i32 prec = 100;
+ u32 prec = 100;
stream_append_f64(s, f, prec);
stream_append_byte(s, 'e');
stream_append_byte(s, scale >= 0? '+' : '-');
- for (i32 i = prec / 10; i > 1; i /= 10)
+ for (u32 i = prec / 10; i > 1; i /= 10)
stream_append_byte(s, '0');
- stream_append_u64(s, ABS(scale));
+ stream_append_u64(s, (u64)ABS(scale));
}
function void
@@ -370,7 +380,7 @@ arena_stream(Arena a)
{
Stream result = {0};
result.data = a.beg;
- result.cap = a.end - a.beg;
+ result.cap = (i32)(a.end - a.beg);
return result;
}
@@ -487,7 +497,7 @@ function s8
push_s8(Arena *a, s8 str)
{
s8 result = s8_alloc(a, str.len);
- mem_copy(result.data, str.data, result.len);
+ mem_copy(result.data, str.data, (uz)result.len);
return result;
}
@@ -496,7 +506,7 @@ push_s8_zero(Arena *a, s8 str)
{
s8 result = s8_alloc(a, str.len + 1);
result.len -= 1;
- mem_copy(result.data, str.data, result.len);
+ mem_copy(result.data, str.data, (uz)result.len);
return result;
}
diff --git a/util.h b/util.h
@@ -37,7 +37,7 @@
#define DEBUG_IMPORT global
#define DEBUG_EXPORT function
#define DEBUG_DECL(a)
- #define assert(c)
+ #define assert(c) (void)(c)
#endif
#define ASSERT assert
@@ -58,7 +58,7 @@
#define str_(...) #__VA_ARGS__
#define str(...) str_(__VA_ARGS__)
-#define countof(a) (sizeof(a) / sizeof(*a))
+#define countof(a) (iz)(sizeof(a) / sizeof(*a))
#define ARRAY_COUNT(a) (sizeof(a) / sizeof(*a))
#define ABS(x) ((x) < 0 ? (-x) : (x))
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
@@ -102,7 +102,7 @@
#define I32_MAX (0x7FFFFFFFL)
#define U32_MAX (0xFFFFFFFFUL)
#define F32_INFINITY (1e+300*1e+300)
-#define F32_EPSILON (1e-6)
+#define F32_EPSILON (1e-6f)
#ifndef PI
#define PI (3.14159265358979323846f)
#endif
@@ -129,7 +129,7 @@ typedef struct { u8 *beg, *end; } Arena;
typedef struct { Arena *arena; u8 *old_beg; } TempArena;
typedef struct { iz len; u8 *data; } s8;
-#define s8(s) (s8){.len = ARRAY_COUNT(s) - 1, .data = (u8 *)s}
+#define s8(s) (s8){.len = countof(s) - 1, .data = (u8 *)s}
#define s8_comp(s) {sizeof(s) - 1, (u8 *)s}
typedef struct { iz len; u16 *data; } s16;
@@ -221,8 +221,8 @@ typedef union {
typedef struct {
u8 *data;
- u32 widx;
- u32 cap;
+ i32 widx;
+ i32 cap;
b32 errors;
} Stream;
@@ -300,7 +300,7 @@ typedef OS_WRITE_FILE_FN(os_write_file_fn);
#define OS_THREAD_ENTRY_POINT_FN(name) iptr name(iptr _ctx)
typedef OS_THREAD_ENTRY_POINT_FN(os_thread_entry_point_fn);
-#define OS_SHARED_MEMORY_LOCK_REGION_FN(name) b32 name(SharedMemoryRegion *sm, i32 *locks, i32 lock_index, i32 timeout_ms)
+#define OS_SHARED_MEMORY_LOCK_REGION_FN(name) b32 name(SharedMemoryRegion *sm, i32 *locks, i32 lock_index, u32 timeout_ms)
typedef OS_SHARED_MEMORY_LOCK_REGION_FN(os_shared_memory_region_lock_fn);
#define OS_SHARED_MEMORY_UNLOCK_REGION_FN(name) void name(SharedMemoryRegion *sm, i32 *locks, i32 lock_index)
@@ -342,7 +342,7 @@ struct OS {
DEBUG_DECL(renderdoc_end_frame_capture_fn *end_frame_capture;)
};
-#define LABEL_GL_OBJECT(type, id, s) {s8 _s = (s); glObjectLabel(type, id, _s.len, (c8 *)_s.data);}
+#define LABEL_GL_OBJECT(type, id, s) {s8 _s = (s); glObjectLabel(type, id, (i32)_s.len, (c8 *)_s.data);}
#include "util.c"
#include "math.c"