Compare commits
2 Commits
5a3b8ef3b9
...
0f621b4e1b
| Author | SHA1 | Date | |
|---|---|---|---|
| 0f621b4e1b | |||
| 62979b480e |
@@ -205,7 +205,7 @@ mem_save_point :: proc(ainfo := context.allocator, loc := #caller_location) -> A
|
||||
resolve_allocator_proc(ainfo.procedure)({data = ainfo.data, op = .SavePoint, loc = loc}, & out)
|
||||
return out.save_point
|
||||
}
|
||||
mem_alloc :: proc(size: int, alignment: int = MEMORY_ALIGNMENT_DEFAULT, no_zero: bool = false, ainfo : $Type = context.allocator, loc := #caller_location) -> ([]byte, AllocatorError) {
|
||||
mem_alloc :: proc(size: int, alignment: int = MEMORY_ALIGNMENT_DEFAULT, no_zero: bool = false, ainfo: $Type = context.allocator, loc := #caller_location) -> ([]byte, AllocatorError) {
|
||||
assert(ainfo.procedure != nil)
|
||||
input := AllocatorProc_In {
|
||||
data = ainfo.data,
|
||||
|
||||
@@ -159,7 +159,7 @@ array_append_at_value :: proc(self: ^Array($Type), item: Type, id: int) -> Alloc
|
||||
return AllocatorError.None
|
||||
}
|
||||
|
||||
array_back :: #force_inline proc "contextless" (self : Array($Type)) -> Type { assert(self.num > 0); return self.data[self.num - 1] }
|
||||
array_back :: #force_inline proc "contextless" (self : Array($Type)) -> Type { assert_contextless(self.num > 0); return self.data[self.num - 1] }
|
||||
|
||||
array_clear :: #force_inline proc "contextless" (self: Array($Type), zero_data: bool = false) {
|
||||
if zero_data do zero(self.data, int(self.num) * size_of(Type))
|
||||
|
||||
@@ -15,9 +15,9 @@ align_pow2 :: #force_inline proc "contextless" (ptr, align: int) -> int {
|
||||
return ptr & ~(align-1)
|
||||
}
|
||||
|
||||
memory_zero_explicit :: #force_inline proc "contextless" (data: rawptr, len: int) -> rawptr {
|
||||
mem_zero_volatile(data, len) // Use the volatile mem_zero
|
||||
atomic_thread_fence(.Seq_Cst) // Prevent reordering
|
||||
sync_mem_zero :: #force_inline proc "contextless" (data: rawptr, len: int) -> rawptr {
|
||||
mem_zero_volatile(data, len) // Use the volatile mem_zero
|
||||
sync_fence(.Seq_Cst) // Prevent reordering
|
||||
return data
|
||||
}
|
||||
|
||||
@@ -38,11 +38,14 @@ slice_assert :: #force_inline proc "contextless" (s: $SliceType / []$Type) {
|
||||
slice_end :: #force_inline proc "contextless" (s : $SliceType / []$Type) -> ^Type { return cursor(s)[len(s):] }
|
||||
slice_byte_end :: #force_inline proc "contextless" (s : SliceByte) -> ^byte { return s.data[s.len:] }
|
||||
|
||||
slice_zero :: #force_inline proc "contextless" (s: $SliceType / []$Type) {
|
||||
assert_contextless(len(s) > 0)
|
||||
mem_zero(raw_data(s), size_of(Type) * len(s))
|
||||
}
|
||||
slice_copy :: #force_inline proc "contextless" (dst, src: $SliceType / []$Type) -> int {
|
||||
n := max(0, min(len(dst), len(src)))
|
||||
if n > 0 {
|
||||
mem_copy(raw_data(dst), raw_data(src), n * size_of(Type))
|
||||
}
|
||||
assert_contextless(n > 0)
|
||||
mem_copy(raw_data(dst), raw_data(src), n * size_of(Type))
|
||||
return n
|
||||
}
|
||||
|
||||
@@ -84,37 +87,33 @@ calc_padding_with_header :: proc "contextless" (pointer: uintptr, alignment: uin
|
||||
}
|
||||
|
||||
// Helper to get the the beginning of memory after a slice
|
||||
memory_after :: #force_inline proc "contextless" ( s: []byte ) -> ( ^ byte) {
|
||||
@(require_results)
|
||||
memory_after :: #force_inline proc "contextless" (s: []byte ) -> (^byte) {
|
||||
return cursor(s)[len(s):]
|
||||
}
|
||||
|
||||
memory_after_header :: #force_inline proc "contextless" ( header : ^($ Type) ) -> ( [^]byte) {
|
||||
memory_after_header :: #force_inline proc "contextless" (header: ^($Type)) -> ([^]byte) {
|
||||
result := cast( [^]byte) ptr_offset( header, 1 )
|
||||
// result := cast( [^]byte) (cast( [^]Type) header)[ 1:]
|
||||
return result
|
||||
}
|
||||
|
||||
@(require_results)
|
||||
memory_align_formula :: #force_inline proc "contextless" ( size, align : uint) -> uint {
|
||||
memory_align_formula :: #force_inline proc "contextless" (size, align: uint) -> uint {
|
||||
result := size + align - 1
|
||||
return result - result % align
|
||||
}
|
||||
|
||||
// This is here just for docs
|
||||
memory_misalignment :: #force_inline proc ( address, alignment : uintptr) -> uint {
|
||||
memory_misalignment :: #force_inline proc "contextless" (address, alignment: uintptr) -> uint {
|
||||
// address % alignment
|
||||
assert(is_power_of_two(alignment))
|
||||
assert_contextless(is_power_of_two(alignment))
|
||||
return uint( address & (alignment - 1) )
|
||||
}
|
||||
|
||||
// This is here just for docs
|
||||
@(require_results)
|
||||
memory_aign_forward :: #force_inline proc( address, alignment : uintptr) -> uintptr
|
||||
memory_aign_forward :: #force_inline proc "contextless" (address, alignment : uintptr) -> uintptr
|
||||
{
|
||||
assert(is_power_of_two(alignment))
|
||||
|
||||
assert_contextless(is_power_of_two(alignment))
|
||||
aligned_address := address
|
||||
misalignment := cast(uintptr) memory_misalignment( address, alignment )
|
||||
misalignment := transmute(uintptr) memory_misalignment( address, alignment )
|
||||
if misalignment != 0 {
|
||||
aligned_address += alignment - misalignment
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ import "core:os"
|
||||
file_truncate :: os.truncate
|
||||
file_write :: os.write
|
||||
|
||||
file_read_entire_from_filename :: #force_inline proc(name: string, allocator := context.allocator, loc := #caller_location) -> (data: []byte, success: bool) { return os.read_entire_file_from_filename(name, resolve_odin_allocator(allocator), loc) }
|
||||
file_read_entire_from_filename :: #force_inline proc(name: string, allocator := context.allocator, loc := #caller_location) -> ([]byte, bool) { return os.read_entire_file_from_filename(name, resolve_odin_allocator(allocator), loc) }
|
||||
file_write_entire :: os.write_entire_file
|
||||
|
||||
file_read_entire :: proc {
|
||||
@@ -91,15 +91,13 @@ import "core:strings"
|
||||
StrBuilder :: strings.Builder
|
||||
strbuilder_from_bytes :: strings.builder_from_bytes
|
||||
|
||||
import "core:slice"
|
||||
slice_zero :: slice.zero
|
||||
|
||||
import "core:prof/spall"
|
||||
Spall_Context :: spall.Context
|
||||
Spall_Buffer :: spall.Buffer
|
||||
|
||||
import "core:sync"
|
||||
Mutex :: sync.Mutex
|
||||
sync_fence :: sync.atomic_thread_fence
|
||||
sync_load :: sync.atomic_load_explicit
|
||||
sync_store :: sync.atomic_store_explicit
|
||||
|
||||
@@ -122,54 +120,50 @@ array_append :: proc {
|
||||
array_append_array,
|
||||
array_append_slice,
|
||||
}
|
||||
|
||||
array_append_at :: proc {
|
||||
// array_append_at_array,
|
||||
array_append_at_slice,
|
||||
array_append_at_value,
|
||||
}
|
||||
|
||||
cursor :: proc {
|
||||
raw_cursor,
|
||||
ptr_cursor,
|
||||
slice_cursor,
|
||||
string_cursor,
|
||||
}
|
||||
|
||||
end :: proc {
|
||||
slice_end,
|
||||
slice_byte_end,
|
||||
string_end,
|
||||
}
|
||||
|
||||
copy :: proc {
|
||||
mem_copy,
|
||||
slice_copy,
|
||||
}
|
||||
|
||||
copy_non_overlaping :: proc {
|
||||
mem_copy_non_overlapping,
|
||||
slice_copy_overlapping,
|
||||
}
|
||||
|
||||
fill :: proc {
|
||||
mem_fill,
|
||||
slice_fill,
|
||||
}
|
||||
|
||||
iterator :: proc {
|
||||
iterator_ringbuf_fixed,
|
||||
}
|
||||
make :: proc {
|
||||
array_init,
|
||||
}
|
||||
|
||||
peek_back :: proc {
|
||||
ringbuf_fixed_peak_back,
|
||||
}
|
||||
to_bytes :: proc {
|
||||
slice_to_bytes,
|
||||
type_to_bytes,
|
||||
}
|
||||
|
||||
to_string :: proc {
|
||||
strings.to_string,
|
||||
}
|
||||
|
||||
zero :: proc {
|
||||
mem_zero,
|
||||
slice_zero,
|
||||
|
||||
@@ -1,126 +1,96 @@
|
||||
package grime
|
||||
|
||||
RingBufferFixed :: struct( $Type: typeid, $Size: u32 ) {
|
||||
FRingBuffer :: struct( $Type: typeid, $Size: u32 ) {
|
||||
head : u32,
|
||||
tail : u32,
|
||||
num : u32,
|
||||
items : [Size] Type,
|
||||
}
|
||||
|
||||
ringbuf_fixed_clear :: #force_inline proc "contextless" ( using buffer : ^RingBufferFixed( $Type, $Size)) {
|
||||
head = 0
|
||||
tail = 0
|
||||
num = 0
|
||||
}
|
||||
ringbuf_fixed_cslear :: #force_inline proc "contextless" (ring: ^FRingBuffer($Type, $Size)) { ring.head = 0; ring.tail = 0; ring.num = 0 }
|
||||
ringbuf_fixed_is_full :: #force_inline proc "contextless" (ring: FRingBuffer($Type, $Size)) -> bool { return ring.num == ring.Size }
|
||||
ringbuf_fixed_is_empty :: #force_inline proc "contextless" (ring: FRingBuffer($Type, $Size)) -> bool { return ring.num == 0 }
|
||||
|
||||
ringbuf_fixed_is_full :: #force_inline proc "contextless" ( using buffer : RingBufferFixed( $Type, $Size)) -> bool {
|
||||
return num == Size
|
||||
}
|
||||
|
||||
ringbuf_fixed_is_empty :: #force_inline proc "contextless" ( using buffer : RingBufferFixed( $Type, $Size)) -> bool {
|
||||
return num == 0
|
||||
}
|
||||
|
||||
ringbuf_fixed_peek_front_ref :: #force_inline proc "contextless" ( using buffer : ^RingBufferFixed( $Type, $Size)) -> ^Type {
|
||||
assert(num > 0, "Attempted to peek an empty ring buffer")
|
||||
ringbuf_fixed_peek_front_ref :: #force_inline proc "contextless" (using buffer: ^FRingBuffer($Type, $Size)) -> ^Type {
|
||||
assert_contextless(num > 0, "Attempted to peek an empty ring buffer")
|
||||
return & items[ head ]
|
||||
}
|
||||
|
||||
ringbuf_fixed_peek_front :: #force_inline proc "contextless" ( using buffer : RingBufferFixed( $Type, $Size)) -> Type {
|
||||
assert(num > 0, "Attempted to peek an empty ring buffer")
|
||||
ringbuf_fixed_peek_front :: #force_inline proc "contextless" ( using buffer : FRingBuffer( $Type, $Size)) -> Type {
|
||||
assert_contextless(num > 0, "Attempted to peek an empty ring buffer")
|
||||
return items[ head ]
|
||||
}
|
||||
|
||||
ringbuf_fixed_peak_back :: #force_inline proc ( using buffer : RingBufferFixed( $Type, $Size)) -> Type {
|
||||
assert(num > 0, "Attempted to peek an empty ring buffer")
|
||||
|
||||
ringbuf_fixed_peak_back :: #force_inline proc (using buffer : FRingBuffer( $Type, $Size)) -> Type {
|
||||
assert_contextless(num > 0, "Attempted to peek an empty ring buffer")
|
||||
buf_size := u32(Size)
|
||||
index := (tail - 1 + buf_size) % buf_size
|
||||
return items[ index ]
|
||||
}
|
||||
|
||||
ringbuf_fixed_push :: #force_inline proc(using buffer: ^RingBufferFixed($Type, $Size), value: Type) {
|
||||
ringbuf_fixed_push :: #force_inline proc(using buffer: ^FRingBuffer($Type, $Size), value: Type) {
|
||||
if num == Size do head = (head + 1) % Size
|
||||
else do num += 1
|
||||
|
||||
items[ tail ] = value
|
||||
tail = (tail + 1) % Size
|
||||
}
|
||||
|
||||
ringbuf_fixed_push_slice :: proc(buffer: ^RingBufferFixed($Type, $Size), slice: []Type) -> u32
|
||||
ringbuf_fixed_push_slice :: proc "contextless" (buffer: ^FRingBuffer($Type, $Size), slice: []Type) -> u32
|
||||
{
|
||||
size := u32(Size)
|
||||
slice_size := u32(len(slice))
|
||||
|
||||
// assert( slice_size <= size, "Attempting to append a slice that is larger than the ring buffer!" )
|
||||
assert_contextless( slice_size <= size, "Attempting to append a slice that is larger than the ring buffer!" )
|
||||
if slice_size == 0 do return 0
|
||||
|
||||
items_to_add := min( slice_size, size)
|
||||
items_added : u32 = 0
|
||||
|
||||
if items_to_add > Size - buffer.num
|
||||
{
|
||||
// Some or all existing items will be overwritten
|
||||
overwrite_count := items_to_add - (Size - buffer.num)
|
||||
buffer.head = (buffer.head + overwrite_count) % size
|
||||
buffer.num = size
|
||||
if items_to_add > Size - buffer.num {
|
||||
// Some or all existing items will be overwritten
|
||||
overwrite_count := items_to_add - (Size - buffer.num)
|
||||
buffer.head = (buffer.head + overwrite_count) % size
|
||||
buffer.num = size
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer.num += items_to_add
|
||||
else {
|
||||
buffer.num += items_to_add
|
||||
}
|
||||
|
||||
if items_to_add <= size
|
||||
{
|
||||
// Case 1: Slice fits entirely or partially in the buffer
|
||||
space_to_end := size - buffer.tail
|
||||
first_chunk := min(items_to_add, space_to_end)
|
||||
|
||||
// First copy: from tail to end of buffer
|
||||
copy( buffer.items[ buffer.tail: ] , slice[ :first_chunk ] )
|
||||
|
||||
if first_chunk < items_to_add {
|
||||
// Second copy: wrap around to start of buffer
|
||||
second_chunk := items_to_add - first_chunk
|
||||
copy( buffer.items[:], slice[ first_chunk : items_to_add ] )
|
||||
}
|
||||
|
||||
buffer.tail = (buffer.tail + items_to_add) % Size
|
||||
items_added = items_to_add
|
||||
if items_to_add <= size {
|
||||
// Case 1: Slice fits entirely or partially in the buffer
|
||||
space_to_end := size - buffer.tail
|
||||
first_chunk := min(items_to_add, space_to_end)
|
||||
// First copy: from tail to end of buffer
|
||||
copy( buffer.items[ buffer.tail: ] , slice[ :first_chunk ] )
|
||||
if first_chunk < items_to_add {
|
||||
// Second copy: wrap around to start of buffer
|
||||
second_chunk := items_to_add - first_chunk
|
||||
copy( buffer.items[:], slice[ first_chunk : items_to_add ] )
|
||||
}
|
||||
buffer.tail = (buffer.tail + items_to_add) % Size
|
||||
items_added = items_to_add
|
||||
}
|
||||
else
|
||||
{
|
||||
// Case 2: Slice is larger than buffer, only keep last Size elements
|
||||
to_add := slice[ slice_size - size: ]
|
||||
|
||||
// First copy: from start of buffer to end
|
||||
first_chunk := min(Size, u32(len(to_add)))
|
||||
copy( buffer.items[:], to_add[ :first_chunk ] )
|
||||
|
||||
if first_chunk < Size
|
||||
{
|
||||
if first_chunk < Size {
|
||||
// Second copy: wrap around
|
||||
copy( buffer.items[ first_chunk: ], to_add[ first_chunk: ] )
|
||||
}
|
||||
|
||||
buffer.head = 0
|
||||
buffer.tail = 0
|
||||
buffer.num = Size
|
||||
items_added = Size
|
||||
}
|
||||
|
||||
return items_added
|
||||
}
|
||||
|
||||
ringbuf_fixed_pop :: #force_inline proc "contextless" ( using buffer : ^RingBufferFixed( $Type, $Size )) -> Type {
|
||||
assert(num > 0, "Attempted to pop an empty ring buffer")
|
||||
ringbuf_fixed_pop :: #force_inline proc "contextless" (using buffer: ^FRingBuffer($Type, $Size)) -> Type {
|
||||
assert_contextless(num > 0, "Attempted to pop an empty ring buffer")
|
||||
value := items[ head ]
|
||||
head = ( head + 1 ) % Size
|
||||
num -= 1
|
||||
num -= 1
|
||||
return value
|
||||
}
|
||||
|
||||
RingBufferFixedIterator :: struct( $Type : typeid) {
|
||||
FRingBufferIterator :: struct($Type : typeid) {
|
||||
items : []Type,
|
||||
head : u32,
|
||||
tail : u32,
|
||||
@@ -128,41 +98,29 @@ RingBufferFixedIterator :: struct( $Type : typeid) {
|
||||
remaining : u32,
|
||||
}
|
||||
|
||||
iterator_ringbuf_fixed :: proc(buffer: ^RingBufferFixed($Type, $Size)) -> RingBufferFixedIterator(Type)
|
||||
iterator_ringbuf_fixed :: proc "contextless" (buffer: ^FRingBuffer($Type, $Size)) -> FRingBufferIterator(Type)
|
||||
{
|
||||
iter := RingBufferFixedIterator(Type){
|
||||
iter := FRingBufferIterator(Type){
|
||||
items = buffer.items[:],
|
||||
head = buffer.head,
|
||||
tail = buffer.tail,
|
||||
remaining = buffer.num,
|
||||
}
|
||||
|
||||
buff_size := u32(Size)
|
||||
|
||||
if buffer.num > 0 {
|
||||
// Start from the last pushed item (one before tail)
|
||||
iter.index = (buffer.tail - 1 + buff_size) % buff_size
|
||||
} else {
|
||||
iter.index = buffer.tail // This will not be used as remaining is 0
|
||||
}
|
||||
|
||||
return iter
|
||||
}
|
||||
|
||||
next_ringbuf_fixed_iterator :: proc(iter : ^RingBufferFixedIterator( $Type)) -> ^Type
|
||||
{
|
||||
using iter
|
||||
if remaining == 0 {
|
||||
return nil // If there are no items left to iterate over
|
||||
}
|
||||
|
||||
next_ringbuf_fixed_iterator :: proc(iter: ^FRingBufferIterator($Type)) -> ^Type {
|
||||
using iter; if remaining == 0 do return nil // If there are no items left to iterate over
|
||||
buf_size := cast(u32) len(items)
|
||||
|
||||
result := &items[index]
|
||||
|
||||
result := &items[index]
|
||||
// Decrement index and wrap around if necessary
|
||||
index = (index - 1 + buf_size) % buf_size
|
||||
|
||||
index = (index - 1 + buf_size) % buf_size
|
||||
remaining -= 1
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package grime
|
||||
|
||||
//region STATIC MEMORY
|
||||
grime_memory: StaticMemory
|
||||
@thread_local grime_thread: ThreadMemory
|
||||
//endregion STATIC MEMORY
|
||||
@(private) grime_memory: StaticMemory
|
||||
@(private, thread_local) grime_thread: ThreadMemory
|
||||
|
||||
StaticMemory :: struct {
|
||||
spall_context: ^Spall_Context,
|
||||
|
||||
@@ -8,3 +8,13 @@ string_cursor :: #force_inline proc "contextless" (s: string) -> [^]u8 { return
|
||||
string_copy :: #force_inline proc "contextless" (dst, src: string) { slice_copy (transmute([]byte) dst, transmute([]byte) src) }
|
||||
string_end :: #force_inline proc "contextless" (s: string) -> ^u8 { return slice_end (transmute([]byte) s) }
|
||||
string_assert :: #force_inline proc "contextless" (s: string) { slice_assert(transmute([]byte) s) }
|
||||
|
||||
str_to_cstr_capped :: proc(content: string, mem: []byte) -> cstring {
|
||||
copy_len := min(len(content), len(mem) - 1)
|
||||
if copy_len > 0 do copy(mem[:copy_len], transmute([]byte) content)
|
||||
mem[copy_len] = 0
|
||||
return transmute(cstring) raw_data(mem)
|
||||
}
|
||||
|
||||
cstr_len_capped :: #force_inline proc "contextless" (content: cstring, cap: int) -> (len: int) { for len = 0; (len <= cap) && (transmute([^]byte)content)[len] != 0; len += 1 {} return }
|
||||
cstr_to_str_capped :: #force_inline proc "contextless" (content: cstring, mem: []byte) -> string { return transmute(string) Raw_String { cursor(mem), cstr_len_capped (content, len(mem)) } }
|
||||
|
||||
@@ -271,7 +271,6 @@ host_job_worker_entrypoint :: proc(worker_thread: ^SysThread)
|
||||
leader := barrier_wait(& host_memory.lane_job_sync)
|
||||
}
|
||||
|
||||
@export
|
||||
sync_client_api :: proc()
|
||||
{
|
||||
profile(#procedure)
|
||||
|
||||
@@ -35,12 +35,11 @@ then prepare for multi-threaded "laned" tick: thread_wide_startup.
|
||||
@export
|
||||
startup :: proc(host_mem: ^ProcessMemory, thread_mem: ^ThreadMemory)
|
||||
{
|
||||
// Rad Debugger driving me crazy..
|
||||
// NOTE(Ed): This is not necessary, they're just loops for my sanity.
|
||||
for ; memory == nil; { memory = host_mem }
|
||||
for ; thread == nil; { thread = thread_mem }
|
||||
grime_set_profiler_module_context(& memory.spall_context)
|
||||
grime_set_profiler_thread_buffer(& thread.spall_buffer)
|
||||
// (Ignore RAD Debugger's values being null)
|
||||
memory = host_mem
|
||||
thread = thread_mem
|
||||
// grime_set_profiler_module_context(& memory.spall_context)
|
||||
// grime_set_profiler_thread_buffer(& thread.spall_buffer)
|
||||
profile(#procedure)
|
||||
|
||||
startup_tick := tick_now()
|
||||
@@ -126,14 +125,14 @@ hot_reload :: proc(host_mem: ^ProcessMemory, thread_mem: ^ThreadMemory)
|
||||
thread = thread_mem
|
||||
if thread.id == .Master_Prepper {
|
||||
sync_store(& memory, host_mem, .Release)
|
||||
grime_set_profiler_module_context(& memory.spall_context)
|
||||
// grime_set_profiler_module_context(& memory.spall_context)
|
||||
}
|
||||
else {
|
||||
// NOTE(Ed): This is problably not necessary, they're just loops for my sanity.
|
||||
for ; memory == nil; { sync_load(& memory, .Acquire) }
|
||||
for ; thread == nil; { thread = thread_mem }
|
||||
}
|
||||
grime_set_profiler_thread_buffer(& thread.spall_buffer)
|
||||
// grime_set_profiler_thread_buffer(& thread.spall_buffer)
|
||||
}
|
||||
profile(#procedure)
|
||||
// Do hot-reload stuff...
|
||||
@@ -177,7 +176,7 @@ tick_lane_startup :: proc(thread_mem: ^ThreadMemory)
|
||||
{
|
||||
if thread_mem.id != .Master_Prepper {
|
||||
thread = thread_mem
|
||||
grime_set_profiler_thread_buffer(& thread.spall_buffer)
|
||||
// grime_set_profiler_thread_buffer(& thread.spall_buffer)
|
||||
}
|
||||
profile(#procedure)
|
||||
}
|
||||
@@ -187,7 +186,7 @@ job_worker_startup :: proc(thread_mem: ^ThreadMemory)
|
||||
{
|
||||
if thread_mem.id != .Master_Prepper {
|
||||
thread = thread_mem
|
||||
grime_set_profiler_thread_buffer(& thread.spall_buffer)
|
||||
// grime_set_profiler_thread_buffer(& thread.spall_buffer)
|
||||
}
|
||||
profile(#procedure)
|
||||
}
|
||||
|
||||
@@ -2,10 +2,13 @@ package sectr
|
||||
|
||||
import sokol_app "thirdparty:sokol/app"
|
||||
|
||||
//region Sokol App
|
||||
|
||||
sokol_app_init_callback :: proc "c" () {
|
||||
context = memory.client_memory.sokol_context
|
||||
log_print("sokol_app: Confirmed initialization")
|
||||
}
|
||||
|
||||
// This is being filled in but we're directly controlling the lifetime of sokol_app's execution.
|
||||
// So this will only get called during window pan or resize events (on Win32 at least)
|
||||
sokol_app_frame_callback :: proc "c" ()
|
||||
@@ -37,3 +40,220 @@ sokol_app_frame_callback :: proc "c" ()
|
||||
tick_lane_frametime( & client_tick, sokol_delta_ms, sokol_delta_ns, can_sleep = false )
|
||||
window.resized = false
|
||||
}
|
||||
|
||||
sokol_app_cleanup_callback :: proc "c" () {
|
||||
context = memory.client_memory.sokol_context
|
||||
log_print("sokol_app: Confirmed cleanup")
|
||||
}
|
||||
|
||||
sokol_app_alloc :: proc "c" ( size : uint, user_data : rawptr ) -> rawptr {
|
||||
context = memory.client_memory.sokol_context
|
||||
// block, error := mem_alloc( int(size), allocator = persistent_slab_allocator() )
|
||||
// ensure(error == AllocatorError.None, "sokol_app allocation failed")
|
||||
// return block
|
||||
// TODO(Ed): Implement
|
||||
return nil
|
||||
}
|
||||
|
||||
sokol_app_free :: proc "c" ( data : rawptr, user_data : rawptr ) {
|
||||
context = memory.client_memory.sokol_context
|
||||
// mem_free(data, allocator = persistent_slab_allocator() )
|
||||
// TODO(Ed): Implement
|
||||
}
|
||||
|
||||
sokol_app_log_callback :: proc "c" (
|
||||
tag: cstring,
|
||||
log_level: u32,
|
||||
log_item_id: u32,
|
||||
message_or_null: cstring,
|
||||
line_nr: u32,
|
||||
filename_or_null: cstring,
|
||||
user_data: rawptr)
|
||||
{
|
||||
context = memory.client_memory.sokol_context
|
||||
odin_level: LoggerLevel
|
||||
switch log_level {
|
||||
case 0: odin_level = .Fatal
|
||||
case 1: odin_level = .Error
|
||||
case 2: odin_level = .Warning
|
||||
case 3: odin_level = .Info
|
||||
}
|
||||
clone_backing: [16 * Kilo]byte
|
||||
|
||||
cloned_msg: string = "";
|
||||
if message_or_null != nil {
|
||||
cloned_msg = cstr_to_str_capped(message_or_null, clone_backing[:])
|
||||
}
|
||||
cloned_fname: string = ""
|
||||
if filename_or_null != nil {
|
||||
cloned_fname = cstr_to_str_capped(filename_or_null, clone_backing[len(cloned_msg):])
|
||||
}
|
||||
cloned_tag := cstr_to_str_capped(tag, clone_backing[len(cloned_msg) + len(cloned_fname):])
|
||||
log_print_fmt( "%-80s %s::%v", cloned_msg, cloned_tag, line_nr, level = odin_level )
|
||||
}
|
||||
|
||||
// TODO(Ed): Does this need to be queued to a separate thread?
|
||||
sokol_app_event_callback :: proc "c" (sokol_event: ^sokol_app.Event)
|
||||
{
|
||||
context = memory.client_memory.sokol_context
|
||||
event: InputEvent
|
||||
using event
|
||||
|
||||
_sokol_frame_id = sokol_event.frame_count
|
||||
frame_id = get_frametime().current_frame
|
||||
|
||||
mouse.pos = { sokol_event.mouse_x, sokol_event.mouse_y }
|
||||
mouse.delta = { sokol_event.mouse_dx, sokol_event.mouse_dy }
|
||||
|
||||
switch sokol_event.type
|
||||
{
|
||||
case .INVALID:
|
||||
log_print_fmt("sokol_app - event: INVALID?")
|
||||
log_print_fmt("%v", sokol_event)
|
||||
|
||||
case .KEY_DOWN:
|
||||
if sokol_event.key_repeat do return
|
||||
|
||||
type = .Key_Pressed
|
||||
key = to_key_from_sokol( sokol_event.key_code )
|
||||
modifiers = to_modifiers_code_from_sokol( sokol_event.modifiers )
|
||||
sokol_app.consume_event()
|
||||
append_staged_input_events( event )
|
||||
// logf("Key pressed(sokol): %v", key)
|
||||
// logf("frame (sokol): %v", frame_id )
|
||||
|
||||
case .KEY_UP:
|
||||
if sokol_event.key_repeat do return
|
||||
|
||||
type = .Key_Released
|
||||
key = to_key_from_sokol( sokol_event.key_code )
|
||||
modifiers = to_modifiers_code_from_sokol( sokol_event.modifiers )
|
||||
sokol_app.consume_event()
|
||||
append_staged_input_events( event )
|
||||
// logf("Key released(sokol): %v", key)
|
||||
// logf("frame (sokol): %v", frame_id )
|
||||
|
||||
case .CHAR:
|
||||
if sokol_event.key_repeat do return
|
||||
|
||||
type = .Unicode
|
||||
codepoint = transmute(rune) sokol_event.char_code
|
||||
modifiers = to_modifiers_code_from_sokol( sokol_event.modifiers )
|
||||
sokol_app.consume_event()
|
||||
append_staged_input_events( event )
|
||||
|
||||
case .MOUSE_DOWN:
|
||||
type = .Mouse_Pressed
|
||||
mouse.btn = to_mouse_btn_from_sokol( sokol_event.mouse_button )
|
||||
modifiers = to_modifiers_code_from_sokol( sokol_event.modifiers )
|
||||
sokol_app.consume_event()
|
||||
append_staged_input_events( event )
|
||||
|
||||
case .MOUSE_UP:
|
||||
type = .Mouse_Released
|
||||
mouse.btn = to_mouse_btn_from_sokol( sokol_event.mouse_button )
|
||||
modifiers = to_modifiers_code_from_sokol( sokol_event.modifiers )
|
||||
sokol_app.consume_event()
|
||||
append_staged_input_events( event )
|
||||
|
||||
case .MOUSE_SCROLL:
|
||||
type = .Mouse_Scroll
|
||||
mouse.scroll = { sokol_event.scroll_x, sokol_event.scroll_y }
|
||||
modifiers = to_modifiers_code_from_sokol( sokol_event.modifiers )
|
||||
sokol_app.consume_event()
|
||||
append_staged_input_events( event )
|
||||
|
||||
case .MOUSE_MOVE:
|
||||
type = .Mouse_Move
|
||||
modifiers = to_modifiers_code_from_sokol( sokol_event.modifiers )
|
||||
sokol_app.consume_event()
|
||||
append_staged_input_events( event )
|
||||
|
||||
case .MOUSE_ENTER:
|
||||
type = .Mouse_Enter
|
||||
modifiers = to_modifiers_code_from_sokol( sokol_event.modifiers )
|
||||
sokol_app.consume_event()
|
||||
append_staged_input_events( event )
|
||||
|
||||
case .MOUSE_LEAVE:
|
||||
type = .Mouse_Leave
|
||||
modifiers = to_modifiers_code_from_sokol( sokol_event.modifiers )
|
||||
sokol_app.consume_event()
|
||||
append_staged_input_events( event )
|
||||
|
||||
// TODO(Ed): Add support
|
||||
case .TOUCHES_BEGAN:
|
||||
case .TOUCHES_MOVED:
|
||||
case .TOUCHES_ENDED:
|
||||
case .TOUCHES_CANCELLED:
|
||||
|
||||
case .RESIZED: sokol_app.consume_event()
|
||||
case .ICONIFIED: sokol_app.consume_event()
|
||||
case .RESTORED: sokol_app.consume_event()
|
||||
case .FOCUSED: sokol_app.consume_event()
|
||||
case .UNFOCUSED: sokol_app.consume_event()
|
||||
case .SUSPENDED: sokol_app.consume_event()
|
||||
case .RESUMED: sokol_app.consume_event()
|
||||
case .QUIT_REQUESTED: sokol_app.consume_event()
|
||||
case .CLIPBOARD_PASTED: sokol_app.consume_event()
|
||||
case .FILES_DROPPED: sokol_app.consume_event()
|
||||
|
||||
case .DISPLAY_CHANGED:
|
||||
log_print_fmt("sokol_app - event: Display changed")
|
||||
log_print_fmt("refresh rate: %v", sokol_app.refresh_rate())
|
||||
monitor_refresh_hz := sokol_app.refresh_rate()
|
||||
sokol_app.consume_event()
|
||||
}
|
||||
}
|
||||
|
||||
//endregion Sokol App
|
||||
|
||||
//region Sokol GFX
|
||||
|
||||
sokol_gfx_alloc :: proc "c" ( size : uint, user_data : rawptr ) -> rawptr {
|
||||
context = memory.client_memory.sokol_context
|
||||
// block, error := mem_alloc( int(size), allocator = persistent_slab_allocator() )
|
||||
// ensure(error == AllocatorError.None, "sokol_gfx allocation failed")
|
||||
// return block
|
||||
// TODO(Ed): Implement
|
||||
return nil
|
||||
}
|
||||
|
||||
sokol_gfx_free :: proc "c" ( data : rawptr, user_data : rawptr ) {
|
||||
context = memory.client_memory.sokol_context
|
||||
// TODO(Ed): Implement
|
||||
// free(data, allocator = persistent_slab_allocator() )
|
||||
}
|
||||
|
||||
sokol_gfx_log_callback :: proc "c" (
|
||||
tag: cstring,
|
||||
log_level: u32,
|
||||
log_item_id: u32,
|
||||
message_or_null: cstring,
|
||||
line_nr: u32,
|
||||
filename_or_null: cstring,
|
||||
user_data: rawptr)
|
||||
{
|
||||
context = memory.client_memory.sokol_context
|
||||
odin_level : LoggerLevel
|
||||
switch log_level {
|
||||
case 0: odin_level = .Fatal
|
||||
case 1: odin_level = .Error
|
||||
case 2: odin_level = .Warning
|
||||
case 3: odin_level = .Info
|
||||
}
|
||||
clone_backing: [16 * Kilo]byte
|
||||
|
||||
cloned_msg : string = ""
|
||||
if message_or_null != nil {
|
||||
cloned_msg = cstr_to_str_capped(message_or_null, clone_backing[:])
|
||||
}
|
||||
cloned_fname : string = ""
|
||||
if filename_or_null != nil {
|
||||
cloned_fname = cstr_to_str_capped(filename_or_null, clone_backing[len(cloned_msg):])
|
||||
}
|
||||
cloned_tag := cstr_to_str_capped(tag, clone_backing[len(cloned_msg) + len(cloned_fname):])
|
||||
log_print_fmt( "%-80s %s::%v", cloned_msg, cloned_tag, line_nr, level = odin_level )
|
||||
}
|
||||
|
||||
//endregion Sokol GFX
|
||||
|
||||
90
code2/sectr/input/binding.odin
Normal file
90
code2/sectr/input/binding.odin
Normal file
@@ -0,0 +1,90 @@
|
||||
package sectr
|
||||
|
||||
InputBindSig :: distinct u128
|
||||
|
||||
InputBind :: struct {
|
||||
keys: [4]KeyCode,
|
||||
mouse_btns: [4]MouseBtn,
|
||||
scroll: [2]AnalogAxis,
|
||||
modifiers: ModifierCodeFlags,
|
||||
label: string,
|
||||
}
|
||||
|
||||
InputBindStatus :: struct {
|
||||
detected: b32,
|
||||
consumed: b32,
|
||||
frame_id: u64,
|
||||
}
|
||||
|
||||
InputActionProc :: #type proc(user_ptr: rawptr)
|
||||
InputAction :: struct {
|
||||
id: int,
|
||||
user_ptr: rawptr,
|
||||
cb: InputActionProc,
|
||||
always: b32,
|
||||
}
|
||||
|
||||
InputContext :: struct {
|
||||
binds: []InputBind,
|
||||
status: []InputBindStatus,
|
||||
onpush_action: []InputAction,
|
||||
onpop_action: []InputAction,
|
||||
signature: []InputBindSig,
|
||||
}
|
||||
|
||||
inputbind_signature :: proc(binding: InputBind) -> InputBindSig {
|
||||
// TODO(Ed): Figure out best hasher for this...
|
||||
return cast(InputBindSig) 0
|
||||
}
|
||||
|
||||
// Note(Ed): Bindings should be remade for a context when a user modifies any in configuration.
|
||||
|
||||
inputcontext_init :: proc(ctx: ^InputContext, binds: []InputBind, onpush: []InputAction = {}, onpop: []InputAction = {}) {
|
||||
ctx.binds = binds
|
||||
ctx.onpush_action = onpush
|
||||
ctx.onpop_action = onpop
|
||||
|
||||
for bind, id in ctx.binds {
|
||||
ctx.signature[id] = inputbind_signature(bind)
|
||||
}
|
||||
}
|
||||
|
||||
inputcontext_make :: #force_inline proc(binds: []InputBind, onpush: []InputAction = {}, onpop: []InputAction = {}) -> InputContext {
|
||||
ctx: InputContext; inputcontext_init(& ctx, binds, onpush, onpop); return ctx
|
||||
}
|
||||
|
||||
// Should be called by the user explicitly during frame cleanup.
|
||||
inputcontext_clear_status :: #force_inline proc "contextless" (ctx: ^InputContext) {
|
||||
zero(ctx.status)
|
||||
}
|
||||
|
||||
inputbinding_status :: #force_inline proc(id: int) -> InputBindStatus {
|
||||
return get_input_binds().status[id]
|
||||
}
|
||||
|
||||
inputcontext_inherit :: proc(dst: ^InputContext, src: ^InputContext) {
|
||||
for dst_id, dst_sig in dst.signature
|
||||
{
|
||||
for src_id, src_sig in src.signature
|
||||
{
|
||||
if dst_sig != src_sig {
|
||||
continue
|
||||
}
|
||||
dst.status[dst_id] = src.status[src_id]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inputcontext_push :: proc(ctx: ^InputContext, dont_inherit_status: b32 = false) {
|
||||
// push context stack
|
||||
// clear binding status for context
|
||||
// optionally inherit status
|
||||
// detect status
|
||||
// Dispatch push actions meeting conditions
|
||||
}
|
||||
|
||||
inputcontext_pop :: proc(ctx: ^InputContext, dont_inherit_status: b32 = false) {
|
||||
// Dispatch pop actions meeting conditions
|
||||
// parent inherit consumed statuses
|
||||
// pop context stack
|
||||
}
|
||||
298
code2/sectr/input/events.odin
Normal file
298
code2/sectr/input/events.odin
Normal file
@@ -0,0 +1,298 @@
|
||||
package sectr
|
||||
|
||||
InputEventType :: enum u32 {
|
||||
Key_Pressed,
|
||||
Key_Released,
|
||||
Mouse_Pressed,
|
||||
Mouse_Released,
|
||||
Mouse_Scroll,
|
||||
Mouse_Move,
|
||||
Mouse_Enter,
|
||||
Mouse_Leave,
|
||||
Unicode,
|
||||
}
|
||||
|
||||
InputEvent :: struct
|
||||
{
|
||||
frame_id : u64,
|
||||
type : InputEventType,
|
||||
key : KeyCode,
|
||||
modifiers : ModifierCodeFlags,
|
||||
mouse : struct {
|
||||
btn : MouseBtn,
|
||||
pos : V2_F4,
|
||||
delta : V2_F4,
|
||||
scroll : V2_F4,
|
||||
},
|
||||
codepoint : rune,
|
||||
|
||||
// num_touches : u32,
|
||||
// touches : Touchpoint,
|
||||
|
||||
_sokol_frame_id : u64,
|
||||
}
|
||||
|
||||
// TODO(Ed): May just use input event exclusively in the future and have pointers for key and mouse event filters
|
||||
// I'm on the fence about this as I don't want to force
|
||||
|
||||
InputKeyEvent :: struct {
|
||||
frame_id : u64,
|
||||
type : InputEventType,
|
||||
key : KeyCode,
|
||||
modifiers : ModifierCodeFlags,
|
||||
}
|
||||
|
||||
InputMouseEvent :: struct {
|
||||
frame_id : u64,
|
||||
type : InputEventType,
|
||||
btn : MouseBtn,
|
||||
pos : V2_F4,
|
||||
delta : V2_F4,
|
||||
scroll : V2_F4,
|
||||
modifiers : ModifierCodeFlags,
|
||||
}
|
||||
|
||||
// Lets see if we need more than this..
|
||||
InputEvents :: struct {
|
||||
events : FRingBuffer(InputEvent, 64),
|
||||
key_events : FRingBuffer(InputKeyEvent, 32),
|
||||
mouse_events : FRingBuffer(InputMouseEvent, 32),
|
||||
|
||||
codes_pressed : Array(rune),
|
||||
}
|
||||
|
||||
// Note(Ed): There is a staged_input_events : Array(InputEvent), in the state.odin's State struct
|
||||
|
||||
append_staged_input_events :: #force_inline proc(event: InputEvent) {
|
||||
append( & memory.client_memory.staged_input_events, event )
|
||||
}
|
||||
|
||||
pull_staged_input_events :: proc( input: ^InputState, using input_events: ^InputEvents, using staged_events : Array(InputEvent) )
|
||||
{
|
||||
staged_events_slice := array_to_slice(staged_events)
|
||||
push( & input_events.events, staged_events_slice )
|
||||
|
||||
// using input_events
|
||||
|
||||
for event in staged_events_slice
|
||||
{
|
||||
switch event.type {
|
||||
case .Key_Pressed:
|
||||
push( & key_events, InputKeyEvent {
|
||||
frame_id = event.frame_id,
|
||||
type = event.type,
|
||||
key = event.key,
|
||||
modifiers = event.modifiers
|
||||
})
|
||||
// logf("Key pressed(event pushed): %v", event.key)
|
||||
// logf("last key event frame: %v", peek_back(& key_events).frame_id)
|
||||
// logf("last event frame: %v", peek_back(& events).frame_id)
|
||||
|
||||
case .Key_Released:
|
||||
push( & key_events, InputKeyEvent {
|
||||
frame_id = event.frame_id,
|
||||
type = event.type,
|
||||
key = event.key,
|
||||
modifiers = event.modifiers
|
||||
})
|
||||
// logf("Key released(event rpushed): %v", event.key)
|
||||
// logf("last key event frame: %v", peek_back(& key_events).frame_id)
|
||||
// logf("last event frame: %v", peek_back(& events).frame_id)
|
||||
|
||||
case .Unicode:
|
||||
append( & codes_pressed, event.codepoint )
|
||||
|
||||
case .Mouse_Pressed:
|
||||
push( & mouse_events, InputMouseEvent {
|
||||
frame_id = event.frame_id,
|
||||
type = event.type,
|
||||
btn = event.mouse.btn,
|
||||
pos = event.mouse.pos,
|
||||
delta = event.mouse.delta,
|
||||
scroll = event.mouse.scroll,
|
||||
modifiers = event.modifiers,
|
||||
})
|
||||
|
||||
case .Mouse_Released:
|
||||
push( & mouse_events, InputMouseEvent {
|
||||
frame_id = event.frame_id,
|
||||
type = event.type,
|
||||
btn = event.mouse.btn,
|
||||
pos = event.mouse.pos,
|
||||
delta = event.mouse.delta,
|
||||
scroll = event.mouse.scroll,
|
||||
modifiers = event.modifiers,
|
||||
})
|
||||
|
||||
case .Mouse_Scroll:
|
||||
push( & mouse_events, InputMouseEvent {
|
||||
frame_id = event.frame_id,
|
||||
type = event.type,
|
||||
btn = event.mouse.btn,
|
||||
pos = event.mouse.pos,
|
||||
delta = event.mouse.delta,
|
||||
scroll = event.mouse.scroll,
|
||||
modifiers = event.modifiers,
|
||||
})
|
||||
// logf("Detected scroll: %v", event.mouse.scroll)
|
||||
|
||||
case .Mouse_Move:
|
||||
push( & mouse_events, InputMouseEvent {
|
||||
frame_id = event.frame_id,
|
||||
type = event.type,
|
||||
btn = event.mouse.btn,
|
||||
pos = event.mouse.pos,
|
||||
delta = event.mouse.delta,
|
||||
scroll = event.mouse.scroll,
|
||||
modifiers = event.modifiers,
|
||||
})
|
||||
|
||||
case .Mouse_Enter:
|
||||
push( & mouse_events, InputMouseEvent {
|
||||
frame_id = event.frame_id,
|
||||
type = event.type,
|
||||
btn = event.mouse.btn,
|
||||
pos = event.mouse.pos,
|
||||
delta = event.mouse.delta,
|
||||
scroll = event.mouse.scroll,
|
||||
modifiers = event.modifiers,
|
||||
})
|
||||
|
||||
case .Mouse_Leave:
|
||||
push( & mouse_events, InputMouseEvent {
|
||||
frame_id = event.frame_id,
|
||||
type = event.type,
|
||||
btn = event.mouse.btn,
|
||||
pos = event.mouse.pos,
|
||||
delta = event.mouse.delta,
|
||||
scroll = event.mouse.scroll,
|
||||
modifiers = event.modifiers,
|
||||
})
|
||||
}
|
||||
}
|
||||
clear( staged_events )
|
||||
}
|
||||
|
||||
poll_input_events :: proc( input, prev_input : ^InputState, input_events : InputEvents )
|
||||
{
|
||||
input.keyboard = {}
|
||||
input.mouse = {}
|
||||
|
||||
// logf("m's value is: %v (prev)", prev_input.keyboard.keys[KeyCode.M] )
|
||||
|
||||
for prev_key, id in prev_input.keyboard.keys {
|
||||
input.keyboard.keys[id].ended_down = prev_key.ended_down
|
||||
}
|
||||
|
||||
for prev_btn, id in prev_input.mouse.btns {
|
||||
input.mouse.btns[id].ended_down = prev_btn.ended_down
|
||||
}
|
||||
|
||||
input.mouse.raw_pos = prev_input.mouse.raw_pos
|
||||
input.mouse.pos = prev_input.mouse.pos
|
||||
|
||||
input_events := input_events
|
||||
using input_events
|
||||
|
||||
@static prev_frame : u64 = 0
|
||||
|
||||
last_frame : u64 = 0
|
||||
if events.num > 0 {
|
||||
last_frame = peek_back( events).frame_id
|
||||
}
|
||||
|
||||
// No new events, don't update
|
||||
if last_frame == prev_frame do return
|
||||
|
||||
Iterate_Key_Events:
|
||||
{
|
||||
iter_obj := iterator( & key_events ); iter := & iter_obj
|
||||
for event := next( iter ); event != nil; event = next( iter )
|
||||
{
|
||||
// logf("last_frame (iter): %v", last_frame)
|
||||
// logf("frame (iter): %v", event.frame_id )
|
||||
if last_frame > event.frame_id {
|
||||
break
|
||||
}
|
||||
key := & input.keyboard.keys[event.key]
|
||||
prev_key := prev_input.keyboard.keys[event.key]
|
||||
|
||||
// logf("key event: %v", event)
|
||||
|
||||
first_transition := key.half_transitions == 0
|
||||
|
||||
#partial switch event.type {
|
||||
case .Key_Pressed:
|
||||
key.half_transitions += 1
|
||||
key.ended_down = true
|
||||
|
||||
case .Key_Released:
|
||||
key.half_transitions += 1
|
||||
key.ended_down = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Iterate_Mouse_Events:
|
||||
{
|
||||
iter_obj := iterator( & mouse_events ); iter := & iter_obj
|
||||
for event := next( iter ); event != nil; event = next( iter )
|
||||
{
|
||||
if last_frame > event.frame_id {
|
||||
break
|
||||
}
|
||||
|
||||
process_digital_btn :: proc( btn : ^DigitalBtn, prev_btn : DigitalBtn, ended_down : b32 )
|
||||
{
|
||||
first_transition := btn.half_transitions == 0
|
||||
|
||||
btn.half_transitions += 1
|
||||
btn.ended_down = ended_down
|
||||
}
|
||||
|
||||
// logf("mouse event: %v", event)
|
||||
|
||||
#partial switch event.type {
|
||||
case .Mouse_Pressed:
|
||||
btn := & input.mouse.btns[event.btn]
|
||||
prev_btn := prev_input.mouse.btns[event.btn]
|
||||
process_digital_btn( btn, prev_btn, true )
|
||||
|
||||
case .Mouse_Released:
|
||||
btn := & input.mouse.btns[event.btn]
|
||||
prev_btn := prev_input.mouse.btns[event.btn]
|
||||
process_digital_btn( btn, prev_btn, false )
|
||||
|
||||
case .Mouse_Scroll:
|
||||
input.mouse.scroll += event.scroll
|
||||
|
||||
case .Mouse_Move:
|
||||
case .Mouse_Enter:
|
||||
case .Mouse_Leave:
|
||||
// Handled below
|
||||
}
|
||||
|
||||
input.mouse.raw_pos = event.pos
|
||||
input.mouse.pos = render_to_screen_pos( event.pos, memory.client_memory.app_window.extent )
|
||||
input.mouse.delta = event.delta * { 1, -1 }
|
||||
}
|
||||
}
|
||||
|
||||
prev_frame = last_frame
|
||||
}
|
||||
|
||||
input_event_iter :: #force_inline proc () -> FRingBufferIterator(InputEvent) {
|
||||
return iterator_ringbuf_fixed( & memory.client_memory.input_events.events )
|
||||
}
|
||||
|
||||
input_key_event_iter :: #force_inline proc() -> FRingBufferIterator(InputKeyEvent) {
|
||||
return iterator_ringbuf_fixed( & memory.client_memory.input_events.key_events )
|
||||
}
|
||||
|
||||
input_mouse_event_iter :: #force_inline proc() -> FRingBufferIterator(InputMouseEvent) {
|
||||
return iterator_ringbuf_fixed( & memory.client_memory.input_events.mouse_events )
|
||||
}
|
||||
|
||||
input_codes_pressed_slice :: #force_inline proc() -> []rune {
|
||||
return to_slice( memory.client_memory.input_events.codes_pressed )
|
||||
}
|
||||
186
code2/sectr/input/input.odin
Normal file
186
code2/sectr/input/input.odin
Normal file
@@ -0,0 +1,186 @@
|
||||
// TODO(Ed) : This if its gets larget can be moved to its own package
|
||||
package sectr
|
||||
|
||||
import "base:runtime"
|
||||
|
||||
AnalogAxis :: f32
|
||||
AnalogStick :: struct {
|
||||
X, Y : f32
|
||||
}
|
||||
|
||||
DigitalBtn :: struct {
|
||||
half_transitions : i32,
|
||||
ended_down : b32,
|
||||
}
|
||||
|
||||
btn_pressed :: #force_inline proc "contextless" (btn: DigitalBtn) -> b32 { return btn.ended_down && btn.half_transitions > 0 }
|
||||
btn_released :: #force_inline proc "contextless" (btn: DigitalBtn) -> b32 { return btn.ended_down == false && btn.half_transitions > 0 }
|
||||
|
||||
MaxMouseBtns :: 16
|
||||
MouseBtn :: enum u32 {
|
||||
Left = 0x0,
|
||||
Middle = 0x1,
|
||||
Right = 0x2,
|
||||
Side = 0x3,
|
||||
Forward = 0x4,
|
||||
Back = 0x5,
|
||||
Extra = 0x6,
|
||||
|
||||
Invalid = 0x100,
|
||||
|
||||
count
|
||||
}
|
||||
|
||||
KeyboardState :: struct #raw_union {
|
||||
keys : [KeyCode.count] DigitalBtn,
|
||||
using individual : struct {
|
||||
null : DigitalBtn, // 0x00
|
||||
ignored : DigitalBtn, // 0x01
|
||||
|
||||
// GFLW / Sokol
|
||||
menu,
|
||||
world_1, world_2 : DigitalBtn,
|
||||
// 0x02 - 0x04
|
||||
|
||||
__0x05_0x07_Unassigned__ : [ 3 * size_of( DigitalBtn)] u8,
|
||||
|
||||
tab, backspace : DigitalBtn,
|
||||
// 0x08 - 0x09
|
||||
|
||||
right, left, up, down : DigitalBtn,
|
||||
// 0x0A - 0x0D
|
||||
|
||||
enter : DigitalBtn, // 0x0E
|
||||
|
||||
__0x0F_Unassigned__ : [ 1 * size_of( DigitalBtn)] u8,
|
||||
|
||||
caps_lock,
|
||||
scroll_lock,
|
||||
num_lock : DigitalBtn,
|
||||
// 0x10 - 0x12
|
||||
|
||||
left_alt,
|
||||
left_shift,
|
||||
left_control,
|
||||
right_alt,
|
||||
right_shift,
|
||||
right_control : DigitalBtn,
|
||||
// 0x13 - 0x18
|
||||
|
||||
print_screen,
|
||||
pause,
|
||||
escape,
|
||||
home,
|
||||
end,
|
||||
page_up,
|
||||
page_down,
|
||||
space : DigitalBtn,
|
||||
// 0x19 - 0x20
|
||||
|
||||
exlamation,
|
||||
quote_dbl,
|
||||
hash,
|
||||
dollar,
|
||||
percent,
|
||||
ampersand,
|
||||
quote,
|
||||
paren_open,
|
||||
paren_close,
|
||||
asterisk,
|
||||
plus,
|
||||
comma,
|
||||
minus,
|
||||
period,
|
||||
slash : DigitalBtn,
|
||||
// 0x21 - 0x2F
|
||||
|
||||
nrow_0, // 0x30
|
||||
nrow_1, // 0x31
|
||||
nrow_2, // 0x32
|
||||
nrow_3, // 0x33
|
||||
nrow_4, // 0x34
|
||||
nrow_5, // 0x35
|
||||
nrow_6, // 0x36
|
||||
nrow_7, // 0x37
|
||||
nrow_8, // 0x38
|
||||
nrow_9, // 0x39
|
||||
|
||||
__0x3A_Unassigned__ : [ 1 * size_of(DigitalBtn)] u8,
|
||||
|
||||
semicolon,
|
||||
less,
|
||||
equals,
|
||||
greater,
|
||||
question,
|
||||
at : DigitalBtn,
|
||||
|
||||
A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z : DigitalBtn,
|
||||
|
||||
bracket_open,
|
||||
backslash,
|
||||
bracket_close,
|
||||
underscore,
|
||||
backtick : DigitalBtn,
|
||||
|
||||
kpad_0,
|
||||
kpad_1,
|
||||
kpad_2,
|
||||
kpad_3,
|
||||
kpad_4,
|
||||
kpad_5,
|
||||
kpad_6,
|
||||
kpad_7,
|
||||
kpad_8,
|
||||
kpad_9,
|
||||
kpad_decimal,
|
||||
kpad_equals,
|
||||
kpad_plus,
|
||||
kpad_minus,
|
||||
kpad_multiply,
|
||||
kpad_divide,
|
||||
kpad_enter : DigitalBtn,
|
||||
|
||||
F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12 : DigitalBtn,
|
||||
|
||||
insert, delete : DigitalBtn,
|
||||
|
||||
F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, F25 : DigitalBtn,
|
||||
}
|
||||
}
|
||||
|
||||
ModifierCode :: enum u32 {
|
||||
Shift,
|
||||
Control,
|
||||
Alt,
|
||||
Left_Mouse,
|
||||
Right_Mouse,
|
||||
Middle_Mouse,
|
||||
Left_Shift,
|
||||
Right_Shift,
|
||||
Left_Control,
|
||||
Right_Control,
|
||||
Left_Alt,
|
||||
Right_Alt,
|
||||
}
|
||||
ModifierCodeFlags :: bit_set[ModifierCode; u32]
|
||||
|
||||
MouseState :: struct {
|
||||
using _ : struct #raw_union {
|
||||
btns : [16] DigitalBtn,
|
||||
using individual : struct {
|
||||
left, middle, right : DigitalBtn,
|
||||
side, forward, back, extra : DigitalBtn,
|
||||
}
|
||||
},
|
||||
raw_pos, pos, delta : V2_F4,
|
||||
scroll : [2]AnalogAxis,
|
||||
}
|
||||
|
||||
mouse_world_delta :: #force_inline proc "contextless" (mouse_delta: V2_F4, cam: ^Camera) -> V2_F4 {
|
||||
return mouse_delta * ( 1 / cam.zoom )
|
||||
}
|
||||
|
||||
InputState :: struct {
|
||||
keyboard : KeyboardState,
|
||||
mouse : MouseState,
|
||||
}
|
||||
84
code2/sectr/input/input_sokol.odin
Normal file
84
code2/sectr/input/input_sokol.odin
Normal file
@@ -0,0 +1,84 @@
|
||||
package sectr
|
||||
|
||||
import "base:runtime"
|
||||
import "core:os"
|
||||
import "core:c/libc"
|
||||
import sokol_app "thirdparty:sokol/app"
|
||||
|
||||
to_modifiers_code_from_sokol :: proc( sokol_modifiers : u32 ) -> ( modifiers : ModifierCodeFlags )
|
||||
{
|
||||
if sokol_modifiers & sokol_app.MODIFIER_SHIFT != 0 do modifiers |= { .Shift }
|
||||
if sokol_modifiers & sokol_app.MODIFIER_CTRL != 0 do modifiers |= { .Control }
|
||||
if sokol_modifiers & sokol_app.MODIFIER_ALT != 0 do modifiers |= { .Alt }
|
||||
if sokol_modifiers & sokol_app.MODIFIER_LMB != 0 do modifiers |= { .Left_Mouse }
|
||||
if sokol_modifiers & sokol_app.MODIFIER_RMB != 0 do modifiers |= { .Right_Mouse }
|
||||
if sokol_modifiers & sokol_app.MODIFIER_MMB != 0 do modifiers |= { .Middle_Mouse }
|
||||
if sokol_modifiers & sokol_app.MODIFIER_LSHIFT != 0 do modifiers |= { .Left_Shift }
|
||||
if sokol_modifiers & sokol_app.MODIFIER_RSHIFT != 0 do modifiers |= { .Right_Shift }
|
||||
if sokol_modifiers & sokol_app.MODIFIER_LCTRL != 0 do modifiers |= { .Left_Control }
|
||||
if sokol_modifiers & sokol_app.MODIFIER_RCTRL != 0 do modifiers |= { .Right_Control }
|
||||
if sokol_modifiers & sokol_app.MODIFIER_LALT != 0 do modifiers |= { .Left_Alt }
|
||||
if sokol_modifiers & sokol_app.MODIFIER_RALT != 0 do modifiers |= { .Right_Alt }
|
||||
return
|
||||
}
|
||||
|
||||
to_key_from_sokol :: proc( sokol_key : sokol_app.Keycode ) -> ( key : KeyCode )
|
||||
{
|
||||
world_code_offset :: i32(sokol_app.Keycode.WORLD_1) - i32(KeyCode.world_1)
|
||||
arrow_code_offset :: i32(sokol_app.Keycode.RIGHT) - i32(KeyCode.right)
|
||||
func_row_code_offset :: i32(sokol_app.Keycode.F1) - i32(KeyCode.F1)
|
||||
func_extra_code_offset :: i32(sokol_app.Keycode.F13) - i32(KeyCode.F25)
|
||||
keypad_num_offset :: i32(sokol_app.Keycode.KP_0) - i32(KeyCode.kpad_0)
|
||||
|
||||
switch sokol_key {
|
||||
case .INVALID ..= .GRAVE_ACCENT : key = transmute(KeyCode) sokol_key
|
||||
case .WORLD_1, .WORLD_2 : key = transmute(KeyCode) (i32(sokol_key) - world_code_offset)
|
||||
case .ESCAPE : key = .escape
|
||||
case .ENTER : key = .enter
|
||||
case .TAB : key = .tab
|
||||
case .BACKSPACE : key = .backspace
|
||||
case .INSERT : key = .insert
|
||||
case .DELETE : key = .delete
|
||||
case .RIGHT ..= .UP : key = transmute(KeyCode) (i32(sokol_key) - arrow_code_offset)
|
||||
case .PAGE_UP : key = .page_up
|
||||
case .PAGE_DOWN : key = .page_down
|
||||
case .HOME : key = .home
|
||||
case .END : key = .end
|
||||
case .CAPS_LOCK : key = .caps_lock
|
||||
case .SCROLL_LOCK : key = .scroll_lock
|
||||
case .NUM_LOCK : key = .num_lock
|
||||
case .PRINT_SCREEN : key = .print_screen
|
||||
case .PAUSE : key = .pause
|
||||
case .F1 ..= .F12 : key = transmute(KeyCode) (i32(sokol_key) - func_row_code_offset)
|
||||
case .F13 ..= .F25 : key = transmute(KeyCode) (i32(sokol_key) - func_extra_code_offset)
|
||||
case .KP_0 ..= .KP_9 : key = transmute(KeyCode) (i32(sokol_key) - keypad_num_offset)
|
||||
case .KP_DECIMAL : key = .kpad_decimal
|
||||
case .KP_DIVIDE : key = .kpad_divide
|
||||
case .KP_MULTIPLY : key = .kpad_multiply
|
||||
case .KP_SUBTRACT : key = .kpad_minus
|
||||
case .KP_ADD : key = .kpad_plus
|
||||
case .KP_ENTER : key = .kpad_enter
|
||||
case .KP_EQUAL : key = .kpad_equals
|
||||
case .LEFT_SHIFT : key = .left_shift
|
||||
case .LEFT_CONTROL : key = .left_control
|
||||
case .LEFT_ALT : key = .left_alt
|
||||
case .LEFT_SUPER : key = .ignored
|
||||
case .RIGHT_SHIFT : key = .right_shift
|
||||
case .RIGHT_CONTROL : key = .right_control
|
||||
case .RIGHT_ALT : key = .right_alt
|
||||
case .RIGHT_SUPER : key = .ignored
|
||||
case .MENU : key = .menu
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
to_mouse_btn_from_sokol :: proc( sokol_mouse : sokol_app.Mousebutton ) -> ( btn : MouseBtn )
|
||||
{
|
||||
switch sokol_mouse {
|
||||
case .LEFT : btn = .Left
|
||||
case .MIDDLE : btn = .Middle
|
||||
case .RIGHT : btn = .Right
|
||||
case .INVALID : btn = .Invalid
|
||||
}
|
||||
return
|
||||
}
|
||||
239
code2/sectr/input/keyboard_qwerty.odin
Normal file
239
code2/sectr/input/keyboard_qwerty.odin
Normal file
@@ -0,0 +1,239 @@
|
||||
package sectr
|
||||
|
||||
// Based off of SDL2's Scancode; which is based off of:
|
||||
// https://usb.org/sites/default/files/hut1_12.pdf
|
||||
// I gutted values I would never use
|
||||
QeurtyCode :: enum u32 {
|
||||
unknown = 0,
|
||||
|
||||
A = 4,
|
||||
B = 5,
|
||||
C = 6,
|
||||
D = 7,
|
||||
E = 8,
|
||||
F = 9,
|
||||
G = 10,
|
||||
H = 11,
|
||||
I = 12,
|
||||
J = 13,
|
||||
K = 14,
|
||||
L = 15,
|
||||
M = 16,
|
||||
N = 17,
|
||||
O = 18,
|
||||
P = 19,
|
||||
Q = 20,
|
||||
R = 21,
|
||||
S = 22,
|
||||
T = 23,
|
||||
U = 24,
|
||||
V = 25,
|
||||
W = 26,
|
||||
X = 27,
|
||||
Y = 28,
|
||||
Z = 29,
|
||||
|
||||
nrow_1 = 30,
|
||||
nrow_2 = 31,
|
||||
nrow_3 = 32,
|
||||
nrow_4 = 33,
|
||||
nrow_5 = 34,
|
||||
nrow_6 = 35,
|
||||
nrow_7 = 36,
|
||||
nrow_8 = 37,
|
||||
nrow_9 = 38,
|
||||
nrow_0 = 39,
|
||||
|
||||
enter = 40,
|
||||
escape = 41,
|
||||
backspace = 42,
|
||||
tab = 43,
|
||||
space = 44,
|
||||
|
||||
minus = 45,
|
||||
equals = 46,
|
||||
bracket_open = 47,
|
||||
bracket_close = 48,
|
||||
backslash = 49,
|
||||
NONUSHASH = 50,
|
||||
semicolon = 51,
|
||||
apostrophe = 52,
|
||||
grave = 53,
|
||||
comma = 54,
|
||||
period = 55,
|
||||
slash = 56,
|
||||
|
||||
capslock = 57,
|
||||
|
||||
F1 = 58,
|
||||
F2 = 59,
|
||||
F3 = 60,
|
||||
F4 = 61,
|
||||
F5 = 62,
|
||||
F6 = 63,
|
||||
F7 = 64,
|
||||
F8 = 65,
|
||||
F9 = 66,
|
||||
F10 = 67,
|
||||
F11 = 68,
|
||||
F12 = 69,
|
||||
|
||||
// print_screen = 70,
|
||||
// scroll_lock = 71,
|
||||
pause = 72,
|
||||
insert = 73,
|
||||
home = 74,
|
||||
page_up = 75,
|
||||
delete = 76,
|
||||
end = 77,
|
||||
page_down = 78,
|
||||
right = 79,
|
||||
left = 80,
|
||||
down = 81,
|
||||
up = 82,
|
||||
|
||||
numlock_clear = 83,
|
||||
kpad_divide = 84,
|
||||
kpad_multiply = 85,
|
||||
kpad_minus = 86,
|
||||
kpad_plus = 87,
|
||||
kpad_enter = 88,
|
||||
kpad_1 = 89,
|
||||
kpad_2 = 90,
|
||||
kpad_3 = 91,
|
||||
kpad_4 = 92,
|
||||
kpad_5 = 93,
|
||||
kpad_6 = 94,
|
||||
kpad_7 = 95,
|
||||
kpad_8 = 96,
|
||||
kpad_9 = 97,
|
||||
kpad_0 = 98,
|
||||
kpad_period = 99,
|
||||
|
||||
// NONUSBACKSLASH = 100,
|
||||
// OS_Compose = 101,
|
||||
// power = 102,
|
||||
kpad_equals = 103,
|
||||
|
||||
// F13 = 104,
|
||||
// F14 = 105,
|
||||
// F15 = 106,
|
||||
// F16 = 107,
|
||||
// F17 = 108,
|
||||
// F18 = 109,
|
||||
// F19 = 110,
|
||||
// F20 = 111,
|
||||
// F21 = 112,
|
||||
// F22 = 113,
|
||||
// F23 = 114,
|
||||
// F24 = 115,
|
||||
|
||||
// execute = 116,
|
||||
// help = 117,
|
||||
// menu = 118,
|
||||
// select = 119,
|
||||
// stop = 120,
|
||||
// again = 121,
|
||||
// undo = 122,
|
||||
// cut = 123,
|
||||
// copy = 124,
|
||||
// paste = 125,
|
||||
// find = 126,
|
||||
// mute = 127,
|
||||
// volume_up = 128,
|
||||
// volume_down = 129,
|
||||
/* LOCKINGCAPSLOCK = 130, */
|
||||
/* LOCKINGNUMLOCK = 131, */
|
||||
/* LOCKINGSCROLLLOCK = 132, */
|
||||
// kpad_comma = 133,
|
||||
// kpad_equals_AS400 = 134,
|
||||
|
||||
// international_1 = 135,
|
||||
// international_2 = 136,
|
||||
// international_3 = 137,
|
||||
// international_4 = 138,
|
||||
// international_5 = 139,
|
||||
// international_6 = 140,
|
||||
// international_7 = 141,
|
||||
// international_8 = 142,
|
||||
// international_9 = 143,
|
||||
// lang_1 = 144,
|
||||
// lang_2 = 145,
|
||||
// lang_3 = 146,
|
||||
// lang_4 = 147,
|
||||
// lang_5 = 148,
|
||||
// lang_6 = 149,
|
||||
// lang_7 = 150,
|
||||
// lang_8 = 151,
|
||||
// lang_9 = 152,
|
||||
|
||||
// alt_erase = 153,
|
||||
// sysreq = 154,
|
||||
// cancel = 155,
|
||||
// clear = 156,
|
||||
// prior = 157,
|
||||
// return_2 = 158,
|
||||
// separator = 159,
|
||||
// out = 160,
|
||||
// OPER = 161,
|
||||
// clear_again = 162,
|
||||
// CRSEL = 163,
|
||||
// EXSEL = 164,
|
||||
|
||||
// KP_00 = 176,
|
||||
// KP_000 = 177,
|
||||
// THOUSANDSSEPARATOR = 178,
|
||||
// DECIMALSEPARATOR = 179,
|
||||
// CURRENCYUNIT = 180,
|
||||
// CURRENCYSUBUNIT = 181,
|
||||
// KP_LEFTPAREN = 182,
|
||||
// KP_RIGHTPAREN = 183,
|
||||
// KP_LEFTBRACE = 184,
|
||||
// KP_RIGHTBRACE = 185,
|
||||
// KP_TAB = 186,
|
||||
// KP_BACKSPACE = 187,
|
||||
// KP_A = 188,
|
||||
// KP_B = 189,
|
||||
// KP_C = 190,
|
||||
// KP_D = 191,
|
||||
// KP_E = 192,
|
||||
// KP_F = 193,
|
||||
// KP_XOR = 194,
|
||||
// KP_POWER = 195,
|
||||
// KP_PERCENT = 196,
|
||||
// KP_LESS = 197,
|
||||
// KP_GREATER = 198,
|
||||
// KP_AMPERSAND = 199,
|
||||
// KP_DBLAMPERSAND = 200,
|
||||
// KP_VERTICALBAR = 201,
|
||||
// KP_DBLVERTICALBAR = 202,
|
||||
// KP_COLON = 203,
|
||||
// KP_HASH = 204,
|
||||
// KP_SPACE = 205,
|
||||
// KP_AT = 206,
|
||||
// KP_EXCLAM = 207,
|
||||
// KP_MEMSTORE = 208,
|
||||
// KP_MEMRECALL = 209,
|
||||
// KP_MEMCLEAR = 210,
|
||||
// KP_MEMADD = 211,
|
||||
// KP_MEMSUBTRACT = 212,
|
||||
// KP_MEMMULTIPLY = 213,
|
||||
// KP_MEMDIVIDE = 214,
|
||||
// KP_PLUSMINUS = 215,
|
||||
// KP_CLEAR = 216,
|
||||
// KP_CLEARENTRY = 217,
|
||||
// KP_BINARY = 218,
|
||||
// KP_OCTAL = 219,
|
||||
// KP_DECIMAL = 220,
|
||||
// KP_HEXADECIMAL = 221,
|
||||
|
||||
left_control = 224,
|
||||
left_shift = 225,
|
||||
left_alt = 226,
|
||||
// LGUI = 227,
|
||||
right_control = 228,
|
||||
right_shift = 229,
|
||||
right_alt = 230,
|
||||
|
||||
count = 512,
|
||||
}
|
||||
168
code2/sectr/input/keycode.odin
Normal file
168
code2/sectr/input/keycode.odin
Normal file
@@ -0,0 +1,168 @@
|
||||
package sectr
|
||||
|
||||
MaxKeyboardKeys :: 512
|
||||
|
||||
KeyCode :: enum u32 {
|
||||
null = 0x00,
|
||||
|
||||
ignored = 0x01,
|
||||
menu = 0x02,
|
||||
world_1 = 0x03,
|
||||
world_2 = 0x04,
|
||||
|
||||
// 0x05
|
||||
// 0x06
|
||||
// 0x07
|
||||
|
||||
backspace = '\b', // 0x08
|
||||
tab = '\t', // 0x09
|
||||
|
||||
right = 0x0A,
|
||||
left = 0x0B,
|
||||
down = 0x0C,
|
||||
up = 0x0D,
|
||||
|
||||
enter = '\r', // 0x0E
|
||||
|
||||
// 0x0F
|
||||
|
||||
caps_lock = 0x10,
|
||||
scroll_lock = 0x11,
|
||||
num_lock = 0x12,
|
||||
|
||||
left_alt = 0x13,
|
||||
left_shift = 0x14,
|
||||
left_control = 0x15,
|
||||
right_alt = 0x16,
|
||||
right_shift = 0x17,
|
||||
right_control = 0x18,
|
||||
|
||||
print_screen = 0x19,
|
||||
pause = 0x1A,
|
||||
escape = '\x1B', // 0x1B
|
||||
home = 0x1C,
|
||||
end = 0x1D,
|
||||
page_up = 0x1E,
|
||||
page_down = 0x1F,
|
||||
space = ' ', // 0x20
|
||||
|
||||
exclamation = '!', // 0x21
|
||||
quote_dbl = '"', // 0x22
|
||||
hash = '#', // 0x23
|
||||
dollar = '$', // 0x24
|
||||
percent = '%', // 0x25
|
||||
ampersand = '&', // 0x26
|
||||
quote = '\'', // 0x27
|
||||
paren_open = '(', // 0x28
|
||||
paren_close = ')', // 0x29
|
||||
asterisk = '*', // 0x2A
|
||||
plus = '+', // 0x2B
|
||||
comma = ',', // 0x2C
|
||||
minus = '-', // 0x2D
|
||||
period = '.', // 0x2E
|
||||
slash = '/', // 0x2F
|
||||
|
||||
nrow_0 = '0', // 0x30
|
||||
nrow_1 = '1', // 0x31
|
||||
nrow_2 = '2', // 0x32
|
||||
nrow_3 = '3', // 0x33
|
||||
nrow_4 = '4', // 0x34
|
||||
nrow_5 = '5', // 0x35
|
||||
nrow_6 = '6', // 0x36
|
||||
nrow_7 = '7', // 0x37
|
||||
nrow_8 = '8', // 0x38
|
||||
nrow_9 = '9', // 0x39
|
||||
|
||||
// 0x3A
|
||||
|
||||
semicolon = ';', // 0x3B
|
||||
less = '<', // 0x3C
|
||||
equals = '=', // 0x3D
|
||||
greater = '>', // 0x3E
|
||||
question = '?', // 0x3F
|
||||
at = '@', // 0x40
|
||||
|
||||
A = 'A', // 0x41
|
||||
B = 'B', // 0x42
|
||||
C = 'C', // 0x43
|
||||
D = 'D', // 0x44
|
||||
E = 'E', // 0x45
|
||||
F = 'F', // 0x46
|
||||
G = 'G', // 0x47
|
||||
H = 'H', // 0x48
|
||||
I = 'I', // 0x49
|
||||
J = 'J', // 0x4A
|
||||
K = 'K', // 0x4B
|
||||
L = 'L', // 0x4C
|
||||
M = 'M', // 0x4D
|
||||
N = 'N', // 0x4E
|
||||
O = 'O', // 0x4F
|
||||
P = 'P', // 0x50
|
||||
Q = 'Q', // 0x51
|
||||
R = 'R', // 0x52
|
||||
S = 'S', // 0x53
|
||||
T = 'T', // 0x54
|
||||
U = 'U', // 0x55
|
||||
V = 'V', // 0x56
|
||||
W = 'W', // 0x57
|
||||
X = 'X', // 0x58
|
||||
Y = 'Y', // 0x59
|
||||
Z = 'Z', // 0x5A
|
||||
|
||||
bracket_open = '[', // 0x5B
|
||||
backslash = '\\', // 0x5C
|
||||
bracket_close = ']', // 0x5D
|
||||
caret = '^', // 0x5E
|
||||
underscore = '_', // 0x5F
|
||||
backtick = '`', // 0x60
|
||||
|
||||
kpad_0 = 0x61,
|
||||
kpad_1 = 0x62,
|
||||
kpad_2 = 0x63,
|
||||
kpad_3 = 0x64,
|
||||
kpad_4 = 0x65,
|
||||
kpad_5 = 0x66,
|
||||
kpad_6 = 0x67,
|
||||
kpad_7 = 0x68,
|
||||
kpad_8 = 0x69,
|
||||
kpad_9 = 0x6A,
|
||||
kpad_decimal = 0x6B,
|
||||
kpad_equals = 0x6C,
|
||||
kpad_plus = 0x6D,
|
||||
kpad_minus = 0x6E,
|
||||
kpad_multiply = 0x6F,
|
||||
kpad_divide = 0x70,
|
||||
kpad_enter = 0x71,
|
||||
|
||||
F1 = 0x72,
|
||||
F2 = 0x73,
|
||||
F3 = 0x74,
|
||||
F4 = 0x75,
|
||||
F5 = 0x76,
|
||||
F6 = 0x77,
|
||||
F7 = 0x78,
|
||||
F8 = 0x79,
|
||||
F9 = 0x7A,
|
||||
F10 = 0x7B,
|
||||
F11 = 0x7C,
|
||||
F12 = 0x7D,
|
||||
|
||||
insert = 0x7E,
|
||||
delete = 0x7F,
|
||||
|
||||
F13 = 0x80,
|
||||
F14 = 0x81,
|
||||
F15 = 0x82,
|
||||
F16 = 0x83,
|
||||
F17 = 0x84,
|
||||
F18 = 0x85,
|
||||
F19 = 0x86,
|
||||
F20 = 0x87,
|
||||
F21 = 0x88,
|
||||
F22 = 0x89,
|
||||
F23 = 0x8A,
|
||||
F24 = 0x8B,
|
||||
F25 = 0x8C,
|
||||
|
||||
count = 0x8D,
|
||||
}
|
||||
@@ -28,8 +28,7 @@ f32_Min :: 0x00800000
|
||||
// Note(Ed) : I don't see an intrinsict available anywhere for this. So I'll be using the Terathon non-sse impl
|
||||
// Inverse Square Root
|
||||
// C++ Source https://github.com/EricLengyel/Terathon-Math-Library/blob/main/TSMath.cpp#L191
|
||||
inverse_sqrt_f32 :: proc "contextless" ( value: f32 ) -> f32
|
||||
{
|
||||
inverse_sqrt_f32 :: proc "contextless" ( value: f32 ) -> f32 {
|
||||
if ( value < f32_Min) { return f32_Infinity }
|
||||
value_u32 := transmute(u32) value
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import "core:log"
|
||||
LoggerLevel :: log.Level
|
||||
|
||||
import "core:mem"
|
||||
AllocatorError :: mem.Allocator_Error
|
||||
// Used strickly for the logger
|
||||
Odin_Arena :: mem.Arena
|
||||
odin_arena_allocator :: mem.arena_allocator
|
||||
@@ -60,14 +61,38 @@ import "core:time"
|
||||
tick_now :: time.tick_now
|
||||
|
||||
import "codebase:grime"
|
||||
Logger :: grime.Logger
|
||||
logger_init :: grime.logger_init
|
||||
to_odin_logger :: grime.to_odin_logger
|
||||
|
||||
Array :: grime.Array
|
||||
array_to_slice :: grime.array_to_slice
|
||||
array_append_array :: grime.array_append_array
|
||||
array_append_slice :: grime.array_append_slice
|
||||
array_append_value :: grime.array_append_value
|
||||
array_back :: grime.array_back
|
||||
array_clear :: grime.array_clear
|
||||
// Logging
|
||||
Logger :: grime.Logger
|
||||
logger_init :: grime.logger_init
|
||||
// Memory
|
||||
mem_alloc :: grime.mem_alloc
|
||||
mem_copy :: grime.mem_copy
|
||||
mem_copy_non_overlapping :: grime.mem_copy_non_overlapping
|
||||
mem_zero :: grime.mem_zero
|
||||
slice_zero :: grime.slice_zero
|
||||
// Ring Buffer
|
||||
FRingBuffer :: grime.FRingBuffer
|
||||
FRingBufferIterator :: grime.FRingBufferIterator
|
||||
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
|
||||
iterator_ringbuf_fixed :: grime.iterator_ringbuf_fixed
|
||||
next_ringbuf_fixed_iterator :: grime.next_ringbuf_fixed_iterator
|
||||
// Strings
|
||||
cstr_to_str_capped :: grime.cstr_to_str_capped
|
||||
to_odin_logger :: grime.to_odin_logger
|
||||
// Operating System
|
||||
set__scheduler_granularity :: grime.set__scheduler_granularity
|
||||
|
||||
grime_set_profiler_module_context :: grime.set_profiler_module_context
|
||||
grime_set_profiler_thread_buffer :: grime.set_profiler_thread_buffer
|
||||
// grime_set_profiler_module_context :: grime.set_profiler_module_context
|
||||
// grime_set_profiler_thread_buffer :: grime.set_profiler_thread_buffer
|
||||
|
||||
Kilo :: 1024
|
||||
Mega :: Kilo * 1024
|
||||
@@ -141,13 +166,24 @@ add :: proc {
|
||||
add_r2f4,
|
||||
add_biv3f4,
|
||||
}
|
||||
|
||||
append :: proc {
|
||||
array_append_array,
|
||||
array_append_slice,
|
||||
array_append_value,
|
||||
}
|
||||
array_append :: proc {
|
||||
array_append_array,
|
||||
array_append_slice,
|
||||
array_append_value,
|
||||
}
|
||||
biv3f4 :: proc {
|
||||
biv3f4_via_f32s,
|
||||
v3f4_to_biv3f4,
|
||||
}
|
||||
bivec :: biv3f4
|
||||
|
||||
clear :: proc {
|
||||
array_clear,
|
||||
}
|
||||
cross :: proc {
|
||||
cross_s,
|
||||
cross_v2,
|
||||
@@ -156,11 +192,9 @@ cross :: proc {
|
||||
cross_v3f4_uv3f4,
|
||||
cross_u3f4_v3f4,
|
||||
}
|
||||
|
||||
div :: proc {
|
||||
div_biv3f4_f32,
|
||||
}
|
||||
|
||||
dot :: proc {
|
||||
sdot,
|
||||
vdot,
|
||||
@@ -171,75 +205,76 @@ dot :: proc {
|
||||
dot_v3f4_uv3f4,
|
||||
dot_uv3f4_v3f4,
|
||||
}
|
||||
|
||||
equal :: proc {
|
||||
equal_r2f4,
|
||||
}
|
||||
|
||||
is_power_of_two :: proc {
|
||||
is_power_of_two_u32,
|
||||
// is_power_of_two_uintptr,
|
||||
}
|
||||
|
||||
iterator :: proc {
|
||||
iterator_ringbuf_fixed,
|
||||
}
|
||||
mov_avg_exp :: proc {
|
||||
mov_avg_exp_f32,
|
||||
mov_avg_exp_f64,
|
||||
}
|
||||
|
||||
mul :: proc {
|
||||
mul_biv3f4,
|
||||
mul_biv3f4_f32,
|
||||
mul_f32_biv3f4,
|
||||
}
|
||||
|
||||
join :: proc {
|
||||
join_r2f4,
|
||||
}
|
||||
|
||||
inverse_sqrt :: proc {
|
||||
inverse_sqrt_f32,
|
||||
}
|
||||
|
||||
next :: proc {
|
||||
next_ringbuf_fixed_iterator,
|
||||
}
|
||||
point3 :: proc {
|
||||
v3f4_to_point3f4,
|
||||
}
|
||||
|
||||
pow2 :: proc {
|
||||
pow2_v3f4,
|
||||
}
|
||||
|
||||
peek_back :: proc {
|
||||
ringbuf_fixed_peak_back,
|
||||
}
|
||||
push :: proc {
|
||||
ringbuf_fixed_push,
|
||||
ringbuf_fixed_push_slice,
|
||||
}
|
||||
quatf4 :: proc {
|
||||
quatf4_from_rotor3f4,
|
||||
}
|
||||
|
||||
regress :: proc {
|
||||
regress_biv3f4,
|
||||
}
|
||||
|
||||
rotor3 :: proc {
|
||||
rotor3f4_via_comps_f4,
|
||||
rotor3f4_via_bv_s_f4,
|
||||
// rotor3f4_via_from_to_v3f4,
|
||||
}
|
||||
|
||||
size :: proc {
|
||||
size_r2f4,
|
||||
}
|
||||
|
||||
sub :: proc {
|
||||
sub_r2f4,
|
||||
sub_biv3f4,
|
||||
// join_point3_f4,
|
||||
// join_pointflat3_f4,
|
||||
}
|
||||
|
||||
to_slice :: proc {
|
||||
array_to_slice,
|
||||
}
|
||||
v2f4 :: proc {
|
||||
v2f4_from_f32s,
|
||||
v2f4_from_scalar,
|
||||
v2f4_from_v2s4,
|
||||
v2s4_from_v2f4,
|
||||
}
|
||||
|
||||
v3f4 :: proc {
|
||||
v3f4_via_f32s,
|
||||
biv3f4_to_v3f4,
|
||||
@@ -247,14 +282,12 @@ v3f4 :: proc {
|
||||
pointflat3f4_to_v3f4,
|
||||
uv3f4_to_v3f4,
|
||||
}
|
||||
|
||||
v2 :: proc {
|
||||
v2f4_from_f32s,
|
||||
v2f4_from_scalar,
|
||||
v2f4_from_v2s4,
|
||||
v2s4_from_v2f4,
|
||||
}
|
||||
|
||||
v3 :: proc {
|
||||
v3f4_via_f32s,
|
||||
biv3f4_to_v3f4,
|
||||
@@ -262,12 +295,14 @@ v3 :: proc {
|
||||
pointflat3f4_to_v3f4,
|
||||
uv3f4_to_v3f4,
|
||||
}
|
||||
|
||||
v4 :: proc {
|
||||
uv4f4_to_v4f4,
|
||||
}
|
||||
|
||||
wedge :: proc {
|
||||
wedge_v3f4,
|
||||
wedge_biv3f4,
|
||||
}
|
||||
zero :: proc {
|
||||
mem_zero,
|
||||
slice_zero,
|
||||
}
|
||||
|
||||
@@ -24,12 +24,35 @@ when ODIN_OS == .Windows {
|
||||
// 1 inch = 2.54 cm, 96 inch * 2.54 = 243.84 DPCM
|
||||
}
|
||||
|
||||
//region Unit Conversion Impl
|
||||
|
||||
// cm_to_points :: proc( cm : f32 ) -> f32 {
|
||||
// }
|
||||
// points_to_cm :: proc( points : f32 ) -> f32 {
|
||||
// screen_dpc := get_state().app_window.dpc
|
||||
// cm_per_pixel := 1.0 / screen_dpc
|
||||
// pixels := points * DPT_DPC * cm_per_pixel
|
||||
// return points *
|
||||
// }
|
||||
f32_cm_to_pixels :: #force_inline proc "contextless"(cm, screen_ppcm: f32) -> f32 { return cm * screen_ppcm }
|
||||
f32_pixels_to_cm :: #force_inline proc "contextless"(pixels, screen_ppcm: f32) -> f32 { return pixels * (1.0 / screen_ppcm) }
|
||||
f32_points_to_pixels :: #force_inline proc "contextless"(points, screen_ppcm: f32) -> f32 { return points * DPT_PPCM * (1.0 / screen_ppcm) }
|
||||
f32_pixels_to_points :: #force_inline proc "contextless"(pixels, screen_ppcm: f32) -> f32 { return pixels * (1.0 / screen_ppcm) * Points_Per_CM }
|
||||
v2f4_cm_to_pixels :: #force_inline proc "contextless"(v: V2_F4, screen_ppcm: f32) -> V2_F4 { return v * screen_ppcm }
|
||||
v2f4_pixels_to_cm :: #force_inline proc "contextless"(v: V2_F4, screen_ppcm: f32) -> V2_F4 { return v * (1.0 / screen_ppcm) }
|
||||
v2f4_points_to_pixels :: #force_inline proc "contextless"(vpoints: V2_F4, screen_ppcm: f32) -> V2_F4 { return vpoints * DPT_PPCM * (1.0 / screen_ppcm) }
|
||||
r2f4_cm_to_pixels :: #force_inline proc "contextless"(range: R2_F4, screen_ppcm: f32) -> R2_F4 { return R2_F4 { range.p0 * screen_ppcm, range.p1 * screen_ppcm } }
|
||||
range2_pixels_to_cm :: #force_inline proc "contextless"(range: R2_F4, screen_ppcm: f32) -> R2_F4 { cm_per_pixel := 1.0 / screen_ppcm; return R2_F4 { range.p0 * cm_per_pixel, range.p1 * cm_per_pixel } }
|
||||
// vec2_points_to_cm :: proc( vpoints : Vec2 ) -> Vec2 {
|
||||
// }
|
||||
|
||||
//endregion Unit Conversion Impl
|
||||
|
||||
AreaSize :: V2_F4
|
||||
|
||||
Bounds2 :: struct {
|
||||
top_left, bottom_right: V2_F4,
|
||||
}
|
||||
|
||||
BoundsCorners2 :: struct {
|
||||
top_left, top_right, bottom_left, bottom_right: V2_F4,
|
||||
}
|
||||
@@ -57,3 +80,66 @@ CameraZoomMode :: enum u32 {
|
||||
|
||||
Extents2_F4 :: V2_F4
|
||||
Extents2_S4 :: V2_S4
|
||||
|
||||
|
||||
bounds2_radius :: #force_inline proc "contextless" (bounds: Bounds2) -> f32 { return max( bounds.bottom_right.x, bounds.top_left.y ) }
|
||||
extent_from_size :: #force_inline proc "contextless" (size: AreaSize) -> Extents2_F4 { return transmute(Extents2_F4) (size * 2.0) }
|
||||
screen_size :: #force_inline proc "contextless" (screen_extent: Extents2_F4) -> AreaSize { return transmute(AreaSize) (screen_extent * 2.0) }
|
||||
screen_get_bounds :: #force_inline proc "contextless" (screen_extent: Extents2_F4) -> R2_F4 { return R2_F4 { { -screen_extent.x, -screen_extent.y} /*bottom_left*/, { screen_extent.x, screen_extent.y} /*top_right*/ } }
|
||||
screen_get_corners :: #force_inline proc "contextless"(screen_extent: Extents2_F4) -> BoundsCorners2 { return {
|
||||
top_left = { -screen_extent.x, screen_extent.y },
|
||||
top_right = { screen_extent.x, screen_extent.y },
|
||||
bottom_left = { -screen_extent.x, -screen_extent.y },
|
||||
bottom_right = { screen_extent.x, -screen_extent.y },
|
||||
}}
|
||||
view_get_bounds :: #force_inline proc "contextless"(cam: Camera, screen_extent: Extents2_F4) -> R2_F4 {
|
||||
cam_zoom_ratio := 1.0 / cam.zoom
|
||||
bottom_left := V2_F4 { -screen_extent.x, -screen_extent.y}
|
||||
top_right := V2_F4 { screen_extent.x, screen_extent.y}
|
||||
bottom_left = screen_to_ws_view_pos(bottom_left, cam.position, cam.zoom)
|
||||
top_right = screen_to_ws_view_pos(top_right, cam.position, cam.zoom)
|
||||
return R2_F4{bottom_left, top_right}
|
||||
}
|
||||
view_get_corners :: #force_inline proc "contextless"(cam: Camera, screen_extent: Extents2_F4) -> BoundsCorners2 {
|
||||
cam_zoom_ratio := 1.0 / cam.zoom
|
||||
zoomed_extent := screen_extent * cam_zoom_ratio
|
||||
top_left := cam.position + V2_F4 { -zoomed_extent.x, zoomed_extent.y }
|
||||
top_right := cam.position + V2_F4 { zoomed_extent.x, zoomed_extent.y }
|
||||
bottom_left := cam.position + V2_F4 { -zoomed_extent.x, -zoomed_extent.y }
|
||||
bottom_right := cam.position + V2_F4 { zoomed_extent.x, -zoomed_extent.y }
|
||||
return { top_left, top_right, bottom_left, bottom_right }
|
||||
}
|
||||
render_to_screen_pos :: #force_inline proc "contextless" (pos: V2_F4, screen_extent: Extents2_F4) -> V2_F4 { return V2_F4 { pos.x - screen_extent.x, (pos.y * -1) + screen_extent.y } }
|
||||
render_to_ws_view_pos :: #force_inline proc "contextless" (pos: V2_F4) -> V2_F4 { return {} } //TODO(Ed): Implement?
|
||||
screen_to_ws_view_pos :: #force_inline proc "contextless" (pos: V2_F4, cam_pos: V2_F4, cam_zoom: f32, ) -> V2_F4 { return pos * (/*Camera Zoom Ratio*/1.0 / cam_zoom) - cam_pos } // TODO(Ed): Doesn't take into account view extent.
|
||||
screen_to_render_pos :: #force_inline proc "contextless" (pos: V2_F4, screen_extent: Extents2_F4) -> V2_F4 { return pos + screen_extent } // Centered screen space to conventional screen space used for rendering
|
||||
|
||||
// TODO(Ed): These should assume a cam_context or have the ability to provide it in params
|
||||
ws_view_extent :: #force_inline proc "contextless" (cam_view: Extents2_F4, cam_zoom: f32) -> Extents2_F4 { return cam_view * (/*Camera Zoom Ratio*/1.0 / cam_zoom) }
|
||||
ws_view_to_screen_pos :: #force_inline proc "contextless" (ws_pos : V2_F4, cam: Camera) -> V2_F4 {
|
||||
// Apply camera transformation
|
||||
view_pos := (ws_pos - cam.position) * cam.zoom
|
||||
// TODO(Ed): properly take into account cam.view
|
||||
screen_pos := view_pos
|
||||
return screen_pos
|
||||
}
|
||||
ws_view_to_render_pos :: #force_inline proc "contextless"(position: V2_F4, cam: Camera, screen_extent: Extents2_F4) -> V2_F4 {
|
||||
extent_offset: V2_F4 = { screen_extent.x, screen_extent.y } * { 1, 1 }
|
||||
position := V2_F4 { position.x, position.y }
|
||||
cam_offset := V2_F4 { cam.position.x, cam.position.y }
|
||||
return extent_offset + (position + cam_offset) * cam.zoom
|
||||
}
|
||||
|
||||
// Workspace view to screen space position (zoom agnostic)
|
||||
// TODO(Ed): Support a position which would not be centered on the screen if in a viewport
|
||||
ws_view_to_screen_pos_no_zoom :: #force_inline proc "contextless"(position: V2_F4, cam: Camera) -> V2_F4 {
|
||||
cam_zoom_ratio := 1.0 / cam.zoom
|
||||
return { position.x, position.y } * cam_zoom_ratio
|
||||
}
|
||||
|
||||
// Workspace view to render space position (zoom agnostic)
|
||||
// TODO(Ed): Support a position which would not be centered on the screen if in a viewport
|
||||
ws_view_to_render_pos_no_zoom :: #force_inline proc "contextless"(position: V2_F4, cam: Camera) -> V2_F4 {
|
||||
cam_zoom_ratio := 1.0 / cam.zoom
|
||||
return { position.x, position.y } * cam_zoom_ratio
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@ package sectr
|
||||
|
||||
//region STATIC MEMORY
|
||||
// This should be the only global on client module side.
|
||||
memory: ^ProcessMemory
|
||||
@(thread_local) thread: ^ThreadMemory
|
||||
@(private) memory: ^ProcessMemory
|
||||
@(private, thread_local) thread: ^ThreadMemory
|
||||
//endregion STATIC MEMORy
|
||||
|
||||
MemoryConfig :: struct {
|
||||
@@ -70,16 +70,28 @@ FrameTime :: struct {
|
||||
}
|
||||
|
||||
State :: struct {
|
||||
sokol_frame_count: i64,
|
||||
sokol_context: Context,
|
||||
|
||||
config: AppConfig,
|
||||
app_window: AppWindow,
|
||||
|
||||
logger: Logger,
|
||||
|
||||
// Overall frametime of the tick frame (currently main thread's)
|
||||
using frametime : FrameTime,
|
||||
|
||||
logger: Logger,
|
||||
|
||||
sokol_frame_count: i64,
|
||||
sokol_context: Context,
|
||||
input_data : [2]InputState,
|
||||
input_prev : ^InputState,
|
||||
input : ^InputState, // TODO(Ed): Rename to indicate its the device's signal state for the frame?
|
||||
|
||||
input_events: InputEvents,
|
||||
input_binds_stack: Array(InputContext),
|
||||
|
||||
// Note(Ed): Do not modify directly, use its interface in app/event.odin
|
||||
staged_input_events : Array(InputEvent),
|
||||
// TODO(Ed): Add a multi-threaded guard for accessing or mutating staged_input_events.
|
||||
}
|
||||
|
||||
ThreadState :: struct {
|
||||
@@ -96,3 +108,7 @@ ThreadState :: struct {
|
||||
|
||||
app_config :: #force_inline proc "contextless" () -> AppConfig { return memory.client_memory.config }
|
||||
get_frametime :: #force_inline proc "contextless" () -> FrameTime { return memory.client_memory.frametime }
|
||||
// get_state :: #force_inline proc "contextless" () -> ^State { return memory.client_memory }
|
||||
|
||||
get_input_binds :: #force_inline proc "contextless" () -> InputContext { return array_back (memory.client_memory.input_binds_stack) }
|
||||
get_input_binds_stack :: #force_inline proc "contextless" () -> []InputContext { return array_to_slice(memory.client_memory.input_binds_stack) }
|
||||
|
||||
@@ -97,6 +97,7 @@ $flag_radlink = '-radlink'
|
||||
$flag_sanitize_address = '-sanitize:address'
|
||||
$flag_sanitize_memory = '-sanitize:memory'
|
||||
$flag_sanitize_thread = '-sanitize:thread'
|
||||
$flag_show_definables = '-show-defineables'
|
||||
$flag_subsystem = '-subsystem:'
|
||||
$flag_show_debug_messages = '-show-debug-messages'
|
||||
$flag_show_timings = '-show-timings'
|
||||
@@ -233,13 +234,14 @@ push-location $path_root
|
||||
# $build_args += $flag_sanitize_address
|
||||
# $build_args += $flag_sanitize_memory
|
||||
# $build_args += $flag_show_debug_messages
|
||||
$build_args += $flag_show_definabless
|
||||
$build_args += $flag_show_timings
|
||||
# $build_args += $flag_build_diagnostics
|
||||
# TODO(Ed): Enforce nil default allocator
|
||||
|
||||
foreach ($arg in $build_args) {
|
||||
write-host `t $arg -ForegroundColor Cyan
|
||||
}
|
||||
# foreach ($arg in $build_args) {
|
||||
# write-host `t $arg -ForegroundColor Cyan
|
||||
# }
|
||||
|
||||
if ( Test-Path $module_dll) {
|
||||
$module_dll_pre_build_hash = get-filehash -path $module_dll -Algorithm MD5
|
||||
@@ -301,8 +303,8 @@ push-location $path_root
|
||||
# $build_args += $flag_micro_architecture_native
|
||||
$build_args += $flag_microarch_zen5
|
||||
$build_args += $flag_thread_count + $CoreCount_Physical
|
||||
$build_args += $flag_optimize_none
|
||||
# $build_args += $flag_optimize_minimal
|
||||
# $build_args += $flag_optimize_none
|
||||
$build_args += $flag_optimize_minimal
|
||||
# $build_args += $flag_optimize_speed
|
||||
# $build_args += $falg_optimize_aggressive
|
||||
$build_args += $flag_debug
|
||||
@@ -318,11 +320,12 @@ push-location $path_root
|
||||
# $build_args += $flag_sanitize_address
|
||||
# $build_args += $flag_sanitize_memory
|
||||
# $build_args += $flag_build_diagnostics
|
||||
$build_args += $flag_show_definabless
|
||||
# TODO(Ed): Enforce nil default allocator
|
||||
|
||||
foreach ($arg in $build_args) {
|
||||
write-host `t $arg -ForegroundColor Cyan
|
||||
}
|
||||
# foreach ($arg in $build_args) {
|
||||
# write-host `t $arg -ForegroundColor Cyan
|
||||
# }
|
||||
|
||||
if ( Test-Path $executable) {
|
||||
$executable_pre_build_hash = get-filehash -path $executable -Algorithm MD5
|
||||
|
||||
Reference in New Issue
Block a user