1 // Copyright 2018 The Amber Authors. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #ifndef AMBER_RECIPE_H_ 16 #define AMBER_RECIPE_H_ 17 18 #include <string> 19 #include <utility> 20 #include <vector> 21 22 #include "amber/shader_info.h" 23 24 namespace amber { 25 26 /// Internal recipe implementation. 27 class RecipeImpl { 28 public: 29 virtual ~RecipeImpl(); 30 31 /// Retrieves information on all the shaders in the given recipe. 32 virtual std::vector<ShaderInfo> GetShaderInfo() const = 0; 33 34 /// Returns required features in the given recipe. 35 virtual std::vector<std::string> GetRequiredFeatures() const = 0; 36 37 /// Returns required device extensions in the given recipe. 38 virtual std::vector<std::string> GetRequiredDeviceExtensions() const = 0; 39 40 /// Returns required instance extensions in the given recipe. 41 virtual std::vector<std::string> GetRequiredInstanceExtensions() const = 0; 42 43 /// Sets the fence timeout value to |timeout_ms|. 44 virtual void SetFenceTimeout(uint32_t timeout_ms) = 0; 45 46 protected: 47 RecipeImpl(); 48 }; 49 50 /// A recipe is the parsed representation of the input script. 51 class Recipe { 52 public: 53 Recipe(); 54 ~Recipe(); 55 56 /// Retrieves information on all the shaders in the recipe. 57 std::vector<ShaderInfo> GetShaderInfo() const; 58 GetImpl()59 RecipeImpl* GetImpl() const { return impl_; } 60 /// Sets the recipe implementation. Ownership transfers to the recipe. SetImpl(RecipeImpl * impl)61 void SetImpl(RecipeImpl* impl) { impl_ = impl; } 62 63 /// Returns required features in the given recipe. 64 std::vector<std::string> GetRequiredFeatures() const; 65 66 /// Returns required device extensions in the given recipe. 67 std::vector<std::string> GetRequiredDeviceExtensions() const; 68 69 /// Returns required instance extensions in the given recipe. 70 std::vector<std::string> GetRequiredInstanceExtensions() const; 71 72 /// Sets the timeout value for fences to |timeout_ms|. 73 void SetFenceTimeout(uint32_t timeout_ms); 74 75 private: 76 RecipeImpl* impl_; 77 }; 78 79 } // namespace amber 80 81 #endif // AMBER_RECIPE_H_ 82