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 
641  ENV_MAX_INT_CONTROLS // <- Must be last
642 };
643 
645 {
646  // UT: Public interface
650 
651  // UT: Internal variables
653 
654  // IMG: Public interface
657 
658  // RE
660 
661  // UI
664 
665  // GR
667 
668  // Custom
670 
671  // ROP: Internal variables
673 
674  // OpenCL: Memory pool size, as percentage of GPU memory.
676 
677  // OpenCL: amount of VRAM that IMX layers are allowed to use.
679 
680  // CH
682 
683  // LOP interactive selection redraw time
685 
686  // Percent grey that shows as a zero exposure value when displaying
687  // pixel luminance in log terms. Values outside (0, 1) cause us to
688  // not calculate or display luminance in log terms.
690 
691  ENV_MAX_FLT_CONTROLS // <- Must be last
692 };
693 
695 {
696  // UT: Public interface
716 
717  // UT: Internal variables
721 
722  // external tools
724 
725  // IMG: Public interface
728 
729  // VEX(VMAT)
738 
739  // HOM
741 
742  // OP
743  ENV_HOUDINI_HIP_DEFAULT_NAME, // "untitled.hip"
746 
747  // VOP
749 
750  // GEO
752 
753  // COP
760 
761  // CHOP
763 
764  // TOP
766 
767  // LOP
769 
770  // IFD
776 
777  // UI
788 
789  // FUI
792 
793  // CHUI
795 
796  // OPUI
800 
801  // VEX(VCC)
803 
804  // Custom
812  ENV_HOUDINI_VIEW_METACAM, //OTLs that lock to view in a special way
813 
814  // Path variables
817 
848 
852 
854 
857 
859 
865 
867 
869 
874 
881 
884 
886 
888 
889  // These are here so we can have them show up in hconfig and provide
890  // help. They should only be used implicitly.
891  ENV_HSITE, // Between HFS and HOME.
892  ENV_JOB, // We should not use JOB!
893 
895 
901 
903 
904  // OPENGL
911 
912  // OPENCL
919 
920  // Orbolt
922 
923  // Anonymous Usage Statistics
925 
927 
929 
931 
932  // Optix
934 
936 
937  // BGEO plugin for USD default load arguments
939 
940  // LM
959 
960  // Python
962 
963  // Logging
967 
968  // Default asset/material catalog databases
972 
973  // Networking
976 
977  // HQueue
983 
984  // Render delegate to use by default on new Houdini clones
989 
990  // Render Product Types that should not show their AOVs in the list
991  // that shows up in the viewport menu.
993 
996 
998 
999  // When a loaded HDA changes on disk, perform this action by default
1000  // instead of showing the interactive message.
1002 
1003  // Compression method to specify a default compression method for
1004  // .hip files
1006 
1007  // Compression codec to use when compressing in blosc.
1009 
1011 
1012  ENV_MAX_STR_CONTROLS // <- Must be last
1013 };
1014 
1015 // If these constraints are ever violated in a HEAD branch, it's time to
1016 // increase MAX_CONTROLS_WITH_BUFFER. If these constraints are violated in
1017 // a released build, get rid of the "+50" part, and if they are exceeded
1018 // again then we must increate MAX_CONTROLS_WITH_BUFFER in a daily build and
1019 // break ABI compatiblity. But hopefully that won't happen...
1023 
1025 {
1026 public:
1027  UT_EnvControl();
1028  ~UT_EnvControl();
1029 
1030  UT_EnvControl(const UT_EnvControl &) = delete;
1031  UT_EnvControl &operator=(const UT_EnvControl &) = delete;
1032 
1033  void init();
1034 
1035  static int getInt(UT_IntControl i)
1036  { return getControl().myIValues[i]; }
1038  { return getControl().myFValues[i]; }
1039  static const char *getString(UT_StrControl i)
1040  { return getControl().mySValues[i]; }
1041 
1042  // Look up the appropriate variable name for the token
1043  static const char *getIntVar(UT_IntControl i);
1044  static const char *getFloatVar(UT_FltControl i);
1045  static const char *getStringVar(UT_StrControl i);
1046 
1047  static void setStringVar(UT_StrControl i, const char *value);
1048 
1049  // Look up the appropriate old style variable name for the token. This can
1050  // be used to check for old environment variables.
1051  static const char *getOldIntVar(UT_IntControl i);
1052  static const char *getOldFloatVar(UT_FltControl i);
1053  static const char *getOldStringVar(UT_StrControl i);
1054 
1055  /// Indicate that the given variable changed and update our cached values.
1056  /// If varname is NULL, then all variables are updated.
1057  static void varChanged(const char *varname)
1058  { varChanged(varname, nullptr); }
1059 
1060  /// Update the cached varname value with the given value so that we can
1061  /// avoid an extraneous HoudiniGetenv() for the equivalent code snippet:
1062  /// @code
1063  /// HoudiniSetenv(name, value);
1064  /// UT_EnvControl::varChanged(name);
1065  /// @endcode
1066  /// @return true if name was found and value is non-null, in which case the
1067  /// HoudiniSetenv() was called, else false is returned.
1068  static bool varChanged(const char *varname, const char *value);
1069 
1070  static void changeExistLookupDefault(UT_IntControl i, int new_def);
1071 
1072  /// Queries the cached variable value. Unrecognized variables are
1073  /// returned as UT_Variant::Type::Unknown. String values are returned
1074  /// as UT_Variant::Type::Pointer to allow distinguishing between null
1075  /// pointers and empty strings. If you intend to hold onto the string
1076  /// value beyond immediately using it, you must make your own copy!
1077  static UT_Variant getVarValue(const char *varname);
1078 
1079  /// Set all additional .env files to be parsed for env variable values.
1080  /// It is best to call getAdditionalEnvironmentFiles() first and then
1081  /// append to the list because this function will overwrite all the
1082  /// additional paths that were previously set.
1083  /// You can still use the HOUDINI_NO_ENV_FILE_OVERRIDES to disallow
1084  /// overwrites, knowing that these files get applied AFTER the default
1085  /// houdini.env file in the user's home directory.
1086  /// That said, HOUDINI_NO_ENV_FILE will have no effect on this function.
1087  /// If additional files are set, they will be used, regardless of the
1088  /// value of HOUDINI_NO_ENV_FILE.
1089  static void setAdditionalEnvironmentFiles(
1090  const UT_StringArray &files);
1091 
1092  /// Return the current list of additional environment files.
1093  static const UT_StringArray&
1094  getAdditionalEnvironmentFiles();
1095 
1096  // Print messages collected during init phase to console
1097  static void logMessages()
1098  {
1099  getControl().logMessagesToConsole();
1100  }
1101 
1102  // Package loader management
1103  // Load the pakages located in the folders specified by pkg_paths.
1104  // Use this method for loading package dynamically
1105  static void loadPackages(UT_StringArray const &pkg_paths, UT_Package::Loader& pkg_loader);
1106  static UT_Package::Package & loadPackage(char const * pkg_filepath, UT_Package::Loader& pkg_loader);
1107 
1108  // Returns the main package loader, this loader contains all
1109  // packages loaded at runtime.
1110  static UT_Package::Loader& packageLoader();
1111 
1112 private:
1113  void doInit(bool init_defaults);
1114  void setDefaults();
1115  bool loadEnvironmentFile(const char *path,
1116  bool allow_overrides);
1117  void loadDefaultEnvironmentFile();
1118  void loadEnvironmentFiles();
1119  void loadEnvironment(bool init_defaults);
1120 
1121  void updateExistLookup(int i, const char *value = nullptr);
1122  void updateIntLookup(int i, const char *value = nullptr);
1123  void updateFltLookup(int i, const char *value = nullptr);
1124  void updateStrLookup(int i, bool fix_path,
1125  const char *value = nullptr);
1126 
1127  void updateVarTables(UT_Package::Loader const& pkg_loader);
1128 
1129  void loadPackageConfig();
1130  void logMessagesToConsole() const;
1131 
1132  int myIValues[MAX_CONTROLS_WITH_BUFFER];
1133  float myFValues[MAX_CONTROLS_WITH_BUFFER];
1134  char *mySValues[MAX_CONTROLS_WITH_BUFFER];
1135 
1136  static UT_EnvControl &getControl()
1137  {
1138  if (!theControl)
1139  {
1140  theControl = new UT_EnvControl();
1141  theControl->init();
1142 
1143  }
1144  return *theControl;
1145  }
1146  static UT_EnvControl *theControl;
1147 
1148  UT_StringHolder myLogMessages;
1149 };
1150 
1151 #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