Fixed input event buffer issues
Queue doesn't properly act as a ring buffer had to roll my own. I want to make a allocated ring buffer as well...
This commit is contained in:
		| @@ -1,60 +0,0 @@ | ||||
| /* | ||||
| The default arena allocator Odin provides does fragmented resizes even for the last most allocated block getting resized. | ||||
| This is an alternative to alleviates that. | ||||
|  | ||||
| TODO(Ed): Implement? Maybe we should trash this I' haven't seen a need to step away from using odin's | ||||
| */ | ||||
| package sectr | ||||
|  | ||||
| import "core:mem" | ||||
|  | ||||
| // Initialize a sub-section of our virtual memory as a sub-arena | ||||
| sub_arena_init :: proc( address : ^byte, size : int ) -> ( ^ Arena) { | ||||
| 	Arena :: mem.Arena | ||||
|  | ||||
| 	arena_size :: size_of( Arena) | ||||
| 	sub_arena  := cast( ^ Arena ) address | ||||
| 	mem_slice  := slice_ptr( ptr_offset( address, arena_size), size ) | ||||
| 	arena_init( sub_arena, mem_slice ) | ||||
| 	return sub_arena | ||||
| } | ||||
|  | ||||
| ArenaFixedHeader :: struct { | ||||
| 	data      : []byte, | ||||
| 	offset    : uint, | ||||
| 	peak_used : uint, | ||||
| } | ||||
|  | ||||
| ArenaFixed :: struct { | ||||
| 	using header : ^ArenaFixedHeader, | ||||
| } | ||||
|  | ||||
| arena_fixed_init :: proc( backing : []byte ) -> (arena : ArenaFixed) { | ||||
| 	header_size := size_of(ArenaFixedHeader) | ||||
|  | ||||
| 	verify(len(backing) >= (header_size + Kilobyte), "Attempted to init an arena with less than kilobyte of memory...") | ||||
|  | ||||
| 	arena.header = cast(^ArenaFixedHeader) raw_data(backing) | ||||
| 	using arena.header | ||||
| 	data_ptr := cast([^]byte) (cast( [^]ArenaFixedHeader) arena.header)[ 1:] | ||||
| 	data      = slice_ptr( data_ptr, len(backing) - header_size ) | ||||
| 	offset    = 0 | ||||
| 	peak_used = 0 | ||||
| 	return | ||||
| } | ||||
|  | ||||
| arena_fixed_allocator_proc :: proc( | ||||
| 	allocator_data : rawptr, | ||||
| 	mode           : AllocatorMode, | ||||
| 	size           : int, | ||||
| 	alignment      : int, | ||||
| 	old_memory     : rawptr, | ||||
| 	old_size       : int, | ||||
| 	location       := #caller_location | ||||
| ) -> ([]byte, AllocatorError) | ||||
| { | ||||
|  | ||||
|  | ||||
| 	return nil, .Out_Of_Memory | ||||
| } | ||||
|  | ||||
| @@ -30,8 +30,8 @@ import "base:runtime" | ||||
|  | ||||
| import c "core:c/libc" | ||||
|  | ||||
| import "core:container/queue" | ||||
| 	Queue :: queue.Queue | ||||
| // import "core:container/queue" | ||||
| 	// Queue :: queue.Queue | ||||
|  | ||||
| // import "core:dynlib" | ||||
|  | ||||
| @@ -188,12 +188,26 @@ import "codebase:grime" | ||||
| 	hmap_zpl_reload :: grime.hmap_zpl_reload | ||||
| 	hmap_zpl_set    :: grime.hmap_zpl_set | ||||
|  | ||||
| 	make_queue :: grime.make_queue | ||||
| 	// make_queue :: grime.make_queue | ||||
|  | ||||
| 	next_queue_iterator :: grime.next_queue_iterator | ||||
| 	// next_queue_iterator :: grime.next_queue_iterator | ||||
|  | ||||
| 	Pool :: grime.Pool | ||||
|  | ||||
| 	RingBufferFixed         :: grime.RingBufferFixed | ||||
| 	RingBufferFixedIterator :: grime.RingBufferFixedIterator | ||||
|  | ||||
| 	ringbuf_fixed_clear      :: grime.ringbuf_fixed_clear | ||||
| 	ringbuf_fixed_is_full    :: grime.ringbuf_fixed_is_full | ||||
| 	ringbuf_fixed_is_empty   :: grime.ringbuf_fixed_is_empty | ||||
| 	ringbuf_fixed_peak_back  :: grime.ringbuf_fixed_peak_back | ||||
| 	ringbuf_fixed_push       :: grime.ringbuf_fixed_push | ||||
| 	ringbuf_fixed_push_slice :: grime.ringbuf_fixed_push_slice | ||||
| 	ringbuf_fixed_pop        :: grime.ringbuf_fixed_pop | ||||
|  | ||||
| 	iterator_ringbuf_fixed :: grime.iterator_ringbuf_fixed | ||||
| 	next_ringbuf_fixed_iterator :: grime.next_ringbuf_fixed_iterator | ||||
|  | ||||
| 	Slab          :: grime.Slab | ||||
| 	SlabPolicy    :: grime.SlabPolicy | ||||
| 	SlabSizeClass :: grime.SlabSizeClass | ||||
| @@ -368,14 +382,15 @@ is_power_of_two :: proc { | ||||
| } | ||||
|  | ||||
| iterator :: proc { | ||||
| 	grime.iterator_queue, | ||||
| 	// grime.iterator_queue, | ||||
| 	grime.iterator_ringbuf_fixed, | ||||
| } | ||||
|  | ||||
| make :: proc { | ||||
| 	array_init, | ||||
| 	hmap_chained_init, | ||||
| 	hmap_zpl_init, | ||||
| 	make_queue, | ||||
| 	// make_queue, | ||||
|  | ||||
| 	// Usual | ||||
| 	make_slice, | ||||
| @@ -396,16 +411,17 @@ mov_avg_exp :: proc { | ||||
| } | ||||
|  | ||||
| next :: proc { | ||||
| 	next_queue_iterator, | ||||
| 	// next_queue_iterator, | ||||
| 	next_ringbuf_fixed_iterator, | ||||
| } | ||||
|  | ||||
| peek_back :: proc { | ||||
| 	queue.peek_back, | ||||
| 	ringbuf_fixed_peak_back, | ||||
| } | ||||
|  | ||||
| peek_front :: proc { | ||||
| 	queue.peek_front, | ||||
| } | ||||
| // peek_front :: proc { | ||||
| // 	queue.peek_front, | ||||
| // } | ||||
|  | ||||
| pixels_to_cm :: proc { | ||||
| 	f32_pixels_to_cm, | ||||
| @@ -444,8 +460,11 @@ pressed :: proc { | ||||
| } | ||||
|  | ||||
| push :: proc { | ||||
| 	queue.push_back, | ||||
| 	grime.push_back_slice_queue, | ||||
| 	ringbuf_fixed_push, | ||||
| 	ringbuf_fixed_push_slice, | ||||
|  | ||||
| 	// queue.push_back, | ||||
| 	// grime.push_back_slice_queue, | ||||
|  | ||||
| 	stack_push, | ||||
| 	stack_allocator_push, | ||||
| @@ -476,10 +495,6 @@ reload :: proc { | ||||
| 	grime.reload_map, | ||||
| } | ||||
|  | ||||
| space_left :: proc { | ||||
| 	queue.space, | ||||
| } | ||||
|  | ||||
| scope :: proc { | ||||
| 	ui_layout_scope_via_layout, | ||||
| 	ui_layout_scope_via_combo, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user