[Mesa-dev] [PATCH 4/4] nouveau: flip DEBUG -> !NDEBUG

Karol Herbst kherbst at redhat.com
Fri Jul 26 09:52:59 UTC 2019


Reviewed-by: Karol Herbst <kherbst at redhat.com>

On Fri, Jul 26, 2019 at 5:31 AM Ilia Mirkin <imirkin at alum.mit.edu> wrote:
>
> The meson conversion chose to change the meaning of DEBUG to "used for
> debugging" to be "used for expensive things for debugging", primarily
> for nir_validate. Flip things over so that we get nice things with
> optimizations enabled.
>
> While we're at it, also kill off nouveau_statebuf.h which is unused (and
> has a mention of DEBUG which is how I found it).
>
> Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
> ---
>  src/gallium/drivers/nouveau/Makefile.sources  |  1 -
>  .../drivers/nouveau/codegen/nv50_ir_driver.h  |  2 +-
>  .../drivers/nouveau/codegen/nv50_ir_inlines.h |  2 +-
>  .../drivers/nouveau/codegen/nv50_ir_util.h    |  8 ++---
>  src/gallium/drivers/nouveau/meson.build       |  1 -
>  src/gallium/drivers/nouveau/nouveau_screen.h  |  2 +-
>  .../drivers/nouveau/nouveau_statebuf.h        | 32 -------------------
>  .../drivers/nouveau/nv50/nv50_program.c       |  2 +-
>  .../drivers/nouveau/nvc0/nvc0_program.c       |  8 ++---
>  .../drivers/nouveau/nvc0/nve4_compute.c       |  6 ++--
>  10 files changed, 15 insertions(+), 49 deletions(-)
>  delete mode 100644 src/gallium/drivers/nouveau/nouveau_statebuf.h
>
> diff --git a/src/gallium/drivers/nouveau/Makefile.sources b/src/gallium/drivers/nouveau/Makefile.sources
> index c6a1aff7110..6c360992a53 100644
> --- a/src/gallium/drivers/nouveau/Makefile.sources
> +++ b/src/gallium/drivers/nouveau/Makefile.sources
> @@ -12,7 +12,6 @@ C_SOURCES := \
>         nouveau_mm.h \
>         nouveau_screen.c \
>         nouveau_screen.h \
> -       nouveau_statebuf.h \
>         nouveau_video.c \
>         nouveau_video.h \
>         nouveau_vp3_video_bsp.c \
> diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_driver.h b/src/gallium/drivers/nouveau/codegen/nv50_ir_driver.h
> index 95b3d633ee6..322bdd02557 100644
> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_driver.h
> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_driver.h
> @@ -54,7 +54,7 @@ struct nv50_ir_varying
>     ubyte si; /* TGSI semantic index */
>  };
>
> -#ifdef DEBUG
> +#ifndef NDEBUG
>  # define NV50_IR_DEBUG_BASIC     (1 << 0)
>  # define NV50_IR_DEBUG_VERBOSE   (2 << 0)
>  # define NV50_IR_DEBUG_REG_ALLOC (1 << 2)
> diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_inlines.h b/src/gallium/drivers/nouveau/codegen/nv50_ir_inlines.h
> index 4cb53ab42ed..b4ca5ed8215 100644
> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_inlines.h
> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_inlines.h
> @@ -222,7 +222,7 @@ Instruction *Value::getUniqueInsn() const
>              return (*it)->getInsn();
>        // should be unreachable and trigger assertion at the end
>     }
> -#ifdef DEBUG
> +#ifndef NDEBUG
>     if (reg.data.id < 0) {
>        int n = 0;
>        for (DefCIterator it = defs.begin(); n < 2 && it != defs.end(); ++it)
> diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_util.h b/src/gallium/drivers/nouveau/codegen/nv50_ir_util.h
> index affe04a2dd9..307c23d5e03 100644
> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_util.h
> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_util.h
> @@ -36,14 +36,14 @@
>  #include "util/u_inlines.h"
>  #include "util/u_memory.h"
>
> -#define ERROR(args...) debug_printf("ERROR: " args)
> -#define WARN(args...) debug_printf("WARNING: " args)
> -#define INFO(args...) debug_printf(args)
> +#define ERROR(args...) _debug_printf("ERROR: " args)
> +#define WARN(args...) _debug_printf("WARNING: " args)
> +#define INFO(args...) _debug_printf(args)
>
>  #define INFO_DBG(m, f, args...)          \
>     do {                                  \
>        if (m & NV50_IR_DEBUG_##f)         \
> -         debug_printf(args);             \
> +         _debug_printf(args);             \
>     } while(0)
>
>  #define FATAL(args...)          \
> diff --git a/src/gallium/drivers/nouveau/meson.build b/src/gallium/drivers/nouveau/meson.build
> index 64138212b5b..b3e79bf7089 100644
> --- a/src/gallium/drivers/nouveau/meson.build
> +++ b/src/gallium/drivers/nouveau/meson.build
> @@ -32,7 +32,6 @@ files_libnouveau = files(
>    'nouveau_mm.h',
>    'nouveau_screen.c',
>    'nouveau_screen.h',
> -  'nouveau_statebuf.h',
>    'nouveau_video.c',
>    'nouveau_video.h',
>    'nouveau_vp3_video_bsp.c',
> diff --git a/src/gallium/drivers/nouveau/nouveau_screen.h b/src/gallium/drivers/nouveau/nouveau_screen.h
> index 1302c608bec..450c7c466be 100644
> --- a/src/gallium/drivers/nouveau/nouveau_screen.h
> +++ b/src/gallium/drivers/nouveau/nouveau_screen.h
> @@ -6,7 +6,7 @@
>  #include "util/u_atomic.h"
>  #include "util/u_memory.h"
>
> -#ifdef DEBUG
> +#ifndef NDEBUG
>  # define NOUVEAU_ENABLE_DRIVER_STATISTICS
>  #endif
>
> diff --git a/src/gallium/drivers/nouveau/nouveau_statebuf.h b/src/gallium/drivers/nouveau/nouveau_statebuf.h
> deleted file mode 100644
> index da5d7972d9c..00000000000
> --- a/src/gallium/drivers/nouveau/nouveau_statebuf.h
> +++ /dev/null
> @@ -1,32 +0,0 @@
> -#ifndef __NOUVEAU_STATEBUF_H__
> -#define __NOUVEAU_STATEBUF_H__
> -
> -/* state buffers: lightweight state objects interface */
> -/* relocations are not supported, but Gallium CSOs don't require them */
> -
> -struct nouveau_statebuf_builder
> -{
> -   uint32_t* p;
> -#ifdef DEBUG
> -   uint32_t* pend;
> -#endif
> -};
> -
> -#ifdef DEBUG
> -#define sb_init(var) {var, var + sizeof(var) / sizeof((var)[0])}
> -#define sb_data(sb, v) do {assert((sb).p != (sb).pend);  *(sb).p++ = (v);} while(0)
> -#else
> -#define sb_init(var) {var}
> -#define sb_data(sb, v) *(sb).p++ = (v)
> -#endif
> -
> -static inline uint32_t sb_header(unsigned subc, unsigned mthd, unsigned size)
> -{
> -   return (size << 18) | (subc << 13) | mthd;
> -}
> -
> -#define sb_method(sb, v, n)  sb_data(sb, sb_header(SUBC_3D(v), n));
> -
> -#define sb_len(sb, var) ((sb).p - (var))
> -#define sb_emit(push, sb_buf, sb_len) do {PUSH_SPACE((push), (sb_len)); PUSH_DATAp((push), (sb_buf), (sb_len)); } while(0)
> -#endif
> diff --git a/src/gallium/drivers/nouveau/nv50/nv50_program.c b/src/gallium/drivers/nouveau/nv50/nv50_program.c
> index a725aedcd8e..c9d01e8cee7 100644
> --- a/src/gallium/drivers/nouveau/nv50/nv50_program.c
> +++ b/src/gallium/drivers/nouveau/nv50/nv50_program.c
> @@ -378,7 +378,7 @@ nv50_program_translate(struct nv50_program *prog, uint16_t chipset,
>
>     info->driverPriv = prog;
>
> -#ifdef DEBUG
> +#ifndef NDEBUG
>     info->optLevel = debug_get_num_option("NV50_PROG_OPTIMIZE", 3);
>     info->dbgFlags = debug_get_num_option("NV50_PROG_DEBUG", 0);
>     info->omitLineNum = debug_get_num_option("NV50_PROG_DEBUG_OMIT_LINENUM", 0);
> diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_program.c b/src/gallium/drivers/nouveau/nvc0/nvc0_program.c
> index 180b31ea893..32487248c7a 100644
> --- a/src/gallium/drivers/nouveau/nvc0/nvc0_program.c
> +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_program.c
> @@ -544,7 +544,7 @@ nvc0_program_create_tfb_state(const struct nv50_ir_prog_info *info,
>     return tfb;
>  }
>
> -#ifdef DEBUG
> +#ifndef NDEBUG
>  static void
>  nvc0_program_dump(struct nvc0_program *prog)
>  {
> @@ -594,7 +594,7 @@ nvc0_program_translate(struct nvc0_program *prog, uint16_t chipset,
>        return false;
>     }
>
> -#ifdef DEBUG
> +#ifndef NDEBUG
>     info->target = debug_get_num_option("NV50_PROG_CHIPSET", chipset);
>     info->optLevel = debug_get_num_option("NV50_PROG_OPTIMIZE", 3);
>     info->dbgFlags = debug_get_num_option("NV50_PROG_DEBUG", 0);
> @@ -714,7 +714,7 @@ nvc0_program_translate(struct nvc0_program *prog, uint16_t chipset,
>                        prog->num_gprs, info->bin.instructions,
>                        info->bin.codeSize);
>
> -#ifdef DEBUG
> +#ifndef NDEBUG
>     if (debug_get_option("NV50_PROG_CHIPSET", NULL) && info->dbgFlags)
>        nvc0_program_dump(prog);
>  #endif
> @@ -880,7 +880,7 @@ nvc0_program_upload(struct nvc0_context *nvc0, struct nvc0_program *prog)
>
>     nvc0_program_upload_code(nvc0, prog);
>
> -#ifdef DEBUG
> +#ifndef NDEBUG
>     if (debug_get_bool_option("NV50_PROG_DEBUG", false))
>        nvc0_program_dump(prog);
>  #endif
> diff --git a/src/gallium/drivers/nouveau/nvc0/nve4_compute.c b/src/gallium/drivers/nouveau/nvc0/nve4_compute.c
> index a1c40d1e6b9..eedb1b610d4 100644
> --- a/src/gallium/drivers/nouveau/nvc0/nve4_compute.c
> +++ b/src/gallium/drivers/nouveau/nvc0/nve4_compute.c
> @@ -27,7 +27,7 @@
>
>  #include "codegen/nv50_ir_driver.h"
>
> -#ifdef DEBUG
> +#ifndef NDEBUG
>  static void nve4_compute_dump_launch_desc(const struct nve4_cp_launch_desc *);
>  static void gp100_compute_dump_launch_desc(const struct gp100_cp_launch_desc *);
>  #endif
> @@ -741,7 +741,7 @@ nve4_launch_grid(struct pipe_context *pipe, const struct pipe_grid_info *info)
>
>     nve4_compute_upload_input(nvc0, info);
>
> -#ifdef DEBUG
> +#ifndef NDEBUG
>     if (debug_get_num_option("NV50_PROG_DEBUG", 0)) {
>        if (nvc0->screen->compute->oclass >= GP100_COMPUTE_CLASS)
>           gp100_compute_dump_launch_desc(desc);
> @@ -878,7 +878,7 @@ nve4_compute_validate_textures(struct nvc0_context *nvc0)
>  }
>
>
> -#ifdef DEBUG
> +#ifndef NDEBUG
>  static const char *nve4_cache_split_name(unsigned value)
>  {
>     switch (value) {
> --
> 2.21.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list