Po-Hsien Wang | 00777b2 | 2019-04-24 16:37:09 -0700 | [diff] [blame] | 1 | // Copyright 2019 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef __VKBENCH_TESTBASE_H__ |
| 6 | #define __VKBENCH_TESTBASE_H__ |
| 7 | |
Po-Hsien Wang | 00777b2 | 2019-04-24 16:37:09 -0700 | [diff] [blame] | 8 | #include <vector> |
| 9 | #include <vulkan/vulkan.hpp> |
| 10 | |
| 11 | #include "utils.h" |
Po-Hsien Wang | a0e1c31 | 2020-09-24 22:06:52 +0800 | [diff] [blame^] | 12 | #include "vkBase.h" |
Po-Hsien Wang | 00777b2 | 2019-04-24 16:37:09 -0700 | [diff] [blame] | 13 | |
| 14 | namespace vkbench { |
| 15 | class testBase { |
| 16 | public: |
Po-Hsien Wang | 42e116c | 2020-06-09 16:10:27 -0700 | [diff] [blame] | 17 | virtual ~testBase() {} |
Po-Hsien Wang | 00777b2 | 2019-04-24 16:37:09 -0700 | [diff] [blame] | 18 | // Name of test. |
| 19 | virtual const char* Name() const = 0; |
| 20 | // Description of the test. |
| 21 | virtual const char* Desp() const = 0; |
| 22 | // Unit for formatted measurement. |
| 23 | virtual const char* Unit() const = 0; |
| 24 | // Given time elapse per iteration, format it into meaningful numbers. |
| 25 | virtual double FormatMeasurement(double time) { return time; } |
| 26 | |
Po-Hsien Wang | a0e1c31 | 2020-09-24 22:06:52 +0800 | [diff] [blame^] | 27 | // SaveImage saves the rendered image to file_name. |
| 28 | virtual void SaveImage(std::string file_name) const { |
| 29 | throw std::runtime_error("Not Implemented!"); |
| 30 | }; |
| 31 | |
Po-Hsien Wang | 00777b2 | 2019-04-24 16:37:09 -0700 | [diff] [blame] | 32 | // Test related resources allocation. The resources allocated here would be |
Po-Hsien Wang | 42e116c | 2020-06-09 16:10:27 -0700 | [diff] [blame] | 33 | // shared by all Run iterations. Time spent here will not be recorded. |
| 34 | virtual void Initialize() {} |
Po-Hsien Wang | 00777b2 | 2019-04-24 16:37:09 -0700 | [diff] [blame] | 35 | // Test configuration before running the test. This will run once before |
Po-Hsien Wang | 42e116c | 2020-06-09 16:10:27 -0700 | [diff] [blame] | 36 | // each Run loop. Time spent here will be recorded. |
| 37 | virtual void Setup() {} |
Po-Hsien Wang | 00777b2 | 2019-04-24 16:37:09 -0700 | [diff] [blame] | 38 | // Test body. Time spent will be recorded. |
Po-Hsien Wang | 42e116c | 2020-06-09 16:10:27 -0700 | [diff] [blame] | 39 | virtual void Run() = 0; |
| 40 | // Test cleanup after looping Run. Time spent here will be recorded. |
Po-Hsien Wang | a0e1c31 | 2020-09-24 22:06:52 +0800 | [diff] [blame^] | 41 | virtual void Cleanup() {}; |
Po-Hsien Wang | 42e116c | 2020-06-09 16:10:27 -0700 | [diff] [blame] | 42 | // Free and Destroy any resources allocated during Initialize. Time |
Po-Hsien Wang | 00777b2 | 2019-04-24 16:37:09 -0700 | [diff] [blame] | 43 | // spent here will not be recorded. |
Po-Hsien Wang | 42e116c | 2020-06-09 16:10:27 -0700 | [diff] [blame] | 44 | virtual void Destroy() = 0; |
Po-Hsien Wang | 00777b2 | 2019-04-24 16:37:09 -0700 | [diff] [blame] | 45 | |
Po-Hsien Wang | a0e1c31 | 2020-09-24 22:06:52 +0800 | [diff] [blame^] | 46 | vkbench::vkBase* vk; |
Po-Hsien Wang | 00777b2 | 2019-04-24 16:37:09 -0700 | [diff] [blame] | 47 | }; |
| 48 | |
| 49 | } // namespace vkbench |
| 50 | #endif |