diff --git a/code/sectr/engine/client_api.odin b/code/sectr/engine/client_api.odin index a6d495a..708a9ab 100644 --- a/code/sectr/engine/client_api.odin +++ b/code/sectr/engine/client_api.odin @@ -457,17 +457,18 @@ tick :: proc( host_delta_time_ms : f64, host_delta_ns : Duration ) -> b32 should_close |= cast(b32) sokol_app.pre_client_frame() profile_end() - profile( "Client Tick" ) + profile_begin( "Client Tick" ) context.logger = to_odin_logger( & Memory_App.logger ) state := get_state(); using state - client_tick := time.tick_now() should_close |= tick_work_frame( host_delta_time_ms) - tick_frametime( & client_tick, host_delta_time_ms, host_delta_ns ) + profile_end() profile_begin("sokol_app: post_client_tick") sokol_app.post_client_frame() profile_end() + + tick_frametime( & client_tick, host_delta_time_ms, host_delta_ns ) return ! should_close } diff --git a/code/sectr/engine/render_vefc.odin b/code/sectr/engine/render_vefc.odin index 677ec9d..88f15d3 100644 --- a/code/sectr/engine/render_vefc.odin +++ b/code/sectr/engine/render_vefc.odin @@ -79,7 +79,9 @@ render :: proc() // "Draw text" using immediate mode api { - text_test_str := str_fmt("frametime: %0.2f", frametime_avg_ms) + @static index : i32 + index += 1 + text_test_str := str_fmt("frametime: %0.2f\nframe id : %d", frametime_avg_ms, index ) // log(text_test_str) // text_test_str := str_fmt("HELLO VE FONT CACHE!") // text_test_str := str_fmt("C") @@ -96,9 +98,16 @@ render :: proc() ve.draw_text( & ve_font_cache, fdef.ve_id, text_test_str, {0.1, 0.2}, Vec2{1 / width, 1 / height} ) } + + sokol_gfx.begin_pass(sokol_gfx.Pass { action = pass_actions.bg_clear_black, swapchain = sokol_glue.swapchain() }) + sokol_gfx.end_pass(); + // Process the draw calls for drawing text if true { + profile("ve render frame") + + ve.optimize_draw_list( & ve_font_cache ) draw_list := ve.get_draw_list( & ve_font_cache ) draw_list_vert_slice := array_to_slice(draw_list.vertices) @@ -111,14 +120,18 @@ render :: proc() for & draw_call in array_to_slice(draw_list.calls) { watch := draw_call - profile("ve draw call") + // profile("ve 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("ve draw call: glyph") + if (draw_call.end_index - draw_call.start_index) == 0 && ! draw_call.clear_before_draw { + continue + } + width := ve_font_cache.atlas.buffer_width height := ve_font_cache.atlas.buffer_height @@ -129,8 +142,8 @@ render :: proc() } sokol_gfx.begin_pass( pass ) - sokol_gfx.apply_viewport( 0,0, width, height, origin_top_left = true ) - sokol_gfx.apply_scissor_rect( 0,0, width, height, origin_top_left = true ) + // sokol_gfx.apply_viewport( 0,0, width, height, origin_top_left = true ) + // sokol_gfx.apply_scissor_rect( 0,0, width, height, origin_top_left = true ) sokol_gfx.apply_pipeline( glyph_pipeline ) @@ -150,7 +163,11 @@ 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("ve draw call: atlas") + if (draw_call.end_index - draw_call.start_index) == 0 && ! draw_call.clear_before_draw { + continue + } + width := ve_font_cache.atlas.width height := ve_font_cache.atlas.height @@ -188,20 +205,23 @@ render :: proc() case .None: fallthrough case .Target: fallthrough case .Target_Uncached: - profile("ve draw call: target") + if (draw_call.end_index - draw_call.start_index) == 0 { + continue + } + + // profile("ve 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.action.colors[0].clear_value.a = 0.0 + pass.action.colors[0].load_action = .LOAD } pass.swapchain = sokol_glue.swapchain() sokol_gfx.begin_pass( pass ) - sokol_gfx.apply_viewport( 0, 0, width, height, origin_top_left = true ) - sokol_gfx.apply_scissor_rect( 0, 0, width, height, origin_top_left = true ) + // sokol_gfx.apply_viewport( 0, 0, width, height, origin_top_left = true ) + // sokol_gfx.apply_scissor_rect( 0, 0, width, height, origin_top_left = true ) sokol_gfx.apply_pipeline( screen_pipeline ) @@ -210,7 +230,7 @@ render :: proc() fs_target_uniform := Ve_Draw_Text_Fs_Params { down_sample = 0, - colour = {1, 1, 1, 1}, + colour = {1.0, 1.0, 1.0, 1}, } if draw_call.pass == .Target_Uncached { diff --git a/code/sectr/font/provider_VEFontCache.odin b/code/sectr/font/provider_VEFontCache.odin index 889dc48..5d53ec1 100644 --- a/code/sectr/font/provider_VEFontCache.odin +++ b/code/sectr/font/provider_VEFontCache.odin @@ -75,10 +75,9 @@ font_provider_startup :: proc() ve.configure_snap( & provider_data.ve_font_cache, u32(state.app_window.extent.x * 2.0), u32(state.app_window.extent.y * 2.0) ) - provider_data.ve_font_cache.debug_print = true - provider_data.ve_font_cache.debug_print_verbose = true + // provider_data.ve_font_cache.debug_print = true + // provider_data.ve_font_cache.debug_print_verbose = true - // TODO(Ed): Setup sokol hookup for VEFontCache { AttachmentDesc :: sokol_gfx.Attachment_Desc @@ -172,7 +171,7 @@ font_provider_startup :: proc() depth = { pixel_format = .DEPTH, compare = .ALWAYS, - write_enabled = true, + write_enabled = false, }, cull_mode = .NONE, sample_count = 1, @@ -246,6 +245,16 @@ font_provider_startup :: proc() // clear_value = {0.01,0.01,0.01,1}, clear_value = {0.00, 0.00, 0.00, 1.00}, } + }, + depth = { + load_action = .DONTCARE, + store_action = .DONTCARE, + clear_value = 0.0, + }, + stencil = { + load_action = .DONTCARE, + store_action = .DONTCARE, + clear_value = 0, } } @@ -302,7 +311,7 @@ font_provider_startup :: proc() depth = { pixel_format = .DEPTH, compare = .ALWAYS, - write_enabled = true, + write_enabled = false, }, cull_mode = .NONE, sample_count = 1, @@ -374,6 +383,16 @@ font_provider_startup :: proc() store_action = .STORE, clear_value = {0.00, 0.00, 0.00, 1.0}, } + }, + depth = { + load_action = .DONTCARE, + store_action = .DONTCARE, + clear_value = 0.0, + }, + stencil = { + load_action = .DONTCARE, + store_action = .DONTCARE, + clear_value = 0, } } @@ -445,7 +464,7 @@ font_provider_startup :: proc() 0 = { load_action = .CLEAR, store_action = .STORE, - clear_value = {0.0, 0.0, 0.0, 1.0}, + clear_value = {0.00, 0.00, 0.00, 1.0}, } } } @@ -506,7 +525,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, 120.0 ) + def.ve_id = ve.load_font( & provider_data.ve_font_cache, desired_id, font_data, 122.0 ) fid := FontID { key, desired_id } return fid