Misc: VFontCache perf and features, exposing config on prototype side...

This commit is contained in:
2025-01-09 13:23:35 -05:00
parent ce84652417
commit b4abde1094
19 changed files with 5023 additions and 227 deletions

View File

@ -10,8 +10,11 @@ UI_SettingsMenu :: struct
zoom_smooth_sensitivity_input : UI_TextInputBox,
zoom_digital_sensitivity_input : UI_TextInputBox,
zoom_scroll_delta_scale_input : UI_TextInputBox,
font_size_canvas_scalar_input : UI_TextInputBox,
font_size_screen_scalar_input : UI_TextInputBox,
text_snap_glyph_shape_posiiton : UI_TextInputBox,
text_snap_glyph_render_height : UI_TextInputBox,
text_size_canvas_scalar_input : UI_TextInputBox,
text_size_screen_scalar_input : UI_TextInputBox,
text_alpha_sharpen : UI_TextInputBox,
cfg_drop_down : UI_DropDown,
zoom_mode_drop_down : UI_DropDown,
@ -496,9 +499,77 @@ ui_settings_menu_builder :: proc( captures : rawptr = nil ) -> ( should_raise :
}
}
Text_Snap_Glyph_Shape_Position:
{
ui_settings_entry_inputbox( & text_snap_glyph_shape_posiiton, false, "settings_menu.text_snap_glyph_shape_posiiton", str_intern("Text: Snap Glyph Shape Position"),
UI_TextInput_Policy {
digits_only = true,
disallow_leading_zeros = false,
disallow_decimal = false,
digit_min = 0,
digit_max = 1,
max_length = 1,
}
)
using text_snap_glyph_shape_posiiton
if was_active
{
value, success := parse_f32(to_string(array_to_slice(input_str)))
if success {
value = clamp(value, 0, 1)
value_b32 := cast(b32) i32(value)
if config.text_snap_glyph_shape_position != value_b32 {
font_provider_flush_caches()
font_provider_set_snap_glyph_shape_position( value_b32 )
config.text_snap_glyph_shape_position = value_b32
}
}
}
else
{
clear( input_str )
append( & input_str, to_runes( str_fmt("%v", i32(config.text_snap_glyph_shape_position) ) ))
}
}
Text_Snap_Glyph_Render_Height:
{
ui_settings_entry_inputbox( & text_snap_glyph_render_height, false, "settings_menu.text_snap_glyph_render_height", str_intern("Text: Snap Glyph Render Height"),
UI_TextInput_Policy {
digits_only = true,
disallow_leading_zeros = false,
disallow_decimal = false,
digit_min = 0,
digit_max = 1,
max_length = 1,
}
)
using text_snap_glyph_render_height
if was_active
{
value, success := parse_f32(to_string(array_to_slice(input_str)))
if success {
value = clamp(value, 0, 1)
value_b32 := cast(b32) i32(value)
if config.text_snap_glyph_render_height != value_b32 {
font_provider_flush_caches()
font_provider_set_snap_glyph_render_height( value_b32 )
config.text_snap_glyph_render_height = value_b32
}
}
}
else
{
clear( input_str )
append( & input_str, to_runes( str_fmt("%v", i32(config.text_snap_glyph_render_height) ) ))
}
}
Text_Size_Screen_Scalar:
{
ui_settings_entry_inputbox( & font_size_screen_scalar_input, false, "settings_menu.font_size_screen_scalar", str_intern("Font: Size Screen Scalar"),
ui_settings_entry_inputbox( & text_size_screen_scalar_input, false, "settings_menu.text_size_screen_scalar", str_intern("Text: Size Screen Scalar"),
UI_TextInput_Policy {
digits_only = true,
disallow_leading_zeros = false,
@ -508,7 +579,7 @@ ui_settings_menu_builder :: proc( captures : rawptr = nil ) -> ( should_raise :
max_length = 5,
}
)
using font_size_screen_scalar_input
using text_size_screen_scalar_input
if was_active
{
@ -525,38 +596,9 @@ ui_settings_menu_builder :: proc( captures : rawptr = nil ) -> ( should_raise :
}
}
Text_Snap_Glyph_Positions:
{
ui_settings_entry_inputbox( & font_size_canvas_scalar_input, false, "settings_menu.font_size_canvas_scalar", str_intern("Font: Size Canvas Scalar"),
UI_TextInput_Policy {
digits_only = true,
disallow_leading_zeros = false,
disallow_decimal = false,
digit_min = 0,
digit_max = 1,
max_length = 1,
}
)
using font_size_canvas_scalar_input
if was_active
{
value, success := parse_f32(to_string(array_to_slice(input_str)))
if success {
value = clamp(value, 0, 1)
config.text_snap_glyph_positions = cast(b32) i32(value)
}
}
else
{
clear( input_str )
append( & input_str, to_runes(str_fmt("%v", config.text_snap_glyph_positions)))
}
}
Text_Size_Canvas_Scalar:
{
ui_settings_entry_inputbox( & font_size_canvas_scalar_input, false, "settings_menu.font_size_canvas_scalar", str_intern("Font: Size Canvas Scalar"),
ui_settings_entry_inputbox( & text_size_canvas_scalar_input, false, "settings_menu.text_size_canvas_scalar", str_intern("Text: Size Canvas Scalar"),
UI_TextInput_Policy {
digits_only = true,
disallow_leading_zeros = false,
@ -566,7 +608,7 @@ ui_settings_menu_builder :: proc( captures : rawptr = nil ) -> ( should_raise :
max_length = 5,
}
)
using font_size_canvas_scalar_input
using text_size_canvas_scalar_input
if was_active
{
@ -585,24 +627,25 @@ ui_settings_menu_builder :: proc( captures : rawptr = nil ) -> ( should_raise :
Text_Alpha_Sharpen:
{
ui_settings_entry_inputbox( & font_size_canvas_scalar_input, false, "settings_menu.text_alpha_sharpen", str_intern("Text: Alpha Sharpen"),
ui_settings_entry_inputbox( & text_alpha_sharpen, false, "settings_menu.text_alpha_sharpen", str_intern("Text: Alpha Sharpen"),
UI_TextInput_Policy {
digits_only = true,
disallow_leading_zeros = false,
disallow_decimal = false,
digit_min = 0.001,
digit_max = 10,
digit_max = 999,
max_length = 4,
}
)
using font_size_canvas_scalar_input
using text_alpha_sharpen
if was_active
{
value, success := parse_f32(to_string(array_to_slice(input_str)))
if success {
value = clamp(value, 0.001, 10.0)
value = clamp(value, 0, 10.0)
config.text_alpha_sharpen = value
font_provider_set_alpha_sharpen(value)
}
}
else

View File

@ -161,10 +161,11 @@ AppConfig :: struct {
color_theme : AppColorTheme,
text_snap_glyph_positions : b32,
text_size_screen_scalar : f32,
text_size_canvas_scalar : f32,
text_alpha_sharpen : f32,
text_snap_glyph_shape_position : b32,
text_snap_glyph_render_height : b32,
text_size_screen_scalar : f32,
text_size_canvas_scalar : f32,
text_alpha_sharpen : f32,
}
AppWindow :: struct {

View File

@ -136,7 +136,7 @@ startup :: proc( prof : ^SpallProfiler, persistent_mem, frame_mem, transient_mem
resolution_height = 600
refresh_rate = 0
cam_min_zoom = 0.025
cam_min_zoom = 0.034
cam_max_zoom = 5.0
cam_zoom_mode = .Digital
cam_zoom_smooth_snappiness = 4.0
@ -152,10 +152,11 @@ startup :: proc( prof : ^SpallProfiler, persistent_mem, frame_mem, transient_mem
color_theme = App_Thm_Dusk
text_snap_glyph_positions = true
text_size_screen_scalar = 2.0
text_size_canvas_scalar = 2.0
text_alpha_sharpen = 0.25
text_snap_glyph_shape_position = false
text_snap_glyph_render_height = false
text_size_screen_scalar = 1.89
text_size_canvas_scalar = 1.89
text_alpha_sharpen = 0.1
}
Desired_OS_Scheduler_MS :: 1
@ -356,8 +357,9 @@ startup :: proc( prof : ^SpallProfiler, persistent_mem, frame_mem, transient_mem
// debug.path_lorem = str_fmt("C:/projects/SectrPrototype/examples/Lorem Ipsum (197).txt", allocator = persistent_slab_allocator())
// debug.path_lorem = str_fmt("C:/projects/SectrPrototype/examples/Lorem Ipsum (1022).txt", allocator = persistent_slab_allocator())
debug.path_lorem = str_fmt("C:/projects/SectrPrototype/examples/sokol_gp.h", allocator = persistent_slab_allocator())
// debug.path_lorem = str_fmt("C:/projects/SectrPrototype/examples/ve_fontcache.h", allocator = persistent_slab_allocator())
debug.path_lorem = str_fmt("C:/projects/SectrPrototype/examples/sokol_gp.h", allocator = persistent_slab_allocator())
// debug.path_lorem = str_fmt("C:/projects/SectrPrototype/examples/sokol_gl.h", allocator = persistent_slab_allocator())
alloc_error : AllocatorError; success : bool
debug.lorem_content, success = os.read_entire_file( debug.path_lorem, persistent_slab_allocator() )
@ -530,9 +532,6 @@ tick_work_frame :: #force_inline proc( host_delta_time_ms : f64 ) -> b32
debug.draw_ui_padding_bounds = false
debug.draw_ui_content_bounds = false
font_provider_set_alpha_sharpen(0.25)
font_provider_set_snap_glyph_pos(true)
// config.engine_refresh_hz = 165
// config.color_theme = App_Thm_Light

View File

@ -123,7 +123,7 @@ render_mode_screenspace :: proc( screen_extent : Extents2, screen_ui : ^UI_State
screen_size := screen_extent * 2
screen_ratio := screen_size.x * ( 1.0 / screen_size.y )
font_provider_set_px_scalar( app_config().text_size_canvas_scalar )
font_provider_set_px_scalar( app_config().text_size_screen_scalar )
ve.configure_snap( ve_ctx, u32(screen_size.x), u32(screen_size.y) )
render_screen_ui( screen_extent, screen_ui, ve_ctx, ve_render )

View File

@ -302,6 +302,7 @@ update :: proc( delta_time : f64 ) -> b32
// TODO(Ed): We need input buffer so that we can consume input actions based on the UI with priority
font_provider_set_px_scalar( app_config().text_size_screen_scalar )
ui_screen_tick( & get_state().screen_ui )
//region WorkspaceImgui Tick

View File

@ -61,6 +61,13 @@ font_provider_reload :: proc( ctx : ^FontProviderContext )
ve.clear_shape_cache(& ctx.ve_ctx)
}
font_provider_flush_caches :: proc()
{
ve_ctx := & get_state().font_provider_ctx.ve_ctx
ve.clear_atlas_region_caches(ve_ctx)
ve.clear_shape_cache(ve_ctx)
}
font_provider_shutdown :: proc( ctx : ^FontProviderContext )
{
ve.shutdown( & ctx.ve_ctx )
@ -120,8 +127,12 @@ font_provider_set_px_scalar :: #force_inline proc( scalar : f32 ) {
ve.set_px_scalar( & get_state().font_provider_ctx.ve_ctx, scalar )
}
font_provider_set_snap_glyph_pos :: #force_inline proc( should_snap : b32 ) {
ve.set_snap_glyph_pos( & get_state().font_provider_ctx.ve_ctx, should_snap )
font_provider_set_snap_glyph_shape_position :: #force_inline proc( should_snap : b32 ) {
ve.set_snap_glyph_shape_position( & get_state().font_provider_ctx.ve_ctx, should_snap )
}
font_provider_set_snap_glyph_render_height :: #force_inline proc( should_snap : b32 ) {
ve.set_snap_glyph_render_height( & get_state().font_provider_ctx.ve_ctx, should_snap )
}
Font_Use_Default_Size :: f32(0.0)

View File

@ -89,9 +89,9 @@ PWS_ParseError :: struct {
}
PWS_ParseError_Max :: 32
PWS_TokenArray_ReserveSize :: 128
PWS_NodeArray_ReserveSize :: 32 * Kilobyte
PWS_LineArray_ReserveSize :: 32 * Kilobyte
PWS_TokenArray_ReserveSize :: 4 * Kilobyte
PWS_NodeArray_ReserveSize :: 64 * Kilobyte
PWS_LineArray_ReserveSize :: 64 * Kilobyte
// TODO(Ed) : The ast arrays should be handled by a slab allocator dedicated to PWS_ASTs
// This can grow in undeterministic ways, persistent will get very polluted otherwise.

View File

@ -114,8 +114,8 @@ UI_Layout_Stack_Size :: 512
UI_Style_Stack_Size :: 512
UI_Parent_Stack_Size :: 512
// UI_Built_Boxes_Array_Size :: 8
UI_Built_Boxes_Array_Size :: 56 * Kilobyte
UI_BoxCache_TableSize :: 8 * Kilobyte
UI_Built_Boxes_Array_Size :: 128 * Kilobyte
UI_BoxCache_TableSize :: 32 * Kilobyte
// TODO(Ed): Rename to UI_Context
UI_State :: struct {
@ -381,7 +381,7 @@ ui_hash_part_from_key_string :: proc ( content : string ) -> string {
ui_key_from_string :: #force_inline proc "contextless" ( value : string ) -> UI_Key
{
// profile(#procedure)
USE_RAD_DEBUGGERS_METHOD :: true
USE_RAD_DEBUGGERS_METHOD :: false
key : UI_Key