HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VCC_Utils.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: VCC_Utils.h ( CVEX Library, C++)
7  *
8  * COMMENTS: This file contains utility functions for compiling VEX code.
9  */
10 
11 #ifndef __VCC_Utils__
12 #define __VCC_Utils__
13 
14 #include "VCC_API.h"
15 #include <CVEX/CVEX_Function.h>
16 
17 #include <VEX/VEX_PodTypes.h>
18 template <VEX_Precision PREC> class CVEX_ContextT;
19 
20 class UT_WorkBuffer;
21 class UT_JSONParser;
22 class UT_JSONWriter;
23 
25 {
26 public:
27  template <VEX_Precision PREC>
28  static CVEX_Function preloadLocalFunction(
29  CVEX_ContextT<PREC> &context,
30  const UT_WorkBuffer &source_code,
31  int node_id = -1);
32 
33  /// Information about VEX shader parameter.
35  {
36  public:
37  /// Constructors.
40  VEX_Type type,
41  const UT_StringRef& struct_name = UT_StringRef());
42 
43  /// Parameter name.
44  const UT_StringHolder & getName() const
45  { return myName; }
46 
47  /// @{ Parameter type.
48  VEX_Type getType() const
49  { return myType; }
51  { return myStructName; }
52  bool isStruct() const
53  { return myStructName; }
54  /// @}
55 
56  /// @{ Export (outgoing parm flag) info.
57  bool isExport() const
58  { return myIsExport; }
59  void setIsExport( bool is_export )
60  { myIsExport = is_export; }
61 
62  /// @}
63 
64  /// @{ Array info.
65  bool isArray() const
66  { return myIsArray; }
67  void setIsArray( bool is_array )
68  { myIsArray = is_array; }
69 
71  { return myArraySize; }
72  void setArraySize( exint array_size )
73  { myArraySize = array_size; }
74  /// @}
75 
76  /// @{ Default values.
78  { return myFloatValues; }
80  { myFloatValues = values; }
81 
82  const UT_IntArray & getIntValues() const
83  { return myIntValues; }
85  { myIntValues = values; }
86 
88  { return myStringValues; }
90  { myStringValues = values; }
91  /// @}
92 
93  bool save(UT_JSONWriter &w) const;
94  bool load(UT_JSONParser &p);
95 
96  private:
97  UT_StringHolder myName;
98  UT_StringHolder myStructName;
99  UT_DoubleArray myFloatValues;
100  UT_IntArray myIntValues;
101  UT_StringArray myStringValues;
102  VEX_Type myType;
103  bool myIsExport;
104  bool myIsArray;
105  exint myArraySize;
106  };
107 
108  /// Information about the VEX shader.
110  {
111  public:
112  // Constructor
113  ShaderInfo();
114 
115  /// @{ VEX context type (surface, displacement, etc).
117  { return myContextType; }
119  { myContextType = type; }
120  /// @}
121 
122  /// @{ Shader function name.
124  { return myFunctionName; }
126  { myFunctionName = name; }
127  /// @}
128 
129  /// @{ Shader function parameters.
131  { return myParms; }
133  { myParms.setCapacity( capacity ); }
134 
136  { myParms.emplace_back( parm ); }
137 
138  /// @}
139 
140  bool save(UT_JSONWriter &w) const;
141  bool load(UT_JSONParser &p);
142 
143  private:
144  VEX_ContextType myContextType;
145  UT_StringHolder myFunctionName;
146  UT_Array<ShaderParmInfo> myParms;
147  };
148 
149  /// Returns information about VEX shader given the shader file path.
150  static bool getShaderInfoFromFile(
151  VCC_Utils::ShaderInfo &info,
152  const UT_StringRef &file);
153 
154  /// Returns information about VEX shader given the shader source code.
155  static bool getShaderInfoFromCode(
156  VCC_Utils::ShaderInfo &info,
157  const UT_StringRef &code);
158 };
159 
160 #endif
type
Definition: core.h:977
VEX_Type
VEX variable types.
Definition: VEX_VexTypes.h:18
Information about VEX shader parameter.
Definition: VCC_Utils.h:34
void setFunctionName(const UT_StringRef &name)
Shader function name.
Definition: VCC_Utils.h:125
bool isArray() const
Array info.
Definition: VCC_Utils.h:65
int64 exint
Definition: SYS_Types.h:125
JSON reader class which handles parsing of JSON or bJSON files.
Definition: UT_JSONParser.h:76
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:35
const UT_StringHolder & getStructName() const
Parameter type.
Definition: VCC_Utils.h:50
GLuint const GLchar * name
Definition: glcorearb.h:785
Information about the VEX shader.
Definition: VCC_Utils.h:109
void appendParameter(ShaderParmInfo &&parm)
Shader function parameters.
Definition: VCC_Utils.h:135
GLenum GLsizei GLsizei GLint * values
Definition: glcorearb.h:1601
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:856
VEX_Type getType() const
Parameter type.
Definition: VCC_Utils.h:48
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
void setArraySize(exint array_size)
Array info.
Definition: VCC_Utils.h:72
void setStringValues(const UT_StringArray &values)
Default values.
Definition: VCC_Utils.h:89
const UT_IntArray & getIntValues() const
Default values.
Definition: VCC_Utils.h:82
bool isStruct() const
Parameter type.
Definition: VCC_Utils.h:52
VEX_ContextType getContextType() const
VEX context type (surface, displacement, etc).
Definition: VCC_Utils.h:116
const UT_StringHolder & getName() const
Parameter name.
Definition: VCC_Utils.h:44
GLfloat GLfloat p
Definition: glew.h:16656
void setIntValues(const UT_IntArray &values)
Default values.
Definition: VCC_Utils.h:84
void setFloatValues(const UT_DoubleArray &values)
Default values.
Definition: VCC_Utils.h:79
void setParameterArrayCapacity(exint capacity)
Shader function parameters.
Definition: VCC_Utils.h:132
void setIsExport(bool is_export)
Export (outgoing parm flag) info.
Definition: VCC_Utils.h:59
#define VCC_API
Definition: VCC_API.h:10
void setIsArray(bool is_array)
Array info.
Definition: VCC_Utils.h:67
A class holding a VEX function.
Definition: CVEX_Function.h:30
const UT_StringHolder & getFunctionName() const
Shader function name.
Definition: VCC_Utils.h:123
const UT_DoubleArray & getFloatValues() const
Default values.
Definition: VCC_Utils.h:77
bool isExport() const
Export (outgoing parm flag) info.
Definition: VCC_Utils.h:57
void setContextType(VEX_ContextType type)
VEX context type (surface, displacement, etc).
Definition: VCC_Utils.h:118
exint getArraySize() const
Array info.
Definition: VCC_Utils.h:70
VEX_ContextType
Definition: VEX_VexTypes.h:60
Call VEX from C++.
Definition: CVEX_Context.h:175
const UT_StringArray & getStringValues() const
Default values.
Definition: VCC_Utils.h:87
const UT_Array< ShaderParmInfo > & getParameters() const
Shader function parameters.
Definition: VCC_Utils.h:130