blob: 424e021a56caffc94152ea12e8e27844d061647f [file] [log] [blame]
Po-Hsien Wang00777b22019-04-24 16:37:09 -07001// 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 Wang00777b22019-04-24 16:37:09 -07008#include <vector>
9#include <vulkan/vulkan.hpp>
10
11#include "utils.h"
Po-Hsien Wanga0e1c312020-09-24 22:06:52 +080012#include "vkBase.h"
Po-Hsien Wang00777b22019-04-24 16:37:09 -070013
14namespace vkbench {
15class testBase {
16 public:
Po-Hsien Wang42e116c2020-06-09 16:10:27 -070017 virtual ~testBase() {}
Po-Hsien Wang00777b22019-04-24 16:37:09 -070018 // 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 Wanga0e1c312020-09-24 22:06:52 +080027 // 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 Wang00777b22019-04-24 16:37:09 -070032 // Test related resources allocation. The resources allocated here would be
Po-Hsien Wang42e116c2020-06-09 16:10:27 -070033 // shared by all Run iterations. Time spent here will not be recorded.
34 virtual void Initialize() {}
Po-Hsien Wang00777b22019-04-24 16:37:09 -070035 // Test configuration before running the test. This will run once before
Po-Hsien Wang42e116c2020-06-09 16:10:27 -070036 // each Run loop. Time spent here will be recorded.
37 virtual void Setup() {}
Po-Hsien Wang00777b22019-04-24 16:37:09 -070038 // Test body. Time spent will be recorded.
Po-Hsien Wang42e116c2020-06-09 16:10:27 -070039 virtual void Run() = 0;
40 // Test cleanup after looping Run. Time spent here will be recorded.
Po-Hsien Wanga0e1c312020-09-24 22:06:52 +080041 virtual void Cleanup() {};
Po-Hsien Wang42e116c2020-06-09 16:10:27 -070042 // Free and Destroy any resources allocated during Initialize. Time
Po-Hsien Wang00777b22019-04-24 16:37:09 -070043 // spent here will not be recorded.
Po-Hsien Wang42e116c2020-06-09 16:10:27 -070044 virtual void Destroy() = 0;
Po-Hsien Wang00777b22019-04-24 16:37:09 -070045
Po-Hsien Wanga0e1c312020-09-24 22:06:52 +080046 vkbench::vkBase* vk;
Po-Hsien Wang00777b22019-04-24 16:37:09 -070047};
48
49} // namespace vkbench
50#endif