Loading...
Searching...
No Matches
glslfxConfig.h
Go to the documentation of this file.
1//
2// Copyright 2016 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef PXR_IMAGING_HIO_GLSLFX_CONFIG_H
8#define PXR_IMAGING_HIO_GLSLFX_CONFIG_H
9
11
12#include "pxr/pxr.h"
13#include "pxr/imaging/hio/api.h"
14#include "pxr/base/tf/token.h"
16
17#include <string>
18
19PXR_NAMESPACE_OPEN_SCOPE
20
29{
30public:
39 enum Role {
40 RoleNone = 0,
41 RoleColor = 1,
42 };
43
48 class Parameter {
49 public:
50 Parameter(std::string const & name,
51 VtValue const & defaultValue,
52 std::string const & docString = "",
53 Role const & role = RoleNone) :
54 name(name),
55 defaultValue(defaultValue),
56 docString(docString),
57 role(role) { }
58
59 std::string name;
60 VtValue defaultValue;
61 std::string docString;
62 Role role;
63 };
64
65 typedef std::vector<Parameter> Parameters;
66
71 class Texture {
72 public:
73 Texture(std::string const & name,
74 VtValue const & defaultValue,
75 std::string const & docString = "") :
76 name(name),
77 defaultValue(defaultValue),
78 docString(docString) { }
79
80 std::string name;
81 VtValue defaultValue;
82 std::string docString;
83 };
84
85 typedef std::vector<Texture> Textures;
86
91 class Attribute {
92 public:
93 Attribute(std::string const & name,
94 VtValue const & defaultValue,
95 std::string const & docString = "") :
96 name(name),
97 defaultValue(defaultValue),
98 docString(docString) { }
99
100 std::string name;
101 VtValue defaultValue;
102 std::string docString;
103 };
104
105 typedef std::vector<Attribute> Attributes;
106
111 HIO_API
112 static HioGlslfxConfig * Read(TfToken const & technique,
113 std::string const & input,
114 std::string const & filename,
115 std::string *errorStr);
116
117 typedef std::vector<std::string> SourceKeys;
118
120
122 HIO_API
123 SourceKeys GetSourceKeys(TfToken const & shaderStageKey) const;
124
126 HIO_API
127 Parameters GetParameters() const;
128
130 HIO_API
131 Textures GetTextures() const;
132
134 HIO_API
135 Attributes GetAttributes() const;
136
138 HIO_API
140
141private:
142 // private ctor. should only be called by ::Read
143 HioGlslfxConfig(TfToken const& technique,
144 VtDictionary const & dict,
145 std::string *errorStr);
146
147 void _Init(VtDictionary const & dict, std::string *errorStr);
148
149 Parameters _GetParameters(VtDictionary const & dict,
150 std::string *errorStr) const;
151 Textures _GetTextures(VtDictionary const & dict,
152 std::string *errorStr) const;
153
154 Attributes _GetAttributes(VtDictionary const & dict,
155 std::string *errorStr) const;
156
157 MetadataDictionary _GetMetadata(VtDictionary const & dict,
158 std::string *errorStr) const;
159
160 typedef std::map<std::string, SourceKeys> _SourceKeyMap;
161 _SourceKeyMap _GetSourceKeyMap(VtDictionary const & dict,
162 std::string *errorStr) const;
163
164 TfToken _technique;
165 Parameters _params;
166 Textures _textures;
167 Attributes _attributes;
168 MetadataDictionary _metadata;
169 _SourceKeyMap _sourceKeyMap;
170};
171
172
173PXR_NAMESPACE_CLOSE_SCOPE
174
175#endif
A class representing an attribute.
Definition: glslfxConfig.h:91
A class representing a parameter.
Definition: glslfxConfig.h:48
A class representing a texture.
Definition: glslfxConfig.h:71
A class representing the configuration of a glslfx file.
Definition: glslfxConfig.h:29
HIO_API Textures GetTextures() const
Return the textures specified in the configuration.
HIO_API MetadataDictionary GetMetadata() const
Returns the metadata specified in the configuration.
static HIO_API HioGlslfxConfig * Read(TfToken const &technique, std::string const &input, std::string const &filename, std::string *errorStr)
Create a new HioGlslfxConfig from an input string.
Role
Enumerates Roles that parameters can have.
Definition: glslfxConfig.h:39
HIO_API Parameters GetParameters() const
Return the parameters specified in the configuration.
HIO_API SourceKeys GetSourceKeys(TfToken const &shaderStageKey) const
Return the set of source keys for a particular shader stage.
HIO_API Attributes GetAttributes() const
Returns the attributes specified in the configuration.
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
A map with string keys and VtValue values.
Definition: dictionary.h:52
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:90
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...