24 #ifndef PXR_IMAGING_HIO_GLSLFX_H
25 #define PXR_IMAGING_HIO_GLSLFX_H
30 #include "pxr/imaging/hio/api.h"
42 PXR_NAMESPACE_OPEN_SCOPE
46 #define HIO_GLSLFX_API_VERSION 1
48 #define HIO_GLSLFX_TOKENS \
53 (geometryShaderInjection) \
58 (vertexShaderInjection) \
61 (displacementShader) \
158 std::string
const & filePath,
159 TfToken const & technique = HioGlslfxTokens->defVal);
165 TfToken const & technique = HioGlslfxTokens->defVal);
185 bool IsValid(std::string *reason=NULL)
const;
209 const std::string &
GetFilePath()
const {
return _globalContext.filename; }
215 const std::set<std::string>&
GetFiles()
const {
return _seenFiles; }
225 static std::vector<std::string>
ExtractImports(
const std::string& filename);
228 class _ParseContext {
232 _ParseContext(std::string
const & filePath) :
233 filename(filePath), lineNo(0), version(-1.0) { }
235 std::string filename;
238 std::string currentLine;
239 std::string currentSectionType;
240 std::string currentSectionId;
241 std::vector<std::string> imports;
245 bool _ProcessFile(std::string
const & filePath,
246 _ParseContext & context);
247 bool _ProcessInput(std::istream * input,
248 _ParseContext & context);
249 bool _ProcessImport(_ParseContext & context);
250 bool _ParseSectionLine(_ParseContext & context);
251 bool _ParseGLSLSectionLine(std::vector<std::string>
const &tokens,
252 _ParseContext & context);
253 bool _ParseVersionLine(std::vector<std::string>
const &tokens,
254 _ParseContext & context);
255 bool _ParseConfigurationLine(_ParseContext & context);
256 bool _ComposeConfiguration(std::string *reason);
257 std::string _GetSource(
const TfToken &shaderStageKey)
const;
260 _ParseContext _globalContext;
262 typedef std::map<std::string, std::string> _SourceMap;
264 _SourceMap _sourceMap;
265 _SourceMap _configMap;
266 std::vector<std::string> _configOrder;
267 std::set<std::string> _seenFiles;
269 std::unique_ptr<HioGlslfxConfig> _config;
274 std::string _invalidReason;
279 PXR_NAMESPACE_CLOSE_SCOPE
HIO_API HioGlslfxConfig::MetadataDictionary GetMetadata() const
Return the metadata specified in the configuration.
HIO_API std::string GetDisplacementSource() const
Get the displacement source string.
A map with string keys and VtValue values.
HIO_API bool IsValid(std::string *reason=NULL) const
Returns true if this is a valid glslfx file.
HIO_API HioGlslfxConfig::Textures GetTextures() const
Return the textures specified in the configuration.
Token for efficient comparison, assignment, and hashing of known strings.
HIO_API std::string GetSurfaceSource() const
Get the surface source string.
size_t GetHash() const
Return the computed hash value based on the 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.
#define TF_DECLARE_PUBLIC_TOKENS(...)
Macro to define public tokens.
HIO_API HioGlslfxConfig::Parameters GetParameters() const
Return the parameters specified in the configuration.
HIO_API std::string GetVolumeSource() const
Get the volume source string.
HIO_API HioGlslfx()
Create an invalid glslfx object.
A class representing the config and shader source of a glslfx file.
static HIO_API std::vector< std::string > ExtractImports(const std::string &filename)
Extract imported files from the specified glslfx file.
This file defines some macros that are useful for declaring and using static TfTokens.
const std::set< std::string > & GetFiles() const
Return set of all files processed for this glslfx object.
HIO_API std::string GetSource(const TfToken &shaderStageKey) const
Get the shader source associated with given key.
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...