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 * Licensed under the Apache License, Version 2.0 (the "License"); 11 * you may not use this file except in compliance with the License. 12 * You may obtain a copy of the License at 13 * 14 * http://www.apache.org/licenses/LICENSE-2.0 15 * 16 * Unless required by applicable law or agreed to in writing, software 17 * distributed under the License is distributed on an "AS IS" BASIS, 18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 * See the License for the specific language governing permissions and 20 * limitations under the License. 21 * 22 *//*! 23 * \file 24 * \brief Vulkan ShaderExecutor 25 *//*--------------------------------------------------------------------*/ 26 27#include "tcuDefs.hpp" 28#include "vktTestCase.hpp" 29#include "gluVarType.hpp" 30 31#include <vector> 32#include <string> 33 34namespace vkt 35{ 36namespace shaderexecutor 37{ 38 39//! Shader input / output variable declaration. 40struct Symbol 41{ 42 std::string name; //!< Symbol name. 43 glu::VarType varType; //!< Symbol type. 44 45 Symbol (void) {} 46 Symbol (const std::string& name_, const glu::VarType& varType_) : name(name_), varType(varType_) {} 47}; 48 49//! Complete shader specification. 50struct ShaderSpec 51{ 52 std::vector<Symbol> inputs; 53 std::vector<Symbol> outputs; 54 std::string globalDeclarations; //!< These are placed into global scope. Can contain uniform declarations for example. 55 std::string source; //!< Source snippet to be executed. 56 57 ShaderSpec (void) {} 58}; 59 60enum 61{ 62 //!< Descriptor set index for additional resources 63 EXTRA_RESOURCES_DESCRIPTOR_SET_INDEX = 1, 64}; 65 66//! Base class for shader executor. 67class ShaderExecutor 68{ 69public: 70 virtual ~ShaderExecutor (void); 71 72 //! Execute 73 virtual void execute (int numValues, const void* const* inputs, void* const* outputs, vk::VkDescriptorSet extraResources = (vk::VkDescriptorSet)0) = 0; 74 75protected: 76 ShaderExecutor (Context& context, const ShaderSpec& shaderSpec) 77 : m_context (context) 78 , m_shaderSpec (shaderSpec) 79 {} 80 81 Context& m_context; 82 const ShaderSpec m_shaderSpec; 83 84private: 85 ShaderExecutor (const ShaderExecutor&); 86 ShaderExecutor& operator= (const ShaderExecutor&); 87}; 88 89void generateSources (glu::ShaderType shaderType, const ShaderSpec& shaderSpec, vk::SourceCollections& dst); 90ShaderExecutor* createExecutor (Context& context, glu::ShaderType shaderType, const ShaderSpec& shaderSpec, vk::VkDescriptorSetLayout extraResourcesLayout = (vk::VkDescriptorSetLayout)0); 91 92} // shaderexecutor 93} // vkt 94 95#endif // _VKTSHADEREXECUTOR_HPP 96