1e5c31af7Sopenharmony_ci#ifndef _GLSSHADEREXECUTIL_HPP 2e5c31af7Sopenharmony_ci#define _GLSSHADEREXECUTIL_HPP 3e5c31af7Sopenharmony_ci/*------------------------------------------------------------------------- 4e5c31af7Sopenharmony_ci * drawElements Quality Program OpenGL (ES) Module 5e5c31af7Sopenharmony_ci * ----------------------------------------------- 6e5c31af7Sopenharmony_ci * 7e5c31af7Sopenharmony_ci * Copyright 2014 The Android Open Source Project 8e5c31af7Sopenharmony_ci * 9e5c31af7Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 10e5c31af7Sopenharmony_ci * you may not use this file except in compliance with the License. 11e5c31af7Sopenharmony_ci * You may obtain a copy of the License at 12e5c31af7Sopenharmony_ci * 13e5c31af7Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 14e5c31af7Sopenharmony_ci * 15e5c31af7Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 16e5c31af7Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 17e5c31af7Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18e5c31af7Sopenharmony_ci * See the License for the specific language governing permissions and 19e5c31af7Sopenharmony_ci * limitations under the License. 20e5c31af7Sopenharmony_ci * 21e5c31af7Sopenharmony_ci *//*! 22e5c31af7Sopenharmony_ci * \file 23e5c31af7Sopenharmony_ci * \brief Shader execution utilities. 24e5c31af7Sopenharmony_ci *//*--------------------------------------------------------------------*/ 25e5c31af7Sopenharmony_ci 26e5c31af7Sopenharmony_ci#include "tcuDefs.hpp" 27e5c31af7Sopenharmony_ci#include "gluVarType.hpp" 28e5c31af7Sopenharmony_ci#include "gluShaderUtil.hpp" 29e5c31af7Sopenharmony_ci 30e5c31af7Sopenharmony_cinamespace tcu 31e5c31af7Sopenharmony_ci{ 32e5c31af7Sopenharmony_ciclass TestLog; 33e5c31af7Sopenharmony_ci} 34e5c31af7Sopenharmony_ci 35e5c31af7Sopenharmony_cinamespace glu 36e5c31af7Sopenharmony_ci{ 37e5c31af7Sopenharmony_ciclass RenderContext; 38e5c31af7Sopenharmony_ci} 39e5c31af7Sopenharmony_ci 40e5c31af7Sopenharmony_cinamespace deqp 41e5c31af7Sopenharmony_ci{ 42e5c31af7Sopenharmony_cinamespace gls 43e5c31af7Sopenharmony_ci{ 44e5c31af7Sopenharmony_cinamespace ShaderExecUtil 45e5c31af7Sopenharmony_ci{ 46e5c31af7Sopenharmony_ci 47e5c31af7Sopenharmony_ci//! Shader input / output variable declaration. 48e5c31af7Sopenharmony_cistruct Symbol 49e5c31af7Sopenharmony_ci{ 50e5c31af7Sopenharmony_ci std::string name; //!< Symbol name. 51e5c31af7Sopenharmony_ci glu::VarType varType; //!< Symbol type. 52e5c31af7Sopenharmony_ci 53e5c31af7Sopenharmony_ci Symbol (void) {} 54e5c31af7Sopenharmony_ci Symbol (const std::string& name_, const glu::VarType& varType_) : name(name_), varType(varType_) {} 55e5c31af7Sopenharmony_ci}; 56e5c31af7Sopenharmony_ci 57e5c31af7Sopenharmony_ci//! Complete shader specification. 58e5c31af7Sopenharmony_cistruct ShaderSpec 59e5c31af7Sopenharmony_ci{ 60e5c31af7Sopenharmony_ci glu::GLSLVersion version; //!< Shader version. 61e5c31af7Sopenharmony_ci std::vector<Symbol> inputs; 62e5c31af7Sopenharmony_ci std::vector<Symbol> outputs; 63e5c31af7Sopenharmony_ci std::string globalDeclarations; //!< These are placed into global scope. Can contain uniform declarations for example. 64e5c31af7Sopenharmony_ci std::string source; //!< Source snippet to be executed. 65e5c31af7Sopenharmony_ci 66e5c31af7Sopenharmony_ci ShaderSpec (void) : version(glu::GLSL_VERSION_300_ES) {} 67e5c31af7Sopenharmony_ci}; 68e5c31af7Sopenharmony_ci 69e5c31af7Sopenharmony_ci//! Base class for shader executor. 70e5c31af7Sopenharmony_ciclass ShaderExecutor 71e5c31af7Sopenharmony_ci{ 72e5c31af7Sopenharmony_cipublic: 73e5c31af7Sopenharmony_ci virtual ~ShaderExecutor (void); 74e5c31af7Sopenharmony_ci 75e5c31af7Sopenharmony_ci //! Check if executor can be used. 76e5c31af7Sopenharmony_ci virtual bool isOk (void) const = 0; 77e5c31af7Sopenharmony_ci 78e5c31af7Sopenharmony_ci //! Log executor details (program etc.). 79e5c31af7Sopenharmony_ci virtual void log (tcu::TestLog& log) const = 0; 80e5c31af7Sopenharmony_ci 81e5c31af7Sopenharmony_ci //! Get program. 82e5c31af7Sopenharmony_ci virtual deUint32 getProgram (void) const = 0; 83e5c31af7Sopenharmony_ci 84e5c31af7Sopenharmony_ci //! Set this shader program current in context. Must be called before execute(). 85e5c31af7Sopenharmony_ci virtual void useProgram (void); 86e5c31af7Sopenharmony_ci 87e5c31af7Sopenharmony_ci //! Execute active program. useProgram() must be called before this. 88e5c31af7Sopenharmony_ci virtual void execute (int numValues, const void* const* inputs, void* const* outputs) = 0; 89e5c31af7Sopenharmony_ci 90e5c31af7Sopenharmony_ciprotected: 91e5c31af7Sopenharmony_ci ShaderExecutor (const glu::RenderContext& renderCtx, const ShaderSpec& shaderSpec); 92e5c31af7Sopenharmony_ci 93e5c31af7Sopenharmony_ci const glu::RenderContext& m_renderCtx; 94e5c31af7Sopenharmony_ci 95e5c31af7Sopenharmony_ci std::vector<Symbol> m_inputs; 96e5c31af7Sopenharmony_ci std::vector<Symbol> m_outputs; 97e5c31af7Sopenharmony_ci}; 98e5c31af7Sopenharmony_ci 99e5c31af7Sopenharmony_ciinline tcu::TestLog& operator<< (tcu::TestLog& log, const ShaderExecutor* executor) { executor->log(log); return log; } 100e5c31af7Sopenharmony_ciinline tcu::TestLog& operator<< (tcu::TestLog& log, const ShaderExecutor& executor) { executor.log(log); return log; } 101e5c31af7Sopenharmony_ci 102e5c31af7Sopenharmony_cibool executorSupported(glu::ShaderType shaderType); 103e5c31af7Sopenharmony_ciShaderExecutor* createExecutor (const glu::RenderContext& renderCtx, glu::ShaderType shaderType, const ShaderSpec& shaderSpec); 104e5c31af7Sopenharmony_ci 105e5c31af7Sopenharmony_ci} // ShaderExecUtil 106e5c31af7Sopenharmony_ci} // gls 107e5c31af7Sopenharmony_ci} // deqp 108e5c31af7Sopenharmony_ci 109e5c31af7Sopenharmony_ci#endif // _GLSSHADEREXECUTIL_HPP 110