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 show_version_info, 44 std::unique_ptr<amber::EngineConfig>* config) = 0; 45 }; 46 47 /// Wrapper of ConfigHelperImpl. 48 class ConfigHelper { 49 public: 50 ConfigHelper(); 51 ~ConfigHelper(); 52 53 /// Create instance and device and return them as amber::EngineConfig. 54 /// |required_features| and |required_extensions| contain lists of 55 /// required features and required extensions, respectively. |engine| 56 /// indicates whether the caller required VulkanEngineConfig or 57 /// DawnEngineConfig. 58 amber::Result CreateConfig( 59 amber::EngineType engine, 60 uint32_t engine_major, 61 uint32_t engine_minor, 62 int32_t selected_device, 63 const std::vector<std::string>& required_features, 64 const std::vector<std::string>& required_instance_extensions, 65 const std::vector<std::string>& required_device_extensions, 66 bool disable_validation_layer, 67 bool show_version_info, 68 std::unique_ptr<amber::EngineConfig>* config); 69 70 private: 71 std::unique_ptr<ConfigHelperImpl> impl_; 72 }; 73 74 } // namespace sample 75 76 #endif // SAMPLES_CONFIG_HELPER_H_ 77