blob: 4e5a3e71821fe603c14f251671c147b6845d3045 [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
Po-Hsien Wanga956e652020-11-11 16:29:04 -080011#include "filepath.h"
Po-Hsien Wanga956e652020-11-11 16:29:04 -080012#include "utils.h"
Po-Hsien Wang53230a22020-11-12 18:03:18 -080013#include "vkBase.h"
Po-Hsien Wang00777b22019-04-24 16:37:09 -070014
15namespace vkbench {
16class testBase {
17 public:
Po-Hsien Wang42e116c2020-06-09 16:10:27 -070018 virtual ~testBase() {}
Po-Hsien Wang00777b22019-04-24 16:37:09 -070019 // Name of test.
20 virtual const char* Name() const = 0;
21 // Description of the test.
22 virtual const char* Desp() const = 0;
23 // Unit for formatted measurement.
24 virtual const char* Unit() const = 0;
25 // Given time elapse per iteration, format it into meaningful numbers.
26 virtual double FormatMeasurement(double time) { return time; }
27
Po-Hsien Wang53230a22020-11-12 18:03:18 -080028 // Image returns the rendered image.
29 virtual Image GetImage() const { return vkbench::Image(); };
Po-Hsien Wanga0e1c312020-09-24 22:06:52 +080030
Po-Hsien Wang00777b22019-04-24 16:37:09 -070031 // Test related resources allocation. The resources allocated here would be
Po-Hsien Wang42e116c2020-06-09 16:10:27 -070032 // shared by all Run iterations. Time spent here will not be recorded.
33 virtual void Initialize() {}
Po-Hsien Wang00777b22019-04-24 16:37:09 -070034 // Test configuration before running the test. This will run once before
Po-Hsien Wang42e116c2020-06-09 16:10:27 -070035 // each Run loop. Time spent here will be recorded.
36 virtual void Setup() {}
Po-Hsien Wang00777b22019-04-24 16:37:09 -070037 // Test body. Time spent will be recorded.
Po-Hsien Wang42e116c2020-06-09 16:10:27 -070038 virtual void Run() = 0;
39 // Test cleanup after looping Run. Time spent here will be recorded.
Po-Hsien Wanga956e652020-11-11 16:29:04 -080040 virtual void Cleanup(){};
Po-Hsien Wang42e116c2020-06-09 16:10:27 -070041 // Free and Destroy any resources allocated during Initialize. Time
Po-Hsien Wang00777b22019-04-24 16:37:09 -070042 // spent here will not be recorded.
Po-Hsien Wang42e116c2020-06-09 16:10:27 -070043 virtual void Destroy() = 0;
Po-Hsien Wang00777b22019-04-24 16:37:09 -070044
Po-Hsien Wanga0e1c312020-09-24 22:06:52 +080045 vkbench::vkBase* vk;
Po-Hsien Wang00777b22019-04-24 16:37:09 -070046};
47
48} // namespace vkbench
49#endif