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_StaticAssert.h>
28 #include <SYS/SYS_Types.h>
29 
30 class UT_StringArray;
31 class UT_Variant;
32 
33 namespace UT_Package
34 {
35  class Loader;
36  class Package;
37 }
38 
39 // This define declares a fixed size of array for holding our cached
40 // environment variable values. It should be larger than any of our actual
41 // requirements so that we can add new enum values to the end of these
42 // tables without breaking ABI compatibility (as long as we don't actually
43 // exceed this value and need to increase it).
44 #define MAX_CONTROLS_WITH_BUFFER 512
45 
47 {
48  // UT library: Public interface
66 
67  // UT: Internal controls
79 
80  // Houdini Environment File Control
83 
84  // FS: Public interface
92 
93  // GA: Public interface
95 
96  // IMG3D: Public interface
98 
99  // IMG: Public interface
128  // IMG: Private interface
137 
138  // MV: Public interface
140 
141  // VEX: Public interface
152 
153  // VEX: Private interface
155 
156  // RE: Public interface
166 
167  // CMD
170 
171  // OP
175 
176  // GEO
180 
181  // GU
183 
184  // RAY
195 
199 
222 
225 
226  // COP2
229 
230  // IFD
234 
235  // MAT
237 
238  // UI
260 
261  // OPUI
267 
268  // DM
271 
272  // MATUI
274 
275  // Custom
280 
281  // LM
292 
293  // CHOP
295 
296  // SHOP
299 
300  // VOP
302 
303  // SHLF
306 
307  // Other
313 
314  // Backwards Compatability
323 
336 
338  // Have houdini check process fallback to the old deprecated API
342 
344 
345  // hscript
349 
351 
352  // This is for "internal use" only. It turns on features that are not
353  // ready for prime-time.
355 
356  // Maximum number of files to keep in the backup directory
358 
360 
362 
364 
367 
370 
372 
373  // Controls the number of complete FBX scenes to
374  // keep cached in memory after import. Defaults to 1.
376 
377  // Controls whether to transform the results of evaluating a MotionClip
378  // by the intrinsic matrix of the packed primitive.
380 
385 
388 
389  // OpenGL
393 
394  // OpenCL
398  ENV_HOUDINI_OCL_OGL_INTEROP, // Use CE_Context::shouldUseOCLOGLInterop instead of raw access to this that does additional compatability checks
401  // Can be used to force disable the use of images for advection by the Gas
402  // Advect CL 2.0 DOP.
404  // Can be used to force use of SwiftShader by the Rasterize Geometry COP.
406  // The rasterizer COP can use interop to copy from vulkan memory to OpenCL
407  // memory without leaving the GPU. However, this causes a memory leak on
408  // some NVIDIA drivers. This environment variable controls that
409  // functionality (0 means no interop, 1 means do it if we can).
412 
416 
418 
419  // Maximum megabytes in write buffer.
421 
423 
427 
430 
432 
434 
436 
438 
440 
443 
445 
447 
448  // Used to force regular LM checks on Steam builds
450 
451  // OptiX
453 
455 
456  // Package
459 
460  // Viewer state
462 
464 
466 
468 
469  // TOP
482 
483  // HAPI
485 
486  // LOP
490 
492 
494 
495  // HDA plugin for USD geometry cache size
497 
499 
501 
503 
504  // Send python panel erros to the console
506 
508 
510 
512 
513  // Specify whether or not Houdini GL should use Mtlx materials
515 
516  // New op viewer, defaults to on.
518 
520 
522 
524 
526 
527  ENV_KARMA_DICING_LEGACY, // Karma legacy dicing behaviour
528  ENV_KARMA_VARYING_ARRAY_PRIMVARS, // Varying length array primvars
531 
532  // Save HDA internal sections alphabetically (where it makes sens)
534 
536 
537  // MV
539 
541 
543 
544  // microfacet conductor fresnel to fix glowing issue with rough metals
546 
547  // texturing issues relating to bad derivatives
549 
551 
553 
555 
557 
560 
561  // Suppress creation of the non-critical files when expanding an HDA
563 
564  // Tells Houdini to prefer "last cooked" context options over "global"
565  // options when a node is asked to cook with its last cooked options.
567 
569 
571 
573 
575 
580 
582 
584 
585  // Change to behavior of primitive sub-patterns. New behavior is
586  // definitely more correct, but might change things in unexpected ways.
588 
591 
593 
595 
596  ENV_MAX_INT_CONTROLS // <- Must be last
597 };
598 
600 {
601  // UT: Public interface
605 
606  // UT: Internal variables
608 
609  // IMG: Public interface
612 
613  // RE
615 
616  // UI
619 
620  // GR
622 
623  // Custom
625 
626  // ROP: Internal variables
628 
629  // OpenCL: Memory pool size, as percentage of GPU memory.
631 
632  // OpenCL: amount of VRAM that IMX layers are allowed to use.
634 
635  // CH
637 
638  // LOP interactive selection redraw time
640 
641  // Percent grey that shows as a zero exposure value when displaying
642  // pixel luminance in log terms. Values outside (0, 1) cause us to
643  // not calculate or display luminance in log terms.
645 
646  ENV_MAX_FLT_CONTROLS // <- Must be last
647 };
648 
650 {
651  // UT: Public interface
671 
672  // UT: Internal variables
676 
677  // external tools
679 
680  // IMG: Public interface
683 
684  // VEX(VMAT)
693 
694  // HOM
696 
697  // OP
698  ENV_HOUDINI_HIP_DEFAULT_NAME, // "untitled.hip"
701 
702  // VOP
704 
705  // GEO
707 
708  // COP
715 
716  // CHOP
718 
719  // TOP
721 
722  // LOP
724 
725  // IFD
731 
732  // UI
743 
744  // FUI
747 
748  // CHUI
750 
751  // OPUI
755 
756  // VEX(VCC)
758 
759  // Custom
767  ENV_HOUDINI_VIEW_METACAM, //OTLs that lock to view in a special way
768 
769  // Path variables
772 
803 
807 
809 
812 
814 
820 
822 
824 
829 
836 
839 
841 
843 
844  // These are here so we can have them show up in hconfig and provide
845  // help. They should only be used implicitly.
846  ENV_HSITE, // Between HFS and HOME.
847  ENV_JOB, // We should not use JOB!
848 
850 
853 
855 
856  // OPENGL
863 
864  // OPENCL
871 
872  // Orbolt
874 
875  // Anonymous Usage Statistics
877 
879 
881 
883 
884  // Optix
886 
888 
889  // BGEO plugin for USD default load arguments
891 
892  // LM
910 
911  // Python
913 
914  // Logging
918 
919  // Default asset/material catalog databases
923 
924  // Networking
927 
928  // HQueue
934 
935  // Render delegate to use by default on new Houdini clones
940 
941  // Render Product Types that should not show their AOVs in the list
942  // that shows up in the viewport menu.
944 
947 
949 
950  // When a loaded HDA changes on disk, perform this action by default
951  // instead of showing the interactive message.
953 
954  // Compression method to specify a default compression method for
955  // .hip files
957 
958  ENV_MAX_STR_CONTROLS // <- Must be last
959 };
960 
961 // If these constraints are ever violated in a HEAD branch, it's time to
962 // increase MAX_CONTROLS_WITH_BUFFER. If these constraints are violated in
963 // a released build, get rid of the "+50" part, and if they are exceeded
964 // again then we must increate MAX_CONTROLS_WITH_BUFFER in a daily build and
965 // break ABI compatiblity. But hopefully that won't happen...
969 
971 {
972 public:
973  UT_EnvControl();
974  ~UT_EnvControl();
975 
976  UT_EnvControl(const UT_EnvControl &) = delete;
977  UT_EnvControl &operator=(const UT_EnvControl &) = delete;
978 
979  void init();
980 
981  static int getInt(UT_IntControl i)
982  { return getControl().myIValues[i]; }
984  { return getControl().myFValues[i]; }
985  static const char *getString(UT_StrControl i)
986  { return getControl().mySValues[i]; }
987 
988  // Look up the appropriate variable name for the token
989  static const char *getIntVar(UT_IntControl i);
990  static const char *getFloatVar(UT_FltControl i);
991  static const char *getStringVar(UT_StrControl i);
992 
993  static void setStringVar(UT_StrControl i, const char *value);
994 
995  // Look up the appropriate old style variable name for the token. This can
996  // be used to check for old environment variables.
997  static const char *getOldIntVar(UT_IntControl i);
998  static const char *getOldFloatVar(UT_FltControl i);
999  static const char *getOldStringVar(UT_StrControl i);
1000 
1001  /// Indicate that the given variable changed and update our cached values.
1002  /// If varname is NULL, then all variables are updated.
1003  static void varChanged(const char *varname)
1004  { varChanged(varname, nullptr); }
1005 
1006  /// Update the cached varname value with the given value so that we can
1007  /// avoid an extraneous HoudiniGetenv() for the equivalent code snippet:
1008  /// @code
1009  /// HoudiniSetenv(name, value);
1010  /// UT_EnvControl::varChanged(name);
1011  /// @endcode
1012  /// @return true if name was found and value is non-null, in which case the
1013  /// HoudiniSetenv() was called, else false is returned.
1014  static bool varChanged(const char *varname, const char *value);
1015 
1016  static void changeExistLookupDefault(UT_IntControl i, int new_def);
1017 
1018  /// Queries the cached variable value. Unrecognized variables are
1019  /// returned as UT_Variant::Type::Unknown. String values are returned
1020  /// as UT_Variant::Type::Pointer to allow distinguishing between null
1021  /// pointers and empty strings. If you intend to hold onto the string
1022  /// value beyond immediately using it, you must make your own copy!
1023  static UT_Variant getVarValue(const char *varname);
1024 
1025  /// Set all additional .env files to be parsed for env variable values.
1026  /// It is best to call getAdditionalEnvironmentFiles() first and then
1027  /// append to the list because this function will overwrite all the
1028  /// additional paths that were previously set.
1029  /// You can still use the HOUDINI_NO_ENV_FILE_OVERRIDES to disallow
1030  /// overwrites, knowing that these files get applied AFTER the default
1031  /// houdini.env file in the user's home directory.
1032  /// That said, HOUDINI_NO_ENV_FILE will have no effect on this function.
1033  /// If additional files are set, they will be used, regardless of the
1034  /// value of HOUDINI_NO_ENV_FILE.
1035  static void setAdditionalEnvironmentFiles(
1036  const UT_StringArray &files);
1037 
1038  /// Return the current list of additional environment files.
1039  static const UT_StringArray&
1040  getAdditionalEnvironmentFiles();
1041 
1042  // Print messages collected during init phase to console
1043  static void logMessages()
1044  {
1045  getControl().logMessagesToConsole();
1046  }
1047 
1048  // Package loader management
1049  // Load the pakages located in the folders specified by pkg_paths.
1050  // Use this method for loading package dynamically
1051  static void loadPackages(UT_StringArray const &pkg_paths, UT_Package::Loader& pkg_loader);
1052  static UT_Package::Package & loadPackage(char const * pkg_filepath, UT_Package::Loader& pkg_loader);
1053 
1054  // Returns the main package loader, this loader contains all
1055  // packages loaded at runtime.
1056  static UT_Package::Loader& packageLoader();
1057 
1058 private:
1059  void doInit(bool init_defaults);
1060  void setDefaults();
1061  bool loadEnvironmentFile(const char *path,
1062  bool allow_overrides);
1063  void loadDefaultEnvironmentFile();
1064  void loadEnvironmentFiles();
1065  void loadEnvironment(bool init_defaults);
1066 
1067  void updateExistLookup(int i, const char *value = nullptr);
1068  void updateIntLookup(int i, const char *value = nullptr);
1069  void updateFltLookup(int i, const char *value = nullptr);
1070  void updateStrLookup(int i, bool fix_path,
1071  const char *value = nullptr);
1072 
1073  void updateVarTables(UT_Package::Loader const& pkg_loader);
1074 
1075  void loadPackageConfig();
1076  void logMessagesToConsole() const;
1077 
1078  int myIValues[MAX_CONTROLS_WITH_BUFFER];
1079  float myFValues[MAX_CONTROLS_WITH_BUFFER];
1080  char *mySValues[MAX_CONTROLS_WITH_BUFFER];
1081 
1082  static UT_EnvControl &getControl()
1083  {
1084  if (!theControl)
1085  {
1086  theControl = new UT_EnvControl();
1087  theControl->init();
1088 
1089  }
1090  return *theControl;
1091  }
1092  static UT_EnvControl *theControl;
1093 
1094  UT_StringHolder myLogMessages;
1095 };
1096 
1097 #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:278
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:44
UT_IntControl
Definition: UT_EnvControl.h:46