7 #ifndef PXR_IMAGING_HIO_GLSLFX_H
8 #define PXR_IMAGING_HIO_GLSLFX_H
29 #define HIO_GLSLFX_API_VERSION 1
31 #define HIO_GLSLFX_TOKENS \
36 (geometryShaderInjection) \
40 (postTessControlShader) \
41 (postTessVertexShader) \
43 (vertexShaderInjection) \
46 (displacementShader) \
143 std::string
const & filePath,
144 TfToken const & technique = HioGlslfxTokens->defVal);
150 TfToken const & technique = HioGlslfxTokens->defVal);
170 bool IsValid(std::string *reason=NULL)
const;
194 std::string *errorStr)
const;
201 const std::string &
GetFilePath()
const {
return _globalContext.filename; }
207 const std::set<std::string>&
GetFiles()
const {
return _seenFiles; }
220 class _ParseContext {
224 _ParseContext(std::string
const & filePath) :
230 std::string currentLine;
231 std::string currentSectionType;
232 std::string currentSectionId;
233 std::vector<std::string> imports;
237 bool _ProcessFile(std::string
const & filePath,
238 _ParseContext & context);
239 bool _ProcessInput(std::istream * input,
240 _ParseContext & context);
241 bool _ProcessImport(_ParseContext & context);
242 bool _ParseSectionLine(_ParseContext & context);
243 bool _ParseGLSLSectionLine(std::vector<std::string>
const &tokens,
244 _ParseContext & context);
245 bool _ParseLayoutSectionLine(std::vector<std::string>
const &tokens,
246 _ParseContext & context);
247 bool _ParseVersionLine(std::vector<std::string>
const &tokens,
248 _ParseContext & context);
249 bool _ParseConfigurationLine(_ParseContext & context);
250 bool _ComposeConfiguration(std::string *reason);
252 std::string _GetLayout(
const TfToken &shaderStageKey)
const;
253 std::string _GetSource(
const TfToken &shaderStageKey)
const;
257 std::string _GetLayoutAsString(
const TfTokenVector &shaderStageKeys)
const;
260 _ParseContext _globalContext;
262 typedef std::map<std::string, std::string> _SourceMap;
264 _SourceMap _sourceMap;
265 _SourceMap _layoutMap;
266 _SourceMap _configMap;
267 std::vector<std::string> _configOrder;
268 std::set<std::string> _seenFiles;
270 std::unique_ptr<HioGlslfxConfig> _config;
275 std::string _invalidReason;
GT_API const UT_StringHolder filename
std::vector< Attribute > Attributes
HIO_API HioGlslfxConfig::Parameters GetParameters() const
Return the parameters specified in the configuration.
static HIO_API std::vector< std::string > ExtractImports(const std::string &filename)
HIO_API HioGlslfxConfig::Attributes GetAttributes() const
Return the attributes specified in the configuration.
HIO_API bool IsValid(std::string *reason=NULL) const
Returns true if this is a valid glslfx file.
HIO_API std::string GetSurfaceSource() const
Get the surface source string.
const std::set< std::string > & GetFiles() const
std::vector< Parameter > Parameters
size_t GetHash() const
Return the computed hash value based on the string.
std::vector< TfToken > TfTokenVector
Convenience types.
#define HIO_GLSLFX_TOKENS
GT_API const UT_StringHolder version
const std::string & GetFilePath() const
Get the original file name passed to the constructor.
HIO_API VtDictionary GetLayoutAsDictionary(const TfTokenVector &shaderStageKeys, std::string *errorStr) const
HIO_API HioGlslfxConfig::MetadataDictionary GetMetadata() const
Return the metadata specified in the configuration.
HIO_API HioGlslfxConfig::Textures GetTextures() const
Return the textures specified in the configuration.
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
#define PXR_NAMESPACE_CLOSE_SCOPE
HIO_API std::string GetVolumeSource() const
Get the volume source string.
TF_DECLARE_PUBLIC_TOKENS(HioGlslfxTokens, HIO_API, HIO_GLSLFX_TOKENS)
std::vector< Texture > Textures
HIO_API HioGlslfx()
Create an invalid glslfx object.
HIO_API std::string GetSource(const TfToken &shaderStageKey) const
Get the shader source associated with given key.
HIO_API std::string GetDisplacementSource() const
Get the displacement source string.