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