Blender V5.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
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 }
57
62 VKRenderGraphLinks &links,
63 const CreateInfo &create_info) override
64 {
65 create_info.resources.build_links(resources, links);
66 ResourceWithStamp buffer_resource = resources.get_buffer(
67 create_info.dispatch_indirect_node.buffer);
68 links.buffers.append({buffer_resource, VK_ACCESS_INDIRECT_COMMAND_READ_BIT});
69 }
70
75 Data &data,
76 Span<uint8_t> storage_push_constants,
77 VKBoundPipelines &r_bound_pipelines) override
78 {
80 data.pipeline_data,
81 storage_push_constants,
82 r_bound_pipelines.compute,
83 VK_PIPELINE_BIND_POINT_COMPUTE,
84 VK_SHADER_STAGE_COMPUTE_BIT);
85 command_buffer.dispatch_indirect(data.buffer, data.offset);
86 }
87};
88} // namespace blender::gpu::render_graph
NonCopyable(const NonCopyable &other)=delete
virtual void dispatch_indirect(VkBuffer buffer, VkDeviceSize offset)=0
void build_links(VKResourceStateTracker &resources, VKRenderGraphLinks &links, const CreateInfo &create_info) override
void build_commands(VKCommandBufferInterface &command_buffer, Data &data, Span< uint8_t > storage_push_constants, VKBoundPipelines &r_bound_pipelines) override
static void set_node_data(Node &node, Storage &, const CreateInfo &create_info)
ResourceWithStamp get_buffer(ResourceHandle buffer_handle) const
void vk_pipeline_data_build_commands(VKCommandBufferInterface &command_buffer, const VKPipelineData &pipeline_data, Span< uint8_t > storage_push_constants, VKBoundPipeline &r_bound_pipeline, VkPipelineBindPoint vk_pipeline_bind_point, VkShaderStageFlags vk_shader_stage_flags)
BMesh const char void * data
VKDispatchIndirectCreateInfo(const VKResourceAccessInfo &resources)
void build_links(VKResourceStateTracker &resources, VKRenderGraphLinks &links) const