From 099af13f2f09edff9ed8573e96fcf50bfb0f3e8e Mon Sep 17 00:00:00 2001 From: light7734 Date: Thu, 9 Oct 2025 16:50:41 +0330 Subject: [PATCH] wip --- .../private/backend/vk/context/instance.cpp | 13 +++- .../private/backend/vk/context/swapchain.cpp | 62 +++++++++---------- 2 files changed, 41 insertions(+), 34 deletions(-) diff --git a/modules/renderer/private/backend/vk/context/instance.cpp b/modules/renderer/private/backend/vk/context/instance.cpp index 9211180..19c13bc 100644 --- a/modules/renderer/private/backend/vk/context/instance.cpp +++ b/modules/renderer/private/backend/vk/context/instance.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #if defined(_WIN32) #error "Unsupported platform (currently)" @@ -190,11 +191,21 @@ void Instance::initialize_instance() .pValues = &setting_duplicate_message_limit, }, }); + auto disable = VK_VALIDATION_FEATURE_DISABLE_SHADER_VALIDATION_CACHE_EXT; + + auto validation_features = VkValidationFeaturesEXT { + .sType = VK_STRUCTURE_TYPE_VALIDATION_FEATURES_EXT, + .enabledValidationFeatureCount = 0u, + .pEnabledValidationFeatures = nullptr, + .disabledValidationFeatureCount = 1u, + .pDisabledValidationFeatures = &disable, + }; const VkLayerSettingsCreateInfoEXT layer_settings_create_info = { .sType = VK_STRUCTURE_TYPE_LAYER_SETTINGS_CREATE_INFO_EXT, + .pNext = &validation_features, .settingCount = settings.size(), - .pSettings = settings.data() + .pSettings = settings.data(), }; auto layers = std::vector { diff --git a/modules/renderer/private/backend/vk/context/swapchain.cpp b/modules/renderer/private/backend/vk/context/swapchain.cpp index 5c85785..212f9fb 100644 --- a/modules/renderer/private/backend/vk/context/swapchain.cpp +++ b/modules/renderer/private/backend/vk/context/swapchain.cpp @@ -44,39 +44,39 @@ Swapchain::Swapchain(ISurface *surface, IGpu *gpu, IDevice *device) .oldSwapchain = nullptr, } ); - log_dbg("CREATED SWAPCHAIN @ {:x}", std::bit_cast(m_swapchain)); m_resolution = capabilities.currentExtent; m_device->name(m_swapchain, "swapchain {}", idx++); m_device->wait_idle(); - // m_images = m_device->get_swapchain_images(m_swapchain); - // m_image_views.resize(m_images.size()); - // for (auto idx = 0u; auto [image, view] : std::views::zip(m_images, m_image_views)) - // { - // view = m_device->create_image_view(VkImageViewCreateInfo { - // .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, - // .image = image, - // .viewType = VK_IMAGE_VIEW_TYPE_2D, - // .format = surface_format.format, - // .components = VkComponentMapping { - // .r = VK_COMPONENT_SWIZZLE_IDENTITY, - // .g = VK_COMPONENT_SWIZZLE_IDENTITY, - // .b = VK_COMPONENT_SWIZZLE_IDENTITY, - // .a = VK_COMPONENT_SWIZZLE_IDENTITY, - // }, - // .subresourceRange = VkImageSubresourceRange { - // .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, - // .baseMipLevel = 0u, - // .levelCount = 1u, - // .baseArrayLayer = 0u, - // .layerCount = 1u, - // } - // }); - // - // m_device->name(image, "swapchain image {}", idx++); - // m_device->name(view, "swapchain image view {}", idx++); - // } + m_images = m_device->get_swapchain_images(m_swapchain); + m_image_views.resize(m_images.size()); + for (auto idx = 0u; auto [image, view] : std::views::zip(m_images, m_image_views)) + { + view = m_device->create_image_view(VkImageViewCreateInfo { + .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, + .image = image, + .viewType = VK_IMAGE_VIEW_TYPE_2D, + .format = surface_format.format, + .components = VkComponentMapping { + .r = VK_COMPONENT_SWIZZLE_IDENTITY, + .g = VK_COMPONENT_SWIZZLE_IDENTITY, + .b = VK_COMPONENT_SWIZZLE_IDENTITY, + .a = VK_COMPONENT_SWIZZLE_IDENTITY, + }, + .subresourceRange = VkImageSubresourceRange { + .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, + .baseMipLevel = 0u, + .levelCount = 1u, + .baseArrayLayer = 0u, + .layerCount = 1u, + } + }); + + m_device->name(image, "swapchain image {}", idx++); + m_device->name(view, "swapchain image view {}", idx++); + } + m_device->wait_idle(); } Swapchain::~Swapchain() @@ -89,13 +89,9 @@ Swapchain::~Swapchain() try { m_device->wait_idle(); - log_dbg("DESTROYING SWAPCHAIN @ {:x}", std::bit_cast(m_swapchain)); - std::this_thread::sleep_for(std::chrono::seconds { 10 }); + m_device->destroy_image_views(m_image_views); m_device->destroy_swapchain(m_swapchain); m_device->wait_idle(); - - std::this_thread::sleep_for(std::chrono::seconds { 10 }); - std::cout << "EEP" << std::endl; } catch (const std::exception &exp) {