diff --git a/src/main.cpp b/src/main.cpp index 47d92cb..76349d0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -135,7 +135,7 @@ struct AppState { int main() { AppState app = {}; - WpAllocator arena = wpMemArenaAllocatorInitZero(MiB(64)); + WpAllocator arena = wpMemArenaAllocatorInitZero(MiB(128)); // {{{ Initialisation check(SDL_Init(SDL_INIT_VIDEO), EXIT_CODE_SDL_INIT_FAILED); @@ -148,14 +148,12 @@ int main() { // }}} // {{{ Instance creation - WpAllocator scratch = wpMemArenaAllocatorInitZero(MiB(64)); - PrRhiInstanceDesc inst_desc = {}; app.inst = prRhiCreateInstance(inst_desc, &arena); // }}} // {{{ Physical device selection - PrRhiPhysicalDeviceArray pdevs = prRhiGetPhysicalDevices(app.inst, &scratch); + PrRhiPhysicalDeviceArray pdevs = prRhiGetPhysicalDevices(app.inst, &arena); check(wpArrayCount(pdevs) > 0, EXIT_CODE_NO_PHYSICAL_DEVICES); i32 selected = -1; @@ -197,9 +195,6 @@ int main() { u32 qfi = prRhiGetQueueFamilyIndex(app.device); // }}} - wpMemArenaAllocatorDestroy(&scratch); - scratch = wpMemArenaAllocatorInitZero(MiB(64)); - // {{{ Swapchain creation PrRhiSwapchainDesc swap_desc = {}; swap_desc.surface = app.surface; @@ -221,8 +216,8 @@ int main() { check(tinyobj::LoadObj(&attrib, &shapes, &materials, nullptr, nullptr, "assets/suzanne.obj"), EXIT_CODE_MESH_LOAD_FAILED); - VertexArray vertices = wpArrayAllocCapacity(Vertex, &scratch, 128, WP_ARRAY_INIT_NONE); - U16Array indices = wpArrayAllocCapacity(u16, &scratch, 128, WP_ARRAY_INIT_NONE); + VertexArray vertices = wpArrayAllocCapacity(Vertex, &arena, 128, WP_ARRAY_INIT_NONE); + U16Array indices = wpArrayAllocCapacity(u16, &arena, 128, WP_ARRAY_INIT_NONE); for (auto &idx : shapes[0].mesh.indices) { Vertex v = {}; @@ -242,8 +237,8 @@ int main() { }; u16 index = (u16)wpArrayCount(indices); - vertices = wpArrayAppendAlloc(Vertex, &scratch, vertices, &v, WP_ARRAY_INIT_NONE); - indices = wpArrayAppendAlloc(u16, &scratch, indices, &index, WP_ARRAY_INIT_NONE); + vertices = wpArrayAppendAlloc(Vertex, &arena, vertices, &v, WP_ARRAY_INIT_NONE); + indices = wpArrayAppendAlloc(u16, &arena, indices, &index, WP_ARRAY_INIT_NONE); } app.vertex_buf_size = sizeof(Vertex) * wpArrayCount(vertices); @@ -316,13 +311,11 @@ int main() { AppState::max_frames_in_flight, &arena); // }}} - wpMemArenaAllocatorTempBegin(&scratch); - // {{{ Texture loading app.textures = wpArrayAllocCapacity(TextureResources, &arena, AppState::texture_count, WP_ARRAY_INIT_FILLED); - PrRhiCommandBufferArray upload_cbs = prRhiAllocateCommandBuffers(app.device, app.cmd_pool, 1, &scratch); + PrRhiCommandBufferArray upload_cbs = prRhiAllocateCommandBuffers(app.device, app.cmd_pool, 1, &arena); PrRhiCommandBuffer *upload_cb = upload_cbs[0]; for (u32 i = 0; i < AppState::texture_count; ++i) { @@ -344,7 +337,7 @@ int main() { } prRhiFreeCommandBuffers(app.device, app.cmd_pool, 1, upload_cbs); - wpArrayDealloc(PrRhiCommandBuffer *, &scratch, &upload_cbs); + wpArrayDealloc(PrRhiCommandBuffer *, &arena, &upload_cbs); // }}} // {{{ Descriptor set layout, pool, set @@ -398,8 +391,6 @@ int main() { prRhiUpdateDescriptorSet(app.device, writes); // }}} - wpMemArenaAllocatorTempEnd(&scratch); - // {{{ Shader compilation (Slang) slang::createGlobalSession(app.slang_session.writeRef()); diff --git a/src/prism/rhi/vulkan/pr_rhi_vk.c b/src/prism/rhi/vulkan/pr_rhi_vk.c index 8d6bcd1..8d78b65 100644 --- a/src/prism/rhi/vulkan/pr_rhi_vk.c +++ b/src/prism/rhi/vulkan/pr_rhi_vk.c @@ -1210,7 +1210,7 @@ PrRhiTexture *prRhiCreateTextureFromKtxVk(PrRhiDevice *device, const char *path, vkEndCommandBuffer(vk_cb); // Submit and wait - PrRhiFenceDesc fence_desc = { .signaled = VK_TRUE }; + PrRhiFenceDesc fence_desc = { .signaled = false }; PrRhiFence *fence = prRhiCreateFenceVk(device, fence_desc, allocator); prRhiQueueSubmitVk(device, cb, NULL, NULL, fence); prRhiWaitForFencesVk(device, &(PrRhiFence *){ fence }, 1, VK_TRUE, UINT64_MAX);