Fixes
This commit is contained in:
+8
-17
@@ -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());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user