MaterialX 1.39.1
Loading...
Searching...
No Matches
MdlSyntax.h
Go to the documentation of this file.
1//
2// Copyright Contributors to the MaterialX Project
3// SPDX-License-Identifier: Apache-2.0
4//
5
6#ifndef MATERIALX_MDLSYNTAX_H
7#define MATERIALX_MDLSYNTAX_H
8
11
13
15
16MATERIALX_NAMESPACE_BEGIN
17
18class MdlSyntax;
19
21using MdlSyntaxPtr = shared_ptr<MdlSyntax>;
22
25class MX_GENMDL_API MdlSyntax : public Syntax
26{
27 public:
28 MdlSyntax();
29
30 static SyntaxPtr create() { return std::make_shared<MdlSyntax>(); }
31
32 const string& getConstantQualifier() const override { return CONST_QUALIFIER; };
33 const string& getUniformQualifier() const override { return UNIFORM_QUALIFIER; };
34 const string& getSourceFileExtension() const override { return SOURCE_FILE_EXTENSION; };
35
37 string getArrayTypeSuffix(TypeDesc type, const Value& value) const override;
38
40 string getArrayVariableSuffix(TypeDesc, const Value&) const override { return EMPTY_STRING; };
41
42 static const string CONST_QUALIFIER;
43 static const string UNIFORM_QUALIFIER;
44 static const string SOURCE_FILE_EXTENSION;
45 static const StringVec VECTOR2_MEMBERS;
46 static const StringVec VECTOR3_MEMBERS;
47 static const StringVec VECTOR4_MEMBERS;
48 static const StringVec COLOR3_MEMBERS;
49 static const StringVec COLOR4_MEMBERS;
50 static const StringVec ADDRESSMODE_MEMBERS;
51 static const StringVec COORDINATESPACE_MEMBERS;
52 static const StringVec FILTERLOOKUPMODE_MEMBERS;
53 static const StringVec FILTERTYPE_MEMBERS;
54 static const StringVec DISTRIBUTIONTYPE_MEMBERS;
55 static const StringVec SCATTER_MODE_MEMBERS;
56
58 TypeDesc getEnumeratedType(const string& value) const;
59
62 bool remapEnumeration(const string& value, TypeDesc type, const string& enumNames, std::pair<TypeDesc, ValuePtr>& result) const override;
63
65 void makeValidName(string& name) const override;
66};
67
68namespace Type
69{
70
71TYPEDESC_DEFINE_TYPE(MDL_COORDINATESPACE, "coordinatespace", TypeDesc::BASETYPE_NONE, TypeDesc::SEMANTIC_ENUM, 0)
72TYPEDESC_DEFINE_TYPE(MDL_ADDRESSMODE, "addressmode", TypeDesc::BASETYPE_NONE, TypeDesc::SEMANTIC_ENUM, 0)
73TYPEDESC_DEFINE_TYPE(MDL_FILTERLOOKUPMODE, "filterlookup", TypeDesc::BASETYPE_NONE, TypeDesc::SEMANTIC_ENUM, 0)
74TYPEDESC_DEFINE_TYPE(MDL_FILTERTYPE, "filtertype", TypeDesc::BASETYPE_NONE, TypeDesc::SEMANTIC_ENUM, 0)
75TYPEDESC_DEFINE_TYPE(MDL_DISTRIBUTIONTYPE, "distributiontype", TypeDesc::BASETYPE_NONE, TypeDesc::SEMANTIC_ENUM, 0)
76TYPEDESC_DEFINE_TYPE(MDL_SCATTER_MODE, "scatter_mode", TypeDesc::BASETYPE_NONE, TypeDesc::SEMANTIC_ENUM, 0)
77
78} // namespace Type
79
80MATERIALX_NAMESPACE_END
81
82#endif
vector< string > StringVec
A vector of strings.
Definition: Library.h:55
Macros for declaring imported and exported symbols.
shared_ptr< MdlSyntax > MdlSyntaxPtr
Shared pointer to an MdlSyntax.
Definition: MdlSyntax.h:21
Base class for syntax handling for shader generators.
shared_ptr< Syntax > SyntaxPtr
Shared pointer to a Syntax.
Definition: Syntax.h:27
#define TYPEDESC_DEFINE_TYPE(T, name, basetype, semantic, size)
Macro to define global type descriptions for commonly used types.
Definition: TypeDesc.h:171
Syntax class for MDL (Material Definition Language)
Definition: MdlSyntax.h:26
bool remapEnumeration(const string &value, TypeDesc type, const string &enumNames, std::pair< TypeDesc, ValuePtr > &result) const override
Given an input specification attempt to remap this to an enumeration which is accepted by the shader ...
const string & getConstantQualifier() const override
Get the qualifier used when declaring constant variables.
Definition: MdlSyntax.h:32
const string & getUniformQualifier() const override
Get the qualifier used when declaring uniform variables.
Definition: MdlSyntax.h:33
const string & getSourceFileExtension() const override
Return the file extension used for source code files in this language.
Definition: MdlSyntax.h:34
string getArrayTypeSuffix(TypeDesc type, const Value &value) const override
Override to return array type suffix.
void makeValidName(string &name) const override
Modify the given name string to remove any invalid characters or tokens.
string getArrayVariableSuffix(TypeDesc, const Value &) const override
Override to indicate array variables have no array suffix.
Definition: MdlSyntax.h:40
TypeDesc getEnumeratedType(const string &value) const
Get an type description for an enumeration based on member value.
Base class for syntax objects used by shader generators to emit code with correct syntax for each lan...
Definition: Syntax.h:41
A type descriptor for MaterialX data types.
Definition: TypeDesc.h:35
A generic, discriminated value, whose type may be queried dynamically.
Definition: Value.h:45