| 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 #include "vulkan/vulkan_handles.hpp"
16
17 namespace impeller {
18
19 class CommandBufferVK;
20 class SamplerVK;
21
22 class RenderPassVK final : public RenderPass {
23 public:
24 // |RenderPass|
25 ~RenderPassVK() override;
26
27 private:
28 friend class CommandBufferVK;
29
30 std::shared_ptr<CommandBufferVK> command_buffer_;
31 std::string debug_label_;
32 SharedHandleVK<vk::RenderPass> render_pass_;
33 bool is_valid_ = false;
34
35 vk::CommandBuffer command_buffer_vk_;
36 std::shared_ptr<Texture> color_image_vk_;
37 std::shared_ptr<Texture> resolve_image_vk_;
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 vertex_count_ = 0u;
50 bool has_index_buffer_ = false;
51 bool has_label_ = false;
52 const Pipeline<PipelineDescriptor>* pipeline_;
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(
62 const std::shared_ptr<Pipeline<PipelineDescriptor>>& pipeline) override;
63
64 // |RenderPass|
65 void SetCommandLabel(std::string_view label) override;
66
67 // |RenderPass|
68 void SetStencilReference(uint32_t value) override;
69
70 // |RenderPass|
71 void SetBaseVertex(uint64_t value) override;
72
73 // |RenderPass|
74 void SetViewport(Viewport viewport) override;
75
76 // |RenderPass|
77 void SetScissor(IRect scissor) override;
78
79 // |RenderPass|
80 void SetInstanceCount(size_t count) override;
81
82 // |RenderPass|
83 bool SetVertexBuffer(VertexBuffer buffer) override;
84
85 // |RenderPass|
86 fml::Status Draw() override;
87
88 // |RenderPass|
89 void ReserveCommands(size_t command_count) override {}
90
91 // |ResourceBinder|
92 bool BindResource(ShaderStage stage,
93 DescriptorType type,
94 const ShaderUniformSlot& slot,
95 const ShaderMetadata& metadata,
96 BufferView view) override;
97
98 // |RenderPass|
99 bool BindResource(ShaderStage stage,
100 DescriptorType type,
101 const ShaderUniformSlot& slot,
102 const std::shared_ptr<const ShaderMetadata>& metadata,
103 BufferView view) override;
104
105 // |ResourceBinder|
106 bool BindResource(ShaderStage stage,
107 DescriptorType type,
108 const SampledImageSlot& slot,
109 const ShaderMetadata& metadata,
110 std::shared_ptr<const Texture> texture,
111 const std::unique_ptr<const Sampler>& sampler) override;
112
113 bool BindResource(size_t binding,
114 DescriptorType type,
115 const BufferView& view);
116
117 // |RenderPass|
118 bool IsValid() const override;
119
120 // |RenderPass|
121 void OnSetLabel(std::string label) override;
122
123 // |RenderPass|
124 bool OnEncodeCommands(const Context& context) const override;
125
126 SharedHandleVK<vk::RenderPass> CreateVKRenderPass(
127 const ContextVK& context,
128 const SharedHandleVK<vk::RenderPass>& recycled_renderpass,
129 const std::shared_ptr<CommandBufferVK>& command_buffer) const;
130
131 SharedHandleVK<vk::Framebuffer> CreateVKFramebuffer(
132 const ContextVK& context,
133 const vk::RenderPass& pass) const;
134
135 RenderPassVK(const RenderPassVK&) = delete;
136
137 RenderPassVK& operator=(const RenderPassVK&) = delete;
138 };
139
140 } // namespace impeller
141
142 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_RENDER_PASS_VK_H_
impeller::Pipeline< PipelineDescriptor >
impeller::ShaderUniformSlot
Metadata required to bind a buffer.
Definition: shader_types.h:81
shared_object_vk.h
impeller::ShaderMetadata
Definition: shader_types.h:72
impeller::VertexBuffer
Definition: vertex_buffer.h:13
impeller::ShaderStage
ShaderStage
Definition: shader_types.h:22
pipeline_vk.h
render_pass.h
impeller::SampledImageSlot
Metadata required to bind a combined texture and sampler.
Definition: shader_types.h:98
type
GLenum type
Definition: blit_command_gles.cc:126
impeller::RenderTarget
Definition: render_target.h:38
impeller::CommandBufferVK
Definition: command_buffer_vk.h:18
impeller::ContextVK
Definition: context_vk.h:42
impeller::RenderPass
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition: render_pass.h:33
impeller::Viewport
Definition: formats.h:397
command_buffer.h
impeller::BufferView
Definition: buffer_view.h:15
impeller::Context
To do anything rendering related with Impeller, you need a context.
Definition: context.h:45
impeller::RenderPassVK
Definition: render_pass_vk.h:22
buffer_view.h
impeller::SharedHandleVK
std::shared_ptr< SharedObjectVKT< T > > SharedHandleVK
Definition: shared_object_vk.h:53
impeller::RenderPassVK::~RenderPassVK
~RenderPassVK() override
render_target.h
context_vk.h
impeller
Definition: aiks_blend_unittests.cc:18
impeller::TRect
Definition: rect.h:122
impeller::DescriptorType
DescriptorType
Definition: shader_types.h:153