| 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 uint32_t current_stencil_ = 0;
38
39 // Per-command state.
40 std::array<vk::DescriptorImageInfo, kMaxBindings> image_workspace_;
41 std::array<vk::DescriptorBufferInfo, kMaxBindings> buffer_workspace_;
42 std::array<vk::WriteDescriptorSet, kMaxBindings + kMaxBindings>
43 write_workspace_;
44 size_t bound_image_offset_ = 0u;
45 size_t bound_buffer_offset_ = 0u;
46 size_t descriptor_write_offset_ = 0u;
47 size_t instance_count_ = 1u;
48 size_t base_vertex_ = 0u;
49 size_t element_count_ = 0u;
50 bool has_index_buffer_ = false;
51 bool has_label_ = false;
52 PipelineRef pipeline_ = PipelineRef(nullptr);
53 bool pipeline_uses_input_attachments_ = false;
54 std::shared_ptr<SamplerVK> immutable_sampler_;
55
56 RenderPassVK(const std::shared_ptr<const Context>& context,
57 const RenderTarget& target,
58 std::shared_ptr<CommandBufferVK> command_buffer);
59
60 // |RenderPass|
61 void SetPipeline(PipelineRef pipeline) override;
62
63 // |RenderPass|
64 void SetCommandLabel(std::string_view label) override;
65
66 // |RenderPass|
67 void SetStencilReference(uint32_t value) override;
68
69 // |RenderPass|
70 void SetBaseVertex(uint64_t value) override;
71
72 // |RenderPass|
73 void SetViewport(Viewport viewport) override;
74
75 // |RenderPass|
76 void SetScissor(IRect scissor) override;
77
78 // |RenderPass|
79 void SetElementCount(size_t count) override;
80
81 // |RenderPass|
82 void SetInstanceCount(size_t count) override;
83
84 // |RenderPass|
85 bool SetVertexBuffer(BufferView vertex_buffers[],
86 size_t vertex_buffer_count) override;
87
88 // |RenderPass|
89 bool SetIndexBuffer(BufferView index_buffer, IndexType index_type) override;
90
91 // |RenderPass|
92 fml::Status Draw() override;
93
94 // |ResourceBinder|
95 bool BindResource(ShaderStage stage,
96 DescriptorType type,
97 const ShaderUniformSlot& slot,
98 const ShaderMetadata* metadata,
99 BufferView view) override;
100
101 // |ResourceBinder|
102 bool BindResource(ShaderStage stage,
103 DescriptorType type,
104 const SampledImageSlot& slot,
105 const ShaderMetadata* metadata,
106 std::shared_ptr<const Texture> texture,
107 raw_ptr<const Sampler> sampler) override;
108
109 // |RenderPass|
110 bool BindDynamicResource(ShaderStage stage,
111 DescriptorType type,
112 const ShaderUniformSlot& slot,
113 std::unique_ptr<ShaderMetadata> metadata,
114 BufferView view) override;
115
116 // |RenderPass|
117 bool BindDynamicResource(ShaderStage stage,
118 DescriptorType type,
119 const SampledImageSlot& slot,
120 std::unique_ptr<ShaderMetadata> metadata,
121 std::shared_ptr<const Texture> texture,
122 raw_ptr<const Sampler> sampler) override;
123
124 bool BindResource(size_t binding, DescriptorType type, BufferView view);
125
126 // |RenderPass|
127 bool IsValid() const override;
128
129 // |RenderPass|
130 void OnSetLabel(std::string_view label) override;
131
132 // |RenderPass|
133 bool OnEncodeCommands(const Context& context) const override;
134
135 SharedHandleVK<vk::RenderPass> CreateVKRenderPass(
136 const ContextVK& context,
137 const SharedHandleVK<vk::RenderPass>& recycled_renderpass,
138 const std::shared_ptr<CommandBufferVK>& command_buffer,
139 bool is_swapchain) const;
140
141 SharedHandleVK<vk::Framebuffer> CreateVKFramebuffer(
142 const ContextVK& context,
143 const vk::RenderPass& pass) const;
144
145 RenderPassVK(const RenderPassVK&) = delete;
146
147 RenderPassVK& operator=(const RenderPassVK&) = delete;
148 };
149
150 } // namespace impeller
151
152 #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:65
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
value
int32_t value
Definition: dl_golden_unittests.cc:459
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:88
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
context_vk.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