diff --git a/sccube/CMakeLists.txt b/sccube/CMakeLists.txt index 34453698..f38ddddb 100644 --- a/sccube/CMakeLists.txt +++ b/sccube/CMakeLists.txt @@ -20,7 +20,6 @@ endif() include(CMakeDependentOption) option(COMPILE_CUBE_SHADERS "Compile GLSL shaders to SPIR-V" OFF) -option(BUILD_IMAGE_DUMP_SUPPORT "Build Image dump support" ON) option(BUILD_WSI_DISPLAY_SUPPORT "Build DISPLAY WSI support" ON) cmake_dependent_option(BUILD_WSI_XCB_SUPPORT "Build XCB WSI support" ON "VKSC_SYSTEM_LINUX_LIKE" OFF) cmake_dependent_option(BUILD_WSI_XLIB_SUPPORT "Build Xlib WSI support" ON "VKSC_SYSTEM_LINUX_LIKE" OFF) @@ -29,9 +28,6 @@ cmake_dependent_option(BUILD_WSI_DIRECTFB_SUPPORT "Build DirectFB WSI support" O cmake_dependent_option(BUILD_WSI_WIN32_SUPPORT "Build Win32 WSI support" ON "WIN32" OFF) # Collect enabled back-ends -if(BUILD_IMAGE_DUMP_SUPPORT) - list(APPEND ENABLED_CUBE_PLATFORMS CUBE_USE_IMAGE_DUMP) -endif() if(BUILD_WSI_DISPLAY_SUPPORT) list(APPEND ENABLED_CUBE_PLATFORMS VK_USE_PLATFORM_DISPLAY_KHR) endif() @@ -81,10 +77,6 @@ if(COMPILE_CUBE_SHADERS) ) endif() -if(BUILD_IMAGE_DUMP_SUPPORT) - find_path(STB_INCLUDE_DIR stb_image_write.h REQUIRED - PATH_SUFFIXES include) -endif() if(BUILD_WSI_XCB_SUPPORT) pkg_check_modules(XCB REQUIRED IMPORTED_TARGET xcb) endif() @@ -228,7 +220,6 @@ target_compile_definitions(vksccube PRIVATE target_include_directories(vksccube PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../cube # xyz_loader.h, linmath.h, etc. ${CMAKE_CURRENT_BINARY_DIR} # pipeline_cache.h pipeline_offline_info.h - $<$:${STB_INCLUDE_DIR}> $<$:${CMAKE_CURRENT_BINARY_DIR}> ) target_link_libraries(vksccube PRIVATE diff --git a/sccube/cube.c b/sccube/cube.c index ab78eadc..83339e66 100644 --- a/sccube/cube.c +++ b/sccube/cube.c @@ -141,6 +141,9 @@ void DbgMsg(char *fmt, ...) { } #endif +PFN_vkSetDebugUtilsObjectNameEXT fpnSetDebugUtilsObjectNameEXT; +PFN_vkCmdBeginDebugUtilsLabelEXT pfnCmdBeginDebugUtilsLabelEXT; +PFN_vkCmdEndDebugUtilsLabelEXT pfnCmdEndDebugUtilsLabelEXT; PFN_vkCreateDebugUtilsMessengerEXT pfnCreateDebugUtilsMessengerEXT; PFN_vkCreateWin32SurfaceKHR pfnCreateWin32SurfaceKHR; PFN_vkGetPhysicalDeviceSurfaceSupportKHR pfnGetPhysicalDeviceSurfaceSupportKHR; @@ -149,8 +152,15 @@ PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR pfnGetPhysicalDeviceSurfaceCapabil PFN_vkGetPhysicalDeviceSurfacePresentModesKHR pfnGetPhysicalDeviceSurfacePresentModesKHR; PFN_vkCreateSwapchainKHR pfnCreateSwapchainKHR; PFN_vkGetSwapchainImagesKHR pfnGetSwapchainImagesKHR; +PFN_vkGetPastPresentationTimingGOOGLE pfnGetPastPresentationTimingGOOGLE; +PFN_vkGetRefreshCycleDurationGOOGLE pfnGetRefreshCycleDurationGOOGLE; void instExtInitialize(VkInstance instance) { + fpnSetDebugUtilsObjectNameEXT = + (PFN_vkSetDebugUtilsObjectNameEXT)vkGetInstanceProcAddr(instance, "vkSetDebugUtilsObjectNameEXT"); + pfnCmdBeginDebugUtilsLabelEXT = + (PFN_vkCmdBeginDebugUtilsLabelEXT)vkGetInstanceProcAddr(instance, "vkCmdBeginDebugUtilsLabelEXT"); + pfnCmdEndDebugUtilsLabelEXT = (PFN_vkCmdEndDebugUtilsLabelEXT)vkGetInstanceProcAddr(instance, "vkCmdEndDebugUtilsLabelEXT"); pfnCreateDebugUtilsMessengerEXT = (PFN_vkCreateDebugUtilsMessengerEXT)vkGetInstanceProcAddr(instance, "vkCreateDebugUtilsMessengerEXT"); pfnCreateWin32SurfaceKHR = (PFN_vkCreateWin32SurfaceKHR)vkGetInstanceProcAddr(instance, "vkCreateWin32SurfaceKHR"); pfnGetPhysicalDeviceSurfaceSupportKHR = (PFN_vkGetPhysicalDeviceSurfaceSupportKHR)vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceSurfaceSupportKHR"); @@ -159,6 +169,10 @@ void instExtInitialize(VkInstance instance) { pfnGetPhysicalDeviceSurfacePresentModesKHR = (PFN_vkGetPhysicalDeviceSurfacePresentModesKHR)vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceSurfacePresentModesKHR"); pfnCreateSwapchainKHR = (PFN_vkCreateSwapchainKHR)vkGetInstanceProcAddr(instance, "vkCreateSwapchainKHR"); pfnGetSwapchainImagesKHR = (PFN_vkGetSwapchainImagesKHR)vkGetInstanceProcAddr(instance, "vkGetSwapchainImagesKHR"); + pfnGetPastPresentationTimingGOOGLE = + (PFN_vkGetPastPresentationTimingGOOGLE)vkGetInstanceProcAddr(instance, "vkGetPastPresentationTimingGOOGLE"); + pfnGetRefreshCycleDurationGOOGLE = + (PFN_vkGetRefreshCycleDurationGOOGLE)vkGetInstanceProcAddr(instance, "vkGetRefreshCycleDurationGOOGLE"); } /* @@ -339,7 +353,6 @@ typedef enum WSI_PLATFORM { WSI_PLATFORM_WAYLAND, WSI_PLATFORM_DIRECTFB, WSI_PLATFORM_DISPLAY, - WSI_PLATFORM_IMAGE, WSI_PLATFORM_INVALID, // Sentinel just to indicate invalid user input } WSI_PLATFORM; @@ -371,9 +384,6 @@ WSI_PLATFORM wsi_from_string(const char *str) { #endif #if defined(VK_USE_PLATFORM_DISPLAY_KHR) if (strcmp(str, "display") == 0) return WSI_PLATFORM_DISPLAY; -#endif -#if defined(CUBE_USE_IMAGE_DUMP) - if (strcmp(str, "image") == 0) return WSI_PLATFORM_IMAGE; #endif return WSI_PLATFORM_INVALID; }; @@ -417,10 +427,6 @@ const char *wsi_to_string(WSI_PLATFORM wsi_platform) { #if defined(VK_USE_PLATFORM_DISPLAY_KHR) case (WSI_PLATFORM_DISPLAY): return "display"; -#endif -#if defined(CUBE_USE_IMAGE_DUMP) - case (WSI_PLATFORM_IMAGE): - return "image"; #endif default: return "unknown"; @@ -555,11 +561,7 @@ struct demo { VkMemoryAllocateInfo mem_alloc; VkDeviceMemory mem; VkImageView view; - } depth, surface_image; - - VkBuffer staging_buffer; - VkMemoryAllocateInfo staging_mem_alloc; - VkDeviceMemory staging_mem; + } depth; struct texture_object textures[DEMO_TEXTURE_COUNT]; struct texture_object staging_texture; @@ -760,7 +762,7 @@ static void demo_name_object(struct demo *demo, VkObjectType object_type, uint64 if (!demo->validate) { return; } - //VkResult U_ASSERT_ONLY err; + VkResult U_ASSERT_ONLY err; char name[1024]; va_list argptr; va_start(argptr, format); @@ -775,8 +777,8 @@ static void demo_name_object(struct demo *demo, VkObjectType object_type, uint64 .objectHandle = vulkan_handle, .pObjectName = name, }; - //err = vkSetDebugUtilsObjectNameEXT(demo->device, &obj_name); - //assert(!err); + err = fpnSetDebugUtilsObjectNameEXT(demo->device, &obj_name); + assert(!err); } DECORATE_PRINTF(4, 5) @@ -800,14 +802,14 @@ static void demo_push_cb_label(struct demo *demo, VkCommandBuffer cb, const floa memcpy(label.color, color, sizeof(label.color)); } - //vkCmdBeginDebugUtilsLabelEXT(cb, &label); + pfnCmdBeginDebugUtilsLabelEXT(cb, &label); } static void demo_pop_cb_label(struct demo *demo, VkCommandBuffer cb) { if (!demo->validate) { return; } - //vkCmdEndDebugUtilsLabelEXT(cb); + pfnCmdEndDebugUtilsLabelEXT(cb); } static bool memory_type_from_properties(struct demo *demo, uint32_t typeBits, VkFlags requirements_mask, uint32_t *typeIndex) { @@ -1015,32 +1017,6 @@ static void demo_draw_build_cmd(struct demo *demo, VkCommandBuffer cmd_buf) { vkCmdPipelineBarrier(cmd_buf, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, 0, 0, NULL, 0, NULL, 1, &image_ownership_barrier); } - - // TODO: remove - VkImageMemoryBarrier image_wait_barrier = {.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, - .pNext = NULL, - .srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, - .dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT, - .oldLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, - .newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, - .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, - .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, - .image = demo->surface_image.image, - .subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}}; - - vkCmdPipelineBarrier(cmd_buf, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, NULL, 0, - NULL, 1, &image_wait_barrier); - - VkBufferImageCopy copy_region = { - .bufferOffset = 0, - .bufferRowLength = demo->width, - .bufferImageHeight = demo->height, - .imageSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1}, - .imageOffset = {0, 0, 0}, - .imageExtent = {demo->width, demo->height, 1}, - }; - vkCmdCopyImageToBuffer(cmd_buf, demo->surface_image.image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, demo->staging_buffer, 1, ©_region); - demo_pop_cb_label(demo, cmd_buf); err = vkEndCommandBuffer(cmd_buf); assert(!err); @@ -1093,17 +1069,17 @@ void demo_update_data_buffer(struct demo *demo) { void DemoUpdateTargetIPD(struct demo *demo) { // Look at what happened to previous presents, and make appropriate // adjustments in timing: - //VkResult U_ASSERT_ONLY err; + VkResult U_ASSERT_ONLY err; VkPastPresentationTimingGOOGLE *past = NULL; uint32_t count = 0; - //err = vkGetPastPresentationTimingGOOGLE(demo->device, demo->swapchain, &count, NULL); - //assert(!err); + err = pfnGetPastPresentationTimingGOOGLE(demo->device, demo->swapchain, &count, NULL); + assert(!err); if (count) { past = (VkPastPresentationTimingGOOGLE *)malloc(sizeof(VkPastPresentationTimingGOOGLE) * count); - //assert(past); - //err = vkGetPastPresentationTimingGOOGLE(demo->device, demo->swapchain, &count, past); - //assert(!err); + assert(past); + err = pfnGetPastPresentationTimingGOOGLE(demo->device, demo->swapchain, &count, past); + assert(!err); bool early = false; bool late = false; @@ -1206,49 +1182,6 @@ void DemoUpdateTargetIPD(struct demo *demo) { } } -static void demo_prepare_display_buffer(struct demo *demo) { - VkResult U_ASSERT_ONLY err; - bool U_ASSERT_ONLY pass; - - const VkBufferCreateInfo buffer_create_info = {.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, - .pNext = NULL, - .flags = 0, - .size = demo->width * demo->height * 4, - .usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT, - .sharingMode = VK_SHARING_MODE_EXCLUSIVE, - .queueFamilyIndexCount = 0, - .pQueueFamilyIndices = NULL}; - - err = vkCreateBuffer(demo->device, &buffer_create_info, NULL, &demo->staging_buffer); - assert(!err); - demo_name_object(demo, VK_OBJECT_TYPE_BUFFER, (uint64_t)demo->staging_buffer, "DispBuffer"); - - VkMemoryRequirements mem_reqs; - vkGetBufferMemoryRequirements(demo->device, demo->staging_buffer, &mem_reqs); - - demo->staging_mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; - demo->staging_mem_alloc.pNext = NULL; - demo->staging_mem_alloc.allocationSize = mem_reqs.size; - demo->staging_mem_alloc.memoryTypeIndex = 0; - - VkFlags requirements = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; - pass = memory_type_from_properties(demo, mem_reqs.memoryTypeBits, requirements, &demo->staging_mem_alloc.memoryTypeIndex); - assert(pass); - - err = vkAllocateMemory(demo->device, &demo->staging_mem_alloc, NULL, &demo->staging_mem); - assert(!err); - demo_name_object(demo, VK_OBJECT_TYPE_DEVICE_MEMORY, (uint64_t)demo->staging_mem, "TexBufMemory"); - - /* bind memory */ - err = vkBindBufferMemory(demo->device, demo->staging_buffer, demo->staging_mem, 0); - assert(!err); -} - -#define STB_IMAGE_WRITE_IMPLEMENTATION -#include "stb_image_write.h" - -static void demo_cleanup(struct demo *demo); - static void demo_draw(struct demo *demo) { VkResult U_ASSERT_ONLY err; @@ -1256,7 +1189,6 @@ static void demo_draw(struct demo *demo) { vkWaitForFences(demo->device, 1, &demo->fences[demo->frame_index], VK_TRUE, UINT64_MAX); vkResetFences(demo->device, 1, &demo->fences[demo->frame_index]); - if (demo->wsi_platform != WSI_PLATFORM_IMAGE) { do { // Get the index of the next available swapchain image: err = vkAcquireNextImageKHR(demo->device, demo->swapchain, UINT64_MAX, demo->image_acquired_semaphores[demo->frame_index], @@ -1278,7 +1210,6 @@ static void demo_draw(struct demo *demo) { assert(!err); } } while (err != VK_SUCCESS); - } demo_update_data_buffer(demo); @@ -1304,7 +1235,7 @@ static void demo_draw(struct demo *demo) { submit_info.pNext = NULL; pipe_stage_flags = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; submit_info.pWaitDstStageMask = &pipe_stage_flags; - submit_info.waitSemaphoreCount = 0; + submit_info.waitSemaphoreCount = 1; submit_info.pWaitSemaphores = &demo->image_acquired_semaphores[demo->frame_index]; submit_info.commandBufferCount = 1; submit_info.pCommandBuffers = &demo->swapchain_image_resources[demo->current_buffer].cmd; @@ -1313,21 +1244,6 @@ static void demo_draw(struct demo *demo) { err = vkQueueSubmit(demo->graphics_queue, 1, &submit_info, demo->fences[demo->frame_index]); assert(!err); - if (demo->wsi_platform == WSI_PLATFORM_IMAGE) { - vkQueueWaitIdle(demo->graphics_queue); - //demo_dump_display_image(demo); - void *data; - err = vkMapMemory(demo->device, demo->staging_mem, 0, demo->staging_mem_alloc.allocationSize, 0, &data); - assert(!err); - - int stb_err = stbi_write_png("cube.png", demo->width, demo->height, 4, data, demo->width * 4); - assert(stb_err); - - vkUnmapMemory(demo->device, demo->staging_mem); - demo_cleanup(demo); - exit(0); - } - if (demo->separate_present_queue) { // If we are using separate queues, change image ownership to the // present queue before presenting, waiting for the draw complete @@ -1617,7 +1533,7 @@ static void demo_prepare_buffers(struct demo *demo) { // Note: destroying the swapchain also cleans up all its associated // presentable images once the platform is done with them. if (oldSwapchain != VK_NULL_HANDLE) { - //vkDestroySwapchainKHR(demo->device, oldSwapchain, NULL); + assert(false); // Vulkan SC doesn't support destroying swapchains } err = pfnGetSwapchainImagesKHR(demo->device, demo->swapchain, &demo->swapchainImageCount, NULL); @@ -1664,10 +1580,10 @@ static void demo_prepare_buffers(struct demo *demo) { } if (demo->VK_GOOGLE_display_timing_enabled) { - //VkRefreshCycleDurationGOOGLE rc_dur; - //err = vkGetRefreshCycleDurationGOOGLE(demo->device, demo->swapchain, &rc_dur); - //assert(!err); - //demo->refresh_duration = rc_dur.refreshDuration; + VkRefreshCycleDurationGOOGLE rc_dur; + err = pfnGetRefreshCycleDurationGOOGLE(demo->device, demo->swapchain, &rc_dur); + assert(!err); + demo->refresh_duration = rc_dur.refreshDuration; demo->syncd_with_actual_presents = false; // Initially target 1X the refresh duration: @@ -2168,7 +2084,7 @@ static void demo_prepare_render_pass(struct demo *demo) { const VkAttachmentDescription attachments[2] = { [0] = { - .format = VK_FORMAT_R8G8B8A8_UNORM, + .format = demo->format, .flags = 0, .samples = VK_SAMPLE_COUNT_1_BIT, .loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR, @@ -2176,7 +2092,7 @@ static void demo_prepare_render_pass(struct demo *demo) { .stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE, .stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE, .initialLayout = VK_IMAGE_LAYOUT_UNDEFINED, - .finalLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, + .finalLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR, }, [1] = { @@ -2254,84 +2170,6 @@ static void demo_prepare_render_pass(struct demo *demo) { assert(!err); } -static VkResult demo_prepare_display_image(struct demo *demo) { - demo_prepare_display_buffer(demo); - - demo->swapchainImageCount = 1; - demo->swapchain_image_resources = - (SwapchainImageResources *)malloc(sizeof(SwapchainImageResources) * demo->swapchainImageCount); - - const VkFormat display_format = VK_FORMAT_R8G8B8A8_UNORM; - const VkImageCreateInfo image = { - .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, - .pNext = NULL, - .imageType = VK_IMAGE_TYPE_2D, - .format = display_format, - .extent = {demo->width, demo->height, 1}, - .mipLevels = 1, - .arrayLayers = 1, - .samples = VK_SAMPLE_COUNT_1_BIT, - .tiling = VK_IMAGE_TILING_OPTIMAL, - .usage = VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT, - .flags = 0, - }; - - VkImageViewCreateInfo view = { - .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, - .pNext = NULL, - .image = VK_NULL_HANDLE, - .format = display_format, - .subresourceRange = - {.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, .baseMipLevel = 0, .levelCount = 1, .baseArrayLayer = 0, .layerCount = 1}, - .flags = 0, - .viewType = VK_IMAGE_VIEW_TYPE_2D, - }; - - VkMemoryRequirements mem_reqs; - VkResult U_ASSERT_ONLY err; - bool U_ASSERT_ONLY pass; - - demo->depth.format = display_format; - - /* create image */ - err = vkCreateImage(demo->device, &image, NULL, &demo->surface_image.image); - assert(!err); - demo_name_object(demo, VK_OBJECT_TYPE_IMAGE, (uint64_t)demo->surface_image.image, "SurfaceImage"); - - vkGetImageMemoryRequirements(demo->device, demo->surface_image.image, &mem_reqs); - assert(!err); - - demo->surface_image.mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; - demo->surface_image.mem_alloc.pNext = NULL; - demo->surface_image.mem_alloc.allocationSize = mem_reqs.size; - demo->surface_image.mem_alloc.memoryTypeIndex = 0; - - pass = memory_type_from_properties(demo, mem_reqs.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, - &demo->surface_image.mem_alloc.memoryTypeIndex); - assert(pass); - - /* allocate memory */ - err = vkAllocateMemory(demo->device, &demo->surface_image.mem_alloc, NULL, &demo->surface_image.mem); - assert(!err); - demo_name_object(demo, VK_OBJECT_TYPE_DEVICE_MEMORY, (uint64_t)demo->surface_image.mem, "SurfaceImageMem"); - - /* bind memory */ - err = vkBindImageMemory(demo->device, demo->surface_image.image, demo->surface_image.mem, 0); - assert(!err); - - /* create image view */ - view.image = demo->surface_image.image; - err = vkCreateImageView(demo->device, &view, NULL, &demo->surface_image.view); - assert(!err); - demo_name_object(demo, VK_OBJECT_TYPE_IMAGE_VIEW, (uint64_t)demo->surface_image.view, "SurfaceImageView"); - - demo->swapchain_image_resources[0].uniform_memory = demo->surface_image.mem; - demo->swapchain_image_resources[0].image = demo->surface_image.image; - demo->swapchain_image_resources[0].view = demo->surface_image.view; - - return err; -} - static VkPipelineCacheCreateInfo demo_get_pipeline_cache_info() { static const uint8_t cache_data[] = { #include "pipeline_cache.h" @@ -2472,18 +2310,18 @@ static void demo_prepare_descriptor_pool(struct demo *demo) { [0] = { .type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, - .descriptorCount = 1 + .descriptorCount = demo->swapchainImageCount, }, [1] = { .type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, - .descriptorCount = 1 * DEMO_TEXTURE_COUNT + .descriptorCount = demo->swapchainImageCount * DEMO_TEXTURE_COUNT, }, }; const VkDescriptorPoolCreateInfo descriptor_pool = { .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO, .pNext = NULL, - .maxSets = 1, // Limited to one "swapchain"image + .maxSets = demo->swapchainImageCount, .poolSizeCount = 2, .pPoolSizes = type_counts, }; @@ -2565,11 +2403,7 @@ static void demo_prepare_framebuffers(struct demo *demo) { } static void demo_prepare(struct demo *demo) { - if (demo->wsi_platform != WSI_PLATFORM_IMAGE) { - demo_prepare_buffers(demo); - } else { - demo_prepare_display_image(demo); - } + demo_prepare_buffers(demo); if (demo->is_minimized) { demo->prepared = false; @@ -4177,7 +4011,7 @@ static void demo_init_vk(struct demo *demo) { "Please look at the Getting Started guide for additional information.\n", "vkCreateInstance Failure"); } - if (!platformSurfaceExtFound && demo->wsi_platform != WSI_PLATFORM_IMAGE) { + if (!platformSurfaceExtFound) { #if defined(VK_USE_PLATFORM_WIN32_KHR) if (demo->wsi_platform == WSI_PLATFORM_WIN32) { ERR_EXIT("vkEnumerateInstanceExtensionProperties failed to find the " VK_KHR_WIN32_SURFACE_EXTENSION_NAME @@ -4745,21 +4579,6 @@ static void demo_init_vk_swapchain(struct demo *demo) { demo_create_surface(demo); -#if defined(CUBE_USE_IMAGE_DUMP) - if (demo->wsi_platform == WSI_PLATFORM_IMAGE) { - // Search for the first graphics queue - uint32_t graphicsQueueFamilyIndex = UINT32_MAX; - for (uint32_t i = 0; i < demo->queue_family_count; i++) { - if ((demo->queue_props[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) != 0) { - graphicsQueueFamilyIndex = i; - break; - } - } - demo->graphics_queue_family_index = graphicsQueueFamilyIndex; - demo->separate_present_queue = false; - } else { -#endif - // Iterate over each queue to learn whether it supports presenting: VkBool32 *supportsPresent = (VkBool32 *)malloc(demo->queue_family_count * sizeof(VkBool32)); for (uint32_t i = 0; i < demo->queue_family_count; i++) { @@ -4805,10 +4624,6 @@ static void demo_init_vk_swapchain(struct demo *demo) { demo->separate_present_queue = (demo->graphics_queue_family_index != demo->present_queue_family_index); free(supportsPresent); -#if defined(CUBE_USE_IMAGE_DUMP) - } -#endif - demo_create_device(demo); vkGetDeviceQueue(demo->device, demo->graphics_queue_family_index, 0, &demo->graphics_queue); @@ -4819,10 +4634,6 @@ static void demo_init_vk_swapchain(struct demo *demo) { vkGetDeviceQueue(demo->device, demo->present_queue_family_index, 0, &demo->present_queue); } -#if defined(CUBE_USE_IMAGE_DUMP) - if (demo->wsi_platform != WSI_PLATFORM_IMAGE) { -#endif - // Get the list of VkFormat's that are supported: uint32_t formatCount; err = pfnGetPhysicalDeviceSurfaceFormatsKHR(demo->gpu, demo->surface, &formatCount, NULL); @@ -4834,9 +4645,6 @@ static void demo_init_vk_swapchain(struct demo *demo) { demo->format = surfaceFormat.format; demo->color_space = surfaceFormat.colorSpace; free(surfFormats); -#if defined(CUBE_USE_IMAGE_DUMP) - } -#endif demo->quit = false; demo->curFrame = 0; @@ -5007,12 +4815,6 @@ static void demo_init(struct demo *demo, int argc, char **argv) { } strncat(available_wsi_platforms, "directfb", max_str_len); #endif -#if defined(CUBE_USE_IMAGE_DUMP) - if (strlen(available_wsi_platforms) > 0) { - strncat(available_wsi_platforms, "|", max_str_len); - } - strncat(available_wsi_platforms, "image", max_str_len); -#endif #if defined(VK_USE_PLATFORM_DISPLAY_KHR) if (strlen(available_wsi_platforms) > 0) { strncat(available_wsi_platforms, "|", max_str_len); @@ -5154,11 +4956,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pCmdLine, done = false; // initialize loop condition variable - if (demo.wsi_platform == WSI_PLATFORM_IMAGE) { - demo_draw(&demo); - done = true; - } - // main message loop while (!done) { if (demo.pause) {