diff --git a/src/vrend_debug.h b/src/vrend_debug.h index 40ff226..7afa69b 100644 --- a/src/vrend_debug.h +++ b/src/vrend_debug.h @@ -79,31 +79,30 @@ static inline void vrend_printf(const char *fmt, ...) va_end(va); } -#ifndef NDEBUG +#ifdef NDEBUG +#define VREND_DEBUG_ENABLED (false) +#else +#define VREND_DEBUG_ENABLED (true) +#endif + #define VREND_DEBUG(flag, ctx, ...) \ - if (vrend_debug(ctx, flag)) \ + if (VREND_DEBUG_ENABLED && vrend_debug(ctx, flag)) \ do { \ vrend_print_context_name(ctx); \ vrend_printf(__VA_ARGS__); \ } while (0) #define VREND_DEBUG_EXT(flag, ctx, X) \ - if (vrend_debug(ctx, flag)) \ + if (VREND_DEBUG_ENABLED && vrend_debug(ctx, flag)) \ do { \ vrend_print_context_name(ctx); \ X; \ } while (0) #define VREND_DEBUG_NOCTX(flag, ctx, ...) \ - if (vrend_debug(ctx, flag)) \ + if (VREND_DEBUG_ENABLED && vrend_debug(ctx, flag)) \ do { \ vrend_printf(__VA_ARGS__); \ } while (0) -#else -#define VREND_DEBUG(flag, ctx, ...) (void)ctx -#define VREND_DEBUG_EXT(flag, ctx, X) (void)ctx -#define VREND_DEBUG_NOCTX(flag, ctx, ...) (void)ctx -#endif - #endif diff --git a/src/vrend_decode.c b/src/vrend_decode.c index 3bc5e16..b734512 100644 --- a/src/vrend_decode.c +++ b/src/vrend_decode.c @@ -1711,10 +1711,7 @@ static int vrend_decode_ctx_submit_cmd(struct virgl_context *ctx, uint32_t buf_offset = 0; while (buf_offset < buf_total) { -#ifndef NDEBUG const uint32_t cur_offset = buf_offset; -#endif - const uint32_t *buf = &typed_buf[buf_offset]; uint32_t len = *buf >> 16; uint32_t cmd = *buf & 0xff; diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index 640c44e..626b5f6 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -3864,11 +3864,9 @@ int vrend_create_shader(struct vrend_context *ctx, free(tokens); ret = EINVAL; goto error; - } else { -#ifdef NDEBUG - free(sel->tmp_buf); - sel->tmp_buf = NULL; -#endif + } else if (!VREND_DEBUG_ENABLED) { + free(sel->tmp_buf); + sel->tmp_buf = NULL; } free(tokens); sub_ctx->long_shader_in_progress_handle[type] = 0; @@ -6489,9 +6487,9 @@ int vrend_renderer_init(const struct vrend_if_cbs *cbs, uint32_t flags) vrend_state.max_texture_3d_size = vrend_state.max_texture_cube_size = 16384; -#ifndef NDEBUG - vrend_init_debug_flags(); -#endif + if (VREND_DEBUG_ENABLED) { + vrend_init_debug_flags(); + } ctx_params.shared = false; for (uint32_t i = 0; i < ARRAY_SIZE(gl_versions); i++) {