1e5c31af7Sopenharmony_ci// Copyright 2019 The Amber Authors. 2e5c31af7Sopenharmony_ci// 3e5c31af7Sopenharmony_ci// Licensed under the Apache License, Version 2.0 (the "License"); 4e5c31af7Sopenharmony_ci// you may not use this file except in compliance with the License. 5e5c31af7Sopenharmony_ci// You may obtain a copy of the License at 6e5c31af7Sopenharmony_ci// 7e5c31af7Sopenharmony_ci// http://www.apache.org/licenses/LICENSE-2.0 8e5c31af7Sopenharmony_ci// 9e5c31af7Sopenharmony_ci// Unless required by applicable law or agreed to in writing, software 10e5c31af7Sopenharmony_ci// distributed under the License is distributed on an "AS IS" BASIS, 11e5c31af7Sopenharmony_ci// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12e5c31af7Sopenharmony_ci// See the License for the specific language governing permissions and 13e5c31af7Sopenharmony_ci// limitations under the License. 14e5c31af7Sopenharmony_ci 15e5c31af7Sopenharmony_ci#ifndef SAMPLES_CONFIG_HELPER_H_ 16e5c31af7Sopenharmony_ci#define SAMPLES_CONFIG_HELPER_H_ 17e5c31af7Sopenharmony_ci 18e5c31af7Sopenharmony_ci#include <memory> 19e5c31af7Sopenharmony_ci#include <string> 20e5c31af7Sopenharmony_ci#include <vector> 21e5c31af7Sopenharmony_ci 22e5c31af7Sopenharmony_ci#include "amber/amber.h" 23e5c31af7Sopenharmony_ci 24e5c31af7Sopenharmony_cinamespace sample { 25e5c31af7Sopenharmony_ci 26e5c31af7Sopenharmony_ci/// Proof of concept implementation showing how to provide and use 27e5c31af7Sopenharmony_ci/// EngineConfig within sample amber program. 28e5c31af7Sopenharmony_ciclass ConfigHelperImpl { 29e5c31af7Sopenharmony_ci public: 30e5c31af7Sopenharmony_ci virtual ~ConfigHelperImpl(); 31e5c31af7Sopenharmony_ci 32e5c31af7Sopenharmony_ci /// Create instance and device and return them as amber::EngineConfig. 33e5c31af7Sopenharmony_ci /// |required_features| and |required_extensions| contain lists of 34e5c31af7Sopenharmony_ci /// required features and required extensions, respectively. 35e5c31af7Sopenharmony_ci virtual amber::Result CreateConfig( 36e5c31af7Sopenharmony_ci uint32_t engine_major, 37e5c31af7Sopenharmony_ci uint32_t engine_minor, 38e5c31af7Sopenharmony_ci int32_t selected_device, 39e5c31af7Sopenharmony_ci const std::vector<std::string>& required_features, 40e5c31af7Sopenharmony_ci const std::vector<std::string>& required_instance_extensions, 41e5c31af7Sopenharmony_ci const std::vector<std::string>& required_device_extensions, 42e5c31af7Sopenharmony_ci bool disable_validation_layer, 43e5c31af7Sopenharmony_ci bool show_version_info, 44e5c31af7Sopenharmony_ci std::unique_ptr<amber::EngineConfig>* config) = 0; 45e5c31af7Sopenharmony_ci}; 46e5c31af7Sopenharmony_ci 47e5c31af7Sopenharmony_ci/// Wrapper of ConfigHelperImpl. 48e5c31af7Sopenharmony_ciclass ConfigHelper { 49e5c31af7Sopenharmony_ci public: 50e5c31af7Sopenharmony_ci ConfigHelper(); 51e5c31af7Sopenharmony_ci ~ConfigHelper(); 52e5c31af7Sopenharmony_ci 53e5c31af7Sopenharmony_ci /// Create instance and device and return them as amber::EngineConfig. 54e5c31af7Sopenharmony_ci /// |required_features| and |required_extensions| contain lists of 55e5c31af7Sopenharmony_ci /// required features and required extensions, respectively. |engine| 56e5c31af7Sopenharmony_ci /// indicates whether the caller required VulkanEngineConfig or 57e5c31af7Sopenharmony_ci /// DawnEngineConfig. 58e5c31af7Sopenharmony_ci amber::Result CreateConfig( 59e5c31af7Sopenharmony_ci amber::EngineType engine, 60e5c31af7Sopenharmony_ci uint32_t engine_major, 61e5c31af7Sopenharmony_ci uint32_t engine_minor, 62e5c31af7Sopenharmony_ci int32_t selected_device, 63e5c31af7Sopenharmony_ci const std::vector<std::string>& required_features, 64e5c31af7Sopenharmony_ci const std::vector<std::string>& required_instance_extensions, 65e5c31af7Sopenharmony_ci const std::vector<std::string>& required_device_extensions, 66e5c31af7Sopenharmony_ci bool disable_validation_layer, 67e5c31af7Sopenharmony_ci bool show_version_info, 68e5c31af7Sopenharmony_ci std::unique_ptr<amber::EngineConfig>* config); 69e5c31af7Sopenharmony_ci 70e5c31af7Sopenharmony_ci private: 71e5c31af7Sopenharmony_ci std::unique_ptr<ConfigHelperImpl> impl_; 72e5c31af7Sopenharmony_ci}; 73e5c31af7Sopenharmony_ci 74e5c31af7Sopenharmony_ci} // namespace sample 75e5c31af7Sopenharmony_ci 76e5c31af7Sopenharmony_ci#endif // SAMPLES_CONFIG_HELPER_H_ 77