HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_EnvControl.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: UT_EnvControl.h ( UT Library, C++)
7  *
8  * COMMENTS: In Houdini applications, there are many environment variables
9  * which control the behaviour of certain features/capabilities.
10  * This class provides a centralized place to efficiently query
11  * these variables. The reason for the centralization is so that
12  * we can easily get a list of these control variables. As well,
13  * this mechanism provides ways of changing the control settings
14  * from environment variables to disk file to registry entry.
15  * Currently only environment variable control is supported.
16  *
17  *
18  * When adding a new environment variable, please document the variable in
19  * $SHD/ref/env.txt
20  */
21 
22 #ifndef __UT_EnvControl__
23 #define __UT_EnvControl__
24 
25 #include "UT_API.h"
26 #include "UT_StringHolder.h"
27 #include <SYS/SYS_Allocator.h>
28 #include <SYS/SYS_StaticAssert.h>
29 #include <SYS/SYS_Types.h>
30 
31 class UT_StringArray;
32 class UT_Variant;
33 
34 namespace UT_Package
35 {
36  class Loader;
37  class Package;
38 }
39 
40 // This define declares a fixed size of array for holding our cached
41 // environment variable values. It should be larger than any of our actual
42 // requirements so that we can add new enum values to the end of these
43 // tables without breaking ABI compatibility (as long as we don't actually
44 // exceed this value and need to increase it).
45 #define MAX_CONTROLS_WITH_BUFFER 512
46 
48 {
49  // UT library: Public interface
67 
68  // UT: Internal controls
80 
81  // Houdini Environment File Control
84 
85  // FS: Public interface
93 
94  // GA: Public interface
96 
97  // IMG3D: Public interface
99 
100  // IMG: Public interface
129  // IMG: Private interface
139 
140  // MV: Public interface
142 
143  // VEX: Public interface
154 
155  // VEX: Private interface
157 
158  // RE: Public interface
169 
170  // CMD
173 
174  // OP
178 
179  // GEO
183 
184  // GU
186 
187  // RAY
198 
205 
228 
231 
232  // COP2
235 
236  // IFD
240 
241  // MAT
243 
244  // UI
267 
271 
273 
274  // OPUI
280 
281  // DM
285 
286  // MATUI
288 
289  // Custom
294 
295  // LM
306 
307  // CHOP
309 
310  // SHOP
313 
314  // VOP
316 
317  // SHLF
320 
321  // Other
327 
328  // Backwards Compatability
337 
350 
352  // Have houdini check process fallback to the old deprecated API
356 
358 
359  // hscript
363 
365 
366  // This is for "internal use" only. It turns on features that are not
367  // ready for prime-time.
369 
370  // Maximum number of files to keep in the backup directory
372 
374 
376 
378 
381 
384 
386 
387  // Controls the number of complete FBX scenes to
388  // keep cached in memory after import. Defaults to 1.
390 
391  // Controls whether to transform the results of evaluating a MotionClip
392  // by the intrinsic matrix of the packed primitive.
394 
399 
402 
403  // OpenGL
407 
408  // OpenCL
412  ENV_HOUDINI_OCL_OGL_INTEROP, // Use CE_Context::shouldUseOCLOGLInterop instead of raw access to this that does additional compatability checks
415  // Can be used to force disable the use of images for advection by the Gas
416  // Advect CL 2.0 DOP.
418  // Can be used to force use of SwiftShader by the Rasterize Geometry COP.
420  // The rasterizer COP can use interop to copy from vulkan memory to OpenCL
421  // memory without leaving the GPU. However, this causes a memory leak on
422  // some NVIDIA drivers. This environment variable controls that
423  // functionality (0 means no interop, 1 means do it if we can).
428 
432 
434 
435  // Maximum megabytes in write buffer.
437 
439 
443 
446 
448 
450 
452 
454 
456 
458 
459 #if defined(SYS_ALLOCATOR_TCMALLOC)
460  ENV_HOUDINI_DISABLE_TCMALLOCTEST,
461 #elif defined(SYS_ALLOCATOR_MIMALLOC)
462  ENV_HOUDINI_DISABLE_MIMALLOCTEST,
463 #else
465 #endif
466 
468 
470 
471  // Used to force regular LM checks on Steam builds
473 
474  // OptiX
476 
478 
479  // Package
482 
483  // Viewer state
485 
487 
489 
491 
492  // TOP
505 
506  // HAPI
508 
509  // LOP
516 
518 
519  // HDA plugin for USD geometry cache size
521 
522  // Disables loading of individual third-party USD plugins
526 
528 
530 
532 
533  // Send python panel erros to the console
535 
537 
539 
541 
542  // Specify whether or not Houdini GL should use Mtlx materials
544 
545  // New op viewer, defaults to on.
547 
549 
551 
553 
555 
556  ENV_KARMA_DICING_LEGACY, // Karma legacy dicing behaviour
557  ENV_KARMA_VARYING_ARRAY_PRIMVARS, // Varying length array primvars
560 
561  // Save HDA internal sections alphabetically (where it makes sens)
563 
565 
566  // MV
568 
570 
572 
573  // microfacet conductor fresnel to fix glowing issue with rough metals
575 
576  // texturing issues relating to bad derivatives
578 
580 
582 
584 
586 
589 
590  // Suppress creation of the non-critical files when expanding an HDA
592 
593  // Tells Houdini to prefer "last cooked" context options over "global"
594  // options when a node is asked to cook with its last cooked options.
596 
598 
600 
602 
604 
609 
611 
613 
614  // Change to behavior of primitive sub-patterns. New behavior is
615  // definitely more correct, but might change things in unexpected ways.
617 
619 
620  // APEX: Private Interface
622 
624 
626 
628 
630 
632 
634 
635  // Control whether the Solaris Scene Graph Tree should sort prims
636  // alphabetically, or use the USD prim "child order".
638 
640 
642 
643  ENV_MAX_INT_CONTROLS // <- Must be last
644 };
645 
647 {
648  // UT: Public interface
652 
653  // UT: Internal variables
655 
656  // IMG: Public interface
659 
660  // RE
662 
663  // UI
666 
667  // GR
669 
670  // Custom
672 
673  // ROP: Internal variables
675 
676  // OpenCL: Memory pool size, as percentage of GPU memory.
678 
679  // OpenCL: amount of VRAM that IMX layers are allowed to use.
681 
682  // CH
684 
685  // LOP interactive selection redraw time
687 
688  // Percent grey that shows as a zero exposure value when displaying
689  // pixel luminance in log terms. Values outside (0, 1) cause us to
690  // not calculate or display luminance in log terms.
692 
693  ENV_MAX_FLT_CONTROLS // <- Must be last
694 };
695 
697 {
698  // UT: Public interface
718 
719  // UT: Internal variables
723 
724  // external tools
726 
727  // IMG: Public interface
730 
731  // VEX(VMAT)
740 
741  // HOM
743 
744  // OP
745  ENV_HOUDINI_HIP_DEFAULT_NAME, // "untitled.hip"
748 
749  // VOP
751 
752  // GEO
754 
755  // COP
762 
763  // CHOP
765 
766  // TOP
768 
769  // LOP
771 
772  // IFD
778 
779  // UI
790 
791  // FUI
794 
795  // CHUI
797 
798  // OPUI
802 
803  // VEX(VCC)
805 
806  // Custom
814  ENV_HOUDINI_VIEW_METACAM, //OTLs that lock to view in a special way
815 
816  // Path variables
819 
850 
854 
856 
859 
861 
867 
869 
871 
876 
883 
886 
888 
890 
891  // These are here so we can have them show up in hconfig and provide
892  // help. They should only be used implicitly.
893  ENV_HSITE, // Between HFS and HOME.
894  ENV_JOB, // We should not use JOB!
895 
897 
903 
905 
906  // OPENGL
913 
914  // OPENCL
921 
922  // Orbolt
924 
925  // Anonymous Usage Statistics
927 
929 
931 
933 
934  // Optix
936 
938 
939  // BGEO plugin for USD default load arguments
941 
942  // LM
961 
962  // Python
964 
965  // Logging
969 
970  // Default asset/material catalog databases
974 
975  // Networking
978 
979  // HQueue
985 
986  // Render delegate to use by default on new Houdini clones
991 
992  // Render Product Types that should not show their AOVs in the list
993  // that shows up in the viewport menu.
995 
998 
1000 
1001  // When a loaded HDA changes on disk, perform this action by default
1002  // instead of showing the interactive message.
1004 
1005  // Compression method to specify a default compression method for
1006  // .hip files
1008 
1009  // Compression codec to use when compressing in blosc.
1011 
1013 
1014  ENV_MAX_STR_CONTROLS // <- Must be last
1015 };
1016 
1017 // If these constraints are ever violated in a HEAD branch, it's time to
1018 // increase MAX_CONTROLS_WITH_BUFFER. If these constraints are violated in
1019 // a released build, get rid of the "+50" part, and if they are exceeded
1020 // again then we must increate MAX_CONTROLS_WITH_BUFFER in a daily build and
1021 // break ABI compatiblity. But hopefully that won't happen...
1025 
1027 {
1028 public:
1029  UT_EnvControl();
1030  ~UT_EnvControl();
1031 
1032  UT_EnvControl(const UT_EnvControl &) = delete;
1033  UT_EnvControl &operator=(const UT_EnvControl &) = delete;
1034 
1035  void init();
1036 
1037  static int getInt(UT_IntControl i)
1038  { return getControl().myIValues[i]; }
1040  { return getControl().myFValues[i]; }
1041  static const char *getString(UT_StrControl i)
1042  { return getControl().mySValues[i]; }
1043 
1044  // Look up the appropriate variable name for the token
1045  static const char *getIntVar(UT_IntControl i);
1046  static const char *getFloatVar(UT_FltControl i);
1047  static const char *getStringVar(UT_StrControl i);
1048 
1049  static void setStringVar(UT_StrControl i, const char *value);
1050 
1051  // Look up the appropriate old style variable name for the token. This can
1052  // be used to check for old environment variables.
1053  static const char *getOldIntVar(UT_IntControl i);
1054  static const char *getOldFloatVar(UT_FltControl i);
1055  static const char *getOldStringVar(UT_StrControl i);
1056 
1057  /// Indicate that the given variable changed and update our cached values.
1058  /// If varname is NULL, then all variables are updated.
1059  static void varChanged(const char *varname)
1060  { varChanged(varname, nullptr); }
1061 
1062  /// Update the cached varname value with the given value so that we can
1063  /// avoid an extraneous HoudiniGetenv() for the equivalent code snippet:
1064  /// @code
1065  /// HoudiniSetenv(name, value);
1066  /// UT_EnvControl::varChanged(name);
1067  /// @endcode
1068  /// @return true if name was found and value is non-null, in which case the
1069  /// HoudiniSetenv() was called, else false is returned.
1070  static bool varChanged(const char *varname, const char *value);
1071 
1072  static void changeExistLookupDefault(UT_IntControl i, int new_def);
1073 
1074  /// Queries the cached variable value. Unrecognized variables are
1075  /// returned as UT_Variant::Type::Unknown. String values are returned
1076  /// as UT_Variant::Type::Pointer to allow distinguishing between null
1077  /// pointers and empty strings. If you intend to hold onto the string
1078  /// value beyond immediately using it, you must make your own copy!
1079  static UT_Variant getVarValue(const char *varname);
1080 
1081  /// Set all additional .env files to be parsed for env variable values.
1082  /// It is best to call getAdditionalEnvironmentFiles() first and then
1083  /// append to the list because this function will overwrite all the
1084  /// additional paths that were previously set.
1085  /// You can still use the HOUDINI_NO_ENV_FILE_OVERRIDES to disallow
1086  /// overwrites, knowing that these files get applied AFTER the default
1087  /// houdini.env file in the user's home directory.
1088  /// That said, HOUDINI_NO_ENV_FILE will have no effect on this function.
1089  /// If additional files are set, they will be used, regardless of the
1090  /// value of HOUDINI_NO_ENV_FILE.
1091  static void setAdditionalEnvironmentFiles(
1092  const UT_StringArray &files);
1093 
1094  /// Return the current list of additional environment files.
1095  static const UT_StringArray&
1096  getAdditionalEnvironmentFiles();
1097 
1098  // Print messages collected during init phase to console
1099  static void logMessages()
1100  {
1101  getControl().logMessagesToConsole();
1102  }
1103 
1104  // Package loader management
1105  // Load the pakages located in the folders specified by pkg_paths.
1106  // Use this method for loading package dynamically
1107  static void loadPackages(UT_StringArray const &pkg_paths, UT_Package::Loader& pkg_loader);
1108  static UT_Package::Package & loadPackage(char const * pkg_filepath, UT_Package::Loader& pkg_loader);
1109 
1110  // Returns the main package loader, this loader contains all
1111  // packages loaded at runtime.
1112  static UT_Package::Loader& packageLoader();
1113 
1114 private:
1115  void doInit(bool init_defaults);
1116  void setDefaults();
1117  bool loadEnvironmentFile(const char *path,
1118  bool allow_overrides);
1119  void loadDefaultEnvironmentFile();
1120  void loadEnvironmentFiles();
1121  void loadEnvironment(bool init_defaults);
1122 
1123  void updateExistLookup(int i, const char *value = nullptr);
1124  void updateIntLookup(int i, const char *value = nullptr);
1125  void updateFltLookup(int i, const char *value = nullptr);
1126  void updateStrLookup(int i, bool fix_path,
1127  const char *value = nullptr);
1128 
1129  void updateVarTables(UT_Package::Loader const& pkg_loader);
1130 
1131  void loadPackageConfig();
1132  void logMessagesToConsole() const;
1133 
1134  int myIValues[MAX_CONTROLS_WITH_BUFFER];
1135  float myFValues[MAX_CONTROLS_WITH_BUFFER];
1136  char *mySValues[MAX_CONTROLS_WITH_BUFFER];
1137 
1138  static UT_EnvControl &getControl()
1139  {
1140  if (!theControl)
1141  {
1142  theControl = new UT_EnvControl();
1143  theControl->init();
1144 
1145  }
1146  return *theControl;
1147  }
1148  static UT_EnvControl *theControl;
1149 
1150  UT_StringHolder myLogMessages;
1151 };
1152 
1153 #endif
static void varChanged(const char *varname)
static const char * getString(UT_StrControl i)
GLsizei const GLfloat * value
Definition: glcorearb.h:824
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
#define UT_API
Definition: UT_API.h:14
static void logMessages()
UT_StrControl
static int getInt(UT_IntControl i)
static fpreal getFloat(UT_FltControl i)
fpreal64 fpreal
Definition: SYS_Types.h:283
LeafData & operator=(const LeafData &)=delete
SYS_STATIC_ASSERT(ENV_MAX_INT_CONTROLS+50< MAX_CONTROLS_WITH_BUFFER)
UT_FltControl
#define MAX_CONTROLS_WITH_BUFFER
Definition: UT_EnvControl.h:45
UT_IntControl
Definition: UT_EnvControl.h:47