diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_emit.c b/src/gallium/drivers/freedreno/a2xx/fd2_emit.c index a463507cda1..e0d1bc49ed0 100644 --- a/src/gallium/drivers/freedreno/a2xx/fd2_emit.c +++ b/src/gallium/drivers/freedreno/a2xx/fd2_emit.c @@ -426,7 +426,7 @@ fd2_emit_restore(struct fd_context *ctx, struct fd_ringbuffer *ring) /* enable perfcntrs */ OUT_PKT0(ring, REG_A2XX_CP_PERFMON_CNTL, 1); - OUT_RING(ring, COND(fd_mesa_debug & FD_DBG_PERFC, 1)); + OUT_RING(ring, COND(FD_DBG(PERFC), 1)); /* note: perfcntrs don't work without the PM_OVERRIDE bit */ OUT_PKT0(ring, REG_A2XX_RBBM_PM_OVERRIDE1, 2); diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_screen.c b/src/gallium/drivers/freedreno/a2xx/fd2_screen.c index 825b53a9006..182319ad0af 100644 --- a/src/gallium/drivers/freedreno/a2xx/fd2_screen.c +++ b/src/gallium/drivers/freedreno/a2xx/fd2_screen.c @@ -109,7 +109,7 @@ fd2_screen_init(struct pipe_screen *pscreen) pscreen->is_format_supported = fd2_screen_is_format_supported; screen->setup_slices = fd2_setup_slices; - if (fd_mesa_debug & FD_DBG_TTILE) + if (FD_DBG(TTILE)) screen->tile_mode = fd2_tile_mode; fd2_emit_init_screen(pscreen); diff --git a/src/gallium/drivers/freedreno/a2xx/ir2_assemble.c b/src/gallium/drivers/freedreno/a2xx/ir2_assemble.c index e786a2cdd11..6d2297c74c9 100644 --- a/src/gallium/drivers/freedreno/a2xx/ir2_assemble.c +++ b/src/gallium/drivers/freedreno/a2xx/ir2_assemble.c @@ -541,7 +541,7 @@ void assemble(struct ir2_context *ctx, bool binning) for (int i = 0; i < ctx->info->num_fetch_instrs; i++) ctx->info->fetch_info[i].offset += cfdwords; - if (fd_mesa_debug & FD_DBG_DISASM) { + if (FD_DBG(DISASM)) { DBG("disassemble: type=%d", ctx->so->type); disasm_a2xx(dwords, sizedwords, 0, ctx->so->type); } diff --git a/src/gallium/drivers/freedreno/a2xx/ir2_nir.c b/src/gallium/drivers/freedreno/a2xx/ir2_nir.c index f5cd12db8bb..68f9de521b8 100644 --- a/src/gallium/drivers/freedreno/a2xx/ir2_nir.c +++ b/src/gallium/drivers/freedreno/a2xx/ir2_nir.c @@ -109,7 +109,7 @@ ir2_optimize_nir(nir_shader *s, bool lower) .lower_rect = 0, }; - if (fd_mesa_debug & FD_DBG_DISASM) { + if (FD_DBG(DISASM)) { debug_printf("----------------------\n"); nir_print_shader(s, stdout); debug_printf("----------------------\n"); @@ -1119,7 +1119,7 @@ ir2_nir_compile(struct ir2_context *ctx, bool binning) nir_sweep(ctx->nir); - if (fd_mesa_debug & FD_DBG_DISASM) { + if (FD_DBG(DISASM)) { debug_printf("----------------------\n"); nir_print_shader(ctx->nir, stdout); debug_printf("----------------------\n"); diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_program.c b/src/gallium/drivers/freedreno/a3xx/fd3_program.c index c555f8ce44a..491083c4867 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_program.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_program.c @@ -66,7 +66,7 @@ emit_shader(struct fd_ringbuffer *ring, const struct ir3_shader_variant *so) sb = SB_FRAG_SHADER; } - if (fd_mesa_debug & FD_DBG_DIRECT) { + if (FD_DBG(DIRECT)) { sz = si->sizedwords; src = SS_DIRECT; bin = fd_bo_map(so->bo); diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_screen.c b/src/gallium/drivers/freedreno/a3xx/fd3_screen.c index 4efa5a30017..dce4259c746 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_screen.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_screen.c @@ -111,6 +111,6 @@ fd3_screen_init(struct pipe_screen *pscreen) ir3_screen_init(pscreen); screen->setup_slices = fd3_setup_slices; - if (fd_mesa_debug & FD_DBG_TTILE) + if (FD_DBG(TTILE)) screen->tile_mode = fd3_tile_mode; } diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_program.c b/src/gallium/drivers/freedreno/a4xx/fd4_program.c index 79af5961485..99b3b03315f 100644 --- a/src/gallium/drivers/freedreno/a4xx/fd4_program.c +++ b/src/gallium/drivers/freedreno/a4xx/fd4_program.c @@ -45,7 +45,7 @@ emit_shader(struct fd_ringbuffer *ring, const struct ir3_shader_variant *so) enum a4xx_state_src src; uint32_t i, sz, *bin; - if (fd_mesa_debug & FD_DBG_DIRECT) { + if (FD_DBG(DIRECT)) { sz = si->sizedwords; src = SS4_DIRECT; bin = fd_bo_map(so->bo); diff --git a/src/gallium/drivers/freedreno/a5xx/fd5_context.c b/src/gallium/drivers/freedreno/a5xx/fd5_context.c index 8bb8d309a7f..8ab28633d42 100644 --- a/src/gallium/drivers/freedreno/a5xx/fd5_context.c +++ b/src/gallium/drivers/freedreno/a5xx/fd5_context.c @@ -98,7 +98,7 @@ fd5_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags) fd5_prog_init(pctx); fd5_emit_init(pctx); - if (!(fd_mesa_debug & FD_DBG_NOBLIT)) + if (!FD_DBG(NOBLIT)) fd5_ctx->base.blit = fd5_blitter_blit; pctx = fd_context_init(&fd5_ctx->base, pscreen, primtypes, priv, flags); diff --git a/src/gallium/drivers/freedreno/a5xx/fd5_program.c b/src/gallium/drivers/freedreno/a5xx/fd5_program.c index 128efc9a2fe..bf2015599e9 100644 --- a/src/gallium/drivers/freedreno/a5xx/fd5_program.c +++ b/src/gallium/drivers/freedreno/a5xx/fd5_program.c @@ -48,7 +48,7 @@ fd5_emit_shader(struct fd_ringbuffer *ring, const struct ir3_shader_variant *so) enum a4xx_state_src src; uint32_t i, sz, *bin; - if (fd_mesa_debug & FD_DBG_DIRECT) { + if (FD_DBG(DIRECT)) { sz = si->sizedwords; src = SS4_DIRECT; bin = fd_bo_map(so->bo); diff --git a/src/gallium/drivers/freedreno/a5xx/fd5_resource.c b/src/gallium/drivers/freedreno/a5xx/fd5_resource.c index 92954c70665..52bb1a6ad85 100644 --- a/src/gallium/drivers/freedreno/a5xx/fd5_resource.c +++ b/src/gallium/drivers/freedreno/a5xx/fd5_resource.c @@ -59,7 +59,7 @@ fd5_setup_slices(struct fd_resource *rsc) { struct pipe_resource *prsc = &rsc->base; - if ((fd_mesa_debug & FD_DBG_LRZ) && has_depth(rsc->base.format)) + if (FD_DBG(LRZ) && has_depth(rsc->base.format)) setup_lrz(rsc); fdl5_layout(&rsc->layout, prsc->format, fd_resource_nr_samples(prsc), diff --git a/src/gallium/drivers/freedreno/a5xx/fd5_screen.c b/src/gallium/drivers/freedreno/a5xx/fd5_screen.c index d999f83773b..7ba2e6a494e 100644 --- a/src/gallium/drivers/freedreno/a5xx/fd5_screen.c +++ b/src/gallium/drivers/freedreno/a5xx/fd5_screen.c @@ -130,7 +130,7 @@ fd5_screen_init(struct pipe_screen *pscreen) pscreen->is_format_supported = fd5_screen_is_format_supported; screen->setup_slices = fd5_setup_slices; - if (fd_mesa_debug & FD_DBG_TTILE) + if (FD_DBG(TTILE)) screen->tile_mode = fd5_tile_mode; fd5_emit_init_screen(pscreen); diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_blitter.c b/src/gallium/drivers/freedreno/a6xx/fd6_blitter.c index 6659009790a..e31a1618c23 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_blitter.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_blitter.c @@ -1096,7 +1096,7 @@ fd6_blitter_init(struct pipe_context *pctx) { fd_context(pctx)->clear_ubwc = fd6_clear_ubwc; - if (fd_mesa_debug & FD_DBG_NOBLIT) + if (FD_DBG(NOBLIT)) return; fd_context(pctx)->blit = fd6_blit; diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_resource.c b/src/gallium/drivers/freedreno/a6xx/fd6_resource.c index 34b4c353f7e..50549044867 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_resource.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_resource.c @@ -159,7 +159,7 @@ fd6_setup_slices(struct fd_resource *rsc) { struct pipe_resource *prsc = &rsc->base; - if (!(fd_mesa_debug & FD_DBG_NOLRZ) && has_depth(rsc->base.format)) + if (!FD_DBG(NOLRZ) && has_depth(rsc->base.format)) setup_lrz(rsc); if (rsc->layout.ubwc && !ok_ubwc_format(rsc->base.screen, rsc->base.format)) diff --git a/src/gallium/drivers/freedreno/freedreno_batch.c b/src/gallium/drivers/freedreno/freedreno_batch.c index 361ed7dcae7..42869eda460 100644 --- a/src/gallium/drivers/freedreno/freedreno_batch.c +++ b/src/gallium/drivers/freedreno/freedreno_batch.c @@ -49,7 +49,7 @@ alloc_ring(struct fd_batch *batch, unsigned sz, enum fd_ringbuffer_flags flags) * size of zero. */ if ((fd_device_version(ctx->screen->dev) >= FD_VERSION_UNLIMITED_CMDS) && - !(fd_mesa_debug & FD_DBG_NOGROW)){ + !FD_DBG(NOGROW)) { flags |= FD_RINGBUFFER_GROWABLE; sz = 0; } @@ -536,7 +536,7 @@ fd_batch_check_size(struct fd_batch *batch) { debug_assert(!batch->flushed); - if (unlikely(fd_mesa_debug & FD_DBG_FLUSH)) { + if (FD_DBG(FLUSH)) { fd_batch_flush(batch); return; } diff --git a/src/gallium/drivers/freedreno/freedreno_batch.h b/src/gallium/drivers/freedreno/freedreno_batch.h index e14a563acf4..f7e7b786fbf 100644 --- a/src/gallium/drivers/freedreno/freedreno_batch.h +++ b/src/gallium/drivers/freedreno/freedreno_batch.h @@ -37,7 +37,7 @@ #include "freedreno_util.h" #ifdef DEBUG -# define BATCH_DEBUG (fd_mesa_debug & FD_DBG_MSGS) +# define BATCH_DEBUG FD_DBG(MSGS) #else # define BATCH_DEBUG 0 #endif diff --git a/src/gallium/drivers/freedreno/freedreno_context.c b/src/gallium/drivers/freedreno/freedreno_context.c index bf77e9fd657..a074acb1a89 100644 --- a/src/gallium/drivers/freedreno/freedreno_context.c +++ b/src/gallium/drivers/freedreno/freedreno_context.c @@ -339,8 +339,8 @@ fd_context_destroy(struct pipe_context *pctx) u_trace_context_fini(&ctx->trace_context); - if (fd_mesa_debug & (FD_DBG_BSTAT | FD_DBG_MSGS)) { - printf("batch_total=%u, batch_sysmem=%u, batch_gmem=%u, batch_nondraw=%u, batch_restore=%u\n", + if (FD_DBG(BSTAT) || FD_DBG(MSGS)) { + mesa_logi("batch_total=%u, batch_sysmem=%u, batch_gmem=%u, batch_nondraw=%u, batch_restore=%u\n", (uint32_t)ctx->stats.batch_total, (uint32_t)ctx->stats.batch_sysmem, (uint32_t)ctx->stats.batch_gmem, (uint32_t)ctx->stats.batch_nondraw, (uint32_t)ctx->stats.batch_restore); @@ -527,7 +527,7 @@ fd_context_init(struct fd_context *ctx, struct pipe_screen *pscreen, int i; /* lower numerical value == higher priority: */ - if (fd_mesa_debug & FD_DBG_HIPRIO) + if (FD_DBG(HIPRIO)) prio = 0; else if (flags & PIPE_CONTEXT_HIGH_PRIORITY) prio = 0; diff --git a/src/gallium/drivers/freedreno/freedreno_draw.c b/src/gallium/drivers/freedreno/freedreno_draw.c index 334822732e5..98488e472b8 100644 --- a/src/gallium/drivers/freedreno/freedreno_draw.c +++ b/src/gallium/drivers/freedreno/freedreno_draw.c @@ -259,7 +259,7 @@ fd_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info, * to be able to emulate it, to determine if game is feeding us * bogus data: */ - if (indirect && indirect->buffer && (fd_mesa_debug & FD_DBG_NOINDR)) { + if (indirect && indirect->buffer && FD_DBG(NOINDR)) { util_draw_indirect(pctx, info, indirect); return; } @@ -368,7 +368,7 @@ fd_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info, for (unsigned i = 0; i < ctx->streamout.num_targets; i++) ctx->streamout.offsets[i] += draws[0].count; - if (fd_mesa_debug & FD_DBG_DDRAW) + if (FD_DBG(DDRAW)) fd_context_all_dirty(ctx); fd_batch_unlock_submit(batch); @@ -483,7 +483,7 @@ fd_clear(struct pipe_context *pctx, unsigned buffers, fd_batch_update_queries(batch); if (ctx->clear(ctx, buffers, color, depth, stencil)) { - if (fd_mesa_debug & FD_DBG_DCLEAR) + if (FD_DBG(DCLEAR)) fd_context_all_dirty(ctx); fallback = false; diff --git a/src/gallium/drivers/freedreno/freedreno_gmem.c b/src/gallium/drivers/freedreno/freedreno_gmem.c index fb59ba4417f..12bce5743e8 100644 --- a/src/gallium/drivers/freedreno/freedreno_gmem.c +++ b/src/gallium/drivers/freedreno/freedreno_gmem.c @@ -225,7 +225,7 @@ calc_nbins(struct gmem_key *key, struct fd_gmem_stateobj *gmem) uint32_t max_width = screen->info.tile_max_w; uint32_t max_height = screen->info.tile_max_h; - if (fd_mesa_debug & FD_DBG_MSGS) { + if (FD_DBG(MSGS)) { debug_printf("binning input: cbuf cpp:"); for (unsigned i = 0; i < key->nr_cbufs; i++) debug_printf(" %d", key->cbuf_cpp[i]); @@ -493,7 +493,7 @@ gmem_key_init(struct fd_batch *batch, bool assume_zs, bool no_scis_opt) } else { struct pipe_scissor_state *scissor = &batch->max_scissor; - if (fd_mesa_debug & FD_DBG_NOSCIS) { + if (FD_DBG(NOSCIS)) { scissor->minx = 0; scissor->miny = 0; scissor->maxx = pfb->width; @@ -656,7 +656,7 @@ flush_ring(struct fd_batch *batch) uint32_t timestamp; int out_fence_fd = -1; - if (unlikely(fd_mesa_debug & FD_DBG_NOHW)) + if (FD_DBG(NOHW)) return; fd_submit_flush(batch->submit, batch->in_fence_fd, @@ -683,7 +683,7 @@ fd_gmem_render_tiles(struct fd_batch *batch) if (batch->cleared || batch->gmem_reason || ((batch->num_draws > 5) && !batch->blit) || (pfb->samples > 1)) { - } else if (!(fd_mesa_debug & FD_DBG_NOBYPASS)) { + } else if (!FD_DBG(NOBYPASS)) { sysmem = true; } @@ -693,7 +693,7 @@ fd_gmem_render_tiles(struct fd_batch *batch) } } - if (fd_mesa_debug & FD_DBG_NOGMEM) + if (FD_DBG(NOGMEM)) sysmem = true; /* Layered rendering always needs bypass. */ diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c index 0f0fe1caf1e..225ccd4132b 100644 --- a/src/gallium/drivers/freedreno/freedreno_resource.c +++ b/src/gallium/drivers/freedreno/freedreno_resource.c @@ -984,7 +984,7 @@ fd_resource_allocate_and_resolve(struct pipe_screen *pscreen, linear = true; } - if (fd_mesa_debug & FD_DBG_NOTILE) + if (FD_DBG(NOTILE)) linear = true; /* Normally, for non-shared buffers, allow buffer compression if @@ -1012,7 +1012,7 @@ fd_resource_allocate_and_resolve(struct pipe_screen *pscreen, } } - allow_ubwc &= !(fd_mesa_debug & FD_DBG_NOUBWC); + allow_ubwc &= !FD_DBG(NOUBWC); pipe_reference_init(&prsc->reference, 1); @@ -1056,7 +1056,7 @@ fd_resource_allocate_and_resolve(struct pipe_screen *pscreen, size = rsc->layout.layer_size * prsc->array_size; } - if (fd_mesa_debug & FD_DBG_LAYOUT) + if (FD_DBG(LAYOUT)) fdl_dump_layout(&rsc->layout); /* Hand out the resolved size. */ diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c b/src/gallium/drivers/freedreno/freedreno_screen.c index ed5c007c0ef..ab0bcbf4a88 100644 --- a/src/gallium/drivers/freedreno/freedreno_screen.c +++ b/src/gallium/drivers/freedreno/freedreno_screen.c @@ -498,7 +498,7 @@ fd_screen_get_paramf(struct pipe_screen *pscreen, enum pipe_capf param) * * See: https://code.google.com/p/android/issues/detail?id=206513 */ - if (fd_mesa_debug & FD_DBG_DEQP) + if (FD_DBG(DEQP)) return 48.0f; return 127.0f; case PIPE_CAPF_MAX_POINT_WIDTH: @@ -610,7 +610,7 @@ fd_screen_get_shader_param(struct pipe_screen *pscreen, return ((is_a5xx(screen) || is_a6xx(screen)) && (shader == PIPE_SHADER_COMPUTE || shader == PIPE_SHADER_FRAGMENT) && - !(fd_mesa_debug & FD_DBG_NOFP16)); + !FD_DBG(NOFP16)); case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS: case PIPE_SHADER_CAP_MAX_SAMPLER_VIEWS: return 16; @@ -894,7 +894,7 @@ fd_screen_create(struct fd_device *dev, struct renderonly *ro) fd_mesa_debug = debug_get_option_fd_mesa_debug(); - if (fd_mesa_debug & FD_DBG_NOBIN) + if (FD_DBG(NOBIN)) fd_binning_enabled = false; if (!screen) @@ -1035,7 +1035,7 @@ fd_screen_create(struct fd_device *dev, struct renderonly *ro) freedreno_dev_info_init(&screen->info, screen->gpu_id); - if (fd_mesa_debug & FD_DBG_PERFC) { + if (FD_DBG(PERFC)) { screen->perfcntr_groups = fd_perfcntrs(screen->gpu_id, &screen->num_perfcntr_groups); } @@ -1045,7 +1045,7 @@ fd_screen_create(struct fd_device *dev, struct renderonly *ro) * buffers would be too much otherwise. */ if (fd_device_version(dev) >= FD_VERSION_UNLIMITED_CMDS) - screen->reorder = !(fd_mesa_debug & FD_DBG_INORDER); + screen->reorder = !FD_DBG(INORDER); if (BATCH_DEBUG) screen->live_batches = _mesa_pointer_set_create(NULL); diff --git a/src/gallium/drivers/freedreno/freedreno_util.h b/src/gallium/drivers/freedreno/freedreno_util.h index 71d7085a2c4..2871cebac8c 100644 --- a/src/gallium/drivers/freedreno/freedreno_util.h +++ b/src/gallium/drivers/freedreno/freedreno_util.h @@ -96,8 +96,10 @@ enum fd_debug_flag { extern int fd_mesa_debug; extern bool fd_binning_enabled; +#define FD_DBG(category) unlikely(fd_mesa_debug & FD_DBG_##category) + #define DBG(fmt, ...) \ - do { if (fd_mesa_debug & FD_DBG_MSGS) \ + do { if (FD_DBG(MSGS)) \ mesa_logd("%s:%d: "fmt, \ __FUNCTION__, __LINE__, ##__VA_ARGS__); } while (0) @@ -107,7 +109,7 @@ extern bool fd_binning_enabled; } while(0) #define perf_debug(...) do { \ - if (unlikely(fd_mesa_debug & FD_DBG_PERF)) \ + if (FD_DBG(PERF)) \ mesa_logw(__VA_ARGS__); \ } while(0) diff --git a/src/gallium/drivers/freedreno/ir3/ir3_gallium.c b/src/gallium/drivers/freedreno/ir3/ir3_gallium.c index 13f650ae4fc..696e7a52a69 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_gallium.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_gallium.c @@ -67,15 +67,14 @@ struct ir3_shader_state { static bool initial_variants_synchronous(struct fd_context *ctx) { - return unlikely(ctx->debug.debug_message || - (fd_mesa_debug & FD_DBG_SHADERDB)) || - (fd_mesa_debug & FD_DBG_SERIALC); + return unlikely(ctx->debug.debug_message) || + FD_DBG(SHADERDB) || FD_DBG(SERIALC); } static void dump_shader_info(struct ir3_shader_variant *v, struct pipe_debug_callback *debug) { - if (!unlikely(fd_mesa_debug & FD_DBG_SHADERDB)) + if (!FD_DBG(SHADERDB)) return; pipe_debug_message(debug, SHADER_INFO,