optimize_draw_list now produces parity optimization to original

This commit is contained in:
Edward R. Gonzalez 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^
}
}
}

View File

@ -105,7 +105,7 @@ render :: proc()
// Process the draw calls for drawing text
if true
{
profile("ve render frame")
profile("VEFontCache: render frame")
ve.optimize_draw_list( & ve_font_cache )
draw_list := ve.get_draw_list( & ve_font_cache )
@ -120,14 +120,14 @@ render :: proc()
for & draw_call in array_to_slice(draw_list.calls)
{
watch := draw_call
// profile("ve draw call")
// profile("VEFontCache: draw call")
switch draw_call.pass
{
// 1. Do the glyph rendering pass
// Glyphs are first rendered to an intermediate 2k x 512px R8 texture
case .Glyph:
// profile("ve draw call: glyph")
// profile("VEFontCache: draw call: glyph")
if (draw_call.end_index - draw_call.start_index) == 0 && ! draw_call.clear_before_draw {
continue
}
@ -163,7 +163,7 @@ render :: proc()
// 2. Do the atlas rendering pass
// A simple 16-tap box downsample shader is then used to blit from this intermediate texture to the final atlas location
case .Atlas:
// profile("ve draw call: atlas")
// profile("VEFontCache: draw call: atlas")
if (draw_call.end_index - draw_call.start_index) == 0 && ! draw_call.clear_before_draw {
continue
}
@ -205,18 +205,15 @@ render :: proc()
case .None: fallthrough
case .Target: fallthrough
case .Target_Uncached:
if (draw_call.end_index - draw_call.start_index) == 0 {
if (draw_call.end_index - draw_call.start_index) == 0 && ! draw_call.clear_before_draw {
continue
}
// profile("ve draw call: target")
// profile("VEFontCache: draw call: target")
width := u32(app_window.extent.x * 2)
height := u32(app_window.extent.y * 2)
pass := screen_pass
if ! draw_call.clear_before_draw {
pass.action.colors[0].load_action = .LOAD
}
pass.swapchain = sokol_glue.swapchain()
sokol_gfx.begin_pass( pass )

View File

@ -449,10 +449,10 @@ font_provider_startup :: proc()
sample_count = 1,
depth = {
pixel_format = app_env.defaults.depth_format,
// compare = .ALWAYS,
// write_enabled = true,
compare = .ALWAYS,
write_enabled = false,
},
// cull_mode = .NONE,
cull_mode = .NONE,
})
verify( sokol_gfx.query_pipeline_state(screen_pipeline) < ResourceState.FAILED, "Failed to make screen_pipeline" )
}
@ -462,10 +462,30 @@ font_provider_startup :: proc()
screen_action := PassAction {
colors = {
0 = {
load_action = .CLEAR,
load_action = .LOAD,
store_action = .STORE,
clear_value = {0.00, 0.00, 0.00, 1.0},
clear_value = {0.00, 0.00, 0.00, 0.0},
},
1 = {
load_action = .LOAD,
store_action = .STORE,
clear_value = {0.00, 0.00, 0.00, 0.0},
},
2 = {
load_action = .LOAD,
store_action = .STORE,
clear_value = {0.00, 0.00, 0.00, 0.0},
}
},
depth = {
load_action = .DONTCARE,
store_action = .DONTCARE,
clear_value = 0.0,
},
stencil = {
load_action = .DONTCARE,
store_action = .DONTCARE,
clear_value = 0,
}
}
@ -525,7 +545,7 @@ font_load :: proc(path_file : string,
def.path_file = path_file
// TODO(Ed): Load even sizes from 8px to upper bound.
def.ve_id = ve.load_font( & provider_data.ve_font_cache, desired_id, font_data, 122.0 )
def.ve_id = ve.load_font( & provider_data.ve_font_cache, desired_id, font_data, 80.0 )
fid := FontID { key, desired_id }
return fid

View File

@ -202,13 +202,13 @@ push-location $path_root
$build_args += ($flag_collection + $pkg_collection_codebase)
$build_args += ($flag_collection + $pkg_collection_thirdparty)
# $build_args += $flag_micro_architecture_native
# $build_args += $flag_use_separate_modules
# $build_args += $flag_thread_count + $CoreCount_Physical
$build_args += $flag_use_separate_modules
$build_args += $flag_thread_count + $CoreCount_Physical
$build_args += $flag_optimize_none
# $build_args += $flag_optimize_minimal
# $build_args += $flag_optimize_speed
# $build_args += $falg_optimize_aggressive
$build_args += $flag_debug
# $build_args += $flag_debug
$build_args += $flag_pdb_name + $pdb
$build_args += $flag_subsystem + 'windows'
# $build_args += $flag_show_system_calls
@ -278,8 +278,8 @@ push-location $path_root
$build_args += ($flag_collection + $pkg_collection_codebase)
$build_args += ($flag_collection + $pkg_collection_thirdparty)
# $build_args += $flag_micro_architecture_native
# $build_args += $flag_use_separate_modules
# $build_args += $flag_thread_count + $CoreCount_Physical
$build_args += $flag_use_separate_modules
$build_args += $flag_thread_count + $CoreCount_Physical
$build_args += $flag_optimize_none
# $build_args += $flag_optimize_minimal
# $build_args += $flag_optimize_speed

@ -1 +1 @@
Subproject commit b7a7ada7aef38214c599e8691072f95b33c91913
Subproject commit fe4d6cbe5a85f31d7494f602f2868557da22b253