Blender V5.0
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
8
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, typename Storage>
46 static void set_node_data(Node &node, Storage &storage, const CreateInfo &create_info)
47 {
48 node.storage_index = storage.copy_image.append_and_get_index(create_info.node_data);
49 }
50
55 VKRenderGraphNodeLinks &node_links,
56 const CreateInfo &create_info) override
57 {
58 ResourceWithStamp src_resource = resources.get_image(create_info.node_data.src_image);
59 ResourceWithStamp dst_resource = resources.get_image_and_increase_stamp(
60 create_info.node_data.dst_image);
61 node_links.inputs.append({src_resource,
62 VK_ACCESS_TRANSFER_READ_BIT,
63 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
64 create_info.vk_image_aspect});
65 node_links.outputs.append({dst_resource,
66 VK_ACCESS_TRANSFER_WRITE_BIT,
67 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
68 create_info.vk_image_aspect});
69 }
70
75 Data &data,
76 VKBoundPipelines & /*r_bound_pipelines*/) override
77 {
78 command_buffer.copy_image(data.src_image,
79 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
80 data.dst_image,
81 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
82 1,
83 &data.region);
84 }
85};
86} // namespace blender::gpu::render_graph
BMesh const char void * data
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, Storage &storage, 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