From 40fbb328150d853d0d7a83ce447c3f008de38822 Mon Sep 17 00:00:00 2001 From: gramanas Date: Sun, 16 Jun 2024 22:20:07 +0300 Subject: Start integrating pds, fix warnings and add new test build object --- src/render.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) (limited to 'src/render.c') diff --git a/src/render.c b/src/render.c index 9b7541f..f625dba 100644 --- a/src/render.c +++ b/src/render.c @@ -569,7 +569,7 @@ vulkan_create_graphics_pipeline(VkPolygonMode polygon_mode) .sType = VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO_KHR, .colorAttachmentCount = 1, .pColorAttachmentFormats = &s.vk.swapchain.image_format, - .depthAttachmentFormat = findDepthFormat(s.vk), + .depthAttachmentFormat = vks_find_depth_format(s.vk), }; VkGraphicsPipelineCreateInfo pipelineInfo = {0}; @@ -1147,7 +1147,7 @@ vulkan_create_texture_image() vks_create_image(s.vk, texWidth, texHeight, s.vk_mip_levels, VK_FORMAT_R8G8B8A8_SRGB, VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT, - VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, VK_SAMPLE_COUNT_1_BIT, &s.texture_image); + VK_SAMPLE_COUNT_1_BIT, &s.texture_image); vks_transition_image_layout_info transition_info = { 0 }; @@ -1416,7 +1416,7 @@ void vulkan_create_compute_stuff() VkDeviceSize bufferSize = sizeof(Particle) * PARTICLE_COUNT; vks_buffer stagingBuffer = {0}; - vks_create_buffer(s.vk, bufferSize, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, &stagingBuffer); + vks_create_buffer(s.vk, bufferSize, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, &stagingBuffer); void* data; vkMapMemory(s.vk.device, stagingBuffer.memory, 0, bufferSize, 0, &data); @@ -1424,7 +1424,7 @@ void vulkan_create_compute_stuff() vkUnmapMemory(s.vk.device, stagingBuffer.memory); for (size_t i = 0; i < MAX_FRAMES_IN_FLIGHT; i++) { - vks_create_buffer(s.vk, bufferSize, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, &s.frames[i].shader_storage_buffer); + vks_create_buffer(s.vk, bufferSize, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT, &s.frames[i].shader_storage_buffer); // Copy data from the staging buffer (host) to the shader storage buffer (GPU) vks_copy_buffer(s.vk, stagingBuffer.handle, s.frames[i].shader_storage_buffer.handle, bufferSize); } @@ -1521,8 +1521,6 @@ close_vulkan() vkDestroyCommandPool(s.vk.device, s.vk.command_pool, NULL); - vks_cleanup_swapchain(s.vk); - imgui_destroy(s.vk); vkDestroySampler(s.vk.device, s.vk_texture_sampler, NULL); @@ -1542,15 +1540,8 @@ close_vulkan() vkDestroyPipeline(s.vk.device, s.graphics_pipeline.handle, NULL); vkDestroyPipelineLayout(s.vk.device, s.graphics_pipeline.layout, NULL); - vmaDestroyAllocator(s.vk.allocator); + vks_destroy_vulkan_context(&s.vk); - vkDestroyDevice(s.vk.device, NULL); - vkDestroySurfaceKHR(s.vk.instance, s.vk.surface, NULL); - /* if (enable_validation_layers) { */ - /* DestroyDebugUtilsMessengerEXT(s.vk.instance, s.vk_debug_messenger, NULL); */ - /* } */ - vkDestroyInstance(s.vk.instance, NULL); - if (s.prev_vert_result) { shaderc_result_release(s.prev_vert_result); } @@ -1688,12 +1679,16 @@ draw_frame() #define PDS_IMPLEMENTATION #include "pds.h" +#include "test.h" + int main(int argc, char* argv[]) { (void) argc; (void)argv; + test_func(); + int* lst = pstack_create(int); pstack_push(lst, 1); pstack_push(lst, 2); -- cgit v1.2.3