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

2019-07-26 Thread Karol Herbst
Reviewed-by: Karol Herbst 

On Fri, Jul 26, 2019 at 5:31 AM Ilia Mirkin  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 
> ---
>  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..000
> --- a/src/gallium/drivers/nouveau/nouveau_statebuf.h
> +++ /dev/null
> @@ -1,32 +0,

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

2019-07-25 Thread Ilia Mirkin
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 
---
 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..000
--- 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
-};
-
-#ifd