| Flutter Impeller |

compute_command.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 <map>
8 #include <memory>
9 #include <optional>
10 #include <string>
11
12 #include "flutter/fml/logging.h"
13 #include "flutter/fml/macros.h"
14 #include "impeller/core/buffer_view.h"
15 #include "impeller/core/formats.h"
16 #include "impeller/core/resource_binder.h"
17 #include "impeller/core/sampler.h"
18 #include "impeller/core/shader_types.h"
19 #include "impeller/core/texture.h"
20 #include "impeller/core/vertex_buffer.h"
21 #include "impeller/geometry/rect.h"
22 #include "impeller/renderer/command.h"
23 #include "impeller/renderer/compute_pipeline_descriptor.h"
24 #include "impeller/renderer/pipeline.h"
25 #include "impeller/renderer/vertex_buffer_builder.h"
26 #include "impeller/tessellator/tessellator.h"
27
28 namespace impeller {
29
30 //------------------------------------------------------------------------------
31 /// @brief An object used to specify compute work to the GPU along with
32 /// references to resources the GPU will used when doing said work.
33 ///
34 /// To construct a valid command, follow these steps:
35 /// * Specify a valid pipeline.
36 /// * (Optional) Specify a debug label.
37 ///
38 /// Command are very lightweight objects and can be created
39 /// frequently and on demand. The resources referenced in commands
40 /// views into buffers managed by other allocators and resource
41 /// managers.
42 ///
43 struct ComputeCommand : public ResourceBinder {
44 //----------------------------------------------------------------------------
45 /// The pipeline to use for this command.
46 ///
47 std::shared_ptr<Pipeline<ComputePipelineDescriptor>> pipeline;
48 //----------------------------------------------------------------------------
49 /// The buffer, texture, and sampler bindings used by the compute pipeline
50 /// stage.
51 ///
52 Bindings bindings;
53
54 #ifdef IMPELLER_DEBUG
55 //----------------------------------------------------------------------------
56 /// The debugging label to use for the command.
57 ///
58 std::string label;
59 #endif // IMPELLER_DEBUG
60
61 // |ResourceBinder|
62 bool BindResource(ShaderStage stage,
63 const ShaderUniformSlot& slot,
64 const ShaderMetadata& metadata,
65 const BufferView& view) override;
66
67 // |ResourceBinder|
68 bool BindResource(ShaderStage stage,
69 const SampledImageSlot& slot,
70 const ShaderMetadata& metadata,
71 const std::shared_ptr<const Texture>& texture,
72 const std::shared_ptr<const Sampler>& sampler) override;
73
74 constexpr explicit operator bool() const {
75 return pipeline && pipeline->IsValid();
76 }
77 };
78
79 } // namespace impeller
pipeline.h
impeller::ShaderUniformSlot
Definition: shader_types.h:81
vertex_buffer.h
impeller::ShaderMetadata
Definition: shader_types.h:76
impeller::ComputeCommand::pipeline
std::shared_ptr< Pipeline< ComputePipelineDescriptor > > pipeline
Definition: compute_command.h:47
formats.h
impeller::ShaderStage
ShaderStage
Definition: shader_types.h:20
sampler.h
tessellator.h
command.h
resource_binder.h
impeller::ResourceBinder
An interface for binding resources. This is implemented by |Command| and |ComputeCommand| to make GPU...
Definition: resource_binder.h:27
compute_pipeline_descriptor.h
impeller::SampledImageSlot
Definition: shader_types.h:129
impeller::ComputeCommand::bindings
Bindings bindings
Definition: compute_command.h:52
impeller::ComputeCommand::BindResource
bool BindResource(ShaderStage stage, const ShaderUniformSlot &slot, const ShaderMetadata &metadata, const BufferView &view) override
Definition: compute_command.cc:14
impeller::ComputeCommand
An object used to specify compute work to the GPU along with references to resources the GPU will use...
Definition: compute_command.h:43
impeller::BufferView
Definition: buffer_view.h:13
buffer_view.h
rect.h
texture.h
shader_types.h
impeller
Definition: aiks_context.cc:10
impeller::Bindings
Definition: command.h:77
vertex_buffer_builder.h