| Flutter Impeller |

render_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_RENDER_PASS_VK_H_
6 #define FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_RENDER_PASS_VK_H_
7
8 #include "impeller/core/buffer_view.h"
9 #include "impeller/renderer/backend/vulkan/context_vk.h"
10 #include "impeller/renderer/backend/vulkan/pipeline_vk.h"
11 #include "impeller/renderer/backend/vulkan/shared_object_vk.h"
12 #include "impeller/renderer/command_buffer.h"
13 #include "impeller/renderer/render_pass.h"
14 #include "impeller/renderer/render_target.h"
15
16 namespace impeller {
17
18 class CommandBufferVK;
19 class SamplerVK;
20
21 class RenderPassVK final : public RenderPass {
22 public:
23 // |RenderPass|
24 ~RenderPassVK() override;
25
26 private:
27 friend class CommandBufferVK;
28
29 std::shared_ptr<CommandBufferVK> command_buffer_;
30 std::string debug_label_;
31 SharedHandleVK<vk::RenderPass> render_pass_;
32 bool is_valid_ = false;
33
34 vk::CommandBuffer command_buffer_vk_;
35 std::shared_ptr<Texture> color_image_vk_;
36 std::shared_ptr<Texture> resolve_image_vk_;
37
38 // Per-command state.
39 std::array<vk::DescriptorImageInfo, kMaxBindings> image_workspace_;
40 std::array<vk::DescriptorBufferInfo, kMaxBindings> buffer_workspace_;
41 std::array<vk::WriteDescriptorSet, kMaxBindings + kMaxBindings>
42 write_workspace_;
43 size_t bound_image_offset_ = 0u;
44 size_t bound_buffer_offset_ = 0u;
45 size_t descriptor_write_offset_ = 0u;
46 size_t instance_count_ = 1u;
47 size_t base_vertex_ = 0u;
48 size_t element_count_ = 0u;
49 bool has_index_buffer_ = false;
50 bool has_label_ = false;
51 PipelineRef pipeline_ = PipelineRef(nullptr);
52 bool pipeline_uses_input_attachments_ = false;
53 std::shared_ptr<SamplerVK> immutable_sampler_;
54
55 RenderPassVK(const std::shared_ptr<const Context>& context,
56 const RenderTarget& target,
57 std::shared_ptr<CommandBufferVK> command_buffer);
58
59 // |RenderPass|
60 void SetPipeline(PipelineRef pipeline) override;
61
62 // |RenderPass|
63 void SetCommandLabel(std::string_view label) override;
64
65 // |RenderPass|
66 void SetStencilReference(uint32_t value) override;
67
68 // |RenderPass|
69 void SetBaseVertex(uint64_t value) override;
70
71 // |RenderPass|
72 void SetViewport(Viewport viewport) override;
73
74 // |RenderPass|
75 void SetScissor(IRect scissor) override;
76
77 // |RenderPass|
78 void SetElementCount(size_t count) override;
79
80 // |RenderPass|
81 void SetInstanceCount(size_t count) override;
82
83 // |RenderPass|
84 bool SetVertexBuffer(BufferView vertex_buffers[],
85 size_t vertex_buffer_count) override;
86
87 // |RenderPass|
88 bool SetIndexBuffer(BufferView index_buffer, IndexType index_type) override;
89
90 // |RenderPass|
91 fml::Status Draw() override;
92
93 // |ResourceBinder|
94 bool BindResource(ShaderStage stage,
95 DescriptorType type,
96 const ShaderUniformSlot& slot,
97 const ShaderMetadata* metadata,
98 BufferView view) override;
99
100 // |ResourceBinder|
101 bool BindResource(ShaderStage stage,
102 DescriptorType type,
103 const SampledImageSlot& slot,
104 const ShaderMetadata* metadata,
105 std::shared_ptr<const Texture> texture,
106 raw_ptr<const Sampler> sampler) override;
107
108 // |RenderPass|
109 bool BindDynamicResource(ShaderStage stage,
110 DescriptorType type,
111 const ShaderUniformSlot& slot,
112 std::unique_ptr<ShaderMetadata> metadata,
113 BufferView view) override;
114
115 // |RenderPass|
116 bool BindDynamicResource(ShaderStage stage,
117 DescriptorType type,
118 const SampledImageSlot& slot,
119 std::unique_ptr<ShaderMetadata> metadata,
120 std::shared_ptr<const Texture> texture,
121 raw_ptr<const Sampler> sampler) override;
122
123 bool BindResource(size_t binding, DescriptorType type, BufferView view);
124
125 // |RenderPass|
126 bool IsValid() const override;
127
128 // |RenderPass|
129 void OnSetLabel(std::string_view label) override;
130
131 // |RenderPass|
132 bool OnEncodeCommands(const Context& context) const override;
133
134 SharedHandleVK<vk::RenderPass> CreateVKRenderPass(
135 const ContextVK& context,
136 const SharedHandleVK<vk::RenderPass>& recycled_renderpass,
137 const std::shared_ptr<CommandBufferVK>& command_buffer) const;
138
139 SharedHandleVK<vk::Framebuffer> CreateVKFramebuffer(
140 const ContextVK& context,
141 const vk::RenderPass& pass) const;
142
143 RenderPassVK(const RenderPassVK&) = delete;
144
145 RenderPassVK& operator=(const RenderPassVK&) = delete;
146 };
147
148 } // namespace impeller
149
150 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_RENDER_PASS_VK_H_
type
GLenum type
Definition: blit_command_gles.cc:151
buffer_view.h
impeller::CommandBufferVK
Definition: command_buffer_vk.h:27
impeller::Context
To do anything rendering related with Impeller, you need a context.
Definition: context.h:46
impeller::ContextVK
Definition: context_vk.h:66
impeller::RenderPass
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition: render_pass.h:30
impeller::RenderPassVK
Definition: render_pass_vk.h:21
impeller::RenderPassVK::~RenderPassVK
~RenderPassVK() override
impeller::RenderTarget
Definition: render_target.h:38
impeller::raw_ptr< Pipeline< PipelineDescriptor > >
command_buffer.h
context_vk.h
value
int32_t value
Definition: dl_golden_unittests.cc:444
impeller
Definition: allocation.cc:12
impeller::IndexType
IndexType
Definition: formats.h:343
impeller::SharedHandleVK
std::shared_ptr< SharedObjectVKT< T > > SharedHandleVK
Definition: shared_object_vk.h:53
impeller::PipelineRef
raw_ptr< Pipeline< PipelineDescriptor > > PipelineRef
A raw ptr to a pipeline object.
Definition: pipeline.h:86
impeller::ShaderStage
ShaderStage
Definition: shader_types.h:22
impeller::DescriptorType
DescriptorType
Definition: shader_types.h:158
pipeline_vk.h
render_pass.h
render_target.h
shared_object_vk.h
impeller::BufferView
Definition: buffer_view.h:19
impeller::SampledImageSlot
Metadata required to bind a combined texture and sampler.
Definition: shader_types.h:98
impeller::ShaderMetadata
Definition: shader_types.h:72
impeller::ShaderUniformSlot
Metadata required to bind a buffer.
Definition: shader_types.h:81
impeller::TRect
Definition: rect.h:122
impeller::Viewport
Definition: formats.h:403