24#ifndef PXR_IMAGING_HIO_GLSLFX_H
25#define PXR_IMAGING_HIO_GLSLFX_H
30#include "pxr/imaging/hio/api.h"
42PXR_NAMESPACE_OPEN_SCOPE
46#define HIO_GLSLFX_API_VERSION 1
48#define HIO_GLSLFX_TOKENS \
53 (geometryShaderInjection) \
57 (postTessControlShader) \
58 (postTessVertexShader) \
60 (vertexShaderInjection) \
63 (displacementShader) \
160 std::string
const & filePath,
161 TfToken const & technique = HioGlslfxTokens->defVal);
167 TfToken const & technique = HioGlslfxTokens->defVal);
211 std::string *errorStr)
const;
218 const std::string &
GetFilePath()
const {
return _globalContext.filename; }
224 const std::set<std::string>&
GetFiles()
const {
return _seenFiles; }
237 class _ParseContext {
241 _ParseContext(std::string
const & filePath) :
242 filename(filePath), lineNo(0), version(-1.0) { }
244 std::string filename;
247 std::string currentLine;
248 std::string currentSectionType;
249 std::string currentSectionId;
250 std::vector<std::string> imports;
254 bool _ProcessFile(std::string
const & filePath,
255 _ParseContext & context);
256 bool _ProcessInput(std::istream * input,
257 _ParseContext & context);
258 bool _ProcessImport(_ParseContext & context);
259 bool _ParseSectionLine(_ParseContext & context);
260 bool _ParseGLSLSectionLine(std::vector<std::string>
const &tokens,
261 _ParseContext & context);
262 bool _ParseLayoutSectionLine(std::vector<std::string>
const &tokens,
263 _ParseContext & context);
264 bool _ParseVersionLine(std::vector<std::string>
const &tokens,
265 _ParseContext & context);
266 bool _ParseConfigurationLine(_ParseContext & context);
267 bool _ComposeConfiguration(std::string *reason);
269 std::string _GetLayout(
const TfToken &shaderStageKey)
const;
270 std::string _GetSource(
const TfToken &shaderStageKey)
const;
274 std::string _GetLayoutAsString(
const TfTokenVector &shaderStageKeys)
const;
277 _ParseContext _globalContext;
279 typedef std::map<std::string, std::string> _SourceMap;
281 _SourceMap _sourceMap;
282 _SourceMap _layoutMap;
283 _SourceMap _configMap;
284 std::vector<std::string> _configOrder;
285 std::set<std::string> _seenFiles;
287 std::unique_ptr<HioGlslfxConfig> _config;
292 std::string _invalidReason;
297PXR_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.