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 
221 
222  // COP2
225 
226  // IFD
230 
231  // MAT
233 
234  // UI
255 
256  // OPUI
262 
263  // DM
266 
267  // MATUI
269 
270  // Custom
275 
276  // LM
287 
288  // CHOP
290 
291  // SHOP
294 
295  // VOP
297 
298  // SHLF
301 
302  // Other
308 
309  // Backwards Compatability
318 
330 
332  // Have houdini check process fallback to the old deprecated API
336 
338 
339  // hscript
343 
345 
346  // This is for "internal use" only. It turns on features that are not
347  // ready for prime-time.
349 
350  // Maximum number of files to keep in the backup directory
352 
354 
356 
358 
361 
364 
366 
367  // Controls the number of complete FBX scenes to
368  // keep cached in memory after import. Defaults to 1.
370 
371  // Controls whether to transform the results of evaluating a MotionClip
372  // by the intrinsic matrix of the packed primitive.
374 
379 
381 
384 
385  // OpenGL
389 
390  // OpenCL
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 
406 
408 
409  // Maximum megabytes in write buffer.
411 
413 
417 
420 
422 
424 
426 
428 
430 
433 
435 
437 
438  // Used to force regular LM checks on Steam builds
440 
441  // OptiX
443 
445 
446  // Package
449 
450  // Viewer state
452 
454 
456 
458 
459  // TOP
471 
472  // HAPI
474 
475  // LOP
478 
480 
481  // HDA plugin for USD geometry cache size
483 
485 
487 
489 
490  // Send python panel erros to the console
492 
494 
496 
498 
499  // Specify whether or not Houdini GL should use Mtlx materials
501 
502  // New op viewer, defaults to on.
504 
506 
508 
510 
512 
513  ENV_KARMA_DICING_LEGACY, // Karma legacy dicing behaviour
514  ENV_KARMA_VARYING_ARRAY_PRIMVARS, // Varying length array primvars
517 
518  // Save HDA internal sections alphabetically (where it makes sens)
520 
522 
523  // MV
525 
527 
529 
530  // microfacet conductor fresnel to fix glowing issue with rough metals
532 
534 
535  // texturing issues relating to bad derivatives
537 
539 
541 
543 
546 
547  // Suppress creation of the non-critical files when expanding an HDA
549 
550  // spectral density on uniform volume discolorization bug fix
552 
553  ENV_MAX_INT_CONTROLS // <- Must be last
554 };
555 
557 {
558  // UT: Public interface
562 
563  // UT: Internal variables
565 
566  // IMG: Public interface
569 
570  // RE
572 
573  // UI
576 
577  // GR
579 
580  // Custom
582 
583  // ROP: Internal variables
585 
586  // OpenCL: Memory pool size, as percentage of GPU memory.
588 
589  // OpenCL: amount of VRAM that IMX layers are allowed to use.
591 
592  // CH
594 
595  // LOP interactive selection redraw time
597 
598  // Percent grey that shows as a zero exposure value when displaying
599  // pixel luminance in log terms. Values outside (0, 1) cause us to
600  // not calculate or display luminance in log terms.
602 
603  ENV_MAX_FLT_CONTROLS // <- Must be last
604 };
605 
607 {
608  // UT: Public interface
627 
628  // UT: Internal variables
632 
633  // external tools
635 
636  // IMG: Public interface
639 
640  // VEX(VMAT)
649 
650  // HOM
652 
653  // OP
654  ENV_HOUDINI_HIP_DEFAULT_NAME, // "untitled.hip"
657 
658  // VOP
660 
661  // GEO
663 
664  // COP
671 
672  // CHOP
674 
675  // TOP
677 
678  // LOP
680 
681  // IFD
687 
688  // UI
699 
700  // FUI
703 
704  // CHUI
706 
707  // OPUI
711 
712  // VEX(VCC)
714 
715  // Custom
723  ENV_HOUDINI_VIEW_METACAM, //OTLs that lock to view in a special way
724 
725  // Path variables
757 
761 
763 
766 
768 
774 
776 
781 
788 
791 
793 
795 
796  // These are here so we can have them show up in hconfig and provide
797  // help. They should only be used implicitly.
798  ENV_HSITE, // Between HFS and HOME.
799  ENV_JOB, // We should not use JOB!
800 
802 
805 
807 
808  // OPENGL
815 
816  // OPENCL
823 
824  // Orbolt
826 
827  // Anonymous Usage Statistics
829 
831 
833 
835 
836  // Optix
838 
840 
841  // BGEO plugin for USD default load arguments
843 
844  // LM
862 
863  // Python
865 
866  // Logging
870 
871  // Default asset/material gallery databases
874 
875  // Networking
878 
879  // HQueue
885 
886  // Render delegate to use by default on new Houdini clones
891 
894 
895  ENV_MAX_STR_CONTROLS // <- Must be last
896 };
897 
898 // If these constraints are ever violated in a HEAD branch, it's time to
899 // increase MAX_CONTROLS_WITH_BUFFER. If these constraints are violated in
900 // a released build, get rid of the "+50" part, and if they are exceeded
901 // again then we must increate MAX_CONTROLS_WITH_BUFFER in a daily build and
902 // break ABI compatiblity. But hopefully that won't happen...
906 
908 {
909 public:
910  UT_EnvControl();
911  ~UT_EnvControl();
912 
913  UT_EnvControl(const UT_EnvControl &) = delete;
914  UT_EnvControl &operator=(const UT_EnvControl &) = delete;
915 
916  void init();
917 
918  static int getInt(UT_IntControl i)
919  { return getControl().myIValues[i]; }
921  { return getControl().myFValues[i]; }
922  static const char *getString(UT_StrControl i)
923  { return getControl().mySValues[i]; }
924 
925  // Look up the appropriate variable name for the token
926  static const char *getIntVar(UT_IntControl i);
927  static const char *getFloatVar(UT_FltControl i);
928  static const char *getStringVar(UT_StrControl i);
929 
930  static void setStringVar(UT_StrControl i, const char *value);
931 
932  // Look up the appropriate old style variable name for the token. This can
933  // be used to check for old environment variables.
934  static const char *getOldIntVar(UT_IntControl i);
935  static const char *getOldFloatVar(UT_FltControl i);
936  static const char *getOldStringVar(UT_StrControl i);
937 
938  /// Indicate that the given variable changed and update our cached values.
939  /// If varname is NULL, then all variables are updated.
940  static void varChanged(const char *varname)
941  { varChanged(varname, nullptr); }
942 
943  /// Update the cached varname value with the given value so that we can
944  /// avoid an extraneous HoudiniGetenv() for the equivalent code snippet:
945  /// @code
946  /// HoudiniSetenv(name, value);
947  /// UT_EnvControl::varChanged(name);
948  /// @endcode
949  /// @return true if name was found and value is non-null, in which case the
950  /// HoudiniSetenv() was called, else false is returned.
951  static bool varChanged(const char *varname, const char *value);
952 
953  static void changeExistLookupDefault(UT_IntControl i, int new_def);
954 
955  /// Queries the cached variable value. Unrecognized variables are
956  /// returned as UT_Variant::Type::Unknown. String values are returned
957  /// as UT_Variant::Type::Pointer to allow distinguishing between null
958  /// pointers and empty strings. If you intend to hold onto the string
959  /// value beyond immediately using it, you must make your own copy!
960  static UT_Variant getVarValue(const char *varname);
961 
962  /// Set all additional .env files to be parsed for env variable values.
963  /// It is best to call getAdditionalEnvironmentFiles() first and then
964  /// append to the list because this function will overwrite all the
965  /// additional paths that were previously set.
966  /// You can still use the HOUDINI_NO_ENV_FILE_OVERRIDES to disallow
967  /// overwrites, knowing that these files get applied AFTER the default
968  /// houdini.env file in the user's home directory.
969  /// That said, HOUDINI_NO_ENV_FILE will have no effect on this function.
970  /// If additional files are set, they will be used, regardless of the
971  /// value of HOUDINI_NO_ENV_FILE.
972  static void setAdditionalEnvironmentFiles(
973  const UT_StringArray &files);
974 
975  /// Return the current list of additional environment files.
976  static const UT_StringArray&
977  getAdditionalEnvironmentFiles();
978 
979  // Print messages collected during init phase to console
980  static void logMessages()
981  {
982  getControl().logMessagesToConsole();
983  }
984 
985  // Package loader management
986  // Load the pakages located in the folders specified by pkg_paths.
987  // Use this method for loading package dynamically
988  static void loadPackages(UT_StringArray const &pkg_paths, UT_Package::Loader& pkg_loader);
989  static UT_Package::Package & loadPackage(char const * pkg_filepath, UT_Package::Loader& pkg_loader);
990 
991  // Returns the main package loader, this loader contains all
992  // packages loaded at runtime.
993  static UT_Package::Loader& packageLoader();
994 
995 private:
996  void doInit(bool init_defaults);
997  void setDefaults();
998  bool loadEnvironmentFile(const char *path,
999  bool allow_overrides);
1000  void loadDefaultEnvironmentFile();
1001  void loadEnvironmentFiles();
1002  void loadEnvironment(bool init_defaults);
1003 
1004  void updateExistLookup(int i, const char *value = nullptr);
1005  void updateIntLookup(int i, const char *value = nullptr);
1006  void updateFltLookup(int i, const char *value = nullptr);
1007  void updateStrLookup(int i, bool fix_path,
1008  const char *value = nullptr);
1009 
1010  void updateVarTables(UT_Package::Loader const& pkg_loader);
1011 
1012  void loadPackageConfig();
1013  void logMessagesToConsole() const;
1014 
1015  int myIValues[MAX_CONTROLS_WITH_BUFFER];
1016  float myFValues[MAX_CONTROLS_WITH_BUFFER];
1017  char *mySValues[MAX_CONTROLS_WITH_BUFFER];
1018 
1019  static UT_EnvControl &getControl()
1020  {
1021  if (!theControl)
1022  {
1023  theControl = new UT_EnvControl();
1024  theControl->init();
1025 
1026  }
1027  return *theControl;
1028  }
1029  static UT_EnvControl *theControl;
1030 
1031  UT_StringHolder myLogMessages;
1032 };
1033 
1034 #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