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   /// Sets or clears runtime layer bit to |enabled|.
48   virtual void SetPipelineRuntimeLayerEnabled(bool enabled) = 0;
49 
50  protected:
51   RecipeImpl();
52 };
53 
54 /// A recipe is the parsed representation of the input script.
55 class Recipe {
56  public:
57   Recipe();
58   ~Recipe();
59 
60   /// Retrieves information on all the shaders in the recipe.
61   std::vector<ShaderInfo> GetShaderInfo() const;
62 
GetImpl()63   RecipeImpl* GetImpl() const { return impl_; }
64   /// Sets the recipe implementation. Ownership transfers to the recipe.
SetImpl(RecipeImpl * impl)65   void SetImpl(RecipeImpl* impl) { impl_ = impl; }
66 
67   /// Returns required features in the given recipe.
68   std::vector<std::string> GetRequiredFeatures() const;
69 
70   /// Returns required device extensions in the given recipe.
71   std::vector<std::string> GetRequiredDeviceExtensions() const;
72 
73   /// Returns required instance extensions in the given recipe.
74   std::vector<std::string> GetRequiredInstanceExtensions() const;
75 
76   /// Sets the timeout value for fences to |timeout_ms|.
77   void SetFenceTimeout(uint32_t timeout_ms);
78 
79   /// Sets or clears runtime layer bit to |enabled|.
80   void SetPipelineRuntimeLayerEnabled(bool enabled);
81 
82  private:
83   RecipeImpl* impl_;
84 };
85 
86 }  // namespace amber
87 
88 #endif  // AMBER_RECIPE_H_
89