Skip to content

Commit ea9d5a0

Browse files
committed
enable GL_DEBUG output and cleanup warnings
1 parent 1aa75e3 commit ea9d5a0

File tree

2 files changed

+33
-7
lines changed

2 files changed

+33
-7
lines changed

beamformer.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ alloc_shader_storage(BeamformerCtx *ctx, Arena a)
7474

7575
glBindBuffer(GL_SHADER_STORAGE_BUFFER, cs->raw_data_ssbo);
7676
glBufferStorage(GL_SHADER_STORAGE_BUFFER, ARRAY_COUNT(cs->raw_data_fences) * rf_raw_size,
77-
0, GL_DYNAMIC_STORAGE_BIT|GL_MAP_WRITE_BIT);
77+
0, GL_MAP_WRITE_BIT);
7878

7979
for (u32 i = 0; i < ARRAY_COUNT(cs->rf_data_ssbos); i++) {
8080
glBindBuffer(GL_SHADER_STORAGE_BUFFER, cs->rf_data_ssbos[i]);
@@ -523,7 +523,7 @@ do_beamformer(BeamformerCtx *ctx, Arena arena)
523523
}
524524

525525
/* NOTE: Store the compute time for the last frame. */
526-
{
526+
if (ctx->csctx.timer_fence) {
527527
i32 timer_status, _unused;
528528
glGetSynciv(ctx->csctx.timer_fence, GL_SYNC_STATUS, 4, &_unused, &timer_status);
529529
if (timer_status == GL_SIGNALED) {
@@ -546,11 +546,14 @@ do_beamformer(BeamformerCtx *ctx, Arena arena)
546546
i32 raw_index = ctx->csctx.raw_data_index;
547547
/* NOTE: if this times out it means the command queue is more than 3 frames behind.
548548
* In that case we need to re-evaluate the buffer size */
549-
i32 result = glClientWaitSync(ctx->csctx.raw_data_fences[raw_index], 0, 10000);
550-
if (result == GL_TIMEOUT_EXPIRED) {
551-
//ASSERT(0);
549+
if (ctx->csctx.raw_data_fences[raw_index]) {
550+
i32 result = glClientWaitSync(ctx->csctx.raw_data_fences[raw_index], 0, 10000);
551+
if (result == GL_TIMEOUT_EXPIRED) {
552+
//ASSERT(0);
553+
}
554+
glDeleteSync(ctx->csctx.raw_data_fences[raw_index]);
555+
ctx->csctx.raw_data_fences[raw_index] = NULL;
552556
}
553-
glDeleteSync(ctx->csctx.raw_data_fences[raw_index]);
554557

555558
uv2 rf_raw_dim = ctx->csctx.rf_raw_dim;
556559
size rf_raw_size = rf_raw_dim.x * rf_raw_dim.y * sizeof(i16);

main.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,22 @@ do_debug(void)
6666

6767
#endif /* _DEBUG */
6868

69+
static void
70+
gl_debug_logger(u32 src, u32 type, u32 id, u32 lvl, i32 len, const char *msg, const void *userctx)
71+
{
72+
(void)src; (void)type; (void)id; (void)userctx;
73+
fputs("[GL DEBUG ", stderr);
74+
switch (lvl) {
75+
case GL_DEBUG_SEVERITY_HIGH: fputs("HIGH]: ", stderr); break;
76+
case GL_DEBUG_SEVERITY_MEDIUM: fputs("MEDIUM]: ", stderr); break;
77+
case GL_DEBUG_SEVERITY_LOW: fputs("LOW]: ", stderr); break;
78+
case GL_DEBUG_SEVERITY_NOTIFICATION: fputs("NOTIFICATION]: ", stderr); break;
79+
default: fputs("INVALID]: ", stderr); break;
80+
}
81+
fwrite(msg, 1, len, stderr);
82+
fputc('\n', stderr);
83+
}
84+
6985
static u32
7086
compile_shader(Arena a, u32 type, s8 shader)
7187
{
@@ -169,10 +185,17 @@ main(void)
169185

170186
ctx.params->raw.output_points = ctx.out_data_dim;
171187

188+
189+
/* NOTE: set up OpenGL debug logging */
190+
glDebugMessageCallback(gl_debug_logger, NULL);
191+
#ifdef _DEBUG
192+
glEnable(GL_DEBUG_OUTPUT);
193+
#endif
194+
172195
/* NOTE: allocate space for Uniform Buffer Object but don't send anything yet */
173196
glGenBuffers(1, &ctx.csctx.shared_ubo);
174197
glBindBuffer(GL_UNIFORM_BUFFER, ctx.csctx.shared_ubo);
175-
glBufferData(GL_UNIFORM_BUFFER, sizeof(BeamformerParameters), 0, GL_STATIC_DRAW);
198+
glBufferStorage(GL_UNIFORM_BUFFER, sizeof(BeamformerParameters), 0, GL_MAP_WRITE_BIT);
176199

177200
glGenQueries(CS_LAST, ctx.csctx.timer_ids);
178201

0 commit comments

Comments
 (0)