use SI units for size macros
This commit is contained in:
parent
69a8a7aa9a
commit
994ed1e1e1
@ -226,8 +226,8 @@ void sys_app_entry(struct string args_str)
|
|||||||
bitbuff_test();
|
bitbuff_test();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
G.exit_callbacks_arena = arena_alloc(GIGABYTE(64));
|
G.exit_callbacks_arena = arena_alloc(GIBI(64));
|
||||||
G.arena = arena_alloc(GIGABYTE(64));
|
G.arena = arena_alloc(GIBI(64));
|
||||||
|
|
||||||
G.write_path = initialize_write_directory(G.arena, LIT(WRITE_DIR));
|
G.write_path = initialize_write_directory(G.arena, LIT(WRITE_DIR));
|
||||||
|
|
||||||
|
|||||||
@ -37,7 +37,7 @@ GLOBAL struct {
|
|||||||
struct asset_cache_startup_receipt asset_cache_startup(void)
|
struct asset_cache_startup_receipt asset_cache_startup(void)
|
||||||
{
|
{
|
||||||
/* Init store */
|
/* Init store */
|
||||||
G.store_arena = arena_alloc(GIGABYTE(64));
|
G.store_arena = arena_alloc(GIBI(64));
|
||||||
|
|
||||||
return (struct asset_cache_startup_receipt) { 0 };
|
return (struct asset_cache_startup_receipt) { 0 };
|
||||||
}
|
}
|
||||||
|
|||||||
@ -752,7 +752,7 @@ void bitbuff_test(void)
|
|||||||
|
|
||||||
struct string encoded = ZI;
|
struct string encoded = ZI;
|
||||||
{
|
{
|
||||||
struct bitbuff bb = bitbuff_alloc(GIGABYTE(64));
|
struct bitbuff bb = bitbuff_alloc(GIBI(64));
|
||||||
struct bitbuff_writer bw = bw_from_bitbuff(&bb);
|
struct bitbuff_writer bw = bw_from_bitbuff(&bb);
|
||||||
for (u64 i = 0; i < countof(cases); ++i) {
|
for (u64 i = 0; i < countof(cases); ++i) {
|
||||||
struct test_case c = cases[i];
|
struct test_case c = cases[i];
|
||||||
|
|||||||
@ -10,7 +10,7 @@
|
|||||||
struct buddy_ctx *buddy_ctx_alloc(u64 reserve)
|
struct buddy_ctx *buddy_ctx_alloc(u64 reserve)
|
||||||
{
|
{
|
||||||
/* TODO: Determine meta reserve dynamically */
|
/* TODO: Determine meta reserve dynamically */
|
||||||
struct arena *meta_arena = arena_alloc(GIGABYTE(64));
|
struct arena *meta_arena = arena_alloc(GIBI(64));
|
||||||
struct buddy_ctx *ctx = arena_push(meta_arena, struct buddy_ctx);
|
struct buddy_ctx *ctx = arena_push(meta_arena, struct buddy_ctx);
|
||||||
ctx->meta_arena = meta_arena;
|
ctx->meta_arena = meta_arena;
|
||||||
ctx->data_arena = arena_alloc(reserve);
|
ctx->data_arena = arena_alloc(reserve);
|
||||||
|
|||||||
22
src/common.h
22
src/common.h
@ -235,10 +235,10 @@ void __asan_unpoison_memory_region(void const volatile *add, size_t);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Sizes */
|
/* Sizes */
|
||||||
#define KILOBYTE(n) (n*1024ULL)
|
#define KIBI(n) (n*1024ULL)
|
||||||
#define MEGABYTE(n) (n*KILOBYTE(1024ULL))
|
#define MEBI(n) (n*KIBI(1024ULL))
|
||||||
#define GIGABYTE(n) (n*MEGABYTE(1024ULL))
|
#define GIBI(n) (n*MEBI(1024ULL))
|
||||||
#define TERABYTE(n) (n*GIGABYTE(1024ULL))
|
#define TEBI(n) (n*GIBI(1024ULL))
|
||||||
|
|
||||||
/* Time */
|
/* Time */
|
||||||
#define NS_FROM_SECONDS(s) ((i64)((s) * 1000000000.0))
|
#define NS_FROM_SECONDS(s) ((i64)((s) * 1000000000.0))
|
||||||
@ -657,13 +657,13 @@ INLINE f64 clamp_f64(f64 v, f64 min, f64 max) { return v < min ? min : v > max ?
|
|||||||
|
|
||||||
#include "prof_tracy.h"
|
#include "prof_tracy.h"
|
||||||
|
|
||||||
#define PROF_THREAD_GROUP_WORKERS -7000000
|
#define PROF_THREAD_GROUP_WORKERS -MEBI(7)
|
||||||
#define PROF_THREAD_GROUP_FIBERS -6000000
|
#define PROF_THREAD_GROUP_FIBERS -MEBI(6)
|
||||||
#define PROF_THREAD_GROUP_IO -5000000
|
#define PROF_THREAD_GROUP_IO -MEBI(5)
|
||||||
#define PROF_THREAD_GROUP_WINDOW -4000000
|
#define PROF_THREAD_GROUP_WINDOW -MEBI(4)
|
||||||
#define PROF_THREAD_GROUP_EVICTORS -3000000
|
#define PROF_THREAD_GROUP_EVICTORS -MEBI(3)
|
||||||
#define PROF_THREAD_GROUP_APP -2000000
|
#define PROF_THREAD_GROUP_APP -MEBI(2)
|
||||||
#define PROF_THREAD_GROUP_MAIN -1000000
|
#define PROF_THREAD_GROUP_MAIN -MEBI(1)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@ -49,7 +49,7 @@ struct font_startup_receipt font_startup(struct gp_startup_receipt *gp_sr,
|
|||||||
(UNUSED)ttf_sr;
|
(UNUSED)ttf_sr;
|
||||||
(UNUSED)resource_sr;
|
(UNUSED)resource_sr;
|
||||||
|
|
||||||
G.params.arena = arena_alloc(GIGABYTE(64));
|
G.params.arena = arena_alloc(GIBI(64));
|
||||||
|
|
||||||
return (struct font_startup_receipt) { 0 };
|
return (struct font_startup_receipt) { 0 };
|
||||||
}
|
}
|
||||||
|
|||||||
@ -353,23 +353,23 @@ struct gp_startup_receipt gp_startup(void)
|
|||||||
__prof;
|
__prof;
|
||||||
|
|
||||||
/* Initialize command descriptor heaps pool */
|
/* Initialize command descriptor heaps pool */
|
||||||
G.command_descriptor_heaps_arena = arena_alloc(GIGABYTE(64));
|
G.command_descriptor_heaps_arena = arena_alloc(GIBI(64));
|
||||||
|
|
||||||
/* Initialize command buffers pool */
|
/* Initialize command buffers pool */
|
||||||
G.command_buffers_arena = arena_alloc(GIGABYTE(64));
|
G.command_buffers_arena = arena_alloc(GIBI(64));
|
||||||
G.command_buffers_dict = dict_init(G.command_buffers_arena, 4096);
|
G.command_buffers_dict = dict_init(G.command_buffers_arena, 4096);
|
||||||
|
|
||||||
/* Initialize resources pool */
|
/* Initialize resources pool */
|
||||||
G.resources_arena = arena_alloc(GIGABYTE(64));
|
G.resources_arena = arena_alloc(GIBI(64));
|
||||||
|
|
||||||
/* Initialize pipeline cache */
|
/* Initialize pipeline cache */
|
||||||
G.pipelines_arena = arena_alloc(GIGABYTE(64));
|
G.pipelines_arena = arena_alloc(GIBI(64));
|
||||||
G.pipeline_descs = dict_init(G.pipelines_arena, 1024);
|
G.pipeline_descs = dict_init(G.pipelines_arena, 1024);
|
||||||
G.top_pipelines = dict_init(G.pipelines_arena, 1024);
|
G.top_pipelines = dict_init(G.pipelines_arena, 1024);
|
||||||
G.top_successful_pipelines = dict_init(G.pipelines_arena, 1024);
|
G.top_successful_pipelines = dict_init(G.pipelines_arena, 1024);
|
||||||
|
|
||||||
/* Initialize fenced releases queue */
|
/* Initialize fenced releases queue */
|
||||||
G.fenced_releases_arena = arena_alloc(GIGABYTE(64));
|
G.fenced_releases_arena = arena_alloc(GIBI(64));
|
||||||
|
|
||||||
/* Initialize dx12 */
|
/* Initialize dx12 */
|
||||||
dx12_init_device();
|
dx12_init_device();
|
||||||
@ -864,7 +864,7 @@ INTERNAL SYS_JOB_DEF(pipeline_init_job, job)
|
|||||||
|
|
||||||
struct pipeline *pipeline = NULL;
|
struct pipeline *pipeline = NULL;
|
||||||
{
|
{
|
||||||
struct arena *pipeline_arena = arena_alloc(MEGABYTE(64));
|
struct arena *pipeline_arena = arena_alloc(MEBI(64));
|
||||||
pipeline = arena_push(pipeline_arena, struct pipeline);
|
pipeline = arena_push(pipeline_arena, struct pipeline);
|
||||||
pipeline->arena = pipeline_arena;
|
pipeline->arena = pipeline_arena;
|
||||||
pipelines_out[job.id] = pipeline;
|
pipelines_out[job.id] = pipeline;
|
||||||
@ -1147,7 +1147,7 @@ INTERNAL struct pipeline_scope *pipeline_scope_begin(void)
|
|||||||
if (scope) {
|
if (scope) {
|
||||||
arena = scope->arena;
|
arena = scope->arena;
|
||||||
} else {
|
} else {
|
||||||
arena = arena_alloc(MEGABYTE(64));
|
arena = arena_alloc(MEBI(64));
|
||||||
}
|
}
|
||||||
arena_reset(arena);
|
arena_reset(arena);
|
||||||
scope = arena_push(arena, struct pipeline_scope);
|
scope = arena_push(arena, struct pipeline_scope);
|
||||||
@ -1344,7 +1344,7 @@ INTERNAL struct cpu_descriptor_heap *cpu_descriptor_heap_alloc(enum D3D12_DESCRI
|
|||||||
__prof;
|
__prof;
|
||||||
struct cpu_descriptor_heap *dh = NULL;
|
struct cpu_descriptor_heap *dh = NULL;
|
||||||
{
|
{
|
||||||
struct arena *arena = arena_alloc(MEGABYTE(64));
|
struct arena *arena = arena_alloc(MEBI(64));
|
||||||
dh = arena_push(arena, struct cpu_descriptor_heap);
|
dh = arena_push(arena, struct cpu_descriptor_heap);
|
||||||
dh->arena = arena;
|
dh->arena = arena;
|
||||||
}
|
}
|
||||||
@ -1429,15 +1429,15 @@ INTERNAL struct flow *flow_alloc(void)
|
|||||||
__prof;
|
__prof;
|
||||||
struct flow *flow = NULL;
|
struct flow *flow = NULL;
|
||||||
{
|
{
|
||||||
struct arena *arena = arena_alloc(MEGABYTE(64));
|
struct arena *arena = arena_alloc(MEBI(64));
|
||||||
flow = arena_push(arena, struct flow);
|
flow = arena_push(arena, struct flow);
|
||||||
flow->arena = arena;
|
flow->arena = arena;
|
||||||
}
|
}
|
||||||
|
|
||||||
flow->material_instance_descs_arena = arena_alloc(GIGABYTE(1));
|
flow->material_instance_descs_arena = arena_alloc(GIBI(1));
|
||||||
flow->material_grid_descs_arena = arena_alloc(GIGABYTE(1));
|
flow->material_grid_descs_arena = arena_alloc(GIBI(1));
|
||||||
flow->shape_verts_arena = arena_alloc(GIGABYTE(1));
|
flow->shape_verts_arena = arena_alloc(GIBI(1));
|
||||||
flow->shape_indices_arena = arena_alloc(GIGABYTE(1));
|
flow->shape_indices_arena = arena_alloc(GIBI(1));
|
||||||
|
|
||||||
return flow;
|
return flow;
|
||||||
}
|
}
|
||||||
@ -1601,7 +1601,7 @@ INTERNAL struct dx12_resource *dx12_resource_alloc(D3D12_HEAP_PROPERTIES heap_pr
|
|||||||
cbv_desc.BufferLocation = r->gpu_address;
|
cbv_desc.BufferLocation = r->gpu_address;
|
||||||
//cbv_desc.SizeInBytes = desc.ByteWidth;
|
//cbv_desc.SizeInBytes = desc.ByteWidth;
|
||||||
/* FIXME: Get actual size */
|
/* FIXME: Get actual size */
|
||||||
cbv_desc.SizeInBytes = KILOBYTE(64);
|
cbv_desc.SizeInBytes = KIBI(64);
|
||||||
ID3D12Device_CreateConstantBufferView(G.device, &cbv_desc, r->cbv_descriptor->handle);
|
ID3D12Device_CreateConstantBufferView(G.device, &cbv_desc, r->cbv_descriptor->handle);
|
||||||
}
|
}
|
||||||
if (view_flags & DX12_RESOURCE_VIEW_FLAG_SRV) {
|
if (view_flags & DX12_RESOURCE_VIEW_FLAG_SRV) {
|
||||||
@ -1689,7 +1689,7 @@ INTERNAL struct command_queue *command_queue_alloc(enum D3D12_COMMAND_LIST_TYPE
|
|||||||
__prof;
|
__prof;
|
||||||
struct command_queue *cq = NULL;
|
struct command_queue *cq = NULL;
|
||||||
{
|
{
|
||||||
struct arena *arena = arena_alloc(GIGABYTE(64));
|
struct arena *arena = arena_alloc(GIBI(64));
|
||||||
cq = arena_push(arena, struct command_queue);
|
cq = arena_push(arena, struct command_queue);
|
||||||
cq->arena = arena;
|
cq->arena = arena;
|
||||||
}
|
}
|
||||||
@ -1732,7 +1732,7 @@ INTERNAL struct command_list_pool *command_list_pool_alloc(struct command_queue
|
|||||||
{
|
{
|
||||||
struct command_list_pool *pool = NULL;
|
struct command_list_pool *pool = NULL;
|
||||||
{
|
{
|
||||||
struct arena *arena = arena_alloc(GIGABYTE(64));
|
struct arena *arena = arena_alloc(GIBI(64));
|
||||||
pool = arena_push(arena, struct command_list_pool);
|
pool = arena_push(arena, struct command_list_pool);
|
||||||
pool->arena = arena;
|
pool->arena = arena;
|
||||||
}
|
}
|
||||||
|
|||||||
16
src/host.c
16
src/host.c
@ -176,17 +176,17 @@ struct host_startup_receipt host_startup(struct sock_startup_receipt *sock_sr)
|
|||||||
|
|
||||||
struct host *host_alloc(u16 listen_port)
|
struct host *host_alloc(u16 listen_port)
|
||||||
{
|
{
|
||||||
struct arena *arena = arena_alloc(GIGABYTE(64));
|
struct arena *arena = arena_alloc(GIBI(64));
|
||||||
struct host *host = arena_push(arena, struct host);
|
struct host *host = arena_push(arena, struct host);
|
||||||
|
|
||||||
host->arena = arena;
|
host->arena = arena;
|
||||||
host->cmd_arena = arena_alloc(GIGABYTE(64));
|
host->cmd_arena = arena_alloc(GIBI(64));
|
||||||
host->channel_arena = arena_alloc(GIGABYTE(64));
|
host->channel_arena = arena_alloc(GIBI(64));
|
||||||
host->rcv_buffer_read = arena_push(host->arena, struct host_rcv_buffer);
|
host->rcv_buffer_read = arena_push(host->arena, struct host_rcv_buffer);
|
||||||
host->rcv_buffer_write = arena_push(host->arena, struct host_rcv_buffer);
|
host->rcv_buffer_write = arena_push(host->arena, struct host_rcv_buffer);
|
||||||
host->rcv_buffer_read->arena = arena_alloc(GIGABYTE(64));
|
host->rcv_buffer_read->arena = arena_alloc(GIBI(64));
|
||||||
host->rcv_buffer_write->arena = arena_alloc(GIGABYTE(64));
|
host->rcv_buffer_write->arena = arena_alloc(GIBI(64));
|
||||||
host->buddy = buddy_ctx_alloc(GIGABYTE(64));
|
host->buddy = buddy_ctx_alloc(GIBI(64));
|
||||||
|
|
||||||
host->channels = arena_push_dry(host->channel_arena, struct host_channel);
|
host->channels = arena_push_dry(host->channel_arena, struct host_channel);
|
||||||
|
|
||||||
@ -196,7 +196,7 @@ struct host *host_alloc(u16 listen_port)
|
|||||||
host->num_msg_assembler_lookup_bins = NUM_MSG_ASSEMBLER_LOOKUP_BINS;
|
host->num_msg_assembler_lookup_bins = NUM_MSG_ASSEMBLER_LOOKUP_BINS;
|
||||||
host->msg_assembler_lookup_bins = arena_push_array(host->arena, struct host_msg_assembler_lookup_bin, host->num_msg_assembler_lookup_bins);
|
host->msg_assembler_lookup_bins = arena_push_array(host->arena, struct host_msg_assembler_lookup_bin, host->num_msg_assembler_lookup_bins);
|
||||||
|
|
||||||
host->sock = sock_alloc(listen_port, MEGABYTE(2), MEGABYTE(2));
|
host->sock = sock_alloc(listen_port, MEBI(2), MEBI(2));
|
||||||
|
|
||||||
host->receiver_thread = sys_thread_alloc(&host_receiver_thread_entry_point, host, LIT("Host receiver"), PROF_THREAD_GROUP_IO);
|
host->receiver_thread = sys_thread_alloc(&host_receiver_thread_entry_point, host, LIT("Host receiver"), PROF_THREAD_GROUP_IO);
|
||||||
|
|
||||||
@ -1060,7 +1060,7 @@ void host_update_end(struct host *host)
|
|||||||
|
|
||||||
INTERNAL SYS_THREAD_DEF(host_receiver_thread_entry_point, arg)
|
INTERNAL SYS_THREAD_DEF(host_receiver_thread_entry_point, arg)
|
||||||
{
|
{
|
||||||
u64 read_buff_size = KILOBYTE(64);
|
u64 read_buff_size = KIBI(64);
|
||||||
struct arena *read_buff_arena = arena_alloc(read_buff_size);
|
struct arena *read_buff_arena = arena_alloc(read_buff_size);
|
||||||
struct string read_buff = ZI;
|
struct string read_buff = ZI;
|
||||||
read_buff.len = read_buff_size;
|
read_buff.len = read_buff_size;
|
||||||
|
|||||||
@ -64,7 +64,7 @@ GLOBAL READONLY struct log_level_settings g_log_level_settings[LOG_LEVEL_COUNT]
|
|||||||
|
|
||||||
void log_startup(struct string logfile_path)
|
void log_startup(struct string logfile_path)
|
||||||
{
|
{
|
||||||
G.callbacks_arena = arena_alloc(MEGABYTE(8));
|
G.callbacks_arena = arena_alloc(MEBI(8));
|
||||||
if (logfile_path.len > 0) {
|
if (logfile_path.len > 0) {
|
||||||
/* Create / wipe log file */
|
/* Create / wipe log file */
|
||||||
sys_file_close(sys_file_open_write(logfile_path));
|
sys_file_close(sys_file_open_write(logfile_path));
|
||||||
|
|||||||
@ -72,7 +72,7 @@ GLOBAL struct {
|
|||||||
|
|
||||||
struct mixer_startup_receipt mixer_startup(void)
|
struct mixer_startup_receipt mixer_startup(void)
|
||||||
{
|
{
|
||||||
G.track_arena = arena_alloc(GIGABYTE(64));
|
G.track_arena = arena_alloc(GIBI(64));
|
||||||
G.listener_pos = V2(0, 0);
|
G.listener_pos = V2(0, 0);
|
||||||
G.listener_dir = V2(0, -1);
|
G.listener_dir = V2(0, -1);
|
||||||
|
|
||||||
|
|||||||
@ -52,7 +52,7 @@ INTERNAL APP_EXIT_CALLBACK_FUNC_DEF(resource_shutdown);
|
|||||||
|
|
||||||
struct resource_startup_receipt resource_startup(void)
|
struct resource_startup_receipt resource_startup(void)
|
||||||
{
|
{
|
||||||
G.arena = arena_alloc(GIGABYTE(64));
|
G.arena = arena_alloc(GIBI(64));
|
||||||
|
|
||||||
#if RESOURCES_EMBEDDED
|
#if RESOURCES_EMBEDDED
|
||||||
struct string embedded_data = inc_res_tar();
|
struct string embedded_data = inc_res_tar();
|
||||||
@ -70,7 +70,7 @@ struct resource_startup_receipt resource_startup(void)
|
|||||||
#if RESOURCE_RELOADING
|
#if RESOURCE_RELOADING
|
||||||
G.watch = sys_watch_alloc(LIT("res"));
|
G.watch = sys_watch_alloc(LIT("res"));
|
||||||
|
|
||||||
G.watch_dispatcher_info_arena = arena_alloc(GIGABYTE(64));
|
G.watch_dispatcher_info_arena = arena_alloc(GIBI(64));
|
||||||
|
|
||||||
app_register_exit_callback(&resource_shutdown);
|
app_register_exit_callback(&resource_shutdown);
|
||||||
G.resource_watch_monitor_thread = sys_thread_alloc(resource_watch_monitor_thread_entry_point, NULL, LIT("Resource watch monitor"), PROF_THREAD_GROUP_IO);
|
G.resource_watch_monitor_thread = sys_thread_alloc(resource_watch_monitor_thread_entry_point, NULL, LIT("Resource watch monitor"), PROF_THREAD_GROUP_IO);
|
||||||
|
|||||||
12
src/sim.c
12
src/sim.c
@ -62,7 +62,7 @@ READONLY struct sim_ent **_g_sim_ent_nil = &G.nil_ent;
|
|||||||
|
|
||||||
struct sim_startup_receipt sim_startup(void)
|
struct sim_startup_receipt sim_startup(void)
|
||||||
{
|
{
|
||||||
G.nil_arena = arena_alloc(GIGABYTE(1));
|
G.nil_arena = arena_alloc(GIBI(1));
|
||||||
|
|
||||||
/* Nil client store */
|
/* Nil client store */
|
||||||
G.nil_client_store = arena_push(G.nil_arena, struct sim_client_store);
|
G.nil_client_store = arena_push(G.nil_arena, struct sim_client_store);
|
||||||
@ -106,14 +106,14 @@ struct sim_client_store *sim_client_store_alloc(void)
|
|||||||
__prof;
|
__prof;
|
||||||
struct sim_client_store *store;
|
struct sim_client_store *store;
|
||||||
{
|
{
|
||||||
struct arena *arena = arena_alloc(GIGABYTE(64));
|
struct arena *arena = arena_alloc(GIBI(64));
|
||||||
store = arena_push(arena, struct sim_client_store);
|
store = arena_push(arena, struct sim_client_store);
|
||||||
store->arena = arena;
|
store->arena = arena;
|
||||||
}
|
}
|
||||||
store->valid = true;
|
store->valid = true;
|
||||||
store->num_client_lookup_bins = CLIENT_LOOKUP_BINS;
|
store->num_client_lookup_bins = CLIENT_LOOKUP_BINS;
|
||||||
store->client_lookup_bins = arena_push_array(store->arena, struct sim_client_lookup_bin, store->num_client_lookup_bins);
|
store->client_lookup_bins = arena_push_array(store->arena, struct sim_client_lookup_bin, store->num_client_lookup_bins);
|
||||||
store->clients_arena = arena_alloc(GIGABYTE(64));
|
store->clients_arena = arena_alloc(GIBI(64));
|
||||||
store->clients = arena_push_dry(store->clients_arena, struct sim_client);
|
store->clients = arena_push_dry(store->clients_arena, struct sim_client);
|
||||||
return store;
|
return store;
|
||||||
}
|
}
|
||||||
@ -156,7 +156,7 @@ struct sim_client *sim_client_alloc(struct sim_client_store *store)
|
|||||||
client->valid = true;
|
client->valid = true;
|
||||||
client->handle = handle;
|
client->handle = handle;
|
||||||
|
|
||||||
client->snapshots_arena = arena_alloc(GIGABYTE(8));
|
client->snapshots_arena = arena_alloc(GIBI(8));
|
||||||
client->num_snapshot_lookup_bins = TICK_LOOKUP_BINS;
|
client->num_snapshot_lookup_bins = TICK_LOOKUP_BINS;
|
||||||
client->snapshot_lookup_bins = arena_push_array(client->snapshots_arena, struct sim_snapshot_lookup_bin, client->num_snapshot_lookup_bins);
|
client->snapshot_lookup_bins = arena_push_array(client->snapshots_arena, struct sim_snapshot_lookup_bin, client->num_snapshot_lookup_bins);
|
||||||
|
|
||||||
@ -293,8 +293,8 @@ struct sim_snapshot *sim_snapshot_alloc(struct sim_client *client, struct sim_sn
|
|||||||
arena = ss->arena;
|
arena = ss->arena;
|
||||||
} else {
|
} else {
|
||||||
/* Arenas allocated here will be released with client */
|
/* Arenas allocated here will be released with client */
|
||||||
arena = arena_alloc(GIGABYTE(1));
|
arena = arena_alloc(GIBI(1));
|
||||||
ents_arena = arena_alloc(GIGABYTE(1));
|
ents_arena = arena_alloc(GIBI(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
arena_reset(arena);
|
arena_reset(arena);
|
||||||
|
|||||||
@ -53,7 +53,7 @@ struct sock_startup_receipt sock_startup(void)
|
|||||||
{
|
{
|
||||||
/* Startup winsock */
|
/* Startup winsock */
|
||||||
WSAStartup(MAKEWORD(2, 2), &G.wsa_data);
|
WSAStartup(MAKEWORD(2, 2), &G.wsa_data);
|
||||||
G.win32_socks_arena = arena_alloc(GIGABYTE(64));
|
G.win32_socks_arena = arena_alloc(GIBI(64));
|
||||||
return (struct sock_startup_receipt) { 0 };
|
return (struct sock_startup_receipt) { 0 };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -39,7 +39,7 @@ struct sound_startup_receipt sound_startup(struct asset_cache_startup_receipt *a
|
|||||||
(UNUSED)asset_cache_sr;
|
(UNUSED)asset_cache_sr;
|
||||||
(UNUSED)resource_sr;
|
(UNUSED)resource_sr;
|
||||||
|
|
||||||
G.params.arena = arena_alloc(GIGABYTE(64));
|
G.params.arena = arena_alloc(GIBI(64));
|
||||||
|
|
||||||
return (struct sound_startup_receipt) { 0 };
|
return (struct sound_startup_receipt) { 0 };
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,7 +24,7 @@ struct space *space_alloc(f32 cell_size, u32 num_bins_sqrt)
|
|||||||
{
|
{
|
||||||
struct space *space;
|
struct space *space;
|
||||||
{
|
{
|
||||||
struct arena *arena = arena_alloc(GIGABYTE(64));
|
struct arena *arena = arena_alloc(GIBI(64));
|
||||||
space = arena_push(arena, struct space);
|
space = arena_push(arena, struct space);
|
||||||
space->entry_arena = arena;
|
space->entry_arena = arena;
|
||||||
}
|
}
|
||||||
@ -32,7 +32,7 @@ struct space *space_alloc(f32 cell_size, u32 num_bins_sqrt)
|
|||||||
space->valid = true;
|
space->valid = true;
|
||||||
space->entries = arena_push_dry(space->entry_arena, struct space_entry);
|
space->entries = arena_push_dry(space->entry_arena, struct space_entry);
|
||||||
|
|
||||||
space->cell_arena = arena_alloc(GIGABYTE(64));
|
space->cell_arena = arena_alloc(GIBI(64));
|
||||||
space->cell_size = cell_size;
|
space->cell_size = cell_size;
|
||||||
space->num_bins = num_bins_sqrt * num_bins_sqrt;
|
space->num_bins = num_bins_sqrt * num_bins_sqrt;
|
||||||
space->num_bins_sqrt = num_bins_sqrt;
|
space->num_bins_sqrt = num_bins_sqrt;
|
||||||
|
|||||||
16
src/sprite.c
16
src/sprite.c
@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
/* The evictor will begin evicting once cache usage is > threshold.
|
/* The evictor will begin evicting once cache usage is > threshold.
|
||||||
* It will entries until the budget has shrunk < target. */
|
* It will entries until the budget has shrunk < target. */
|
||||||
#define CACHE_MEMORY_BUDGET_THRESHOLD (MEGABYTE(256))
|
#define CACHE_MEMORY_BUDGET_THRESHOLD (MEBI(256))
|
||||||
#define CACHE_MEMORY_BUDGET_TARGET (MEGABYTE(128))
|
#define CACHE_MEMORY_BUDGET_TARGET (MEBI(128))
|
||||||
STATIC_ASSERT(CACHE_MEMORY_BUDGET_THRESHOLD >= CACHE_MEMORY_BUDGET_TARGET);
|
STATIC_ASSERT(CACHE_MEMORY_BUDGET_THRESHOLD >= CACHE_MEMORY_BUDGET_TARGET);
|
||||||
|
|
||||||
#define CACHE_BINS_COUNT 1024
|
#define CACHE_BINS_COUNT 1024
|
||||||
@ -29,9 +29,9 @@ STATIC_ASSERT(CACHE_MEMORY_BUDGET_THRESHOLD >= CACHE_MEMORY_BUDGET_TARGET);
|
|||||||
#define EVICTOR_GRACE_PERIOD_CYCLES (NS_FROM_SECONDS(10.000) / EVICTOR_CYCLE_INTERVAL_NS)
|
#define EVICTOR_GRACE_PERIOD_CYCLES (NS_FROM_SECONDS(10.000) / EVICTOR_CYCLE_INTERVAL_NS)
|
||||||
|
|
||||||
/* Texture arena only used to store texture struct at the moment. Actual image data is allocated on GPU. */
|
/* Texture arena only used to store texture struct at the moment. Actual image data is allocated on GPU. */
|
||||||
#define TEXTURE_ARENA_RESERVE MEGABYTE(1)
|
#define TEXTURE_ARENA_RESERVE MEBI(1)
|
||||||
|
|
||||||
#define SHEET_ARENA_RESERVE MEGABYTE(64)
|
#define SHEET_ARENA_RESERVE MEBI(64)
|
||||||
#define SHEET_SPAN_LOOKUP_TABLE_BIN_RATIO 2.0
|
#define SHEET_SPAN_LOOKUP_TABLE_BIN_RATIO 2.0
|
||||||
#define SHEET_SLICE_LOOKUP_TABLE_BIN_RATIO 2.0
|
#define SHEET_SLICE_LOOKUP_TABLE_BIN_RATIO 2.0
|
||||||
|
|
||||||
@ -214,7 +214,7 @@ struct sprite_startup_receipt sprite_startup(struct gp_startup_receipt *gp_sr,
|
|||||||
(UNUSED)gp_sr;
|
(UNUSED)gp_sr;
|
||||||
(UNUSED)resource_sr;
|
(UNUSED)resource_sr;
|
||||||
|
|
||||||
G.perm_arena = arena_alloc(MEGABYTE(1));
|
G.perm_arena = arena_alloc(MEBI(1));
|
||||||
{
|
{
|
||||||
/* Init loading texture */
|
/* Init loading texture */
|
||||||
G.loading_texture = arena_push(G.perm_arena, struct sprite_texture);
|
G.loading_texture = arena_push(G.perm_arena, struct sprite_texture);
|
||||||
@ -242,12 +242,12 @@ struct sprite_startup_receipt sprite_startup(struct gp_startup_receipt *gp_sr,
|
|||||||
}
|
}
|
||||||
arena_set_readonly(G.perm_arena);
|
arena_set_readonly(G.perm_arena);
|
||||||
|
|
||||||
G.cache.arena = arena_alloc(GIGABYTE(64));
|
G.cache.arena = arena_alloc(GIBI(64));
|
||||||
G.cache.bins = arena_push_array(G.cache.arena, struct cache_bin, CACHE_BINS_COUNT);
|
G.cache.bins = arena_push_array(G.cache.arena, struct cache_bin, CACHE_BINS_COUNT);
|
||||||
|
|
||||||
G.load_cmds_arena = arena_alloc(GIGABYTE(64));
|
G.load_cmds_arena = arena_alloc(GIBI(64));
|
||||||
|
|
||||||
G.scopes_arena = arena_alloc(GIGABYTE(64));
|
G.scopes_arena = arena_alloc(GIBI(64));
|
||||||
|
|
||||||
G.evictor_scheduler_thread = sys_thread_alloc(sprite_evictor_scheduler_thread_entry_point, NULL, LIT("Sprite evictor scheduler"), PROF_THREAD_GROUP_EVICTORS);
|
G.evictor_scheduler_thread = sys_thread_alloc(sprite_evictor_scheduler_thread_entry_point, NULL, LIT("Sprite evictor scheduler"), PROF_THREAD_GROUP_EVICTORS);
|
||||||
|
|
||||||
|
|||||||
@ -31,8 +31,8 @@
|
|||||||
#define SYS_WINDOW_EVENT_LISTENERS_MAX 512
|
#define SYS_WINDOW_EVENT_LISTENERS_MAX 512
|
||||||
#define WINDOW_CLASS_NAME L"power_play_window_class"
|
#define WINDOW_CLASS_NAME L"power_play_window_class"
|
||||||
|
|
||||||
#define THREAD_STACK_SIZE MEGABYTE(4)
|
#define THREAD_STACK_SIZE KIBI(64)
|
||||||
#define FIBER_STACK_SIZE MEGABYTE(4)
|
#define FIBER_STACK_SIZE MEBI(4)
|
||||||
|
|
||||||
struct win32_mutex {
|
struct win32_mutex {
|
||||||
struct atomic_i32 v; /* Bits 0-30 = shared lock count, bit 30 = is exclusive lock pending, bit 31 = is exclusive locked */
|
struct atomic_i32 v; /* Bits 0-30 = shared lock count, bit 30 = is exclusive lock pending, bit 31 = is exclusive locked */
|
||||||
@ -943,7 +943,7 @@ INTERNAL SYS_THREAD_DEF(test_entry, _)
|
|||||||
/* Start workers */
|
/* Start workers */
|
||||||
G.num_worker_threads = 6;
|
G.num_worker_threads = 6;
|
||||||
//G.num_worker_threads = 2;
|
//G.num_worker_threads = 2;
|
||||||
G.worker_threads_arena = arena_alloc(GIGABYTE(64));
|
G.worker_threads_arena = arena_alloc(GIBI(64));
|
||||||
G.worker_threads = arena_push_array(G.worker_threads_arena, struct sys_thread *, G.num_worker_threads);
|
G.worker_threads = arena_push_array(G.worker_threads_arena, struct sys_thread *, G.num_worker_threads);
|
||||||
G.worker_contexts = arena_push_array(G.worker_threads_arena, struct worker_ctx, G.num_worker_threads);
|
G.worker_contexts = arena_push_array(G.worker_threads_arena, struct worker_ctx, G.num_worker_threads);
|
||||||
for (i32 i = 0; i < G.num_worker_threads; ++i) {
|
for (i32 i = 0; i < G.num_worker_threads; ++i) {
|
||||||
@ -987,7 +987,7 @@ struct sys_scratch_ctx *sys_scratch_ctx_from_fiber_id(i32 id)
|
|||||||
if (!scratch_ctx->arenas[0]) {
|
if (!scratch_ctx->arenas[0]) {
|
||||||
__profn("Initialize scratch context");
|
__profn("Initialize scratch context");
|
||||||
for (u32 i = 0; i < countof(scratch_ctx->arenas); ++i) {
|
for (u32 i = 0; i < countof(scratch_ctx->arenas); ++i) {
|
||||||
scratch_ctx->arenas[i] = arena_alloc(GIGABYTE(64));
|
scratch_ctx->arenas[i] = arena_alloc(GIBI(64));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return scratch_ctx;
|
return scratch_ctx;
|
||||||
@ -1552,7 +1552,7 @@ struct win32_watch {
|
|||||||
HANDLE dir_handle;
|
HANDLE dir_handle;
|
||||||
HANDLE wake_handle;
|
HANDLE wake_handle;
|
||||||
struct win32_watch *next_free;
|
struct win32_watch *next_free;
|
||||||
u8 results_buff[KILOBYTE(64)];
|
u8 results_buff[KIBI(64)];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct sys_watch *sys_watch_alloc(struct string dir_path)
|
struct sys_watch *sys_watch_alloc(struct string dir_path)
|
||||||
@ -2918,20 +2918,20 @@ int CALLBACK wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev_instance,
|
|||||||
__profthread("Main thread", PROF_THREAD_GROUP_MAIN);
|
__profthread("Main thread", PROF_THREAD_GROUP_MAIN);
|
||||||
|
|
||||||
/* Init yielders */
|
/* Init yielders */
|
||||||
G.yielders_arena = arena_alloc(GIGABYTE(64));
|
G.yielders_arena = arena_alloc(GIBI(64));
|
||||||
|
|
||||||
/* Init wait lists */
|
/* Init wait lists */
|
||||||
G.wait_lists_arena = arena_alloc(GIGABYTE(64));
|
G.wait_lists_arena = arena_alloc(GIBI(64));
|
||||||
|
|
||||||
/* Init fibers */
|
/* Init fibers */
|
||||||
G.num_fibers = 1; /* Fiber at index 0 always nil */
|
G.num_fibers = 1; /* Fiber at index 0 always nil */
|
||||||
G.fiber_names_arena = arena_alloc(GIGABYTE(64));
|
G.fiber_names_arena = arena_alloc(GIBI(64));
|
||||||
|
|
||||||
/* Init job queues */
|
/* Init job queues */
|
||||||
for (u32 i = 0; i < countof(G.job_queues); ++i) {
|
for (u32 i = 0; i < countof(G.job_queues); ++i) {
|
||||||
struct job_queue *queue = &G.job_queues[i];
|
struct job_queue *queue = &G.job_queues[i];
|
||||||
queue->kind = (enum job_queue_kind)i;
|
queue->kind = (enum job_queue_kind)i;
|
||||||
queue->arena = arena_alloc(GIGABYTE(64));
|
queue->arena = arena_alloc(GIBI(64));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert main thread to fiber */
|
/* Convert main thread to fiber */
|
||||||
@ -2973,13 +2973,13 @@ int CALLBACK wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev_instance,
|
|||||||
timeBeginPeriod(G.scheduler_period_ms);
|
timeBeginPeriod(G.scheduler_period_ms);
|
||||||
|
|
||||||
/* Set up threads */
|
/* Set up threads */
|
||||||
G.threads_arena = arena_alloc(GIGABYTE(64));
|
G.threads_arena = arena_alloc(GIBI(64));
|
||||||
|
|
||||||
/* Set up watches */
|
/* Set up watches */
|
||||||
G.watches_arena = arena_alloc(GIGABYTE(64));
|
G.watches_arena = arena_alloc(GIBI(64));
|
||||||
|
|
||||||
/* Set up windows */
|
/* Set up windows */
|
||||||
G.windows_arena = arena_alloc(GIGABYTE(64));
|
G.windows_arena = arena_alloc(GIBI(64));
|
||||||
|
|
||||||
/* Initialize vk table */
|
/* Initialize vk table */
|
||||||
win32_init_vk_btn_table();
|
win32_init_vk_btn_table();
|
||||||
|
|||||||
10
src/user.c
10
src/user.c
@ -218,7 +218,7 @@ struct user_startup_receipt user_startup(struct gp_startup_receipt *gp_sr,
|
|||||||
(UNUSED)host_sr;
|
(UNUSED)host_sr;
|
||||||
(UNUSED)sim_sr;
|
(UNUSED)sim_sr;
|
||||||
|
|
||||||
G.arena = arena_alloc(GIGABYTE(64));
|
G.arena = arena_alloc(GIBI(64));
|
||||||
G.real_time_ns = sys_time_ns();
|
G.real_time_ns = sys_time_ns();
|
||||||
|
|
||||||
/* TODO: Remove this */
|
/* TODO: Remove this */
|
||||||
@ -228,7 +228,7 @@ struct user_startup_receipt user_startup(struct gp_startup_receipt *gp_sr,
|
|||||||
G.average_local_to_user_snapshot_publish_dt_ns = NS_FROM_SECONDS(1) / SIM_TICKS_PER_SECOND;
|
G.average_local_to_user_snapshot_publish_dt_ns = NS_FROM_SECONDS(1) / SIM_TICKS_PER_SECOND;
|
||||||
|
|
||||||
/* Sys events */
|
/* Sys events */
|
||||||
G.sys_events_arena = arena_alloc(GIGABYTE(64));
|
G.sys_events_arena = arena_alloc(GIBI(64));
|
||||||
|
|
||||||
/* User blend clients */
|
/* User blend clients */
|
||||||
G.user_client_store = sim_client_store_alloc();
|
G.user_client_store = sim_client_store_alloc();
|
||||||
@ -245,7 +245,7 @@ struct user_startup_receipt user_startup(struct gp_startup_receipt *gp_sr,
|
|||||||
G.world_gp_flow = gp_flow_alloc();
|
G.world_gp_flow = gp_flow_alloc();
|
||||||
G.ui_gp_flow = gp_flow_alloc();
|
G.ui_gp_flow = gp_flow_alloc();
|
||||||
|
|
||||||
G.console_logs_arena = arena_alloc(GIGABYTE(64));
|
G.console_logs_arena = arena_alloc(GIBI(64));
|
||||||
//log_register_callback(debug_console_log_callback, LOG_LEVEL_SUCCESS);
|
//log_register_callback(debug_console_log_callback, LOG_LEVEL_SUCCESS);
|
||||||
log_register_callback(debug_console_log_callback, LOG_LEVEL_DEBUG);
|
log_register_callback(debug_console_log_callback, LOG_LEVEL_DEBUG);
|
||||||
|
|
||||||
@ -2206,8 +2206,8 @@ INTERNAL SYS_JOB_DEF(local_sim_job, _)
|
|||||||
is_master = true;
|
is_master = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct bitbuff msg_writer_bb = bitbuff_alloc(GIGABYTE(64));
|
struct bitbuff msg_writer_bb = bitbuff_alloc(GIBI(64));
|
||||||
struct bitbuff snapshot_writer_bb = bitbuff_alloc(GIGABYTE(64));
|
struct bitbuff snapshot_writer_bb = bitbuff_alloc(GIBI(64));
|
||||||
struct sim_accel accel = sim_accel_alloc();
|
struct sim_accel accel = sim_accel_alloc();
|
||||||
|
|
||||||
struct sim_client_store *store = sim_client_store_alloc();
|
struct sim_client_store *store = sim_client_store_alloc();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user