1 #ifndef _GLSSHADEREXECUTIL_HPP
2 #define _GLSSHADEREXECUTIL_HPP
3 /*-------------------------------------------------------------------------
4 * drawElements Quality Program OpenGL (ES) Module
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 execution utilities.
24 *//*--------------------------------------------------------------------*/
26 #include "tcuDefs.hpp"
27 #include "gluVarType.hpp"
28 #include "gluShaderUtil.hpp"
44 namespace ShaderExecUtil
47 //! Shader input / output variable declaration.
50 std::string name; //!< Symbol name.
51 glu::VarType varType; //!< Symbol type.
54 Symbol (const std::string& name_, const glu::VarType& varType_) : name(name_), varType(varType_) {}
57 //! Complete shader specification.
60 glu::GLSLVersion version; //!< Shader version.
61 std::vector<Symbol> inputs;
62 std::vector<Symbol> outputs;
63 std::string globalDeclarations; //!< These are placed into global scope. Can contain uniform declarations for example.
64 std::string source; //!< Source snippet to be executed.
66 ShaderSpec (void) : version(glu::GLSL_VERSION_300_ES) {}
69 //! Base class for shader executor.
73 virtual ~ShaderExecutor (void);
75 //! Check if executor can be used.
76 virtual bool isOk (void) const = 0;
78 //! Log executor details (program etc.).
79 virtual void log (tcu::TestLog& log) const = 0;
82 virtual deUint32 getProgram (void) const = 0;
84 //! Set this shader program current in context. Must be called before execute().
85 virtual void useProgram (void);
87 //! Execute active program. useProgram() must be called before this.
88 virtual void execute (int numValues, const void* const* inputs, void* const* outputs) = 0;
91 ShaderExecutor (const glu::RenderContext& renderCtx, const ShaderSpec& shaderSpec);
93 const glu::RenderContext& m_renderCtx;
95 std::vector<Symbol> m_inputs;
96 std::vector<Symbol> m_outputs;
99 inline tcu::TestLog& operator<< (tcu::TestLog& log, const ShaderExecutor* executor) { executor->log(log); return log; }
100 inline tcu::TestLog& operator<< (tcu::TestLog& log, const ShaderExecutor& executor) { executor.log(log); return log; }
102 ShaderExecutor* createExecutor (const glu::RenderContext& renderCtx, glu::ShaderType shaderType, const ShaderSpec& shaderSpec);
108 #endif // _GLSSHADEREXECUTIL_HPP