Blender V4.3
vk_draw_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
12#include "vk_node_info.hh"
13
15
27
33
34class VKDrawIndirectNode : public VKNodeInfo<VKNodeType::DRAW_INDIRECT,
35 VKDrawIndirectCreateInfo,
36 VKDrawIndirectData,
37 VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT,
38 VKResourceType::IMAGE | VKResourceType::BUFFER> {
39 public:
47 template<typename Node> static void set_node_data(Node &node, const CreateInfo &create_info)
48 {
49 node.draw_indirect = create_info.node_data;
50 vk_pipeline_data_copy(node.draw_indirect.pipeline_data, create_info.node_data.pipeline_data);
51 }
52
57 VKRenderGraphNodeLinks &node_links,
58 const CreateInfo &create_info) override
59 {
60 create_info.resources.build_links(resources, node_links);
62 resources, node_links, create_info.node_data.vertex_buffers);
63 ResourceWithStamp buffer_resource = resources.get_buffer(
64 create_info.node_data.indirect_buffer);
65 node_links.inputs.append({buffer_resource, VK_ACCESS_INDIRECT_COMMAND_READ_BIT});
66 }
67
72 Data &data,
73 VKBoundPipelines &r_bound_pipelines) override
74 {
76 data.pipeline_data,
77 r_bound_pipelines.graphics.pipeline,
78 VK_PIPELINE_BIND_POINT_GRAPHICS,
79 VK_SHADER_STAGE_ALL_GRAPHICS);
81 command_buffer, data.vertex_buffers, r_bound_pipelines.graphics.vertex_buffers);
82
83 command_buffer.draw_indirect(data.indirect_buffer, data.offset, data.draw_count, data.stride);
84 }
85
86 void free_data(Data &data)
87 {
88 vk_pipeline_data_free(data.pipeline_data);
89 }
90};
91} // namespace blender::gpu::render_graph
virtual void draw_indirect(VkBuffer buffer, VkDeviceSize offset, uint32_t draw_count, uint32_t stride)=0
void build_commands(VKCommandBufferInterface &command_buffer, Data &data, VKBoundPipelines &r_bound_pipelines) override
void build_links(VKResourceStateTracker &resources, VKRenderGraphNodeLinks &node_links, const CreateInfo &create_info) override
static void set_node_data(Node &node, const CreateInfo &create_info)
ResourceWithStamp get_buffer(VkBuffer vk_buffer) const
void vk_pipeline_data_copy(VKPipelineData &dst, const VKPipelineData &src)
void vk_vertex_buffer_bindings_build_links(VKResourceStateTracker &resources, VKRenderGraphNodeLinks &node_links, const VKVertexBufferBindings &vertex_buffers)
void vk_pipeline_data_free(VKPipelineData &data)
void vk_vertex_buffer_bindings_build_commands(VKCommandBufferInterface &command_buffer, const VKVertexBufferBindings &vertex_buffer_bindings, VKVertexBufferBindings &r_bound_vertex_buffers)
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)
unsigned int uint32_t
Definition stdint.h:80
struct blender::gpu::render_graph::VKBoundPipelines::@660 graphics
VKDrawIndirectCreateInfo(const VKResourceAccessInfo &resources)
void build_links(VKResourceStateTracker &resources, VKRenderGraphNodeLinks &node_links) const