[Bf-blender-cvs] [d2728868c01] master: GPU: Improve Codegen variable names

Miguel Pozo noreply at git.blender.org
Tue Nov 15 13:07:03 CET 2022


Commit: d2728868c01d97540c9e5cd24adcf5f0ae6b232a
Author: Miguel Pozo
Date:   Tue Nov 15 13:06:58 2022 +0100
Branches: master
https://developer.blender.org/rBd2728868c01d97540c9e5cd24adcf5f0ae6b232a

GPU: Improve Codegen variable names

Include the node name and parameter index in the variable name for easier debugging.
(Enabled for debug builds only)

Reviewed By: fclem, jbakker

Differential Revision: https://developer.blender.org/D16496

===================================================================

M	source/blender/gpu/intern/gpu_codegen.cc

===================================================================

diff --git a/source/blender/gpu/intern/gpu_codegen.cc b/source/blender/gpu/intern/gpu_codegen.cc
index 42b2151e75b..465a621e864 100644
--- a/source/blender/gpu/intern/gpu_codegen.cc
+++ b/source/blender/gpu/intern/gpu_codegen.cc
@@ -169,14 +169,22 @@ static bool gpu_pass_is_valid(GPUPass *pass)
 /** \name Type > string conversion
  * \{ */
 
+#ifdef DEBUG
+#  define SRC_NAME(io, link, list, type) \
+    link->node->name << "_" << io << BLI_findindex(&link->node->list, (const void *)link) << "_" \
+                     << type
+#else
+#  define SRC_NAME(io, list, link, type) type
+#endif
+
 static std::ostream &operator<<(std::ostream &stream, const GPUInput *input)
 {
   switch (input->source) {
     case GPU_SOURCE_FUNCTION_CALL:
     case GPU_SOURCE_OUTPUT:
-      return stream << "tmp" << input->id;
+      return stream << SRC_NAME("in", input, inputs, "tmp") << input->id;
     case GPU_SOURCE_CONSTANT:
-      return stream << "cons" << input->id;
+      return stream << SRC_NAME("in", input, inputs, "cons") << input->id;
     case GPU_SOURCE_UNIFORM:
       return stream << "node_tree.u" << input->id;
     case GPU_SOURCE_ATTR:
@@ -199,7 +207,7 @@ static std::ostream &operator<<(std::ostream &stream, const GPUInput *input)
 
 static std::ostream &operator<<(std::ostream &stream, const GPUOutput *output)
 {
-  return stream << "tmp" << output->id;
+  return stream << SRC_NAME("out", output, outputs, "tmp") << output->id;
 }
 
 /* Trick type to change overload and keep a somewhat nice syntax. */



More information about the Bf-blender-cvs mailing list