Flutter Impeller
compute_pass_vk.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_BACKEND_VULKAN_COMPUTE_PASS_VK_H_
6 #define FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_COMPUTE_PASS_VK_H_
7 
11 
12 namespace impeller {
13 
14 class CommandBufferVK;
15 
16 class ComputePassVK final : public ComputePass {
17  public:
18  // |ComputePass|
19  ~ComputePassVK() override;
20 
21  private:
22  friend class CommandBufferVK;
23 
24  std::shared_ptr<CommandBufferVK> command_buffer_;
25  std::string label_;
26  std::array<uint32_t, 3> max_wg_size_ = {};
27  bool is_valid_ = false;
28 
29  // Per-command state.
30  std::array<vk::DescriptorImageInfo, kMaxBindings> image_workspace_;
31  std::array<vk::DescriptorBufferInfo, kMaxBindings> buffer_workspace_;
32  std::array<vk::WriteDescriptorSet, kMaxBindings + kMaxBindings>
33  write_workspace_;
34  size_t bound_image_offset_ = 0u;
35  size_t bound_buffer_offset_ = 0u;
36  size_t descriptor_write_offset_ = 0u;
37  bool has_label_ = false;
38  bool pipeline_valid_ = false;
39  vk::DescriptorSet descriptor_set_ = {};
40  vk::PipelineLayout pipeline_layout_ = {};
41 
42  ComputePassVK(std::shared_ptr<const Context> context,
43  std::shared_ptr<CommandBufferVK> command_buffer);
44 
45  // |ComputePass|
46  bool IsValid() const override;
47 
48  // |ComputePass|
49  void OnSetLabel(const std::string& label) override;
50 
51  // |ComputePass|
52  bool EncodeCommands() const override;
53 
54  // |ComputePass|
55  void SetCommandLabel(std::string_view label) override;
56 
57  // |ComputePass|
58  void SetPipeline(const std::shared_ptr<Pipeline<ComputePipelineDescriptor>>&
59  pipeline) override;
60 
61  // |ComputePass|
62  void AddBufferMemoryBarrier() override;
63 
64  // |ComputePass|
65  void AddTextureMemoryBarrier() override;
66 
67  // |ComputePass|
68  fml::Status Compute(const ISize& grid_size) override;
69 
70  // |ResourceBinder|
71  bool BindResource(ShaderStage stage,
73  const ShaderUniformSlot& slot,
74  const ShaderMetadata* metadata,
75  BufferView view) override;
76 
77  // |ResourceBinder|
78  bool BindResource(ShaderStage stage,
80  const SampledImageSlot& slot,
81  const ShaderMetadata* metadata,
82  std::shared_ptr<const Texture> texture,
83  raw_ptr<const Sampler> sampler) override;
84 
85  bool BindResource(size_t binding, DescriptorType type, BufferView view);
86 };
87 
88 } // namespace impeller
89 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_COMPUTE_PASS_VK_H_
GLenum type
Compute passes encode compute shader into the underlying command buffer.
Definition: compute_pass.h:23
ISize64 ISize
Definition: size.h:162