From 36e2314f357e5654ade48e9a7d34a0d9b97f629f Mon Sep 17 00:00:00 2001 From: Kevin Trogant Date: Wed, 28 Feb 2024 16:34:43 +0100 Subject: [PATCH] Fix for allocation problems - Double allocation because of missing break --- src/asset_compiler/asset_compiler.c | 3 ++- src/asset_compiler/pipeline_processor.c | 1 + src/runtime/buffer_manager.c | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/asset_compiler/asset_compiler.c b/src/asset_compiler/asset_compiler.c index 9d2d54f..0c11bfc 100644 --- a/src/asset_compiler/asset_compiler.c +++ b/src/asset_compiler/asset_compiler.c @@ -49,7 +49,7 @@ typedef struct { RT_CVAR_S(rt_AssetDirectory, "Name of the asset directory. Default: assets", "assets"); RT_CVAR_I(rt_AssetDBSize, "Size of the asset database. Default: 1024", 1024); -RT_CVAR_I(rt_AssetProcessingThreads, "Number of asset processing threads. Default: 4", 1); +RT_CVAR_I(rt_AssetProcessingThreads, "Number of asset processing threads. Default: 4", 4); RT_CVAR_I(rt_AssetProcessorArenaSize, "Size of the per-thread asset processor arena. Default: 128 MiB", (int)RT_MB(128)); @@ -421,6 +421,7 @@ rt_loaded_asset LoadAsset(rt_file_id file) { rtLog("AC", "Failed to allocate buffer for loading %s.", path); return (rt_loaded_asset){.buffer = NULL, .size = 0}; } + rtLog("AC", "Allocated %p for %s", buffer, path); rt_aio_state load_state = rtSubmitSingleLoadSync((rt_file_load){ .file = file, diff --git a/src/asset_compiler/pipeline_processor.c b/src/asset_compiler/pipeline_processor.c index 7d61d90..d1f134c 100644 --- a/src/asset_compiler/pipeline_processor.c +++ b/src/asset_compiler/pipeline_processor.c @@ -504,6 +504,7 @@ RT_ASSET_PROCESSOR_FN(PipelineProcessor) { *new_resource_count = 1 + pipeline.shader_count; } out: + rtLog("AC", "Released %p", asset.buffer); rtReleaseBuffer(asset.buffer, asset.size); return result; } diff --git a/src/runtime/buffer_manager.c b/src/runtime/buffer_manager.c index ccce030..1973841 100644 --- a/src/runtime/buffer_manager.c +++ b/src/runtime/buffer_manager.c @@ -103,6 +103,7 @@ RT_DLLEXPORT void *rtAllocBuffer(size_t size) { _bitmap[dword] |= mask; result = _memory + i * BLOCK_SIZE; first_block = i; + break; } else if (lzcnt32(_bitmap[dword]) >= alloc_blocks) { size_t first = (_bitmap[dword] != 0) ? 32 - lzcnt32(_bitmap[dword]) : 0;