summaryrefslogtreecommitdiffstats
path: root/servers/rendering/rendering_device_graph.cpp
diff options
context:
space:
mode:
authorThaddeus Crews <repiteo@outlook.com>2024-10-29 19:25:57 -0500
committerThaddeus Crews <repiteo@outlook.com>2024-10-29 19:25:57 -0500
commit6d09a20c8263f02e1685a24ca01298544fdfecac (patch)
tree240d81b3c9feaddf02c2caeadebbb056c5d4718d /servers/rendering/rendering_device_graph.cpp
parent9169ace8f2ee5cfbc0dd51e833d88930524b11f1 (diff)
parentd36a8724324b5c8f1e4679717d009ae3210afd20 (diff)
downloadredot-engine-6d09a20c8263f02e1685a24ca01298544fdfecac.tar.gz
Merge pull request #97247 from thimenesup/draw_indirect_rd
Add draw indirect to Rendering Device
Diffstat (limited to 'servers/rendering/rendering_device_graph.cpp')
-rw-r--r--servers/rendering/rendering_device_graph.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/servers/rendering/rendering_device_graph.cpp b/servers/rendering/rendering_device_graph.cpp
index 48bb235cac..750753d796 100644
--- a/servers/rendering/rendering_device_graph.cpp
+++ b/servers/rendering/rendering_device_graph.cpp
@@ -708,6 +708,16 @@ void RenderingDeviceGraph::_run_draw_list_command(RDD::CommandBufferID p_command
driver->command_render_draw_indexed(p_command_buffer, draw_indexed_instruction->index_count, draw_indexed_instruction->instance_count, draw_indexed_instruction->first_index, 0, 0);
instruction_data_cursor += sizeof(DrawListDrawIndexedInstruction);
} break;
+ case DrawListInstruction::TYPE_DRAW_INDIRECT: {
+ const DrawListDrawIndirectInstruction *draw_indirect_instruction = reinterpret_cast<const DrawListDrawIndirectInstruction *>(instruction);
+ driver->command_render_draw_indirect(p_command_buffer, draw_indirect_instruction->buffer, draw_indirect_instruction->offset, draw_indirect_instruction->draw_count, draw_indirect_instruction->stride);
+ instruction_data_cursor += sizeof(DrawListDrawIndirectInstruction);
+ } break;
+ case DrawListInstruction::TYPE_DRAW_INDEXED_INDIRECT: {
+ const DrawListDrawIndexedIndirectInstruction *draw_indexed_indirect_instruction = reinterpret_cast<const DrawListDrawIndexedIndirectInstruction *>(instruction);
+ driver->command_render_draw_indexed_indirect(p_command_buffer, draw_indexed_indirect_instruction->buffer, draw_indexed_indirect_instruction->offset, draw_indexed_indirect_instruction->draw_count, draw_indexed_indirect_instruction->stride);
+ instruction_data_cursor += sizeof(DrawListDrawIndexedIndirectInstruction);
+ } break;
case DrawListInstruction::TYPE_EXECUTE_COMMANDS: {
const DrawListExecuteCommandsInstruction *execute_commands_instruction = reinterpret_cast<const DrawListExecuteCommandsInstruction *>(instruction);
driver->command_buffer_execute_secondary(p_command_buffer, execute_commands_instruction->command_buffer);
@@ -1189,6 +1199,16 @@ void RenderingDeviceGraph::_print_draw_list(const uint8_t *p_instruction_data, u
print_line("\tDRAW INDICES", draw_indexed_instruction->index_count, "INSTANCES", draw_indexed_instruction->instance_count, "FIRST INDEX", draw_indexed_instruction->first_index);
instruction_data_cursor += sizeof(DrawListDrawIndexedInstruction);
} break;
+ case DrawListInstruction::TYPE_DRAW_INDIRECT: {
+ const DrawListDrawIndirectInstruction *draw_indirect_instruction = reinterpret_cast<const DrawListDrawIndirectInstruction *>(instruction);
+ print_line("\tDRAW INDIRECT BUFFER ID", itos(draw_indirect_instruction->buffer.id), "OFFSET", draw_indirect_instruction->offset, "DRAW COUNT", draw_indirect_instruction->draw_count, "STRIDE", draw_indirect_instruction->stride);
+ instruction_data_cursor += sizeof(DrawListDrawIndirectInstruction);
+ } break;
+ case DrawListInstruction::TYPE_DRAW_INDEXED_INDIRECT: {
+ const DrawListDrawIndexedIndirectInstruction *draw_indexed_indirect_instruction = reinterpret_cast<const DrawListDrawIndexedIndirectInstruction *>(instruction);
+ print_line("\tDRAW INDEXED INDIRECT BUFFER ID", itos(draw_indexed_indirect_instruction->buffer.id), "OFFSET", draw_indexed_indirect_instruction->offset, "DRAW COUNT", draw_indexed_indirect_instruction->draw_count, "STRIDE", draw_indexed_indirect_instruction->stride);
+ instruction_data_cursor += sizeof(DrawListDrawIndexedIndirectInstruction);
+ } break;
case DrawListInstruction::TYPE_EXECUTE_COMMANDS: {
print_line("\tEXECUTE COMMANDS");
instruction_data_cursor += sizeof(DrawListExecuteCommandsInstruction);
@@ -1611,6 +1631,26 @@ void RenderingDeviceGraph::add_draw_list_draw_indexed(uint32_t p_index_count, ui
instruction->first_index = p_first_index;
}
+void RenderingDeviceGraph::add_draw_list_draw_indirect(RDD::BufferID p_buffer, uint32_t p_offset, uint32_t p_draw_count, uint32_t p_stride) {
+ DrawListDrawIndirectInstruction *instruction = reinterpret_cast<DrawListDrawIndirectInstruction *>(_allocate_draw_list_instruction(sizeof(DrawListDrawIndirectInstruction)));
+ instruction->type = DrawListInstruction::TYPE_DRAW_INDIRECT;
+ instruction->buffer = p_buffer;
+ instruction->offset = p_offset;
+ instruction->draw_count = p_draw_count;
+ instruction->stride = p_stride;
+ draw_instruction_list.stages.set_flag(RDD::PIPELINE_STAGE_DRAW_INDIRECT_BIT);
+}
+
+void RenderingDeviceGraph::add_draw_list_draw_indexed_indirect(RDD::BufferID p_buffer, uint32_t p_offset, uint32_t p_draw_count, uint32_t p_stride) {
+ DrawListDrawIndexedIndirectInstruction *instruction = reinterpret_cast<DrawListDrawIndexedIndirectInstruction *>(_allocate_draw_list_instruction(sizeof(DrawListDrawIndexedIndirectInstruction)));
+ instruction->type = DrawListInstruction::TYPE_DRAW_INDEXED_INDIRECT;
+ instruction->buffer = p_buffer;
+ instruction->offset = p_offset;
+ instruction->draw_count = p_draw_count;
+ instruction->stride = p_stride;
+ draw_instruction_list.stages.set_flag(RDD::PIPELINE_STAGE_DRAW_INDIRECT_BIT);
+}
+
void RenderingDeviceGraph::add_draw_list_execute_commands(RDD::CommandBufferID p_command_buffer) {
DrawListExecuteCommandsInstruction *instruction = reinterpret_cast<DrawListExecuteCommandsInstruction *>(_allocate_draw_list_instruction(sizeof(DrawListExecuteCommandsInstruction)));
instruction->type = DrawListInstruction::TYPE_EXECUTE_COMMANDS;