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  // Controls whether binary PLY files should be written as little-endian.
645 
647 
648  ENV_MAX_INT_CONTROLS // <- Must be last
649 };
650 
652 {
653  // UT: Public interface
657 
658  // UT: Internal variables
660 
661  // IMG: Public interface
664 
665  // RE
667 
668  // UI
671 
672  // GR
674 
675  // Custom
677 
678  // ROP: Internal variables
680 
681  // OpenCL: Memory pool size, as percentage of GPU memory.
683 
684  // OpenCL: amount of VRAM that IMX layers are allowed to use.
686 
687  // CH
689 
690  // LOP interactive selection redraw time
692 
693  // Percent grey that shows as a zero exposure value when displaying
694  // pixel luminance in log terms. Values outside (0, 1) cause us to
695  // not calculate or display luminance in log terms.
697 
698  ENV_MAX_FLT_CONTROLS // <- Must be last
699 };
700 
702 {
703  // UT: Public interface
723 
724  // UT: Internal variables
728 
729  // external tools
731 
732  // IMG: Public interface
735 
736  // VEX(VMAT)
745 
746  // HOM
748 
749  // OP
750  ENV_HOUDINI_HIP_DEFAULT_NAME, // "untitled.hip"
753 
754  // VOP
756 
757  // GEO
759 
760  // COP
767 
768  // CHOP
770 
771  // TOP
773 
774  // LOP
776 
777  // IFD
783 
784  // UI
795 
796  // FUI
799 
800  // CHUI
802 
803  // OPUI
807 
808  // VEX(VCC)
810 
811  // Custom
819  ENV_HOUDINI_VIEW_METACAM, //OTLs that lock to view in a special way
820 
821  // Path variables
824 
855 
859 
861 
864 
866 
872 
874 
876 
881 
888 
891 
893 
895 
896  // These are here so we can have them show up in hconfig and provide
897  // help. They should only be used implicitly.
898  ENV_HSITE, // Between HFS and HOME.
899  ENV_JOB, // We should not use JOB!
900 
902 
908 
910 
911  // OPENGL
918 
919  // OPENCL
926 
927  // Orbolt
929 
930  // Anonymous Usage Statistics
932 
934 
936 
938 
939  // Optix
941 
943 
944  // BGEO plugin for USD default load arguments
946 
947  // LM
966 
967  // Python
969 
970  // Logging
974 
975  // Default asset/material catalog databases
979 
980  // Networking
983 
984  // HQueue
990 
991  // Render delegate to use by default on new Houdini clones
996 
997  // Render Product Types that should not show their AOVs in the list
998  // that shows up in the viewport menu.
1000 
1003 
1005 
1006  // When a loaded HDA changes on disk, perform this action by default
1007  // instead of showing the interactive message.
1009 
1010  // Compression method to specify a default compression method for
1011  // .hip files
1013 
1014  // Compression codec to use when compressing in blosc.
1016 
1018 
1019  ENV_MAX_STR_CONTROLS // <- Must be last
1020 };
1021 
1022 // If these constraints are ever violated in a HEAD branch, it's time to
1023 // increase MAX_CONTROLS_WITH_BUFFER. If these constraints are violated in
1024 // a released build, get rid of the "+50" part, and if they are exceeded
1025 // again then we must increate MAX_CONTROLS_WITH_BUFFER in a daily build and
1026 // break ABI compatiblity. But hopefully that won't happen...
1030 
1032 {
1033 public:
1034  UT_EnvControl();
1035  ~UT_EnvControl();
1036 
1037  UT_EnvControl(const UT_EnvControl &) = delete;
1038  UT_EnvControl &operator=(const UT_EnvControl &) = delete;
1039 
1040  void init();
1041 
1042  static int getInt(UT_IntControl i)
1043  { return getControl().myIValues[i]; }
1045  { return getControl().myFValues[i]; }
1046  static const char *getString(UT_StrControl i)
1047  { return getControl().mySValues[i]; }
1048 
1049  // Look up the appropriate variable name for the token
1050  static const char *getIntVar(UT_IntControl i);
1051  static const char *getFloatVar(UT_FltControl i);
1052  static const char *getStringVar(UT_StrControl i);
1053 
1054  static void setStringVar(UT_StrControl i, const char *value);
1055 
1056  // Look up the appropriate old style variable name for the token. This can
1057  // be used to check for old environment variables.
1058  static const char *getOldIntVar(UT_IntControl i);
1059  static const char *getOldFloatVar(UT_FltControl i);
1060  static const char *getOldStringVar(UT_StrControl i);
1061 
1062  /// Indicate that the given variable changed and update our cached values.
1063  /// If varname is NULL, then all variables are updated.
1064  static void varChanged(const char *varname)
1065  { varChanged(varname, nullptr); }
1066 
1067  /// Update the cached varname value with the given value so that we can
1068  /// avoid an extraneous HoudiniGetenv() for the equivalent code snippet:
1069  /// @code
1070  /// HoudiniSetenv(name, value);
1071  /// UT_EnvControl::varChanged(name);
1072  /// @endcode
1073  /// @return true if name was found and value is non-null, in which case the
1074  /// HoudiniSetenv() was called, else false is returned.
1075  static bool varChanged(const char *varname, const char *value);
1076 
1077  static void changeExistLookupDefault(UT_IntControl i, int new_def);
1078 
1079  /// Queries the cached variable value. Unrecognized variables are
1080  /// returned as UT_Variant::Type::Unknown. String values are returned
1081  /// as UT_Variant::Type::Pointer to allow distinguishing between null
1082  /// pointers and empty strings. If you intend to hold onto the string
1083  /// value beyond immediately using it, you must make your own copy!
1084  static UT_Variant getVarValue(const char *varname);
1085 
1086  /// Set all additional .env files to be parsed for env variable values.
1087  /// It is best to call getAdditionalEnvironmentFiles() first and then
1088  /// append to the list because this function will overwrite all the
1089  /// additional paths that were previously set.
1090  /// You can still use the HOUDINI_NO_ENV_FILE_OVERRIDES to disallow
1091  /// overwrites, knowing that these files get applied AFTER the default
1092  /// houdini.env file in the user's home directory.
1093  /// That said, HOUDINI_NO_ENV_FILE will have no effect on this function.
1094  /// If additional files are set, they will be used, regardless of the
1095  /// value of HOUDINI_NO_ENV_FILE.
1096  static void setAdditionalEnvironmentFiles(
1097  const UT_StringArray &files);
1098 
1099  /// Return the current list of additional environment files.
1100  static const UT_StringArray&
1101  getAdditionalEnvironmentFiles();
1102 
1103  // Print messages collected during init phase to console
1104  static void logMessages()
1105  {
1106  getControl().logMessagesToConsole();
1107  }
1108 
1109  // Package loader management
1110  // Load the pakages located in the folders specified by pkg_paths.
1111  // Use this method for loading package dynamically
1112  static void loadPackages(UT_StringArray const &pkg_paths, UT_Package::Loader& pkg_loader);
1113  static UT_Package::Package & loadPackage(char const * pkg_filepath, UT_Package::Loader& pkg_loader);
1114 
1115  // Returns the main package loader, this loader contains all
1116  // packages loaded at runtime.
1117  static UT_Package::Loader& packageLoader();
1118 
1119 private:
1120  void doInit(bool init_defaults);
1121  void setDefaults();
1122  bool loadEnvironmentFile(const char *path,
1123  bool allow_overrides);
1124  void loadDefaultEnvironmentFile();
1125  void loadEnvironmentFiles();
1126  void loadEnvironment(bool init_defaults);
1127 
1128  void updateExistLookup(int i, const char *value = nullptr);
1129  void updateIntLookup(int i, const char *value = nullptr);
1130  void updateFltLookup(int i, const char *value = nullptr);
1131  void updateStrLookup(int i, bool fix_path,
1132  const char *value = nullptr);
1133 
1134  void updateVarTables(UT_Package::Loader const& pkg_loader);
1135 
1136  void loadPackageConfig();
1137  void logMessagesToConsole() const;
1138 
1139  int myIValues[MAX_CONTROLS_WITH_BUFFER];
1140  float myFValues[MAX_CONTROLS_WITH_BUFFER];
1141  char *mySValues[MAX_CONTROLS_WITH_BUFFER];
1142 
1143  static UT_EnvControl &getControl()
1144  {
1145  if (!theControl)
1146  {
1147  theControl = new UT_EnvControl();
1148  theControl->init();
1149 
1150  }
1151  return *theControl;
1152  }
1153  static UT_EnvControl *theControl;
1154 
1155  UT_StringHolder myLogMessages;
1156 };
1157 
1158 #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