3 /*-------------------------------------------------------------------------
4 * drawElements Quality Program Random Shader Generator
5 * ----------------------------------------------------
7 * Copyright 2014 The Android Open Source Project
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
23 * \brief Shader Class.
24 *//*--------------------------------------------------------------------*/
26 #include "rsgDefs.hpp"
27 #include "rsgVariable.hpp"
28 #include "rsgStatement.hpp"
29 #include "rsgVariableManager.hpp"
30 #include "rsgToken.hpp"
31 #include "rsgExecutionContext.hpp"
43 Function (const char* name);
46 const VariableType& getReturnType (void) const { return m_returnType; }
47 void setReturnType (const VariableType& type) { m_returnType = type; }
49 void addParameter (Variable* variable);
51 BlockStatement& getBody (void) { return m_functionBlock; }
52 const BlockStatement& getBody (void) const { return m_functionBlock; }
54 void tokenize (GeneratorState& state, TokenStream& stream) const;
58 std::vector<Variable*> m_parameters;
59 VariableType m_returnType;
61 BlockStatement m_functionBlock;
67 ShaderInput (const Variable* variable, ConstValueRangeAccess valueRange);
68 ~ShaderInput (void) {}
70 const Variable* getVariable (void) const { return m_variable; }
71 ConstValueRangeAccess getValueRange (void) const { return ConstValueRangeAccess(m_variable->getType(), &m_min[0], &m_max[0]); }
72 ValueRangeAccess getValueRange (void) { return ValueRangeAccess(m_variable->getType(), &m_min[0], &m_max[0]); }
75 const Variable* m_variable;
76 std::vector<Scalar> m_min;
77 std::vector<Scalar> m_max;
94 Type getType (void) const { return m_type; }
95 const char* getSource (void) const { return m_source.c_str(); }
97 void execute (ExecutionContext& execCtx) const;
99 // For generator implementation only
100 Function& getMain (void) { return m_mainFunction; }
101 Function& allocateFunction (void);
103 VariableScope& getGlobalScope (void) { return m_globalScope; }
104 std::vector<Statement*>& getGlobalStatements (void) { return m_globalStatements; }
106 void tokenize (GeneratorState& state, TokenStream& str) const;
107 void setSource (const char* source) { m_source = source; }
109 std::vector<ShaderInput*>& getInputs (void) { return m_inputs; }
110 std::vector<ShaderInput*>& getUniforms (void) { return m_uniforms; }
113 const std::vector<ShaderInput*>& getInputs (void) const { return m_inputs; }
114 const std::vector<ShaderInput*>& getUniforms (void) const { return m_uniforms; }
115 void getOutputs (std::vector<const Variable*>& outputs) const;
120 VariableScope m_globalScope;
121 std::vector<Statement*> m_globalStatements;
123 std::vector<ShaderInput*> m_inputs;
124 std::vector<ShaderInput*> m_uniforms;
126 std::vector<Function*> m_functions;
127 Function m_mainFunction;
129 std::string m_source;
134 #endif // _RSGSHADER_HPP