Blender V5.3
vk_framebuffer.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2022 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
11#include "BLI_array.hh"
12#include "BLI_math_vector.hh"
13#include "BLI_span.hh"
14#include "BLI_vector.hh"
15
17
19#include "vk_common.hh"
20#include "vk_image_view.hh"
21
22namespace blender::gpu {
23class VKContext;
24
25class VKFrameBuffer : public FrameBuffer {
26 private:
28 bool srgb_;
29 bool enabled_srgb_;
30 bool is_rendering_ = false;
31
32 VkFormat depth_attachment_format_ = VK_FORMAT_UNDEFINED;
33 VkFormat stencil_attachment_format_ = VK_FORMAT_UNDEFINED;
34 Vector<VkFormat, GPU_FB_MAX_COLOR_ATTACHMENT> color_attachment_formats_;
35
38
39 public:
43 VKFrameBuffer(const char *name);
44 virtual ~VKFrameBuffer();
45
46 void bind(bool enabled_srgb) override;
47 bool check(char err_out[256]) override;
48 void clear(GPUFrameBufferBits buffers,
49 const double4 clear_color,
50 float clear_depth,
51 uint clear_stencil) override;
52 void clear_multi(Span<double4> clear_cols) override;
53 void clear_attachment(GPUAttachmentType type, const double4 clear_value) override;
54
56
57 protected:
58 void subpass_transition_impl(const GPUAttachmentState depth_attachment_state,
59 Span<GPUAttachmentState> color_attachment_states) override;
60
61 public:
62 void read(GPUFrameBufferBits planes,
63 eGPUDataFormat format,
64 const int area[4],
65 int channel_len,
66 int slot,
67 void *r_data) override;
68
69 void blit_to(GPUFrameBufferBits planes,
70 int src_slot,
71 FrameBuffer *dst,
72 int dst_slot,
73 int dst_offset_x,
74 int dst_offset_y) override;
75 uint32_t viewport_size() const;
78 void render_area_update(VkRect2D &render_area) const;
79 VkFormat depth_attachment_format_get() const;
80 VkFormat stencil_attachment_format_get() const;
85
95 void update_size();
96
97 void update_srgb();
98
106 void rendering_reset();
107
112 void rendering_ensure(VKContext &context);
113 void rendering_ensure_dynamic_rendering(VKContext &context, const VKExtensions &extensions);
114
119 void rendering_end(VKContext &context);
120
121 bool is_rendering() const
122 {
123 return is_rendering_;
124 }
125
134
135 private:
136 /* Clearing attachments */
137 void build_clear_attachments_depth_stencil(
138 GPUFrameBufferBits buffers,
139 float clear_depth,
140 uint32_t clear_stencil,
141 render_graph::VKClearAttachmentsNode::CreateInfo &clear_attachments) const;
142 void build_clear_attachments_color(
143 Span<double4> clear_colors,
144 render_graph::VKClearAttachmentsNode::CreateInfo &clear_attachments) const;
146};
147
148static inline VKFrameBuffer *unwrap(gpu::FrameBuffer *framebuffer)
149{
150 return static_cast<VKFrameBuffer *>(framebuffer);
151}
152
153} // namespace blender::gpu
FrameBuffer(const char *name)
void rendering_ensure_dynamic_rendering(VKContext &context, const VKExtensions &extensions)
void rendering_ensure(VKContext &context)
VKFrameBuffer(const char *name)
VkFormat stencil_attachment_format_get() const
void subpass_transition_impl(const GPUAttachmentState depth_attachment_state, Span< GPUAttachmentState > color_attachment_states) override
void read(GPUFrameBufferBits planes, eGPUDataFormat format, const int area[4], int channel_len, int slot, void *r_data) override
void render_area_update(VkRect2D &render_area) const
void bind(bool enabled_srgb) override
VkFormat depth_attachment_format_get() const
void clear_multi(Span< double4 > clear_cols) override
void blit_to(GPUFrameBufferBits planes, int src_slot, FrameBuffer *dst, int dst_slot, int dst_offset_x, int dst_offset_y) override
void clear(GPUFrameBufferBits buffers, const double4 clear_color, float clear_depth, uint clear_stencil) override
void rendering_end(VKContext &context)
void vk_viewports_append(Vector< VkViewport, GPU_MAX_VIEWPORTS > &r_viewports) const
bool check(char err_out[256]) override
void attachment_set_loadstore_op(GPUAttachmentType type, GPULoadStore) override
int color_attachments_resource_size() const
void vk_render_areas_append(Vector< VkRect2D, GPU_MAX_VIEWPORTS > &r_render_areas) const
void clear_attachment(GPUAttachmentType type, const double4 clear_value) override
Span< VkFormat > color_attachment_formats_get() const
Get color attachment formats in used by the framebuffer.
static Context * unwrap(GPUContext *ctx)
unsigned int uint
Definition BKE_text.h:55
unsigned int uint32_t
Definition BKE_text.h:81
VecBase< double, 4 > double4