blob: 124c69e0dfa423bc1d794bb71f89771ceb1059de [file] [log] [blame]
Po-Hsien Wang5372c812020-10-02 09:41:01 +08001// Copyright 2020 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_CLEARTEST_H
6#define VKBENCH_CLEARTEST_H
7
8#include "testBase.h"
9
10namespace vkbench {
11class ClearTest : public testBase {
12 public:
13 ClearTest(vkBase* base) {
14 vk = base;
15 clear_color_.setColor({std::array<float, 4>{0.f, 0.f, 1.f}}); // Blue
16 snprintf(name_, 100, "ClearTest");
17 snprintf(desp_, 1024, "Time to clear window to specific color.");
18 }
19 ~ClearTest() override = default;
20
21 const char* Name() const override { return name_; }
22 const char* Desp() const override { return desp_; }
23 const char* Unit() const override { return "mpixels_sec"; }
24 virtual double FormatMeasurement(double time) override {
25 return img_size_.width * img_size_.height / time;
26 }
27 void SaveImage(std::string filename) const override;
28
29 protected:
30 void Initialize() override;
31 void Run() override;
32 void Destroy() override;
33
34 private:
35 void CreateRenderPass();
36 void CreateFrameBuffers();
37
38 char name_[100];
39 char desp_[1024];
40 vk::ClearValue clear_color_;
41 std::vector<vk::SubmitInfo> smt_infos_;
42 std::vector<vk::CommandBuffer> cmd_buffers_;
43 vk::Extent2D img_size_{256, 256};
44 vk::Format img_format_ = vk::Format::eR8G8B8A8Unorm;
45
46 vk::RenderPass render_pass_;
47 vk::Framebuffer frame_buffer_;
48 vkImage* img_;
49 vk::ImageView img_view_;
50
51 DISALLOW_COPY_AND_ASSIGN(ClearTest);
52};
53} // namespace vkbench
54#endif // VKBENCH_CLEARTEST_H