Organize render surface sorting key for optimizing API performance.

This commit is contained in:
Dario 2025-10-14 15:54:22 -03:00
parent 36b92128b1
commit b49aea89d0
5 changed files with 44 additions and 12 deletions

View file

@ -35,6 +35,9 @@
#define PRINT_RESOURCE_TRACKER_TOTAL 0
#define PRINT_COMMAND_RECORDING 0
// Prints the total number of bytes used for draw lists in a frame.
#define PRINT_DRAW_LIST_STATS 0
RenderingDeviceGraph::RenderingDeviceGraph() {
driver_honors_barriers = false;
driver_clears_with_copy_engine = false;
@ -835,7 +838,15 @@ void RenderingDeviceGraph::_get_draw_list_render_pass_and_framebuffer(const Reco
r_framebuffer = it->value.framebuffer;
}
#if PRINT_DRAW_LIST_STATS
static uint32_t draw_list_total_size = 0;
#endif
void RenderingDeviceGraph::_run_draw_list_command(RDD::CommandBufferID p_command_buffer, const uint8_t *p_instruction_data, uint32_t p_instruction_data_size) {
#if PRINT_DRAW_LIST_STATS
draw_list_total_size += p_instruction_data_size;
#endif
uint32_t instruction_data_cursor = 0;
while (instruction_data_cursor < p_instruction_data_size) {
DEV_ASSERT((instruction_data_cursor + sizeof(DrawListInstruction)) <= p_instruction_data_size);
@ -2366,6 +2377,10 @@ void RenderingDeviceGraph::end(bool p_reorder_commands, bool p_full_barriers, RD
workarounds_state.draw_list_found = false;
}
#if PRINT_DRAW_LIST_STATS
draw_list_total_size = 0;
#endif
if (p_reorder_commands) {
#if PRINT_RENDER_GRAPH
print_line("BEFORE SORT");
@ -2416,6 +2431,9 @@ void RenderingDeviceGraph::end(bool p_reorder_commands, bool p_full_barriers, RD
_run_label_command_change(r_command_buffer, -1, -1, false, false, nullptr, 0, current_label_index, current_label_level);
#if PRINT_DRAW_LIST_STATS
print_line(vformat("Draw list %d bytes", draw_list_total_size));
#endif
#if PRINT_COMMAND_RECORDING
print_line(vformat("Recorded %d commands", command_count));
#endif