• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <cstdint>
19 #include <string>
20 #include <utility>
21 #include <vector>
22 
23 #include "amber/shader_info.h"
24 
25 namespace amber {
26 
27 /// Internal recipe implementation.
28 class RecipeImpl {
29  public:
30   virtual ~RecipeImpl();
31 
32   /// Retrieves information on all the shaders in the given recipe.
33   virtual std::vector<ShaderInfo> GetShaderInfo() const = 0;
34 
35   /// Returns required features in the given recipe.
36   virtual std::vector<std::string> GetRequiredFeatures() const = 0;
37 
38   /// Returns required device extensions in the given recipe.
39   virtual std::vector<std::string> GetRequiredDeviceExtensions() const = 0;
40 
41   /// Returns required instance extensions in the given recipe.
42   virtual std::vector<std::string> GetRequiredInstanceExtensions() const = 0;
43 
44   /// Sets the fence timeout value to |timeout_ms|.
45   virtual void SetFenceTimeout(uint32_t timeout_ms) = 0;
46 
47  protected:
48   RecipeImpl();
49 };
50 
51 /// A recipe is the parsed representation of the input script.
52 class Recipe {
53  public:
54   Recipe();
55   ~Recipe();
56 
57   /// Retrieves information on all the shaders in the recipe.
58   std::vector<ShaderInfo> GetShaderInfo() const;
59 
GetImpl()60   RecipeImpl* GetImpl() const { return impl_; }
61   /// Sets the recipe implementation. Ownership transfers to the recipe.
SetImpl(RecipeImpl * impl)62   void SetImpl(RecipeImpl* impl) { impl_ = impl; }
63 
64   /// Returns required features in the given recipe.
65   std::vector<std::string> GetRequiredFeatures() const;
66 
67   /// Returns required device extensions in the given recipe.
68   std::vector<std::string> GetRequiredDeviceExtensions() const;
69 
70   /// Returns required instance extensions in the given recipe.
71   std::vector<std::string> GetRequiredInstanceExtensions() const;
72 
73   /// Sets the timeout value for fences to |timeout_ms|.
74   void SetFenceTimeout(uint32_t timeout_ms);
75 
76  private:
77   RecipeImpl* impl_;
78 };
79 
80 }  // namespace amber
81 
82 #endif  // AMBER_RECIPE_H_
83