Blender V5.0
vk_dispatch_indirect_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
13#include "vk_node_info.hh"
14
24
33
34/* Although confusing the spec mentions that VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT should also be
35 * used for dispatches.
36 * (https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkPipelineStageFlagBits.html)
37 */
39 : public VKNodeInfo<VKNodeType::DISPATCH_INDIRECT,
40 VKDispatchIndirectCreateInfo,
41 VKDispatchIndirectData,
42 VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
43 VKResourceType::IMAGE | VKResourceType::BUFFER> {
44 public:
52 template<typename Node, typename Storage>
53 static void set_node_data(Node &node, Storage & /* storage */, const CreateInfo &create_info)
54 {
55 node.dispatch_indirect = create_info.dispatch_indirect_node;
56 vk_pipeline_data_copy(node.dispatch_indirect.pipeline_data,
58 }
59
64 {
65 vk_pipeline_data_free(data.pipeline_data);
66 }
67
72 VKRenderGraphNodeLinks &node_links,
73 const CreateInfo &create_info) override
74 {
75 create_info.resources.build_links(resources, node_links);
76 ResourceWithStamp buffer_resource = resources.get_buffer(
77 create_info.dispatch_indirect_node.buffer);
78 node_links.inputs.append({buffer_resource, VK_ACCESS_INDIRECT_COMMAND_READ_BIT});
79 }
80
85 Data &data,
86 VKBoundPipelines &r_bound_pipelines) override
87 {
89 data.pipeline_data,
90 r_bound_pipelines.compute,
91 VK_PIPELINE_BIND_POINT_COMPUTE,
92 VK_SHADER_STAGE_COMPUTE_BIT);
93 command_buffer.dispatch_indirect(data.buffer, data.offset);
94 }
95};
96} // namespace blender::gpu::render_graph
BMesh const char void * data
NonCopyable(const NonCopyable &other)=delete
virtual void dispatch_indirect(VkBuffer buffer, VkDeviceSize offset)=0
static void set_node_data(Node &node, Storage &, const CreateInfo &create_info)
void build_links(VKResourceStateTracker &resources, VKRenderGraphNodeLinks &node_links, const CreateInfo &create_info) override
void build_commands(VKCommandBufferInterface &command_buffer, Data &data, VKBoundPipelines &r_bound_pipelines) override
ResourceWithStamp get_buffer(VkBuffer vk_buffer) const
void vk_pipeline_data_copy(VKPipelineData &dst, const VKPipelineData &src)
void vk_pipeline_data_free(VKPipelineData &data)
void vk_pipeline_data_build_commands(VKCommandBufferInterface &command_buffer, const VKPipelineData &pipeline_data, VKBoundPipeline &r_bound_pipeline, VkPipelineBindPoint vk_pipeline_bind_point, VkShaderStageFlags vk_shader_stage_flags)
VKDispatchIndirectCreateInfo(const VKResourceAccessInfo &resources)
void build_links(VKResourceStateTracker &resources, VKRenderGraphNodeLinks &node_links) const