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