From 8c7b3e205838e5acbb2fe0d8ca2421abadadf148 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Fri, 3 Jan 2025 13:06:05 -0500 Subject: [PATCH] misc changes --- code/grime/hashing.odin | 5 ++++ code/grime/memory.odin | 6 ++++- code/sectr/font/render_sokol.odin | 4 +-- code/sectr/grime/mappings.odin | 41 ++++++++++++++++++++++++++++++- code/sectr/ui/core/base.odin | 7 ++++++ 5 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 code/grime/hashing.odin diff --git a/code/grime/hashing.odin b/code/grime/hashing.odin new file mode 100644 index 0000000..41fa323 --- /dev/null +++ b/code/grime/hashing.odin @@ -0,0 +1,5 @@ +package grime + +djb8_hash :: #force_inline proc "contextless" ( hash : ^u64, bytes : []byte ) { + for value in bytes do (hash^) = (( (hash^) << 8) + (hash^) ) + u64(value) +} diff --git a/code/grime/memory.odin b/code/grime/memory.odin index 586c186..5c543f9 100644 --- a/code/grime/memory.odin +++ b/code/grime/memory.odin @@ -94,4 +94,8 @@ memory_aign_forward :: #force_inline proc( address, alignment : uintptr) -> uint //endregion Memory Math -swap :: #force_inline proc( a, b : ^ $Type ) -> ( ^ Type, ^ Type ) { return b, a } +swap :: #force_inline proc "contextless" ( a, b : ^ $Type ) -> ( ^ Type, ^ Type ) { return b, a } + +to_bytes :: #force_inline proc "contextless" ( typed_block : ^$Type ) -> []byte { + return slice_ptr( transmute(^byte) typed_block, size_of(Type) ) +} diff --git a/code/sectr/font/render_sokol.odin b/code/sectr/font/render_sokol.odin index 77a80ff..a4c99ad 100644 --- a/code/sectr/font/render_sokol.odin +++ b/code/sectr/font/render_sokol.odin @@ -169,14 +169,14 @@ font_provider_setup_sokol_gfx_objects :: proc( ctx : ^VE_RenderData, ve_ctx : ve glyph_rt_sampler = sokol_gfx.make_sampler( SamplerDescription { min_filter = Image_Filter, mag_filter = Image_Filter, - mipmap_filter = Filter.LINEAR, + mipmap_filter = Filter.NEAREST, wrap_u = .CLAMP_TO_EDGE, wrap_v = .CLAMP_TO_EDGE, min_lod = -1000.0, max_lod = 1000.0, border_color = BorderColor.OPAQUE_BLACK, compare = .NEVER, - max_anisotropy = 16, + max_anisotropy = 1, }) verify( sokol_gfx.query_sampler_state( glyph_rt_sampler) < ResourceState.FAILED, "Failed to make atlas_rt_sampler" ) diff --git a/code/sectr/grime/mappings.odin b/code/sectr/grime/mappings.odin index 7ab3c4f..d439412 100644 --- a/code/sectr/grime/mappings.odin +++ b/code/sectr/grime/mappings.odin @@ -4,7 +4,8 @@ package sectr #region("base") import "base:builtin" - copy :: builtin.copy + copy :: builtin.copy + // byte_slice :: builtin.byte_slice import "base:intrinsics" mem_zero :: intrinsics.mem_zero @@ -51,6 +52,26 @@ import fmt_io "core:fmt" str_tmp_from_any :: fmt_io.tprint import "core:math" + ceil_f16 :: math.ceil_f16 + ceil_f16le :: math.ceil_f16le + ceil_f16be :: math.ceil_f16be + ceil_f32 :: math.ceil_f32 + ceil_f32le :: math.ceil_f32le + ceil_f32be :: math.ceil_f32be + ceil_f64 :: math.ceil_f64 + ceil_f64le :: math.ceil_f64le + ceil_f64be :: math.ceil_f64be + + floor_f16 :: math.floor_f16 + floor_f16le :: math.floor_f16le + floor_f16be :: math.floor_f16be + floor_f32 :: math.floor_f32 + floor_f32le :: math.floor_f32le + floor_f32be :: math.floor_f32be + floor_f64 :: math.floor_f64 + floor_f64le :: math.floor_f64le + floor_f64be :: math.floor_f64be + lerp :: math.lerp import "core:math/bits" @@ -239,6 +260,9 @@ import "codebase:grime" file_exists :: grime.file_exists file_rewind :: grime.file_rewind + // hashing + djb8_hash :: grime.djb8_hash + // linked lists LL_Node :: grime.LL_Node @@ -278,6 +302,7 @@ import "codebase:grime" memory_after_header :: grime.memory_after_header memory_after :: grime.memory_after swap :: grime.swap + to_bytes :: grime.to_bytes // strings StrRunesPair :: grime.StrRunesPair @@ -346,6 +371,20 @@ bivec3 :: proc { vec3_to_bivec3, } +ceil :: proc { + math.ceil_f16, + math.ceil_f16le, + math.ceil_f16be, + math.ceil_f32, + math.ceil_f32le, + math.ceil_f32be, + math.ceil_f64, + math.ceil_f64le, + math.ceil_f64be, + + // ceil_vec2, +} + clear :: proc{ grime.array_clear, } diff --git a/code/sectr/ui/core/base.odin b/code/sectr/ui/core/base.odin index dad6323..860d692 100644 --- a/code/sectr/ui/core/base.odin +++ b/code/sectr/ui/core/base.odin @@ -274,6 +274,13 @@ ui_graph_build_end :: proc( ui : ^UI_State ) for current := ui.root.first; current != nil; current = ui_box_tranverse_next_depth_first( current, bypass_intersection_test = true, ctx = ui ) { + // prev_box := ui_prev_cached_box( current ) + // prev_hash : u64 + // curr_hash : u64 + // djb8_hash( & prev_hash, to_bytes(& prev_box.layout) ) + // djb8_hash( & curr_hash, to_bytes(& current.layout) ) + // current.computed.fresh = prev_hash == curr_hash && (current.parent != nil && current.parent.computed.fresh) + if ! current.computed.fresh { if len(current.text.str) > 0 {