Blender V4.3
vk_copy_image_node.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#pragma once
10
14#include "vk_common.hh"
15#include "vk_node_info.hh"
16
22 VkImage src_image;
23 VkImage dst_image;
24 VkImageCopy region;
25};
26
31
32class VKCopyImageNode : public VKNodeInfo<VKNodeType::COPY_IMAGE,
33 VKCopyImageCreateInfo,
34 VKCopyImageData,
35 VK_PIPELINE_STAGE_TRANSFER_BIT,
36 VKResourceType::IMAGE> {
37 public:
45 template<typename Node> static void set_node_data(Node &node, const CreateInfo &create_info)
46 {
47 node.copy_image = create_info.node_data;
48 }
49
54 VKRenderGraphNodeLinks &node_links,
55 const CreateInfo &create_info) override
56 {
57 ResourceWithStamp src_resource = resources.get_image(create_info.node_data.src_image);
58 ResourceWithStamp dst_resource = resources.get_image_and_increase_stamp(
59 create_info.node_data.dst_image);
60 node_links.inputs.append({src_resource,
61 VK_ACCESS_TRANSFER_READ_BIT,
62 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
63 create_info.vk_image_aspect});
64 node_links.outputs.append({dst_resource,
65 VK_ACCESS_TRANSFER_WRITE_BIT,
66 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
67 create_info.vk_image_aspect});
68 }
69
74 Data &data,
75 VKBoundPipelines & /*r_bound_pipelines*/) override
76 {
77 command_buffer.copy_image(data.src_image,
78 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
79 data.dst_image,
80 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
81 1,
82 &data.region);
83 }
84};
85} // namespace blender::gpu::render_graph
virtual void copy_image(VkImage src_image, VkImageLayout src_image_layout, VkImage dst_image, VkImageLayout dst_image_layout, uint32_t region_count, const VkImageCopy *p_regions)=0
void build_links(VKResourceStateTracker &resources, VKRenderGraphNodeLinks &node_links, const CreateInfo &create_info) override
static void set_node_data(Node &node, const CreateInfo &create_info)
void build_commands(VKCommandBufferInterface &command_buffer, Data &data, VKBoundPipelines &) override
ResourceWithStamp get_image_and_increase_stamp(VkImage vk_image)
ResourceWithStamp get_image(VkImage vk_image) const