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 
554 
555  ENV_MAX_INT_CONTROLS // <- Must be last
556 };
557 
559 {
560  // UT: Public interface
564 
565  // UT: Internal variables
567 
568  // IMG: Public interface
571 
572  // RE
574 
575  // UI
578 
579  // GR
581 
582  // Custom
584 
585  // ROP: Internal variables
587 
588  // OpenCL: Memory pool size, as percentage of GPU memory.
590 
591  // OpenCL: amount of VRAM that IMX layers are allowed to use.
593 
594  // CH
596 
597  // LOP interactive selection redraw time
599 
600  // Percent grey that shows as a zero exposure value when displaying
601  // pixel luminance in log terms. Values outside (0, 1) cause us to
602  // not calculate or display luminance in log terms.
604 
605  ENV_MAX_FLT_CONTROLS // <- Must be last
606 };
607 
609 {
610  // UT: Public interface
629 
630  // UT: Internal variables
634 
635  // external tools
637 
638  // IMG: Public interface
641 
642  // VEX(VMAT)
651 
652  // HOM
654 
655  // OP
656  ENV_HOUDINI_HIP_DEFAULT_NAME, // "untitled.hip"
659 
660  // VOP
662 
663  // GEO
665 
666  // COP
673 
674  // CHOP
676 
677  // TOP
679 
680  // LOP
682 
683  // IFD
689 
690  // UI
701 
702  // FUI
705 
706  // CHUI
708 
709  // OPUI
713 
714  // VEX(VCC)
716 
717  // Custom
725  ENV_HOUDINI_VIEW_METACAM, //OTLs that lock to view in a special way
726 
727  // Path variables
759 
763 
765 
768 
770 
776 
778 
783 
790 
793 
795 
797 
798  // These are here so we can have them show up in hconfig and provide
799  // help. They should only be used implicitly.
800  ENV_HSITE, // Between HFS and HOME.
801  ENV_JOB, // We should not use JOB!
802 
804 
807 
809 
810  // OPENGL
817 
818  // OPENCL
825 
826  // Orbolt
828 
829  // Anonymous Usage Statistics
831 
833 
835 
837 
838  // Optix
840 
842 
843  // BGEO plugin for USD default load arguments
845 
846  // LM
864 
865  // Python
867 
868  // Logging
872 
873  // Default asset/material gallery databases
876 
877  // Networking
880 
881  // HQueue
887 
888  // Render delegate to use by default on new Houdini clones
893 
896 
897  ENV_MAX_STR_CONTROLS // <- Must be last
898 };
899 
900 // If these constraints are ever violated in a HEAD branch, it's time to
901 // increase MAX_CONTROLS_WITH_BUFFER. If these constraints are violated in
902 // a released build, get rid of the "+50" part, and if they are exceeded
903 // again then we must increate MAX_CONTROLS_WITH_BUFFER in a daily build and
904 // break ABI compatiblity. But hopefully that won't happen...
908 
910 {
911 public:
912  UT_EnvControl();
913  ~UT_EnvControl();
914 
915  UT_EnvControl(const UT_EnvControl &) = delete;
916  UT_EnvControl &operator=(const UT_EnvControl &) = delete;
917 
918  void init();
919 
920  static int getInt(UT_IntControl i)
921  { return getControl().myIValues[i]; }
923  { return getControl().myFValues[i]; }
924  static const char *getString(UT_StrControl i)
925  { return getControl().mySValues[i]; }
926 
927  // Look up the appropriate variable name for the token
928  static const char *getIntVar(UT_IntControl i);
929  static const char *getFloatVar(UT_FltControl i);
930  static const char *getStringVar(UT_StrControl i);
931 
932  static void setStringVar(UT_StrControl i, const char *value);
933 
934  // Look up the appropriate old style variable name for the token. This can
935  // be used to check for old environment variables.
936  static const char *getOldIntVar(UT_IntControl i);
937  static const char *getOldFloatVar(UT_FltControl i);
938  static const char *getOldStringVar(UT_StrControl i);
939 
940  /// Indicate that the given variable changed and update our cached values.
941  /// If varname is NULL, then all variables are updated.
942  static void varChanged(const char *varname)
943  { varChanged(varname, nullptr); }
944 
945  /// Update the cached varname value with the given value so that we can
946  /// avoid an extraneous HoudiniGetenv() for the equivalent code snippet:
947  /// @code
948  /// HoudiniSetenv(name, value);
949  /// UT_EnvControl::varChanged(name);
950  /// @endcode
951  /// @return true if name was found and value is non-null, in which case the
952  /// HoudiniSetenv() was called, else false is returned.
953  static bool varChanged(const char *varname, const char *value);
954 
955  static void changeExistLookupDefault(UT_IntControl i, int new_def);
956 
957  /// Queries the cached variable value. Unrecognized variables are
958  /// returned as UT_Variant::Type::Unknown. String values are returned
959  /// as UT_Variant::Type::Pointer to allow distinguishing between null
960  /// pointers and empty strings. If you intend to hold onto the string
961  /// value beyond immediately using it, you must make your own copy!
962  static UT_Variant getVarValue(const char *varname);
963 
964  /// Set all additional .env files to be parsed for env variable values.
965  /// It is best to call getAdditionalEnvironmentFiles() first and then
966  /// append to the list because this function will overwrite all the
967  /// additional paths that were previously set.
968  /// You can still use the HOUDINI_NO_ENV_FILE_OVERRIDES to disallow
969  /// overwrites, knowing that these files get applied AFTER the default
970  /// houdini.env file in the user's home directory.
971  /// That said, HOUDINI_NO_ENV_FILE will have no effect on this function.
972  /// If additional files are set, they will be used, regardless of the
973  /// value of HOUDINI_NO_ENV_FILE.
974  static void setAdditionalEnvironmentFiles(
975  const UT_StringArray &files);
976 
977  /// Return the current list of additional environment files.
978  static const UT_StringArray&
979  getAdditionalEnvironmentFiles();
980 
981  // Print messages collected during init phase to console
982  static void logMessages()
983  {
984  getControl().logMessagesToConsole();
985  }
986 
987  // Package loader management
988  // Load the pakages located in the folders specified by pkg_paths.
989  // Use this method for loading package dynamically
990  static void loadPackages(UT_StringArray const &pkg_paths, UT_Package::Loader& pkg_loader);
991  static UT_Package::Package & loadPackage(char const * pkg_filepath, UT_Package::Loader& pkg_loader);
992 
993  // Returns the main package loader, this loader contains all
994  // packages loaded at runtime.
995  static UT_Package::Loader& packageLoader();
996 
997 private:
998  void doInit(bool init_defaults);
999  void setDefaults();
1000  bool loadEnvironmentFile(const char *path,
1001  bool allow_overrides);
1002  void loadDefaultEnvironmentFile();
1003  void loadEnvironmentFiles();
1004  void loadEnvironment(bool init_defaults);
1005 
1006  void updateExistLookup(int i, const char *value = nullptr);
1007  void updateIntLookup(int i, const char *value = nullptr);
1008  void updateFltLookup(int i, const char *value = nullptr);
1009  void updateStrLookup(int i, bool fix_path,
1010  const char *value = nullptr);
1011 
1012  void updateVarTables(UT_Package::Loader const& pkg_loader);
1013 
1014  void loadPackageConfig();
1015  void logMessagesToConsole() const;
1016 
1017  int myIValues[MAX_CONTROLS_WITH_BUFFER];
1018  float myFValues[MAX_CONTROLS_WITH_BUFFER];
1019  char *mySValues[MAX_CONTROLS_WITH_BUFFER];
1020 
1021  static UT_EnvControl &getControl()
1022  {
1023  if (!theControl)
1024  {
1025  theControl = new UT_EnvControl();
1026  theControl->init();
1027 
1028  }
1029  return *theControl;
1030  }
1031  static UT_EnvControl *theControl;
1032 
1033  UT_StringHolder myLogMessages;
1034 };
1035 
1036 #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