Blender V4.3
vk_framebuffer.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2022 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#include "vk_framebuffer.hh"
10#include "vk_backend.hh"
11#include "vk_context.hh"
12#include "vk_memory.hh"
13#include "vk_state_manager.hh"
14#include "vk_texture.hh"
15
16namespace blender::gpu {
17
22{
23 return {GPU_LOADACTION_LOAD, GPU_STOREACTION_STORE, {0.0f, 0.0f, 0.0f, 0.0f}};
24}
25
26/* -------------------------------------------------------------------- */
31 : FrameBuffer(name),
34{
35 size_set(1, 1);
36 srgb_ = false;
37 enabled_srgb_ = false;
38}
39
41{
42 VKContext &context = *VKContext::get();
43 if (context.active_framebuffer_get() == this) {
44 context.deactivate_framebuffer();
45 }
46}
47
50void VKFrameBuffer::bind(bool enabled_srgb)
51{
52 VKContext &context = *VKContext::get();
53 /* Updating attachments can issue pipeline barriers, this should be done outside the render pass.
54 * When done inside a render pass there should be a self-dependency between sub-passes on the
55 * active render pass. As the active render pass isn't aware of the new render pass (and should
56 * not) it is better to deactivate it before updating the attachments. For more information check
57 * `VkSubpassDependency`. */
58 if (context.has_active_framebuffer()) {
59 context.deactivate_framebuffer();
60 }
61
62 context.activate_framebuffer(*this);
63 enabled_srgb_ = enabled_srgb;
64 Shader::set_framebuffer_srgb_target(enabled_srgb && srgb_);
65 load_stores.fill(default_load_store());
66 attachment_states_.fill(GPU_ATTACHMENT_WRITE);
69}
70
72{
74
75 int index = 0;
76 for (VkViewport &viewport : viewports) {
77 viewport.x = viewport_[index][0];
78 viewport.y = viewport_[index][1];
79 viewport.width = viewport_[index][2];
80 viewport.height = viewport_[index][3];
81 viewport.minDepth = 0.0f;
82 viewport.maxDepth = 1.0f;
83 index++;
84 }
85 return viewports;
86}
87
89{
91
92 for (VkRect2D &render_area : render_areas) {
93 if (scissor_test_get()) {
94 int scissor_rect[4];
95 scissor_get(scissor_rect);
96 render_area.offset.x = clamp_i(scissor_rect[0], 0, width_);
97 render_area.offset.y = clamp_i(scissor_rect[1], 0, height_);
98 render_area.extent.width = clamp_i(scissor_rect[2], 1, width_ - scissor_rect[0]);
99 render_area.extent.height = clamp_i(scissor_rect[3], 1, height_ - scissor_rect[1]);
100 }
101 else {
102 render_area.offset.x = 0;
103 render_area.offset.y = 0;
104 render_area.extent.width = width_;
105 render_area.extent.height = height_;
106 }
107 }
108 return render_areas;
109}
110
111bool VKFrameBuffer::check(char /*err_out*/[256])
112{
113 return true;
114}
115
116void VKFrameBuffer::build_clear_attachments_depth_stencil(
118 float clear_depth,
119 uint32_t clear_stencil,
121{
122 VkImageAspectFlags aspect_mask = (buffers & GPU_DEPTH_BIT ? VK_IMAGE_ASPECT_DEPTH_BIT : 0) |
123 (buffers & GPU_STENCIL_BIT ? VK_IMAGE_ASPECT_STENCIL_BIT : 0);
124
125 VkClearAttachment &clear_attachment =
126 clear_attachments.attachments[clear_attachments.attachment_count++];
127 clear_attachment.aspectMask = aspect_mask;
128 clear_attachment.clearValue.depthStencil.depth = clear_depth;
129 clear_attachment.clearValue.depthStencil.stencil = clear_stencil;
130 clear_attachment.colorAttachment = 0;
131}
132
133void VKFrameBuffer::build_clear_attachments_color(
134 const float (*clear_colors)[4],
135 const bool multi_clear_colors,
137{
138 int color_index = 0;
139 for (int color_slot = 0; color_slot < GPU_FB_MAX_COLOR_ATTACHMENT; color_slot++) {
140 const GPUAttachment &attachment = attachments_[GPU_FB_COLOR_ATTACHMENT0 + color_slot];
141 if (attachment.tex == nullptr) {
142 continue;
143 }
144 VkClearAttachment &clear_attachment =
145 clear_attachments.attachments[clear_attachments.attachment_count++];
146 clear_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
147 clear_attachment.colorAttachment = color_slot;
148 eGPUDataFormat data_format = to_data_format(GPU_texture_format(attachment.tex));
149 clear_attachment.clearValue.color = to_vk_clear_color_value(data_format,
150 &clear_colors[color_index]);
151
152 color_index += multi_clear_colors ? 1 : 0;
153 }
154}
155
156/* -------------------------------------------------------------------- */
161{
162 VKContext &context = *VKContext::get();
163 rendering_ensure(context);
164 context.render_graph.add_node(clear_attachments);
165}
166
168 const float clear_color[4],
169 float clear_depth,
170 uint clear_stencil)
171{
173 clear_attachments.vk_clear_rect.rect = vk_render_areas_get()[0];
174 clear_attachments.vk_clear_rect.baseArrayLayer = 0;
175 clear_attachments.vk_clear_rect.layerCount = 1;
176
178 VKContext &context = *VKContext::get();
179 eGPUWriteMask needed_mask = GPU_WRITE_NONE;
180 if (buffers & GPU_DEPTH_BIT) {
181 needed_mask |= GPU_WRITE_DEPTH;
182 }
183 if (buffers & GPU_STENCIL_BIT) {
184 needed_mask |= GPU_WRITE_STENCIL;
185 }
186
187 /* Clearing depth via vkCmdClearAttachments requires a render pass with write depth or stencil
188 * enabled. When not enabled, clearing should be done via texture directly. */
189 /* WORKAROUND: Clearing depth attachment when using dynamic rendering are not working on AMD
190 * official drivers.
191 * See #129265 */
192 if ((context.state_manager_get().state.write_mask & needed_mask) == needed_mask &&
194 {
195 build_clear_attachments_depth_stencil(
196 buffers, clear_depth, clear_stencil, clear_attachments);
197 }
198 else {
199 VKTexture *depth_texture = unwrap(unwrap(depth_tex()));
200 if (depth_texture != nullptr) {
201 depth_texture->clear_depth_stencil(buffers, clear_depth, clear_stencil);
202 }
203 }
204 }
205 if (buffers & GPU_COLOR_BIT) {
206 float clear_color_single[4];
207 copy_v4_v4(clear_color_single, clear_color);
208 build_clear_attachments_color(&clear_color_single, false, clear_attachments);
209 }
210
211 if (clear_attachments.attachment_count) {
212 clear(clear_attachments);
213 }
214}
215
216void VKFrameBuffer::clear_multi(const float (*clear_color)[4])
217{
219 clear_attachments.vk_clear_rect.rect = vk_render_areas_get()[0];
220 clear_attachments.vk_clear_rect.baseArrayLayer = 0;
221 clear_attachments.vk_clear_rect.layerCount = 1;
222
223 build_clear_attachments_color(clear_color, true, clear_attachments);
224 if (clear_attachments.attachment_count) {
225 clear(clear_attachments);
226 }
227}
228
230 eGPUDataFormat /*data_format*/,
231 const void * /*clear_value*/)
232{
233 /* Clearing of a single attachment was added to implement `clear_multi` in OpenGL. As
234 * `clear_multi` is supported in Vulkan it isn't needed to implement this method.
235 */
237}
238
241/* -------------------------------------------------------------------- */
246{
247 load_stores[type] = ls;
248}
249
250static VkAttachmentLoadOp to_vk_attachment_load_op(eGPULoadOp load_op)
251{
252 switch (load_op) {
254 return VK_ATTACHMENT_LOAD_OP_DONT_CARE;
256 return VK_ATTACHMENT_LOAD_OP_CLEAR;
258 return VK_ATTACHMENT_LOAD_OP_LOAD;
259 }
261 return VK_ATTACHMENT_LOAD_OP_LOAD;
262}
263
264static VkAttachmentStoreOp to_vk_attachment_store_op(eGPUStoreOp store_op)
265{
266 switch (store_op) {
268 return VK_ATTACHMENT_STORE_OP_DONT_CARE;
270 return VK_ATTACHMENT_STORE_OP_STORE;
271 }
273 return VK_ATTACHMENT_STORE_OP_STORE;
274}
275
276static void set_load_store(VkRenderingAttachmentInfo &r_rendering_attachment,
277 const GPULoadStore &ls)
278{
279 copy_v4_v4(r_rendering_attachment.clearValue.color.float32, ls.clear_value);
280 r_rendering_attachment.loadOp = to_vk_attachment_load_op(ls.load_action);
281 r_rendering_attachment.storeOp = to_vk_attachment_store_op(ls.store_action);
282}
283
286/* -------------------------------------------------------------------- */
291 Span<GPUAttachmentState> color_attachment_states)
292{
293 /* TODO: this is a fallback implementation. We should also provide support for
294 * `VK_EXT_dynamic_rendering_local_read`. This extension is only supported on Windows
295 * platforms (2024Q2), but would reduce the rendering synchronization overhead. */
296 VKContext &context = *VKContext::get();
297 if (is_rendering_) {
298 rendering_end(context);
299
300 /* TODO: this might need a better implementation:
301 * READ -> DONTCARE
302 * WRITE -> LOAD, STORE based on previous value.
303 * IGNORE -> DONTCARE -> IGNORE */
304 load_stores.fill(default_load_store());
305 }
306
307 attachment_states_[GPU_FB_DEPTH_ATTACHMENT] = depth_attachment_state;
308 attachment_states_.as_mutable_span()
309 .slice(GPU_FB_COLOR_ATTACHMENT0, color_attachment_states.size())
310 .copy_from(color_attachment_states);
311 for (int index : IndexRange(color_attachment_states.size())) {
312 if (color_attachment_states[index] == GPU_ATTACHMENT_READ) {
313 VKTexture *texture = unwrap(unwrap(color_tex(index)));
314 if (texture) {
315 context.state_manager_get().texture_bind(
316 texture, GPUSamplerState::default_sampler(), index);
317 }
318 }
319 }
320}
321
324/* -------------------------------------------------------------------- */
330 const int area[4],
331 int /*channel_len*/,
332 int slot,
333 void *r_data)
334{
335 GPUAttachment *attachment = nullptr;
336 switch (plane) {
337 case GPU_COLOR_BIT:
338 attachment = &attachments_[GPU_FB_COLOR_ATTACHMENT0 + slot];
339 break;
340
341 case GPU_DEPTH_BIT:
345 break;
346
347 default:
349 return;
350 }
351
352 VKTexture *texture = unwrap(unwrap(attachment->tex));
353 BLI_assert_msg(texture,
354 "Trying to read back texture from framebuffer, but no texture is available in "
355 "requested slot.");
356 if (texture == nullptr) {
357 return;
358 }
359 const int region[6] = {area[0], area[1], 0, area[0] + area[2], area[1] + area[3], 1};
360 IndexRange layers(max_ii(attachment->layer, 0), 1);
361 texture->read_sub(0, format, region, layers, r_data);
362}
363
366/* -------------------------------------------------------------------- */
370static void blit_aspect(VKContext &context,
371 VKTexture &dst_texture,
372 VKTexture &src_texture,
373 int dst_offset_x,
374 int dst_offset_y,
375 VkImageAspectFlags image_aspect)
376{
377 /* Prefer texture copy, as some platforms don't support using D32_SFLOAT_S8_UINT to be used as
378 * a blit destination. */
379 if (dst_offset_x == 0 && dst_offset_y == 0 &&
380 dst_texture.device_format_get() == src_texture.device_format_get() &&
381 src_texture.width_get() == dst_texture.width_get() &&
382 src_texture.height_get() == dst_texture.height_get())
383 {
384 src_texture.copy_to(dst_texture, image_aspect);
385 return;
386 }
387
389
390 blit_image.src_image = src_texture.vk_image_handle();
391 blit_image.dst_image = dst_texture.vk_image_handle();
392 blit_image.filter = VK_FILTER_NEAREST;
393
394 VkImageBlit &region = blit_image.region;
395 region.srcSubresource.aspectMask = image_aspect;
396 region.srcSubresource.mipLevel = 0;
397 region.srcSubresource.baseArrayLayer = 0;
398 region.srcSubresource.layerCount = 1;
399 region.srcOffsets[0].x = 0;
400 region.srcOffsets[0].y = 0;
401 region.srcOffsets[0].z = 0;
402 region.srcOffsets[1].x = src_texture.width_get();
403 region.srcOffsets[1].y = src_texture.height_get();
404 region.srcOffsets[1].z = 1;
405
406 region.dstSubresource.aspectMask = image_aspect;
407 region.dstSubresource.mipLevel = 0;
408 region.dstSubresource.baseArrayLayer = 0;
409 region.dstSubresource.layerCount = 1;
410 region.dstOffsets[0].x = min_ii(dst_offset_x, dst_texture.width_get());
411 region.dstOffsets[0].y = min_ii(dst_offset_y, dst_texture.height_get());
412 region.dstOffsets[0].z = 0;
413 region.dstOffsets[1].x = min_ii(dst_offset_x + src_texture.width_get(), dst_texture.width_get());
414 region.dstOffsets[1].y = min_ii(dst_offset_y + src_texture.height_get(),
415 dst_texture.height_get());
416 region.dstOffsets[1].z = 1;
417
418 context.render_graph.add_node(blit_image);
419}
420
422 int src_slot,
423 FrameBuffer *dst,
424 int dst_slot,
425 int dst_offset_x,
426 int dst_offset_y)
427{
428 BLI_assert(dst);
430 "VKFrameBuffer::blit_to only supports a single color or depth aspect.");
431 UNUSED_VARS_NDEBUG(planes);
432
433 VKContext &context = *VKContext::get();
434 if (!context.has_active_framebuffer()) {
436 return;
437 }
438
439 VKFrameBuffer &dst_framebuffer = *unwrap(dst);
440 if (planes & GPU_COLOR_BIT) {
441 const GPUAttachment &src_attachment = attachments_[GPU_FB_COLOR_ATTACHMENT0 + src_slot];
442 const GPUAttachment &dst_attachment =
443 dst_framebuffer.attachments_[GPU_FB_COLOR_ATTACHMENT0 + dst_slot];
444 if (src_attachment.tex && dst_attachment.tex) {
445 VKTexture &src_texture = *unwrap(unwrap(src_attachment.tex));
446 VKTexture &dst_texture = *unwrap(unwrap(dst_attachment.tex));
447 blit_aspect(context,
448 dst_texture,
449 src_texture,
450 dst_offset_x,
451 dst_offset_y,
452 VK_IMAGE_ASPECT_COLOR_BIT);
453 }
454 }
455
456 if (planes & GPU_DEPTH_BIT) {
457 /* Retrieve source texture. */
461 const GPUAttachment &dst_attachment =
464 dst_framebuffer.attachments_[GPU_FB_DEPTH_ATTACHMENT];
465 if (src_attachment.tex && dst_attachment.tex) {
466 VKTexture &src_texture = *unwrap(unwrap(src_attachment.tex));
467 VKTexture &dst_texture = *unwrap(unwrap(dst_attachment.tex));
468 blit_aspect(context,
469 dst_texture,
470 src_texture,
471 dst_offset_x,
472 dst_offset_y,
473 VK_IMAGE_ASPECT_DEPTH_BIT);
474 }
475 }
476}
477
480/* -------------------------------------------------------------------- */
485{
486 if (!dirty_attachments_) {
487 return;
488 }
489
490 for (int i = 0; i < GPU_FB_MAX_ATTACHMENT; i++) {
491 GPUAttachment &attachment = attachments_[i];
492 if (attachment.tex) {
493 int size[3];
494 GPU_texture_get_mipmap_size(attachment.tex, attachment.mip, size);
495 size_set(size[0], size[1]);
496 return;
497 }
498 }
499}
500
502{
504 VKTexture *texture = unwrap(unwrap(color_tex(i)));
505 if (texture) {
506 srgb_ = (texture->format_flag_get() & GPU_FORMAT_SRGB) != 0;
507 return;
508 }
509 }
510}
511
513{
514 int size = 0;
515 for (int color_slot : IndexRange(GPU_FB_MAX_COLOR_ATTACHMENT)) {
516 if (color_tex(color_slot) != nullptr) {
517 size = max_ii(color_slot + 1, size);
518 }
519 }
520 return size;
521}
522
526{
527 is_rendering_ = false;
528}
529
531{
532 if (is_rendering_) {
533 return;
534 }
535 const VKWorkarounds &workarounds = VKBackend::get().device.workarounds_get();
536 is_rendering_ = true;
537 dirty_attachments_ = false;
538 dirty_state_ = false;
539 depth_attachment_format_ = VK_FORMAT_UNDEFINED;
540 stencil_attachment_format_ = VK_FORMAT_UNDEFINED;
541
543 render_graph::VKBeginRenderingNode::CreateInfo begin_rendering(access_info);
544 begin_rendering.node_data.vk_rendering_info.sType = VK_STRUCTURE_TYPE_RENDERING_INFO;
545 begin_rendering.node_data.vk_rendering_info.layerCount = 1;
546 begin_rendering.node_data.vk_rendering_info.renderArea = vk_render_areas_get()[0];
547
548 color_attachment_formats_.clear();
549 for (int color_attachment_index :
551 {
552 const GPUAttachment &attachment = attachments_[color_attachment_index];
553 if (attachment.tex == nullptr) {
554 continue;
555 }
556
557 VKTexture &color_texture = *unwrap(unwrap(attachment.tex));
558 /* To support `gpu_Layer` we need to set the layerCount to the number of layers it can access.
559 */
560 int layer_count = color_texture.layer_count();
561 if (attachment.layer == -1 && layer_count != 1) {
562 begin_rendering.node_data.vk_rendering_info.layerCount = max_ii(
563 begin_rendering.node_data.vk_rendering_info.layerCount, layer_count);
564 }
565
566 VkRenderingAttachmentInfo &attachment_info =
567 begin_rendering.node_data
568 .color_attachments[begin_rendering.node_data.vk_rendering_info.colorAttachmentCount++];
569 attachment_info.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO;
570
571 VkImageView vk_image_view = VK_NULL_HANDLE;
572 uint32_t layer_base = max_ii(attachment.layer, 0);
573 GPUAttachmentState attachment_state = attachment_states_[color_attachment_index];
574 if (attachment_state == GPU_ATTACHMENT_WRITE) {
575 VKImageViewInfo image_view_info = {
577 IndexRange(layer_base,
578 layer_count != 1 ? max_ii(layer_count - layer_base, 1) : layer_count),
579 IndexRange(attachment.mip, 1),
580 {{'r', 'g', 'b', 'a'}},
581 false,
582 srgb_ && enabled_srgb_,
584 vk_image_view = color_texture.image_view_get(image_view_info).vk_handle();
585 }
586 attachment_info.imageView = vk_image_view;
587 attachment_info.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
588 set_load_store(attachment_info, load_stores[color_attachment_index]);
589
590 access_info.images.append(
591 {color_texture.vk_image_handle(),
592 VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
593 VK_IMAGE_ASPECT_COLOR_BIT,
594 layer_base});
595 color_attachment_formats_.append(
596 (workarounds.dynamic_rendering_unused_attachments && vk_image_view == VK_NULL_HANDLE) ?
597 VK_FORMAT_UNDEFINED :
598 to_vk_format(color_texture.device_format_get()));
599
600 begin_rendering.node_data.vk_rendering_info.pColorAttachments =
601 begin_rendering.node_data.color_attachments;
602 }
603
604 for (int depth_attachment_index : IndexRange(GPU_FB_DEPTH_ATTACHMENT, 2)) {
605 const GPUAttachment &attachment = attachments_[depth_attachment_index];
606
607 if (attachment.tex == nullptr) {
608 continue;
609 }
610 bool is_stencil_attachment = depth_attachment_index == GPU_FB_DEPTH_STENCIL_ATTACHMENT;
611 VKTexture &depth_texture = *unwrap(unwrap(attachment.tex));
612 bool is_depth_stencil_attachment = to_vk_image_aspect_flag_bits(
613 depth_texture.device_format_get()) &
614 VK_IMAGE_ASPECT_STENCIL_BIT;
615 VkImageLayout vk_image_layout = is_depth_stencil_attachment ?
616 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL :
617 VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL;
618 GPUAttachmentState attachment_state = attachment_states_[GPU_FB_DEPTH_ATTACHMENT];
619 VkImageView depth_image_view = VK_NULL_HANDLE;
620 if (attachment_state == GPU_ATTACHMENT_WRITE) {
622 IndexRange(max_ii(attachment.layer, 0), 1),
623 IndexRange(attachment.mip, 1),
624 {{'r', 'g', 'b', 'a'}},
625 is_stencil_attachment,
626 false,
628 depth_image_view = depth_texture.image_view_get(image_view_info).vk_handle();
629 }
630 VkFormat vk_format = (workarounds.dynamic_rendering_unused_attachments &&
631 depth_image_view == VK_NULL_HANDLE) ?
632 VK_FORMAT_UNDEFINED :
633 to_vk_format(depth_texture.device_format_get());
634
635 /* TODO: we should be able to use a single attachment info and only set the
636 * #pDepthAttachment/#pStencilAttachment to the same struct.
637 * But perhaps the stencil clear op might be different. */
638 {
639 VkRenderingAttachmentInfo &attachment_info = begin_rendering.node_data.depth_attachment;
640 attachment_info.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO;
641 attachment_info.imageView = depth_image_view;
642 attachment_info.imageLayout = vk_image_layout;
643
644 set_load_store(attachment_info, load_stores[depth_attachment_index]);
645 depth_attachment_format_ = vk_format;
646 begin_rendering.node_data.vk_rendering_info.pDepthAttachment =
647 &begin_rendering.node_data.depth_attachment;
648 }
649
650 if (is_stencil_attachment) {
651 VkRenderingAttachmentInfo &attachment_info = begin_rendering.node_data.stencil_attachment;
652 attachment_info.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO;
653 attachment_info.imageView = depth_image_view;
654 attachment_info.imageLayout = vk_image_layout;
655
656 set_load_store(attachment_info, load_stores[depth_attachment_index]);
657 stencil_attachment_format_ = vk_format;
658 begin_rendering.node_data.vk_rendering_info.pStencilAttachment =
659 &begin_rendering.node_data.stencil_attachment;
660 }
661
662 access_info.images.append({depth_texture.vk_image_handle(),
663 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT |
664 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
665 is_stencil_attachment ?
666 static_cast<VkImageAspectFlags>(VK_IMAGE_ASPECT_DEPTH_BIT |
667 VK_IMAGE_ASPECT_STENCIL_BIT) :
668 static_cast<VkImageAspectFlags>(VK_IMAGE_ASPECT_DEPTH_BIT),
669 0});
670 break;
671 }
672
673 context.render_graph.add_node(begin_rendering);
674}
675
677{
678 return depth_attachment_format_;
679}
681{
682 return stencil_attachment_format_;
683};
685{
686 return color_attachment_formats_;
687}
688
690{
691 if (!is_rendering_ && use_explicit_load_store_) {
692 rendering_ensure(context);
693 }
694
695 if (is_rendering_) {
697 context.render_graph.add_node(end_rendering);
698 is_rendering_ = false;
699 }
700}
701
702} // namespace blender::gpu
#define BLI_assert_unreachable()
Definition BLI_assert.h:97
#define BLI_assert(a)
Definition BLI_assert.h:50
#define BLI_assert_msg(a, msg)
Definition BLI_assert.h:57
MINLINE int min_ii(int a, int b)
MINLINE int max_ii(int a, int b)
MINLINE int clamp_i(int value, int min, int max)
MINLINE void copy_v4_v4(float r[4], const float a[4])
unsigned int uint
#define UNUSED_VARS_NDEBUG(...)
#define ELEM(...)
@ GPU_LOADACTION_LOAD
@ GPU_LOADACTION_DONT_CARE
@ GPU_LOADACTION_CLEAR
eGPUStoreOp
@ GPU_STOREACTION_STORE
@ GPU_STOREACTION_DONT_CARE
GPUAttachmentState
@ GPU_ATTACHMENT_WRITE
@ GPU_ATTACHMENT_READ
eGPUFrameBufferBits
@ GPU_DEPTH_BIT
@ GPU_STENCIL_BIT
@ GPU_COLOR_BIT
#define GPU_MAX_VIEWPORTS
@ GPU_DRIVER_OFFICIAL
@ GPU_OS_ANY
@ GPU_DEVICE_ATI
bool GPU_type_matches(eGPUDeviceType device, eGPUOSType os, eGPUDriverType driver)
eGPUWriteMask
Definition GPU_state.hh:16
@ GPU_WRITE_STENCIL
Definition GPU_state.hh:23
@ GPU_WRITE_NONE
Definition GPU_state.hh:17
@ GPU_WRITE_DEPTH
Definition GPU_state.hh:22
eGPUDataFormat
void GPU_texture_get_mipmap_size(GPUTexture *texture, int mip_level, int *r_size)
eGPUTextureFormat GPU_texture_format(const GPUTexture *texture)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition btDbvt.cpp:52
MutableSpan< T > as_mutable_span()
Definition BLI_array.hh:237
void fill(const T &value) const
Definition BLI_array.hh:261
constexpr int64_t size() const
Definition BLI_span.hh:253
void append(const T &value)
void size_set(int width, int height)
void scissor_get(int r_scissor[4]) const
GPUTexture * color_tex(int slot) const
GPUAttachment attachments_[GPU_FB_MAX_ATTACHMENT]
int viewport_[GPU_MAX_VIEWPORTS][4]
static void set_framebuffer_srgb_target(int use_srgb_to_linear)
static VKBackend & get()
Definition vk_backend.hh:92
static VKContext * get()
Definition vk_context.hh:97
const VKWorkarounds & workarounds_get() const
Definition vk_device.hh:286
void rendering_ensure(VKContext &context)
VKFrameBuffer(const char *name)
void clear_multi(const float(*clear_color)[4]) override
VkFormat stencil_attachment_format_get() const
void read(eGPUFrameBufferBits planes, eGPUDataFormat format, const int area[4], int channel_len, int slot, void *r_data) override
void subpass_transition_impl(const GPUAttachmentState depth_attachment_state, Span< GPUAttachmentState > color_attachment_states) override
void clear(eGPUFrameBufferBits buffers, const float clear_color[4], float clear_depth, uint clear_stencil) override
void bind(bool enabled_srgb) override
VkFormat depth_attachment_format_get() const
Array< VkViewport, 16 > vk_viewports_get() const
void rendering_end(VKContext &context)
bool check(char err_out[256]) override
void attachment_set_loadstore_op(GPUAttachmentType type, GPULoadStore) override
void blit_to(eGPUFrameBufferBits planes, int src_slot, FrameBuffer *dst, int dst_slot, int dst_offset_x, int dst_offset_y) override
int color_attachments_resource_size() const
void clear_attachment(GPUAttachmentType type, eGPUDataFormat data_format, const void *clear_value) override
Array< VkRect2D, 16 > vk_render_areas_get() const
Span< VkFormat > color_attachment_formats_get() const
VkImageView vk_handle() const
void copy_to(Texture *tex) override
eGPUTextureFormat device_format_get() const
VkImage vk_image_handle() const
Definition vk_texture.hh:99
const VKImageView & image_view_get(const VKImageViewInfo &info)
void clear_depth_stencil(const eGPUFrameBufferBits buffer, float clear_depth, uint clear_stencil)
@ GPU_FB_DEPTH_STENCIL_ATTACHMENT
@ GPU_FB_MAX_ATTACHMENT
@ GPU_FB_COLOR_ATTACHMENT0
@ GPU_FB_DEPTH_ATTACHMENT
#define GPU_FB_MAX_COLOR_ATTACHMENT
format
constexpr GPULoadStore default_load_store()
static Context * unwrap(GPUContext *ctx)
static VkAttachmentStoreOp to_vk_attachment_store_op(eGPUStoreOp store_op)
static void set_load_store(VkRenderingAttachmentInfo &r_rendering_attachment, const GPULoadStore &ls)
static VkAttachmentLoadOp to_vk_attachment_load_op(eGPULoadOp load_op)
VkFormat to_vk_format(const eGPUTextureFormat format)
Definition vk_common.cc:131
VkClearColorValue to_vk_clear_color_value(const eGPUDataFormat format, const void *data)
Definition vk_common.cc:805
VkImageAspectFlags to_vk_image_aspect_flag_bits(const eGPUTextureFormat format)
Definition vk_common.cc:14
eGPUDataFormat to_data_format(eGPUTextureFormat tex_format)
static void blit_aspect(VKContext &context, VKTexture &dst_texture, VKTexture &src_texture, int dst_offset_x, int dst_offset_y, VkImageAspectFlags image_aspect)
unsigned int uint32_t
Definition stdint.h:80
GPUTexture * tex
eGPULoadOp load_action
eGPUStoreOp store_action
static constexpr GPUSamplerState default_sampler()
char * buffers[2]