Blender V5.3
vk_draw_indexed_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
12#include "vk_node_info.hh"
13
15
39
44
46 : public VKDrawNodeInfo<VKNodeType::DRAW_INDEXED_INDIRECT,
47 VKDrawIndexedIndirectCreateInfo,
48 VKDrawIndexedIndirectData,
49 VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT,
50 VKResourceType::IMAGE | VKResourceType::BUFFER> {
51 public:
52 static void reset_data(Data &data)
53 {
54 data.reset();
55 }
56
57 template<typename Storage>
58 static Data &alloc_node_data(Storage &storage, int64_t &r_storage_index)
59 {
60 Data &data = storage.draw_indexed_indirect.alloc(r_storage_index);
62 return data;
63 }
64
65 template<typename Storage> static Data &storage_data(Storage &storage, int64_t storage_index)
66 {
67 return storage.draw_indexed_indirect[storage_index];
68 }
69
74 VKRenderGraphLinks &links,
75 const CreateInfo &create_info,
76 Data &data) override
77 {
78 create_info.resources.build_links(resources, links);
79 if (data.index_buffer.buffer != VK_NULL_HANDLE) {
80 vk_index_buffer_binding_build_links(resources, links, data.index_buffer);
81 }
82
83 vk_vertex_buffer_bindings_build_links(resources, links, data.vertex_buffers);
84 ResourceWithStamp buffer_resource = resources.get_buffer(data.indirect_buffer);
85 links.buffers.append({buffer_resource, VK_ACCESS_INDIRECT_COMMAND_READ_BIT});
86 }
87
92 Data &data,
93 Span<uint8_t> storage_push_constants,
94 VKBoundPipelines &r_bound_pipelines) override
95 {
96 vk_pipeline_dynamic_graphics_build_commands(command_buffer, data.graphics, r_bound_pipelines);
98 data.graphics.pipeline_data,
99 storage_push_constants,
100 r_bound_pipelines.graphics.pipeline,
101 VK_PIPELINE_BIND_POINT_GRAPHICS,
102 VK_SHADER_STAGE_ALL_GRAPHICS);
104 command_buffer, data.index_buffer, r_bound_pipelines.graphics.index_buffer);
106 command_buffer, data.vertex_buffers, r_bound_pipelines.graphics.vertex_buffers);
107
108 if (command_buffer.use_multi_draw_indirect) {
109 command_buffer.draw_indexed_indirect(
110 data.indirect_buffer, data.offset, data.draw_count, data.stride);
111 }
112 else {
113 for (uint32_t i : IndexRange(data.draw_count)) {
114 command_buffer.draw_indexed_indirect(
115 data.indirect_buffer, data.offset + i * data.stride, 1, data.stride);
116 }
117 }
118 }
119};
120} // namespace blender::gpu::render_graph
constexpr IndexRange()=default
virtual void draw_indexed_indirect(VkBuffer buffer, VkDeviceSize offset, uint32_t draw_count, uint32_t stride)=0
void build_commands(VKCommandBufferInterface &command_buffer, Data &data, Span< uint8_t > storage_push_constants, VKBoundPipelines &r_bound_pipelines) override
void build_links(VKResourceStateTracker &resources, VKRenderGraphLinks &links, const CreateInfo &create_info, Data &data) override
static Data & alloc_node_data(Storage &storage, int64_t &r_storage_index)
static Data & storage_data(Storage &storage, int64_t storage_index)
ResourceWithStamp get_buffer(ResourceHandle buffer_handle) const
#define storage(slot, qualifiers)
void vk_index_buffer_binding_build_commands(VKCommandBufferInterface &command_buffer, const VKIndexBufferBinding &index_buffer_binding, VKIndexBufferBinding &r_bound_index_buffer)
void vk_pipeline_dynamic_graphics_build_commands(VKCommandBufferInterface &command_buffer, const VKPipelineDataGraphics &graphics, VKBoundPipelines &r_bound_pipelines)
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, Span< uint8_t > storage_push_constants, VKBoundPipeline &r_bound_pipeline, VkPipelineBindPoint vk_pipeline_bind_point, VkShaderStageFlags vk_shader_stage_flags)
void vk_vertex_buffer_bindings_build_links(VKResourceStateTracker &resources, VKRenderGraphLinks &links, const VKVertexBufferBindings &vertex_buffers)
void vk_index_buffer_binding_build_links(VKResourceStateTracker &resources, VKRenderGraphLinks &links, const VKIndexBufferBinding &index_buffer_binding)
__int64 int64_t
Definition BKE_text.h:90
unsigned int uint32_t
Definition BKE_text.h:81
BMesh const char void * data
struct blender::gpu::render_graph::VKBoundPipelines::@354275304307172366215375121273352137136061330352 graphics
void build_links(VKResourceStateTracker &resources, VKRenderGraphLinks &links) const