optimize_draw_list now produces parity optimization to original

This commit is contained in:
2024-06-16 10:27:58 -04:00
parent 000d46cd73
commit b1927a8461
5 changed files with 51 additions and 26 deletions

View File

@ -401,10 +401,13 @@ merge_draw_list :: proc( dst, src : ^DrawList )
}
}
// Call during a full depth layer pass to optimize the final draw list when necessary
optimize_draw_list :: proc( ctx : ^Context )
{
assert( ctx != nil )
calls := array_to_slice(ctx.draw_list.calls)
write_index : i32 = 0
for index : i32 = 1; index < i32(ctx.draw_list.calls.num); index += 1
{
@ -419,16 +422,21 @@ optimize_draw_list :: proc( ctx : ^Context )
if draw_1.clear_before_draw do merge = false
if draw_0.colour != draw_1.colour do merge = false
if merge {
// logf("merging : %v %v", write_index, index )
if merge
{
// logf("merging %v : %v %v", draw_0.pass, write_index, index )
draw_0.end_index = draw_1.end_index
draw_1.start_index = 0
draw_1.end_index = 0
}
else {
else
{
// logf("can't merge %v : %v %v", draw_0.pass, write_index, index )
write_index += 1
draw_2 := & ctx.draw_list.calls.data[ write_index ]
if write_index != index do draw_2 = draw_1
if write_index != index {
draw_2 := & ctx.draw_list.calls.data[ write_index ]
draw_2^ = draw_1^
}
}
}