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/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
194 
197 
220 
221  // COP2
224 
225  // IFD
229 
230  // MAT
232 
233  // UI
254 
255  // OPUI
261 
262  // DM
265 
266  // MATUI
268 
269  // Custom
274 
275  // LM
286 
287  // CHOP
289 
290  // SHOP
293 
294  // VOP
296 
297  // SHLF
300 
301  // Other
307 
308  // Backwards Compatability
317 
329 
331  // Have houdini check process fallback to the old deprecated API
335 
337 
338  // hscript
342 
344 
345  // This is for "internal use" only. It turns on features that are not
346  // ready for prime-time.
348 
349  // Maximum number of files to keep in the backup directory
351 
353 
355 
357 
360 
363 
365 
366  // Controls the number of complete FBX scenes to
367  // keep cached in memory after import. Defaults to 1.
369 
370  // Controls whether to transform the results of evaluating a MotionClip
371  // by the intrinsic matrix of the packed primitive.
373 
378 
380 
383 
384  // OpenGL
388 
389  // OpenCL
396  // Can be used to force disable the use of images for advection by the Gas
397  // Advect CL 2.0 DOP.
399  // Can be used to force use of SwiftShader by the Rasterize Geometry COP.
401 
405 
407 
408  // Maximum megabytes in write buffer.
410 
412 
416 
419 
421 
423 
425 
427 
429 
432 
434 
436 
437  // Used to force regular LM checks on Steam builds
439 
440  // OptiX
442 
444 
445  // Package
448 
449  // Viewer state
451 
453 
455 
457 
458  // TOP
470 
471  // HAPI
473 
474  // LOP
477 
479 
480  // HDA plugin for USD geometry cache size
482 
484 
486 
488 
489  // Send python panel erros to the console
491 
493 
495 
497 
498  // Specify whether or not Houdini GL should use Mtlx materials
500 
501  // New op viewer, defaults to on.
503 
505 
507 
509 
511 
512  ENV_KARMA_DICING_LEGACY, // Karma legacy dicing behaviour
513  ENV_KARMA_VARYING_ARRAY_PRIMVARS, // Varying length array primvars
516 
517  // Save HDA internal sections alphabetically (where it makes sens)
519 
521 
522  // MV
524 
526 
528 
529  // microfacet conductor fresnel to fix glowing issue with rough metals
531 
533 
534  // texturing issues relating to bad derivatives
536 
538 
540 
542 
545 
546  // Suppress creation of the non-critical files when expanding an HDA
548 
549  // spectral density on uniform volume discolorization bug fix
551 
552  ENV_MAX_INT_CONTROLS // <- Must be last
553 };
554 
556 {
557  // UT: Public interface
561 
562  // UT: Internal variables
564 
565  // IMG: Public interface
568 
569  // RE
571 
572  // UI
575 
576  // GR
578 
579  // Custom
581 
582  // ROP: Internal variables
584 
585  // OpenCL: Memory pool size, as percentage of GPU memory.
587 
588  // OpenCL: amount of VRAM that IMX layers are allowed to use.
590 
591  // CH
593 
594  // LOP interactive selection redraw time
596 
597  ENV_MAX_FLT_CONTROLS // <- Must be last
598 };
599 
601 {
602  // UT: Public interface
621 
622  // UT: Internal variables
626 
627  // external tools
629 
630  // IMG: Public interface
633 
634  // VEX(VMAT)
643 
644  // HOM
646 
647  // OP
648  ENV_HOUDINI_HIP_DEFAULT_NAME, // "untitled.hip"
651 
652  // VOP
654 
655  // GEO
657 
658  // COP
665 
666  // CHOP
668 
669  // TOP
671 
672  // LOP
674 
675  // IFD
681 
682  // UI
693 
694  // FUI
697 
698  // CHUI
700 
701  // OPUI
705 
706  // VEX(VCC)
708 
709  // Custom
717  ENV_HOUDINI_VIEW_METACAM, //OTLs that lock to view in a special way
718 
719  // Path variables
751 
755 
757 
760 
762 
768 
770 
775 
782 
785 
787 
789 
790  // These are here so we can have them show up in hconfig and provide
791  // help. They should only be used implicitly.
792  ENV_HSITE, // Between HFS and HOME.
793  ENV_JOB, // We should not use JOB!
794 
796 
799 
801 
802  // OPENGL
809 
810  // OPENCL
817 
818  // Orbolt
820 
821  // Anonymous Usage Statistics
823 
825 
827 
829 
830  // Optix
832 
834 
835  // BGEO plugin for USD default load arguments
837 
838  // LM
856 
857  // Python
859 
860  // Logging
864 
865  // Default asset/material gallery databases
868 
869  // Networking
872 
873  // HQueue
879 
880  // Render delegate to use by default on new Houdini clones
885 
888 
889  ENV_MAX_STR_CONTROLS // <- Must be last
890 };
891 
892 // If these constraints are ever violated in a HEAD branch, it's time to
893 // increase MAX_CONTROLS_WITH_BUFFER. If these constraints are violated in
894 // a released build, get rid of the "+50" part, and if they are exceeded
895 // again then we must increate MAX_CONTROLS_WITH_BUFFER in a daily build and
896 // break ABI compatiblity. But hopefully that won't happen...
900 
902 {
903 public:
904  UT_EnvControl();
905  ~UT_EnvControl();
906 
907  UT_EnvControl(const UT_EnvControl &) = delete;
908  UT_EnvControl &operator=(const UT_EnvControl &) = delete;
909 
910  void init();
911 
912  static int getInt(UT_IntControl i)
913  { return getControl().myIValues[i]; }
915  { return getControl().myFValues[i]; }
916  static const char *getString(UT_StrControl i)
917  { return getControl().mySValues[i]; }
918 
919  // Look up the appropriate variable name for the token
920  static const char *getIntVar(UT_IntControl i);
921  static const char *getFloatVar(UT_FltControl i);
922  static const char *getStringVar(UT_StrControl i);
923 
924  static void setStringVar(UT_StrControl i, const char *value);
925 
926  // Look up the appropriate old style variable name for the token. This can
927  // be used to check for old environment variables.
928  static const char *getOldIntVar(UT_IntControl i);
929  static const char *getOldFloatVar(UT_FltControl i);
930  static const char *getOldStringVar(UT_StrControl i);
931 
932  /// Indicate that the given variable changed and update our cached values.
933  /// If varname is NULL, then all variables are updated.
934  static void varChanged(const char *varname)
935  { varChanged(varname, nullptr); }
936 
937  /// Update the cached varname value with the given value so that we can
938  /// avoid an extraneous HoudiniGetenv() for the equivalent code snippet:
939  /// @code
940  /// HoudiniSetenv(name, value);
941  /// UT_EnvControl::varChanged(name);
942  /// @endcode
943  /// @return true if name was found and value is non-null, in which case the
944  /// HoudiniSetenv() was called, else false is returned.
945  static bool varChanged(const char *varname, const char *value);
946 
947  static void changeExistLookupDefault(UT_IntControl i, int new_def);
948 
949  /// Queries the cached variable value. Unrecognized variables are
950  /// returned as UT_Variant::Type::Unknown. String values are returned
951  /// as UT_Variant::Type::Pointer to allow distinguishing between null
952  /// pointers and empty strings. If you intend to hold onto the string
953  /// value beyond immediately using it, you must make your own copy!
954  static UT_Variant getVarValue(const char *varname);
955 
956  /// Set all additional .env files to be parsed for env variable values.
957  /// It is best to call getAdditionalEnvironmentFiles() first and then
958  /// append to the list because this function will overwrite all the
959  /// additional paths that were previously set.
960  /// You can still use the HOUDINI_NO_ENV_FILE_OVERRIDES to disallow
961  /// overwrites, knowing that these files get applied AFTER the default
962  /// houdini.env file in the user's home directory.
963  /// That said, HOUDINI_NO_ENV_FILE will have no effect on this function.
964  /// If additional files are set, they will be used, regardless of the
965  /// value of HOUDINI_NO_ENV_FILE.
966  static void setAdditionalEnvironmentFiles(
967  const UT_StringArray &files);
968 
969  /// Return the current list of additional environment files.
970  static const UT_StringArray&
971  getAdditionalEnvironmentFiles();
972 
973  // Print messages collected during init phase to console
974  static void logMessages()
975  {
976  getControl().logMessagesToConsole();
977  }
978 
979  // Package loader management
980  // Load the pakages located in the folders specified by pkg_paths.
981  // Use this method for loading package dynamically
982  static void loadPackages(UT_StringArray const &pkg_paths, UT_Package::Loader& pkg_loader);
983  static UT_Package::Package & loadPackage(char const * pkg_filepath, UT_Package::Loader& pkg_loader);
984 
985  // Returns the main package loader, this loader contains all
986  // packages loaded at runtime.
987  static UT_Package::Loader& packageLoader();
988 
989 private:
990  void doInit(bool init_defaults);
991  void setDefaults();
992  bool loadEnvironmentFile(const char *path,
993  bool allow_overrides);
994  void loadDefaultEnvironmentFile();
995  void loadEnvironmentFiles();
996  void loadEnvironment(bool init_defaults);
997 
998  void updateExistLookup(int i, const char *value = nullptr);
999  void updateIntLookup(int i, const char *value = nullptr);
1000  void updateFltLookup(int i, const char *value = nullptr);
1001  void updateStrLookup(int i, bool fix_path,
1002  const char *value = nullptr);
1003 
1004  void updateVarTables(UT_Package::Loader const& pkg_loader);
1005 
1006  void loadPackageConfig();
1007  void logMessagesToConsole() const;
1008 
1009  int myIValues[MAX_CONTROLS_WITH_BUFFER];
1010  float myFValues[MAX_CONTROLS_WITH_BUFFER];
1011  char *mySValues[MAX_CONTROLS_WITH_BUFFER];
1012 
1013  static UT_EnvControl &getControl()
1014  {
1015  if (!theControl)
1016  {
1017  theControl = new UT_EnvControl();
1018  theControl->init();
1019 
1020  }
1021  return *theControl;
1022  }
1023  static UT_EnvControl *theControl;
1024 
1025  UT_StringHolder myLogMessages;
1026 };
1027 
1028 #endif
static void varChanged(const char *varname)
static const char * getString(UT_StrControl i)
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:277
LeafData & operator=(const LeafData &)=delete
SYS_STATIC_ASSERT(ENV_MAX_INT_CONTROLS+50< MAX_CONTROLS_WITH_BUFFER)
Definition: core.h:1131
UT_FltControl
#define MAX_CONTROLS_WITH_BUFFER
Definition: UT_EnvControl.h:44
UT_IntControl
Definition: UT_EnvControl.h:46