7#ifndef PXR_IMAGING_HIO_GLSLFX_H
8#define PXR_IMAGING_HIO_GLSLFX_H
13#include "pxr/imaging/hio/api.h"
25PXR_NAMESPACE_OPEN_SCOPE
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);
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) :
225 filename(filePath), lineNo(0), version(-1.0) { }
227 std::string filename;
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;
280PXR_NAMESPACE_CLOSE_SCOPE
A class representing the config and shader source of a glslfx file.
HIO_API VtDictionary GetLayoutAsDictionary(const TfTokenVector &shaderStageKeys, std::string *errorStr) const
Get the layout config as a VtDictionary parsed from the JSON layout config corresponding to the shade...
HIO_API std::string GetDisplacementSource() const
Get the displacement source string.
HIO_API std::string GetVolumeSource() const
Get the volume source string.
HIO_API HioGlslfxConfig::Textures GetTextures() const
Return the textures specified in the configuration.
HIO_API HioGlslfx()
Create an invalid glslfx object.
const std::set< std::string > & GetFiles() const
Return set of all files processed for this glslfx object.
HIO_API HioGlslfx(std::istream &is, TfToken const &technique=HioGlslfxTokens->defVal)
Create a glslfx object from a stream.
HIO_API HioGlslfxConfig::MetadataDictionary GetMetadata() const
Return the metadata specified in the configuration.
HIO_API HioGlslfxConfig::Parameters GetParameters() const
Return the parameters specified in the configuration.
HIO_API bool IsValid(std::string *reason=NULL) const
Returns true if this is a valid glslfx file.
HIO_API HioGlslfx(std::string const &filePath, TfToken const &technique=HioGlslfxTokens->defVal)
Create a glslfx object from a file.
size_t GetHash() const
Return the computed hash value based on the string.
HIO_API std::string GetSource(const TfToken &shaderStageKey) const
Get the shader source associated with given key.
HIO_API std::string GetSurfaceSource() const
Get the surface source string.
HIO_API HioGlslfxConfig::Attributes GetAttributes() const
Return the attributes specified in the configuration.
const std::string & GetFilePath() const
Get the original file name passed to the constructor.
static HIO_API std::vector< std::string > ExtractImports(const std::string &filename)
Extract imported files from the specified glslfx file.
Token for efficient comparison, assignment, and hashing of known strings.
A map with string keys and VtValue values.
This file defines some macros that are useful for declaring and using static TfTokens.
#define TF_DECLARE_PUBLIC_TOKENS(...)
Macro to define public tokens.
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...
std::vector< TfToken > TfTokenVector
Convenience types.