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
127  // IMG: Private interface
135 
136  // MV: Public interface
138 
139  // VEX: Public interface
150 
151  // VEX: Private interface
153 
154  // RE: Public interface
164 
165  // CMD
168 
169  // OP
173 
174  // GEO
178 
179  // GU
181 
182  // RAY
193 
197 
219 
222 
223  // COP2
226 
227  // IFD
231 
232  // MAT
234 
235  // UI
256 
257  // OPUI
263 
264  // DM
267 
268  // MATUI
270 
271  // Custom
276 
277  // LM
288 
289  // CHOP
291 
292  // SHOP
295 
296  // VOP
298 
299  // SHLF
302 
303  // Other
309 
310  // Backwards Compatability
319 
332 
334  // Have houdini check process fallback to the old deprecated API
338 
340 
341  // hscript
345 
347 
348  // This is for "internal use" only. It turns on features that are not
349  // ready for prime-time.
351 
352  // Maximum number of files to keep in the backup directory
354 
356 
358 
360 
363 
366 
368 
369  // Controls the number of complete FBX scenes to
370  // keep cached in memory after import. Defaults to 1.
372 
373  // Controls whether to transform the results of evaluating a MotionClip
374  // by the intrinsic matrix of the packed primitive.
376 
381 
384 
385  // OpenGL
389 
390  // OpenCL
394  ENV_HOUDINI_OCL_OGL_INTEROP, // Use CE_Context::shouldUseOCLOGLInterop instead of raw access to this that does additional compatability checks
397  // Can be used to force disable the use of images for advection by the Gas
398  // Advect CL 2.0 DOP.
400  // Can be used to force use of SwiftShader by the Rasterize Geometry COP.
402  // The rasterizer COP can use interop to copy from vulkan memory to OpenCL
403  // memory without leaving the GPU. However, this causes a memory leak on
404  // some NVIDIA drivers. This environment variable controls that
405  // functionality (0 means no interop, 1 means do it if we can).
408 
412 
414 
415  // Maximum megabytes in write buffer.
417 
419 
423 
426 
428 
430 
432 
434 
436 
439 
441 
443 
444  // Used to force regular LM checks on Steam builds
446 
447  // OptiX
449 
451 
452  // Package
455 
456  // Viewer state
458 
460 
462 
464 
465  // TOP
478 
479  // HAPI
481 
482  // LOP
486 
488 
490 
491  // HDA plugin for USD geometry cache size
493 
495 
497 
499 
500  // Send python panel erros to the console
502 
504 
506 
508 
509  // Specify whether or not Houdini GL should use Mtlx materials
511 
512  // New op viewer, defaults to on.
514 
516 
518 
520 
522 
523  ENV_KARMA_DICING_LEGACY, // Karma legacy dicing behaviour
524  ENV_KARMA_VARYING_ARRAY_PRIMVARS, // Varying length array primvars
527 
528  // Save HDA internal sections alphabetically (where it makes sens)
530 
532 
533  // MV
535 
537 
539 
540  // microfacet conductor fresnel to fix glowing issue with rough metals
542 
543  // texturing issues relating to bad derivatives
545 
547 
549 
551 
553 
556 
557  // Suppress creation of the non-critical files when expanding an HDA
559 
560  // Tells Houdini to prefer "last cooked" context options over "global"
561  // options when a node is asked to cook with its last cooked options.
563 
565 
567 
569 
571 
576 
578 
580 
581  ENV_MAX_INT_CONTROLS // <- Must be last
582 };
583 
585 {
586  // UT: Public interface
590 
591  // UT: Internal variables
593 
594  // IMG: Public interface
597 
598  // RE
600 
601  // UI
604 
605  // GR
607 
608  // Custom
610 
611  // ROP: Internal variables
613 
614  // OpenCL: Memory pool size, as percentage of GPU memory.
616 
617  // OpenCL: amount of VRAM that IMX layers are allowed to use.
619 
620  // CH
622 
623  // LOP interactive selection redraw time
625 
626  // Percent grey that shows as a zero exposure value when displaying
627  // pixel luminance in log terms. Values outside (0, 1) cause us to
628  // not calculate or display luminance in log terms.
630 
631  ENV_MAX_FLT_CONTROLS // <- Must be last
632 };
633 
635 {
636  // UT: Public interface
656 
657  // UT: Internal variables
661 
662  // external tools
664 
665  // IMG: Public interface
668 
669  // VEX(VMAT)
678 
679  // HOM
681 
682  // OP
683  ENV_HOUDINI_HIP_DEFAULT_NAME, // "untitled.hip"
686 
687  // VOP
689 
690  // GEO
692 
693  // COP
700 
701  // CHOP
703 
704  // TOP
706 
707  // LOP
709 
710  // IFD
716 
717  // UI
728 
729  // FUI
732 
733  // CHUI
735 
736  // OPUI
740 
741  // VEX(VCC)
743 
744  // Custom
752  ENV_HOUDINI_VIEW_METACAM, //OTLs that lock to view in a special way
753 
754  // Path variables
757 
788 
792 
794 
797 
799 
805 
807 
809 
814 
821 
824 
826 
828 
829  // These are here so we can have them show up in hconfig and provide
830  // help. They should only be used implicitly.
831  ENV_HSITE, // Between HFS and HOME.
832  ENV_JOB, // We should not use JOB!
833 
835 
838 
840 
841  // OPENGL
848 
849  // OPENCL
856 
857  // Orbolt
859 
860  // Anonymous Usage Statistics
862 
864 
866 
868 
869  // Optix
871 
873 
874  // BGEO plugin for USD default load arguments
876 
877  // LM
895 
896  // Python
898 
899  // Logging
903 
904  // Default asset/material catalog databases
908 
909  // Networking
912 
913  // HQueue
919 
920  // Render delegate to use by default on new Houdini clones
925 
926  // Render Product Types that should not show their AOVs in the list
927  // that shows up in the viewport menu.
929 
932 
934 
935  // When a loaded HDA changes on disk, perform this action by default
936  // instead of showing the interactive message.
938 
939  ENV_MAX_STR_CONTROLS // <- Must be last
940 };
941 
942 // If these constraints are ever violated in a HEAD branch, it's time to
943 // increase MAX_CONTROLS_WITH_BUFFER. If these constraints are violated in
944 // a released build, get rid of the "+50" part, and if they are exceeded
945 // again then we must increate MAX_CONTROLS_WITH_BUFFER in a daily build and
946 // break ABI compatiblity. But hopefully that won't happen...
950 
952 {
953 public:
954  UT_EnvControl();
955  ~UT_EnvControl();
956 
957  UT_EnvControl(const UT_EnvControl &) = delete;
958  UT_EnvControl &operator=(const UT_EnvControl &) = delete;
959 
960  void init();
961 
962  static int getInt(UT_IntControl i)
963  { return getControl().myIValues[i]; }
965  { return getControl().myFValues[i]; }
966  static const char *getString(UT_StrControl i)
967  { return getControl().mySValues[i]; }
968 
969  // Look up the appropriate variable name for the token
970  static const char *getIntVar(UT_IntControl i);
971  static const char *getFloatVar(UT_FltControl i);
972  static const char *getStringVar(UT_StrControl i);
973 
974  static void setStringVar(UT_StrControl i, const char *value);
975 
976  // Look up the appropriate old style variable name for the token. This can
977  // be used to check for old environment variables.
978  static const char *getOldIntVar(UT_IntControl i);
979  static const char *getOldFloatVar(UT_FltControl i);
980  static const char *getOldStringVar(UT_StrControl i);
981 
982  /// Indicate that the given variable changed and update our cached values.
983  /// If varname is NULL, then all variables are updated.
984  static void varChanged(const char *varname)
985  { varChanged(varname, nullptr); }
986 
987  /// Update the cached varname value with the given value so that we can
988  /// avoid an extraneous HoudiniGetenv() for the equivalent code snippet:
989  /// @code
990  /// HoudiniSetenv(name, value);
991  /// UT_EnvControl::varChanged(name);
992  /// @endcode
993  /// @return true if name was found and value is non-null, in which case the
994  /// HoudiniSetenv() was called, else false is returned.
995  static bool varChanged(const char *varname, const char *value);
996 
997  static void changeExistLookupDefault(UT_IntControl i, int new_def);
998 
999  /// Queries the cached variable value. Unrecognized variables are
1000  /// returned as UT_Variant::Type::Unknown. String values are returned
1001  /// as UT_Variant::Type::Pointer to allow distinguishing between null
1002  /// pointers and empty strings. If you intend to hold onto the string
1003  /// value beyond immediately using it, you must make your own copy!
1004  static UT_Variant getVarValue(const char *varname);
1005 
1006  /// Set all additional .env files to be parsed for env variable values.
1007  /// It is best to call getAdditionalEnvironmentFiles() first and then
1008  /// append to the list because this function will overwrite all the
1009  /// additional paths that were previously set.
1010  /// You can still use the HOUDINI_NO_ENV_FILE_OVERRIDES to disallow
1011  /// overwrites, knowing that these files get applied AFTER the default
1012  /// houdini.env file in the user's home directory.
1013  /// That said, HOUDINI_NO_ENV_FILE will have no effect on this function.
1014  /// If additional files are set, they will be used, regardless of the
1015  /// value of HOUDINI_NO_ENV_FILE.
1016  static void setAdditionalEnvironmentFiles(
1017  const UT_StringArray &files);
1018 
1019  /// Return the current list of additional environment files.
1020  static const UT_StringArray&
1021  getAdditionalEnvironmentFiles();
1022 
1023  // Print messages collected during init phase to console
1024  static void logMessages()
1025  {
1026  getControl().logMessagesToConsole();
1027  }
1028 
1029  // Package loader management
1030  // Load the pakages located in the folders specified by pkg_paths.
1031  // Use this method for loading package dynamically
1032  static void loadPackages(UT_StringArray const &pkg_paths, UT_Package::Loader& pkg_loader);
1033  static UT_Package::Package & loadPackage(char const * pkg_filepath, UT_Package::Loader& pkg_loader);
1034 
1035  // Returns the main package loader, this loader contains all
1036  // packages loaded at runtime.
1037  static UT_Package::Loader& packageLoader();
1038 
1039 private:
1040  void doInit(bool init_defaults);
1041  void setDefaults();
1042  bool loadEnvironmentFile(const char *path,
1043  bool allow_overrides);
1044  void loadDefaultEnvironmentFile();
1045  void loadEnvironmentFiles();
1046  void loadEnvironment(bool init_defaults);
1047 
1048  void updateExistLookup(int i, const char *value = nullptr);
1049  void updateIntLookup(int i, const char *value = nullptr);
1050  void updateFltLookup(int i, const char *value = nullptr);
1051  void updateStrLookup(int i, bool fix_path,
1052  const char *value = nullptr);
1053 
1054  void updateVarTables(UT_Package::Loader const& pkg_loader);
1055 
1056  void loadPackageConfig();
1057  void logMessagesToConsole() const;
1058 
1059  int myIValues[MAX_CONTROLS_WITH_BUFFER];
1060  float myFValues[MAX_CONTROLS_WITH_BUFFER];
1061  char *mySValues[MAX_CONTROLS_WITH_BUFFER];
1062 
1063  static UT_EnvControl &getControl()
1064  {
1065  if (!theControl)
1066  {
1067  theControl = new UT_EnvControl();
1068  theControl->init();
1069 
1070  }
1071  return *theControl;
1072  }
1073  static UT_EnvControl *theControl;
1074 
1075  UT_StringHolder myLogMessages;
1076 };
1077 
1078 #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