Blender V4.3
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
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> static void set_node_data(Node &node, const CreateInfo &create_info)
53 {
54 node.dispatch_indirect = create_info.dispatch_indirect_node;
55 vk_pipeline_data_copy(node.dispatch_indirect.pipeline_data,
57 }
58
63 {
64 vk_pipeline_data_free(data.pipeline_data);
65 }
66
71 VKRenderGraphNodeLinks &node_links,
72 const CreateInfo &create_info) override
73 {
74 create_info.resources.build_links(resources, node_links);
75 ResourceWithStamp buffer_resource = resources.get_buffer(
76 create_info.dispatch_indirect_node.buffer);
77 node_links.inputs.append({buffer_resource, VK_ACCESS_INDIRECT_COMMAND_READ_BIT});
78 }
79
84 Data &data,
85 VKBoundPipelines &r_bound_pipelines) override
86 {
88 data.pipeline_data,
89 r_bound_pipelines.compute,
90 VK_PIPELINE_BIND_POINT_COMPUTE,
91 VK_SHADER_STAGE_COMPUTE_BIT);
92 command_buffer.dispatch_indirect(data.buffer, data.offset);
93 }
94};
95} // namespace blender::gpu::render_graph
virtual void dispatch_indirect(VkBuffer buffer, VkDeviceSize offset)=0
static void set_node_data(Node &node, 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