vktShaderExecutor.hpp revision e148980e7f95d8a113a7dc84b13ca9906f33869f
1#ifndef _VKTSHADEREXECUTOR_HPP 2#define _VKTSHADEREXECUTOR_HPP 3/*------------------------------------------------------------------------ 4 * Vulkan Conformance Tests 5 * ------------------------ 6 * 7 * Copyright (c) 2015 The Khronos Group Inc. 8 * Copyright (c) 2015 Samsung Electronics Co., Ltd. 9 * 10 * Permission is hereby granted, free of charge, to any person obtaining a 11 * copy of this software and/or associated documentation files (the 12 * "Materials"), to deal in the Materials without restriction, including 13 * without limitation the rights to use, copy, modify, merge, publish, 14 * distribute, sublicense, and/or sell copies of the Materials, and to 15 * permit persons to whom the Materials are furnished to do so, subject to 16 * the following conditions: 17 * 18 * The above copyright notice(s) and this permission notice shall be included 19 * in all copies or substantial portions of the Materials. 20 * 21 * The Materials are Confidential Information as defined by the 22 * Khronos Membership Agreement until designated non-confidential by Khronos, 23 * at which point this condition clause shall be removed. 24 * 25 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 26 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 27 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 28 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 29 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 30 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 31 * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. 32 * 33 *//*! 34 * \file 35 * \brief Vulkan ShaderExecutor 36 *//*--------------------------------------------------------------------*/ 37 38#include "vktTestCase.hpp" 39#include "vkPrograms.hpp" 40 41#include "gluVarType.hpp" 42 43#include <vector> 44 45namespace vkt 46{ 47namespace shaderexecutor 48{ 49 50//! Shader input / output variable declaration. 51struct Symbol 52{ 53 std::string name; //!< Symbol name. 54 glu::VarType varType; //!< Symbol type. 55 56 57 Symbol (void) {} 58 Symbol (const std::string& name_, const glu::VarType& varType_) : name(name_), varType(varType_) {} 59}; 60 61//! Complete shader specification. 62struct ShaderSpec 63{ 64 std::vector<Symbol> inputs; 65 std::vector<Symbol> outputs; 66 std::string globalDeclarations; //!< These are placed into global scope. Can contain uniform declarations for example. 67 std::string source; //!< Source snippet to be executed. 68 69 ShaderSpec (void) {} 70}; 71 72//! Base class for shader executor. 73class ShaderExecutor 74{ 75public: 76 virtual ~ShaderExecutor (void); 77 78 //! Log executor details (program etc.). 79 virtual void log (tcu::TestLog& log) const = 0; 80 81 //! Execute 82 virtual void execute (const Context& ctx, int numValues, const void* const* inputs, void* const* outputs) = 0; 83 84 virtual void setShaderSources (vk::SourceCollections& programCollection) const = 0; 85 86protected: 87 ShaderExecutor (const ShaderSpec& shaderSpec, glu::ShaderType shaderType); 88 89 const ShaderSpec m_shaderSpec; 90 const glu::ShaderType m_shaderType; 91}; 92 93inline tcu::TestLog& operator<< (tcu::TestLog& log, const ShaderExecutor* executor) { executor->log(log); return log; } 94inline tcu::TestLog& operator<< (tcu::TestLog& log, const ShaderExecutor& executor) { executor.log(log); return log; } 95 96ShaderExecutor* createExecutor(glu::ShaderType shaderType, const ShaderSpec& shaderSpec); 97 98} // shaderexecutor 99} // vkt 100 101#endif // _VKTSHADEREXECUTOR_HPP 102