mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-07 22:38:41 +00:00
[tex] move to async layer
This commit is contained in:
@@ -38,12 +38,6 @@ tex_init(void)
|
||||
tex_shared->u2x_ring_base = push_array_no_zero(arena, U8, tex_shared->u2x_ring_size);
|
||||
tex_shared->u2x_ring_cv = os_condition_variable_alloc();
|
||||
tex_shared->u2x_ring_mutex = os_mutex_alloc();
|
||||
tex_shared->xfer_thread_count = Clamp(1, os_get_system_info()->logical_processor_count-1, 4);
|
||||
tex_shared->xfer_threads = push_array(arena, OS_Handle, tex_shared->xfer_thread_count);
|
||||
for(U64 idx = 0; idx < tex_shared->xfer_thread_count; idx += 1)
|
||||
{
|
||||
tex_shared->xfer_threads[idx] = os_thread_launch(tex_xfer_thread__entry_point, (void *)idx, 0);
|
||||
}
|
||||
tex_shared->evictor_thread = os_thread_launch(tex_evictor_thread__entry_point, 0, 0);
|
||||
}
|
||||
|
||||
@@ -207,6 +201,7 @@ tex_texture_from_hash_topology(TEX_Scope *scope, U128 hash, TEX_Topology topolog
|
||||
if(node_is_new)
|
||||
{
|
||||
tex_u2x_enqueue_req(hash, topology, max_U64);
|
||||
async_push_work(tex_xfer_work);
|
||||
}
|
||||
}
|
||||
return handle;
|
||||
@@ -280,10 +275,7 @@ tex_u2x_dequeue_req(U128 *hash_out, TEX_Topology *top_out)
|
||||
os_condition_variable_broadcast(tex_shared->u2x_ring_cv);
|
||||
}
|
||||
|
||||
internal void
|
||||
tex_xfer_thread__entry_point(void *p)
|
||||
{
|
||||
for(;;)
|
||||
ASYNC_WORK_DEF(tex_xfer_work)
|
||||
{
|
||||
HS_Scope *scope = hs_scope_open();
|
||||
|
||||
@@ -342,7 +334,7 @@ tex_xfer_thread__entry_point(void *p)
|
||||
}
|
||||
|
||||
hs_scope_close(scope);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
@@ -351,6 +343,7 @@ tex_xfer_thread__entry_point(void *p)
|
||||
internal void
|
||||
tex_evictor_thread__entry_point(void *p)
|
||||
{
|
||||
ThreadNameF("[tex] evictor thread");
|
||||
for(;;)
|
||||
{
|
||||
U64 check_time_us = os_now_microseconds();
|
||||
|
||||
@@ -102,10 +102,6 @@ struct TEX_Shared
|
||||
OS_Handle u2x_ring_cv;
|
||||
OS_Handle u2x_ring_mutex;
|
||||
|
||||
// rjf: transfer threads
|
||||
U64 xfer_thread_count;
|
||||
OS_Handle *xfer_threads;
|
||||
|
||||
// rjf: evictor thread
|
||||
OS_Handle evictor_thread;
|
||||
};
|
||||
@@ -155,7 +151,7 @@ internal R_Handle tex_texture_from_key_topology(TEX_Scope *scope, U128 key, TEX_
|
||||
|
||||
internal B32 tex_u2x_enqueue_req(U128 hash, TEX_Topology top, U64 endt_us);
|
||||
internal void tex_u2x_dequeue_req(U128 *hash_out, TEX_Topology *top_out);
|
||||
internal void tex_xfer_thread__entry_point(void *p);
|
||||
ASYNC_WORK_DEF(tex_xfer_work);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Evictor Threads
|
||||
|
||||
Reference in New Issue
Block a user