| Flutter Impeller |

compute_playground_test.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter 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 #pragma once
6
7 #include <memory>
8
9 #include "flutter/fml/macros.h"
10 #include "flutter/fml/time/time_delta.h"
11 #include "flutter/testing/testing.h"
12 #include "impeller/core/device_buffer.h"
13 #include "impeller/geometry/scalar.h"
14 #include "impeller/playground/playground.h"
15
16 namespace impeller {
17
18 class ComputePlaygroundTest
19 : public Playground,
20 public ::testing::TestWithParam<PlaygroundBackend> {
21 public:
22 ComputePlaygroundTest();
23
24 virtual ~ComputePlaygroundTest();
25
26 void SetUp() override;
27
28 void TearDown() override;
29
30 // |Playground|
31 std::unique_ptr<fml::Mapping> OpenAssetAsMapping(
32 std::string asset_name) const override;
33
34 std::shared_ptr<RuntimeStage> OpenAssetAsRuntimeStage(
35 const char* asset_name) const;
36
37 // |Playground|
38 std::string GetWindowTitle() const override;
39
40 template <typename T>
41 std::shared_ptr<DeviceBuffer> CreateHostVisibleDeviceBuffer(
42 std::shared_ptr<Context> context,
43 const std::string& label) {
44 DeviceBufferDescriptor desc;
45 desc.storage_mode = StorageMode::kHostVisible;
46 desc.size = sizeof(T);
47 auto buffer = context->GetResourceAllocator()->CreateBuffer(desc);
48 buffer->SetLabel(label);
49 return buffer;
50 }
51
52 private:
53 fml::TimeDelta start_time_;
54
55 FML_DISALLOW_COPY_AND_ASSIGN(ComputePlaygroundTest);
56 };
57
58 #define INSTANTIATE_COMPUTE_SUITE(playground) \
59 INSTANTIATE_TEST_SUITE_P( \
60 Compute, playground, \
61 ::testing::Values(PlaygroundBackend::kMetal, \
62 PlaygroundBackend::kVulkan), \
63 [](const ::testing::TestParamInfo<ComputePlaygroundTest::ParamType>& \
64 info) { return PlaygroundBackendToString(info.param); });
65
66 } // namespace impeller
impeller::ComputePlaygroundTest::SetUp
void SetUp() override
Definition: compute_playground_test.cc:17
impeller::ComputePlaygroundTest::OpenAssetAsRuntimeStage
std::shared_ptr< RuntimeStage > OpenAssetAsRuntimeStage(const char *asset_name) const
Definition: compute_playground_test.cc:44
impeller::DeviceBufferDescriptor
Definition: device_buffer_descriptor.h:13
device_buffer.h
playground.h
impeller::DeviceBufferDescriptor::size
size_t size
Definition: device_buffer_descriptor.h:15
impeller::ComputePlaygroundTest
Definition: compute_playground_test.h:18
impeller::StorageMode::kHostVisible
@ kHostVisible
impeller::ComputePlaygroundTest::GetWindowTitle
std::string GetWindowTitle() const override
Definition: compute_playground_test.cc:64
impeller::Playground
Definition: playground.h:33
impeller::ComputePlaygroundTest::CreateHostVisibleDeviceBuffer
std::shared_ptr< DeviceBuffer > CreateHostVisibleDeviceBuffer(std::shared_ptr< Context > context, const std::string &label)
Definition: compute_playground_test.h:41
impeller::ComputePlaygroundTest::TearDown
void TearDown() override
Definition: compute_playground_test.cc:34
impeller::ComputePlaygroundTest::OpenAssetAsMapping
std::unique_ptr< fml::Mapping > OpenAssetAsMapping(std::string asset_name) const override
Definition: compute_playground_test.cc:39
impeller::ComputePlaygroundTest::~ComputePlaygroundTest
virtual ~ComputePlaygroundTest()
impeller::DeviceBufferDescriptor::storage_mode
StorageMode storage_mode
Definition: device_buffer_descriptor.h:14
scalar.h
impeller::ComputePlaygroundTest::ComputePlaygroundTest
ComputePlaygroundTest()
Definition: compute_playground_test.cc:12
impeller
Definition: aiks_context.cc:10