1 // Copyright 2019 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 SAMPLES_CONFIG_HELPER_H_ 16 #define SAMPLES_CONFIG_HELPER_H_ 17 18 #include <memory> 19 #include <string> 20 #include <vector> 21 22 #include "amber/amber.h" 23 24 namespace sample { 25 26 /// Proof of concept implementation showing how to provide and use 27 /// EngineConfig within sample amber program. 28 class ConfigHelperImpl { 29 public: 30 virtual ~ConfigHelperImpl(); 31 32 /// Create instance and device and return them as amber::EngineConfig. 33 /// |required_features| and |required_extensions| contain lists of 34 /// required features and required extensions, respectively. 35 virtual amber::Result CreateConfig( 36 uint32_t engine_major, 37 uint32_t engine_minor, 38 int32_t selected_device, 39 const std::vector<std::string>& required_features, 40 const std::vector<std::string>& required_instance_extensions, 41 const std::vector<std::string>& required_device_extensions, 42 bool disable_validation_layer, 43 bool enable_pipeline_runtime_layer, 44 bool show_version_info, 45 std::unique_ptr<amber::EngineConfig>* config) = 0; 46 }; 47 48 /// Wrapper of ConfigHelperImpl. 49 class ConfigHelper { 50 public: 51 ConfigHelper(); 52 ~ConfigHelper(); 53 54 /// Create instance and device and return them as amber::EngineConfig. 55 /// |required_features| and |required_extensions| contain lists of 56 /// required features and required extensions, respectively. |engine| 57 /// indicates whether the caller required VulkanEngineConfig or 58 /// DawnEngineConfig. 59 amber::Result CreateConfig( 60 amber::EngineType engine, 61 uint32_t engine_major, 62 uint32_t engine_minor, 63 int32_t selected_device, 64 const std::vector<std::string>& required_features, 65 const std::vector<std::string>& required_instance_extensions, 66 const std::vector<std::string>& required_device_extensions, 67 bool disable_validation_layer, 68 bool enable_pipeline_runtime_layer, 69 bool show_version_info, 70 std::unique_ptr<amber::EngineConfig>* config); 71 72 private: 73 std::unique_ptr<ConfigHelperImpl> impl_; 74 }; 75 76 } // namespace sample 77 78 #endif // SAMPLES_CONFIG_HELPER_H_ 79