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 
221 
224 
225  // COP2
228 
229  // IFD
233 
234  // MAT
236 
237  // UI
259 
260  // OPUI
266 
267  // DM
270 
271  // MATUI
273 
274  // Custom
279 
280  // LM
291 
292  // CHOP
294 
295  // SHOP
298 
299  // VOP
301 
302  // SHLF
305 
306  // Other
312 
313  // Backwards Compatability
322 
335 
337  // Have houdini check process fallback to the old deprecated API
341 
343 
344  // hscript
348 
350 
351  // This is for "internal use" only. It turns on features that are not
352  // ready for prime-time.
354 
355  // Maximum number of files to keep in the backup directory
357 
359 
361 
363 
366 
369 
371 
372  // Controls the number of complete FBX scenes to
373  // keep cached in memory after import. Defaults to 1.
375 
376  // Controls whether to transform the results of evaluating a MotionClip
377  // by the intrinsic matrix of the packed primitive.
379 
384 
387 
388  // OpenGL
392 
393  // OpenCL
397  ENV_HOUDINI_OCL_OGL_INTEROP, // Use CE_Context::shouldUseOCLOGLInterop instead of raw access to this that does additional compatability checks
400  // Can be used to force disable the use of images for advection by the Gas
401  // Advect CL 2.0 DOP.
403  // Can be used to force use of SwiftShader by the Rasterize Geometry COP.
405  // The rasterizer COP can use interop to copy from vulkan memory to OpenCL
406  // memory without leaving the GPU. However, this causes a memory leak on
407  // some NVIDIA drivers. This environment variable controls that
408  // functionality (0 means no interop, 1 means do it if we can).
411 
415 
417 
418  // Maximum megabytes in write buffer.
420 
422 
426 
429 
431 
433 
435 
437 
439 
442 
444 
446 
447  // Used to force regular LM checks on Steam builds
449 
450  // OptiX
452 
454 
455  // Package
458 
459  // Viewer state
461 
463 
465 
467 
468  // TOP
481 
482  // HAPI
484 
485  // LOP
489 
491 
493 
494  // HDA plugin for USD geometry cache size
496 
498 
500 
502 
503  // Send python panel erros to the console
505 
507 
509 
511 
512  // Specify whether or not Houdini GL should use Mtlx materials
514 
515  // New op viewer, defaults to on.
517 
519 
521 
523 
525 
526  ENV_KARMA_DICING_LEGACY, // Karma legacy dicing behaviour
527  ENV_KARMA_VARYING_ARRAY_PRIMVARS, // Varying length array primvars
530 
531  // Save HDA internal sections alphabetically (where it makes sens)
533 
535 
536  // MV
538 
540 
542 
543  // microfacet conductor fresnel to fix glowing issue with rough metals
545 
546  // texturing issues relating to bad derivatives
548 
550 
552 
554 
556 
559 
560  // Suppress creation of the non-critical files when expanding an HDA
562 
563  // Tells Houdini to prefer "last cooked" context options over "global"
564  // options when a node is asked to cook with its last cooked options.
566 
568 
570 
572 
574 
579 
581 
583 
584  // Change to behavior of primitive sub-patterns. New behavior is
585  // definitely more correct, but might change things in unexpected ways.
587 
590 
591  ENV_MAX_INT_CONTROLS // <- Must be last
592 };
593 
595 {
596  // UT: Public interface
600 
601  // UT: Internal variables
603 
604  // IMG: Public interface
607 
608  // RE
610 
611  // UI
614 
615  // GR
617 
618  // Custom
620 
621  // ROP: Internal variables
623 
624  // OpenCL: Memory pool size, as percentage of GPU memory.
626 
627  // OpenCL: amount of VRAM that IMX layers are allowed to use.
629 
630  // CH
632 
633  // LOP interactive selection redraw time
635 
636  // Percent grey that shows as a zero exposure value when displaying
637  // pixel luminance in log terms. Values outside (0, 1) cause us to
638  // not calculate or display luminance in log terms.
640 
641  ENV_MAX_FLT_CONTROLS // <- Must be last
642 };
643 
645 {
646  // UT: Public interface
666 
667  // UT: Internal variables
671 
672  // external tools
674 
675  // IMG: Public interface
678 
679  // VEX(VMAT)
688 
689  // HOM
691 
692  // OP
693  ENV_HOUDINI_HIP_DEFAULT_NAME, // "untitled.hip"
696 
697  // VOP
699 
700  // GEO
702 
703  // COP
710 
711  // CHOP
713 
714  // TOP
716 
717  // LOP
719 
720  // IFD
726 
727  // UI
738 
739  // FUI
742 
743  // CHUI
745 
746  // OPUI
750 
751  // VEX(VCC)
753 
754  // Custom
762  ENV_HOUDINI_VIEW_METACAM, //OTLs that lock to view in a special way
763 
764  // Path variables
767 
798 
802 
804 
807 
809 
815 
817 
819 
824 
831 
834 
836 
838 
839  // These are here so we can have them show up in hconfig and provide
840  // help. They should only be used implicitly.
841  ENV_HSITE, // Between HFS and HOME.
842  ENV_JOB, // We should not use JOB!
843 
845 
848 
850 
851  // OPENGL
858 
859  // OPENCL
866 
867  // Orbolt
869 
870  // Anonymous Usage Statistics
872 
874 
876 
878 
879  // Optix
881 
883 
884  // BGEO plugin for USD default load arguments
886 
887  // LM
905 
906  // Python
908 
909  // Logging
913 
914  // Default asset/material catalog databases
918 
919  // Networking
922 
923  // HQueue
929 
930  // Render delegate to use by default on new Houdini clones
935 
936  // Render Product Types that should not show their AOVs in the list
937  // that shows up in the viewport menu.
939 
942 
944 
945  // When a loaded HDA changes on disk, perform this action by default
946  // instead of showing the interactive message.
948 
949  // Compression method to specify a default compression method for
950  // .hip files
952 
953  ENV_MAX_STR_CONTROLS // <- Must be last
954 };
955 
956 // If these constraints are ever violated in a HEAD branch, it's time to
957 // increase MAX_CONTROLS_WITH_BUFFER. If these constraints are violated in
958 // a released build, get rid of the "+50" part, and if they are exceeded
959 // again then we must increate MAX_CONTROLS_WITH_BUFFER in a daily build and
960 // break ABI compatiblity. But hopefully that won't happen...
964 
966 {
967 public:
968  UT_EnvControl();
969  ~UT_EnvControl();
970 
971  UT_EnvControl(const UT_EnvControl &) = delete;
972  UT_EnvControl &operator=(const UT_EnvControl &) = delete;
973 
974  void init();
975 
976  static int getInt(UT_IntControl i)
977  { return getControl().myIValues[i]; }
979  { return getControl().myFValues[i]; }
980  static const char *getString(UT_StrControl i)
981  { return getControl().mySValues[i]; }
982 
983  // Look up the appropriate variable name for the token
984  static const char *getIntVar(UT_IntControl i);
985  static const char *getFloatVar(UT_FltControl i);
986  static const char *getStringVar(UT_StrControl i);
987 
988  static void setStringVar(UT_StrControl i, const char *value);
989 
990  // Look up the appropriate old style variable name for the token. This can
991  // be used to check for old environment variables.
992  static const char *getOldIntVar(UT_IntControl i);
993  static const char *getOldFloatVar(UT_FltControl i);
994  static const char *getOldStringVar(UT_StrControl i);
995 
996  /// Indicate that the given variable changed and update our cached values.
997  /// If varname is NULL, then all variables are updated.
998  static void varChanged(const char *varname)
999  { varChanged(varname, nullptr); }
1000 
1001  /// Update the cached varname value with the given value so that we can
1002  /// avoid an extraneous HoudiniGetenv() for the equivalent code snippet:
1003  /// @code
1004  /// HoudiniSetenv(name, value);
1005  /// UT_EnvControl::varChanged(name);
1006  /// @endcode
1007  /// @return true if name was found and value is non-null, in which case the
1008  /// HoudiniSetenv() was called, else false is returned.
1009  static bool varChanged(const char *varname, const char *value);
1010 
1011  static void changeExistLookupDefault(UT_IntControl i, int new_def);
1012 
1013  /// Queries the cached variable value. Unrecognized variables are
1014  /// returned as UT_Variant::Type::Unknown. String values are returned
1015  /// as UT_Variant::Type::Pointer to allow distinguishing between null
1016  /// pointers and empty strings. If you intend to hold onto the string
1017  /// value beyond immediately using it, you must make your own copy!
1018  static UT_Variant getVarValue(const char *varname);
1019 
1020  /// Set all additional .env files to be parsed for env variable values.
1021  /// It is best to call getAdditionalEnvironmentFiles() first and then
1022  /// append to the list because this function will overwrite all the
1023  /// additional paths that were previously set.
1024  /// You can still use the HOUDINI_NO_ENV_FILE_OVERRIDES to disallow
1025  /// overwrites, knowing that these files get applied AFTER the default
1026  /// houdini.env file in the user's home directory.
1027  /// That said, HOUDINI_NO_ENV_FILE will have no effect on this function.
1028  /// If additional files are set, they will be used, regardless of the
1029  /// value of HOUDINI_NO_ENV_FILE.
1030  static void setAdditionalEnvironmentFiles(
1031  const UT_StringArray &files);
1032 
1033  /// Return the current list of additional environment files.
1034  static const UT_StringArray&
1035  getAdditionalEnvironmentFiles();
1036 
1037  // Print messages collected during init phase to console
1038  static void logMessages()
1039  {
1040  getControl().logMessagesToConsole();
1041  }
1042 
1043  // Package loader management
1044  // Load the pakages located in the folders specified by pkg_paths.
1045  // Use this method for loading package dynamically
1046  static void loadPackages(UT_StringArray const &pkg_paths, UT_Package::Loader& pkg_loader);
1047  static UT_Package::Package & loadPackage(char const * pkg_filepath, UT_Package::Loader& pkg_loader);
1048 
1049  // Returns the main package loader, this loader contains all
1050  // packages loaded at runtime.
1051  static UT_Package::Loader& packageLoader();
1052 
1053 private:
1054  void doInit(bool init_defaults);
1055  void setDefaults();
1056  bool loadEnvironmentFile(const char *path,
1057  bool allow_overrides);
1058  void loadDefaultEnvironmentFile();
1059  void loadEnvironmentFiles();
1060  void loadEnvironment(bool init_defaults);
1061 
1062  void updateExistLookup(int i, const char *value = nullptr);
1063  void updateIntLookup(int i, const char *value = nullptr);
1064  void updateFltLookup(int i, const char *value = nullptr);
1065  void updateStrLookup(int i, bool fix_path,
1066  const char *value = nullptr);
1067 
1068  void updateVarTables(UT_Package::Loader const& pkg_loader);
1069 
1070  void loadPackageConfig();
1071  void logMessagesToConsole() const;
1072 
1073  int myIValues[MAX_CONTROLS_WITH_BUFFER];
1074  float myFValues[MAX_CONTROLS_WITH_BUFFER];
1075  char *mySValues[MAX_CONTROLS_WITH_BUFFER];
1076 
1077  static UT_EnvControl &getControl()
1078  {
1079  if (!theControl)
1080  {
1081  theControl = new UT_EnvControl();
1082  theControl->init();
1083 
1084  }
1085  return *theControl;
1086  }
1087  static UT_EnvControl *theControl;
1088 
1089  UT_StringHolder myLogMessages;
1090 };
1091 
1092 #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