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  ENV_MAX_INT_CONTROLS // <- Must be last
550 };
551 
553 {
554  // UT: Public interface
558 
559  // UT: Internal variables
561 
562  // IMG: Public interface
565 
566  // RE
568 
569  // UI
572 
573  // GR
575 
576  // Custom
578 
579  // ROP: Internal variables
581 
582  // OpenCL: Memory pool size, as percentage of GPU memory.
584 
585  // OpenCL: amount of VRAM that IMX layers are allowed to use.
587 
588  // CH
590 
591  // LOP interactive selection redraw time
593 
594  ENV_MAX_FLT_CONTROLS // <- Must be last
595 };
596 
598 {
599  // UT: Public interface
618 
619  // UT: Internal variables
623 
624  // external tools
626 
627  // IMG: Public interface
630 
631  // VEX(VMAT)
640 
641  // HOM
643 
644  // OP
645  ENV_HOUDINI_HIP_DEFAULT_NAME, // "untitled.hip"
648 
649  // VOP
651 
652  // GEO
654 
655  // COP
662 
663  // CHOP
665 
666  // TOP
668 
669  // LOP
671 
672  // IFD
678 
679  // UI
690 
691  // FUI
694 
695  // CHUI
697 
698  // OPUI
702 
703  // VEX(VCC)
705 
706  // Custom
714  ENV_HOUDINI_VIEW_METACAM, //OTLs that lock to view in a special way
715 
716  // Path variables
748 
752 
754 
757 
759 
765 
767 
772 
779 
782 
784 
786 
787  // These are here so we can have them show up in hconfig and provide
788  // help. They should only be used implicitly.
789  ENV_HSITE, // Between HFS and HOME.
790  ENV_JOB, // We should not use JOB!
791 
793 
796 
798 
799  // OPENGL
806 
807  // OPENCL
814 
815  // Orbolt
817 
818  // Anonymous Usage Statistics
820 
822 
824 
826 
827  // Optix
829 
831 
832  // BGEO plugin for USD default load arguments
834 
835  // LM
853 
854  // Python
856 
857  // Logging
861 
862  // Default asset/material gallery databases
865 
866  // Networking
869 
870  // HQueue
876 
877  // Render delegate to use by default on new Houdini clones
882 
885 
886  ENV_MAX_STR_CONTROLS // <- Must be last
887 };
888 
889 // If these constraints are ever violated in a HEAD branch, it's time to
890 // increase MAX_CONTROLS_WITH_BUFFER. If these constraints are violated in
891 // a released build, get rid of the "+50" part, and if they are exceeded
892 // again then we must increate MAX_CONTROLS_WITH_BUFFER in a daily build and
893 // break ABI compatiblity. But hopefully that won't happen...
897 
899 {
900 public:
901  UT_EnvControl();
902  ~UT_EnvControl();
903 
904  UT_EnvControl(const UT_EnvControl &) = delete;
905  UT_EnvControl &operator=(const UT_EnvControl &) = delete;
906 
907  void init();
908 
909  static int getInt(UT_IntControl i)
910  { return getControl().myIValues[i]; }
912  { return getControl().myFValues[i]; }
913  static const char *getString(UT_StrControl i)
914  { return getControl().mySValues[i]; }
915 
916  // Look up the appropriate variable name for the token
917  static const char *getIntVar(UT_IntControl i);
918  static const char *getFloatVar(UT_FltControl i);
919  static const char *getStringVar(UT_StrControl i);
920 
921  static void setStringVar(UT_StrControl i, const char *value);
922 
923  // Look up the appropriate old style variable name for the token. This can
924  // be used to check for old environment variables.
925  static const char *getOldIntVar(UT_IntControl i);
926  static const char *getOldFloatVar(UT_FltControl i);
927  static const char *getOldStringVar(UT_StrControl i);
928 
929  /// Indicate that the given variable changed and update our cached values.
930  /// If varname is NULL, then all variables are updated.
931  static void varChanged(const char *varname)
932  { varChanged(varname, nullptr); }
933 
934  /// Update the cached varname value with the given value so that we can
935  /// avoid an extraneous HoudiniGetenv() for the equivalent code snippet:
936  /// @code
937  /// HoudiniSetenv(name, value);
938  /// UT_EnvControl::varChanged(name);
939  /// @endcode
940  /// @return true if name was found and value is non-null, in which case the
941  /// HoudiniSetenv() was called, else false is returned.
942  static bool varChanged(const char *varname, const char *value);
943 
944  static void changeExistLookupDefault(UT_IntControl i, int new_def);
945 
946  /// Queries the cached variable value. Unrecognized variables are
947  /// returned as UT_Variant::Type::Unknown. String values are returned
948  /// as UT_Variant::Type::Pointer to allow distinguishing between null
949  /// pointers and empty strings. If you intend to hold onto the string
950  /// value beyond immediately using it, you must make your own copy!
951  static UT_Variant getVarValue(const char *varname);
952 
953  /// Set all additional .env files to be parsed for env variable values.
954  /// It is best to call getAdditionalEnvironmentFiles() first and then
955  /// append to the list because this function will overwrite all the
956  /// additional paths that were previously set.
957  /// You can still use the HOUDINI_NO_ENV_FILE_OVERRIDES to disallow
958  /// overwrites, knowing that these files get applied AFTER the default
959  /// houdini.env file in the user's home directory.
960  /// That said, HOUDINI_NO_ENV_FILE will have no effect on this function.
961  /// If additional files are set, they will be used, regardless of the
962  /// value of HOUDINI_NO_ENV_FILE.
963  static void setAdditionalEnvironmentFiles(
964  const UT_StringArray &files);
965 
966  /// Return the current list of additional environment files.
967  static const UT_StringArray&
968  getAdditionalEnvironmentFiles();
969 
970  // Print messages collected during init phase to console
971  static void logMessages()
972  {
973  getControl().logMessagesToConsole();
974  }
975 
976  // Package loader management
977  // Load the pakages located in the folders specified by pkg_paths.
978  // Use this method for loading package dynamically
979  static void loadPackages(UT_StringArray const &pkg_paths, UT_Package::Loader& pkg_loader);
980  static UT_Package::Package & loadPackage(char const * pkg_filepath, UT_Package::Loader& pkg_loader);
981 
982  // Returns the main package loader, this loader contains all
983  // packages loaded at runtime.
984  static UT_Package::Loader& packageLoader();
985 
986 private:
987  void doInit(bool init_defaults);
988  void setDefaults();
989  bool loadEnvironmentFile(const char *path,
990  bool allow_overrides);
991  void loadDefaultEnvironmentFile();
992  void loadEnvironmentFiles();
993  void loadEnvironment(bool init_defaults);
994 
995  void updateExistLookup(int i, const char *value = nullptr);
996  void updateIntLookup(int i, const char *value = nullptr);
997  void updateFltLookup(int i, const char *value = nullptr);
998  void updateStrLookup(int i, bool fix_path,
999  const char *value = nullptr);
1000 
1001  void updateVarTables(UT_Package::Loader const& pkg_loader);
1002 
1003  void loadPackageConfig();
1004  void logMessagesToConsole() const;
1005 
1006  int myIValues[MAX_CONTROLS_WITH_BUFFER];
1007  float myFValues[MAX_CONTROLS_WITH_BUFFER];
1008  char *mySValues[MAX_CONTROLS_WITH_BUFFER];
1009 
1010  static UT_EnvControl &getControl()
1011  {
1012  if (!theControl)
1013  {
1014  theControl = new UT_EnvControl();
1015  theControl->init();
1016 
1017  }
1018  return *theControl;
1019  }
1020  static UT_EnvControl *theControl;
1021 
1022  UT_StringHolder myLogMessages;
1023 };
1024 
1025 #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