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