From 93e9ba8972f6cb061cf18a69fffa97c3af2839db Mon Sep 17 00:00:00 2001 From: Johannes Unterguggenberger Date: Thu, 14 Mar 2024 12:05:58 +0100 Subject: [PATCH 1/6] Switched to Vulkan API version 1_3, also using glslangValidator.exe --target-env vulkan1.3 in post build helper. (#191) * Just linking to Auto-Vk after additional draw_*_indirect commands have been added * Linked to latest Auto-Vk after command_buffer_t::prepare_for_reuse() bugfix * Switched to Vulkan API version 1_3, also using glslangValidator.exe --target-env vulkan1.3 in post build helper. * trying to fix windows runner ...by adding `$env:VULKAN_SDK="${{ env.vulkan_sdk }}` before the cmake step * strings were missing the terminator * no idea what im doing * trying different Setup Vulkan step * Trying to set Vulkan_LIBRARY and Vulkan_INCLUDE_DIR * stupidly messing around * --debug-find * ${{ github.workspace }} no idea what i'm doing * i have still no idea what im doing * ${{ github.workspace }}/ * $HOME because... why not? * set env variables before configuring, remove illegal --debug-find * try fix windows-latest * Let's just say that we require SDK 1.3 from now on, shall we?! ^^ * VK_HEADER_VERSION check fixed: vk::createResultValue stopped existing in 216 * We actually don't need that Setup Vulkan step, since we are curling --------- Co-authored-by: Lukas Herzberger --- .github/workflows/cross-platform-check.yml | 16 +++++++++++----- README.md | 4 ++-- auto_vk | 2 +- auto_vk_toolkit/src/context_vulkan.cpp | 6 +++--- .../fallback_post_build_helper.exe | Bin 139776 -> 139776 bytes .../Deployers/VkShaderDeployment.cs | 2 +- 6 files changed, 18 insertions(+), 12 deletions(-) diff --git a/.github/workflows/cross-platform-check.yml b/.github/workflows/cross-platform-check.yml index 142ac4a5..e695c3b9 100644 --- a/.github/workflows/cross-platform-check.yml +++ b/.github/workflows/cross-platform-check.yml @@ -115,8 +115,8 @@ jobs: cc: "cl", cxx: "cl" } - # note: if a specific vulkan version (e.g. 1.1.x, or < 1.2.135) needs testing, you can add it here: - vulkan-sdk: ["latest", "1.2.198.1"] + # note: if a specific vulkan version needs testing, you can add it here: + vulkan-sdk: ["latest", "1.3.204.1"] steps: # IMPORTANT: apparently checkout@v3 pulls to ${{ github.event.repository.name }}/${{ github.event.repository.name }} instead of just ${{ github.event.repository.name }} on windows @@ -149,6 +149,9 @@ jobs: $env:CC="${{ matrix.config.cc }}" $env:CXX="${{ matrix.config.cxx }}" $env:Path += ";${{ env.vulkan_sdk }}\;${{ env.vulkan_sdk }}\Bin\" + $env:VULKAN_SDK="${{ env.vulkan_sdk }}" + $env:Vulkan_LIBRARY="${{ env.vulkan_sdk }}/Bin" + $env:Vulkan_INCLUDE_DIR="${{ env.vulkan_sdk }}/Include" cmake ` -DCMAKE_BUILD_TYPE=$BUILD_TYPE ` -Davk_toolkit_BuildHelloWorld=ON ` @@ -173,8 +176,8 @@ jobs: cc: "cl", cxx: "cl" } - # note: if a specific vulkan version (e.g. 1.1.x, or < 1.2.135) needs testing, you can add it here: - vulkan-sdk: ["latest", "1.2.198.1"] + # note: if a specific vulkan version needs testing, you can add it here: + vulkan-sdk: ["latest", "1.3.204.1"] steps: # IMPORTANT: apparently checkout@v3 pulls to ${{ github.event.repository.name }}/${{ github.event.repository.name }} instead of just ${{ github.event.repository.name }} on windows @@ -206,6 +209,9 @@ jobs: run: | $env:CC="${{ matrix.config.cc }}" $env:CXX="${{ matrix.config.cxx }}" + $env:VULKAN_SDK="${{ env.vulkan_sdk }}" + $env:Vulkan_LIBRARY="${{ env.vulkan_sdk }}/Bin" + $env:Vulkan_INCLUDE_DIR="${{ env.vulkan_sdk }}/Include" $env:Path += ";${{ env.vulkan_sdk }}\;${{ env.vulkan_sdk }}\Bin\" cmake ` -DCMAKE_BUILD_TYPE=$BUILD_TYPE ` @@ -215,4 +221,4 @@ jobs: - name: Build shell: bash working-directory: ${{ runner.workspace }}/${{ github.event.repository.name }}/build - run: VULKAN_SDK=${{ env.vulkan_sdk }} cmake --build . --config $BUILD_TYPE + run: cmake --build . --config $BUILD_TYPE diff --git a/README.md b/README.md index 81f06fe5..fae00a65 100644 --- a/README.md +++ b/README.md @@ -52,12 +52,12 @@ A preconfigured project setup is provided for Visual Studio 2022 on Windows. ### Requirements * Windows 10 or 11 * Visual Studio 2022 with a Windows 10 or 11 SDK installed (For detailed information about project setup and resource management please refer to [`visual_studio/README.md`](./visual_studio/README.md).) -* A [Vulkan SDK from LunarG](https://vulkan.lunarg.com/sdk/home), optimally Vulkan SDK 1.3.250.0 or newer. +* A [Vulkan 1.3 SDK from LunarG](https://vulkan.lunarg.com/sdk/home), optimally Vulkan SDK 1.3.250.0 or newer. ### Setup and build instructions * Clone or download this repository * Execute `git submodule update --init` to pull the [_Auto-Vk_](https://github.com/cg-tuwien/Auto-Vk) framework which is added as a submodule under `auto_vk` -* Download and install one of the latest [Vulkan SDKs for Windows](https://vulkan.lunarg.com/sdk/home#windows)! (At time of writing, the most recent version is 1.3.250.0.) +* Download and install one of the latest [Vulkan SDKs for Windows](https://vulkan.lunarg.com/sdk/home#windows)! * Select the `Vulkan Memory Allocator header.` option so that the [Vulkan Memory Allocator](https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator) (VMA) library is installed. * _Note:_ VMA can be installed through the Vulkan installer or its maintenance tool (e.g., `maintenancetool.exe` on Windows) by selecting the `Vulkan Memory Allocator header.` option. * Download and install [Visual Studio Community 2022](https://visualstudio.microsoft.com/vs/community/), or a newer version. diff --git a/auto_vk b/auto_vk index a4099156..f25c0c0c 160000 --- a/auto_vk +++ b/auto_vk @@ -1 +1 @@ -Subproject commit a40991563e7fdc98306d637dea7e8d8e877e5207 +Subproject commit f25c0c0c45f6c152ae4be10b164a9a8be8c967bb diff --git a/auto_vk_toolkit/src/context_vulkan.cpp b/auto_vk_toolkit/src/context_vulkan.cpp index 2615be33..0eb6f23d 100644 --- a/auto_vk_toolkit/src/context_vulkan.cpp +++ b/auto_vk_toolkit/src/context_vulkan.cpp @@ -99,7 +99,7 @@ namespace avk void context_vulkan::check_vk_result(VkResult err) { const auto& inst = context().vulkan_instance(); -#if VK_HEADER_VERSION >= 204 +#if VK_HEADER_VERSION >= 216 vk::createResultValueType(static_cast(err), "check_vk_result"); #else createResultValue(static_cast(err), inst, "check_vk_result"); @@ -613,8 +613,8 @@ namespace avk // Information about the application for the instance creation call auto appInfo = vk::ApplicationInfo(mSettings.mApplicationName.mValue.c_str(), mSettings.mApplicationVersion.mValue, - "Auto-Vk-Toolkit", VK_MAKE_VERSION(0, 98, 1), // TODO: Real version of Auto-Vk-Toolkit - VK_API_VERSION_1_2); + "Auto-Vk-Toolkit", VK_MAKE_VERSION(0, 99, 1), + VK_API_VERSION_1_3); // GLFW requires several extensions to interface with the window system. Query them. uint32_t glfwExtensionCount = 0; diff --git a/visual_studio/tools/executables/fallback_post_build_helper.exe b/visual_studio/tools/executables/fallback_post_build_helper.exe index 0fbe8ebf84493a4302476d57c9e5e8f7d76f4d3d..c96866ca4f8315ded27fca6f0272d40d54457def 100644 GIT binary patch delta 100 zcmV-q0Gt1S#0Y@I2#|;bYP+1fv5f4C0T7dUjF|xtlM{{m0T8nfj-=HAGq<#30W=2? z<_SUDF9N{QuiKFYxA2Tac+fTDxA\:\""\?\*\|\?\*])+)\:(\d+)\:", RegexOptions.Compiled); private static readonly Regex LineNumberRegex = new Regex(@":(\d+)", RegexOptions.IgnoreCase | RegexOptions.Compiled); private static readonly Regex IncludeDirectiveRegex = new Regex(@"#\s*include\s+\""(.+)\""", RegexOptions.IgnoreCase | RegexOptions.Compiled); From cd7960df45e25618ce953e99c39e07fb0cf5ecc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Sakmary?= Date: Thu, 14 Mar 2024 12:07:20 +0100 Subject: [PATCH 2/6] fixed exceptiton capture - now by const & instead of value (#193) * fixed exceptiton capture - now by const & instead of value * const& formatting --------- Co-authored-by: Johannes Unterguggenberger --- auto_vk_toolkit/src/window.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auto_vk_toolkit/src/window.cpp b/auto_vk_toolkit/src/window.cpp index 34138846..ff93550a 100644 --- a/auto_vk_toolkit/src/window.cpp +++ b/auto_vk_toolkit/src/window.cpp @@ -533,7 +533,7 @@ namespace avk // swap chain will be recreated in the next frame } } - catch (vk::OutOfDateKHRError omg) { + catch (const vk::OutOfDateKHRError& omg) { LOG_INFO(std::format("Swap chain out of date in render_frame. Reason[{}] in frame#{}. Going to recreate it...", omg.what(), current_frame())); mResourceRecreationDeterminator.set_recreation_required_for(recreation_determinator::reason::invalid_swap_chain); // Just do nothing. Ignore the failure. This frame is lost. From f7ea2b35f2ff632a8d128ba71523702293208a85 Mon Sep 17 00:00:00 2001 From: Johannes Unterguggenberger Date: Thu, 14 Mar 2024 12:53:18 +0100 Subject: [PATCH 3/6] Disabling synchronization validation for now in the examples --- auto_vk | 2 +- .../source/compute_image_processing.cpp | 10 +++++----- examples/framebuffer/source/framebuffer.cpp | 2 +- examples/hello_world/source/hello_world.cpp | 2 +- examples/model_loader/source/model_loader.cpp | 2 +- .../source/multi_invokee_rendering.cpp | 2 +- examples/multiple_queues/source/multiple_queues.cpp | 2 +- examples/orca_loader/source/orca_loader.cpp | 2 +- .../source/present_from_compute.cpp | 2 +- examples/vertex_buffers/source/vertex_buffers.cpp | 2 +- 10 files changed, 14 insertions(+), 14 deletions(-) diff --git a/auto_vk b/auto_vk index f25c0c0c..a260d0bf 160000 --- a/auto_vk +++ b/auto_vk @@ -1 +1 @@ -Subproject commit f25c0c0c45f6c152ae4be10b164a9a8be8c967bb +Subproject commit a260d0bf282402603bbff50de56d452af6a4ebb1 diff --git a/examples/compute_image_processing/source/compute_image_processing.cpp b/examples/compute_image_processing/source/compute_image_processing.cpp index 7bb4bb1c..cbaeb5f7 100644 --- a/examples/compute_image_processing/source/compute_image_processing.cpp +++ b/examples/compute_image_processing/source/compute_image_processing.cpp @@ -379,13 +379,13 @@ int main() // <== Starting point == auto composition = configure_and_compose( avk::application_name("Auto-Vk-Toolkit Example: Compute Image Effects Exampl"), [](avk::validation_layers& config) { - config.enable_feature(vk::ValidationFeatureEnableEXT::eSynchronizationValidation); + //config.enable_feature(vk::ValidationFeatureEnableEXT::eSynchronizationValidation); }, // Pass windows: - mainWnd, - // Pass invokees: - app, ui - ); + mainWnd, + // Pass invokees: + app, ui + ); // Create an invoker object, which defines the way how invokees/elements are invoked // (In this case, just sequentially in their execution order): diff --git a/examples/framebuffer/source/framebuffer.cpp b/examples/framebuffer/source/framebuffer.cpp index 18e884ad..3cf55e6b 100644 --- a/examples/framebuffer/source/framebuffer.cpp +++ b/examples/framebuffer/source/framebuffer.cpp @@ -312,7 +312,7 @@ int main() // <== Starting point == auto composition = configure_and_compose( avk::application_name("Auto-Vk-Toolkit Example: Framebuffers"), [](avk::validation_layers& config) { - config.enable_feature(vk::ValidationFeatureEnableEXT::eSynchronizationValidation); + //config.enable_feature(vk::ValidationFeatureEnableEXT::eSynchronizationValidation); }, // Pass windows: mainWnd, diff --git a/examples/hello_world/source/hello_world.cpp b/examples/hello_world/source/hello_world.cpp index a726161e..f211d5e3 100644 --- a/examples/hello_world/source/hello_world.cpp +++ b/examples/hello_world/source/hello_world.cpp @@ -160,7 +160,7 @@ int main() // <== Starting point == auto composition = configure_and_compose( avk::application_name("Hello, Auto-Vk-Toolkit World!"), [](avk::validation_layers& config) { - config.enable_feature(vk::ValidationFeatureEnableEXT::eSynchronizationValidation); + //config.enable_feature(vk::ValidationFeatureEnableEXT::eSynchronizationValidation); }, // Pass windows: mainWnd, diff --git a/examples/model_loader/source/model_loader.cpp b/examples/model_loader/source/model_loader.cpp index 58a984dd..3cc2ded7 100644 --- a/examples/model_loader/source/model_loader.cpp +++ b/examples/model_loader/source/model_loader.cpp @@ -466,7 +466,7 @@ int main() // <== Starting point == auto composition = configure_and_compose( avk::application_name("Auto-Vk-Toolkit Example: Model Loader"), [](avk::validation_layers& config) { - config.enable_feature(vk::ValidationFeatureEnableEXT::eSynchronizationValidation); + //config.enable_feature(vk::ValidationFeatureEnableEXT::eSynchronizationValidation); }, // Pass windows: mainWnd, diff --git a/examples/multi_invokee_rendering/source/multi_invokee_rendering.cpp b/examples/multi_invokee_rendering/source/multi_invokee_rendering.cpp index 87e3cfe3..b85d16a8 100644 --- a/examples/multi_invokee_rendering/source/multi_invokee_rendering.cpp +++ b/examples/multi_invokee_rendering/source/multi_invokee_rendering.cpp @@ -183,7 +183,7 @@ int main() // <== Starting point == auto composition = configure_and_compose( avk::application_name("Auto-Vk-Toolkit Example: Multiple Invokees"), [](avk::validation_layers& config) { - config.enable_feature(vk::ValidationFeatureEnableEXT::eSynchronizationValidation); + //config.enable_feature(vk::ValidationFeatureEnableEXT::eSynchronizationValidation); //config.enable_feature(vk::ValidationFeatureEnableEXT::eBestPractices); }, // Pass windows: diff --git a/examples/multiple_queues/source/multiple_queues.cpp b/examples/multiple_queues/source/multiple_queues.cpp index 803539cf..76fcba24 100644 --- a/examples/multiple_queues/source/multiple_queues.cpp +++ b/examples/multiple_queues/source/multiple_queues.cpp @@ -269,7 +269,7 @@ int main() // <== Starting point == auto composition = configure_and_compose( avk::application_name("Auto-Vk-Toolkit Example: Multiple Queues"), [](avk::validation_layers& config) { - config.enable_feature(vk::ValidationFeatureEnableEXT::eSynchronizationValidation); + //config.enable_feature(vk::ValidationFeatureEnableEXT::eSynchronizationValidation); }, // Pass windows: mainWnd, diff --git a/examples/orca_loader/source/orca_loader.cpp b/examples/orca_loader/source/orca_loader.cpp index 8cec6b40..bbdfb022 100644 --- a/examples/orca_loader/source/orca_loader.cpp +++ b/examples/orca_loader/source/orca_loader.cpp @@ -647,7 +647,7 @@ int main() // <== Starting point == auto composition = configure_and_compose( avk::application_name("Auto-Vk-Toolkit Example: ORCA Loader"), [](avk::validation_layers& config) { - config.enable_feature(vk::ValidationFeatureEnableEXT::eSynchronizationValidation); + //config.enable_feature(vk::ValidationFeatureEnableEXT::eSynchronizationValidation); }, // Pass windows: mainWnd, diff --git a/examples/present_from_compute/source/present_from_compute.cpp b/examples/present_from_compute/source/present_from_compute.cpp index ee5a083e..d7c3cb6e 100644 --- a/examples/present_from_compute/source/present_from_compute.cpp +++ b/examples/present_from_compute/source/present_from_compute.cpp @@ -439,7 +439,7 @@ int main() // <== Starting point == auto composition = configure_and_compose( avk::application_name("Auto-Vk-Toolkit Example: Present from Compute"), [](avk::validation_layers& config) { - config.enable_feature(vk::ValidationFeatureEnableEXT::eSynchronizationValidation); + //config.enable_feature(vk::ValidationFeatureEnableEXT::eSynchronizationValidation); }, // Pass windows: mainWnd, diff --git a/examples/vertex_buffers/source/vertex_buffers.cpp b/examples/vertex_buffers/source/vertex_buffers.cpp index 90409b47..f79b3e1d 100644 --- a/examples/vertex_buffers/source/vertex_buffers.cpp +++ b/examples/vertex_buffers/source/vertex_buffers.cpp @@ -219,7 +219,7 @@ int main() // <== Starting point == auto composition = configure_and_compose( avk::application_name("Auto-Vk-Toolkit Example: Vertex Buffers"), [](avk::validation_layers& config) { - config.enable_feature(vk::ValidationFeatureEnableEXT::eSynchronizationValidation); + //config.enable_feature(vk::ValidationFeatureEnableEXT::eSynchronizationValidation); }, // Pass windows: mainWnd, From 64a37f5d0fa91beb9e30a7654ede48e9526f98c6 Mon Sep 17 00:00:00 2001 From: Johannes Unterguggenberger Date: Thu, 14 Mar 2024 12:53:40 +0100 Subject: [PATCH 4/6] Requesting the acceleration structure extension in the ray tracing examples --- .../source/ray_query_in_ray_tracing_shaders.cpp | 15 ++++++++------- .../source/ray_tracing_custom_intersection.cpp | 2 ++ .../source/ray_tracing_with_shadows_and_ao.cpp | 15 ++++++++------- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/examples/ray_query_in_ray_tracing_shaders/source/ray_query_in_ray_tracing_shaders.cpp b/examples/ray_query_in_ray_tracing_shaders/source/ray_query_in_ray_tracing_shaders.cpp index 90540d01..9a6441a6 100644 --- a/examples/ray_query_in_ray_tracing_shaders/source/ray_query_in_ray_tracing_shaders.cpp +++ b/examples/ray_query_in_ray_tracing_shaders/source/ray_query_in_ray_tracing_shaders.cpp @@ -463,13 +463,14 @@ int main() // <== Starting point == avk::application_name("Auto-Vk-Toolkit Example: Ray Query in Ray Tracing Shaders"), avk::required_device_extensions() // We need several extensions for ray tracing: - .add_extension(VK_KHR_RAY_TRACING_PIPELINE_EXTENSION_NAME) - .add_extension(VK_KHR_RAY_QUERY_EXTENSION_NAME) - .add_extension(VK_KHR_PIPELINE_LIBRARY_EXTENSION_NAME) - .add_extension(VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME) - .add_extension(VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME) - .add_extension(VK_KHR_DEFERRED_HOST_OPERATIONS_EXTENSION_NAME) - .add_extension(VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME), + .add_extension(VK_KHR_ACCELERATION_STRUCTURE_EXTENSION_NAME) + .add_extension(VK_KHR_RAY_TRACING_PIPELINE_EXTENSION_NAME) + .add_extension(VK_KHR_RAY_QUERY_EXTENSION_NAME) + .add_extension(VK_KHR_PIPELINE_LIBRARY_EXTENSION_NAME) + .add_extension(VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME) + .add_extension(VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME) + .add_extension(VK_KHR_DEFERRED_HOST_OPERATIONS_EXTENSION_NAME) + .add_extension(VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME), [](vk::PhysicalDeviceVulkan12Features& aVulkan12Featues) { // Also this Vulkan 1.2 feature is required for ray tracing: aVulkan12Featues.setBufferDeviceAddress(VK_TRUE); diff --git a/examples/ray_tracing_custom_intersection/source/ray_tracing_custom_intersection.cpp b/examples/ray_tracing_custom_intersection/source/ray_tracing_custom_intersection.cpp index 72cea4eb..47cc1b48 100644 --- a/examples/ray_tracing_custom_intersection/source/ray_tracing_custom_intersection.cpp +++ b/examples/ray_tracing_custom_intersection/source/ray_tracing_custom_intersection.cpp @@ -451,6 +451,8 @@ int main() // <== Starting point == avk::application_name("Auto-Vk-Toolkit Example: Real-Time Ray Tracing - Custom Intersection Example"), #if VK_HEADER_VERSION >= 162 avk::required_device_extensions() + // We need several extensions for ray tracing: + .add_extension(VK_KHR_ACCELERATION_STRUCTURE_EXTENSION_NAME) .add_extension(VK_KHR_RAY_TRACING_PIPELINE_EXTENSION_NAME) .add_extension(VK_KHR_PIPELINE_LIBRARY_EXTENSION_NAME) .add_extension(VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME) diff --git a/examples/ray_tracing_with_shadows_and_ao/source/ray_tracing_with_shadows_and_ao.cpp b/examples/ray_tracing_with_shadows_and_ao/source/ray_tracing_with_shadows_and_ao.cpp index c6faeeff..5da89e00 100644 --- a/examples/ray_tracing_with_shadows_and_ao/source/ray_tracing_with_shadows_and_ao.cpp +++ b/examples/ray_tracing_with_shadows_and_ao/source/ray_tracing_with_shadows_and_ao.cpp @@ -464,13 +464,14 @@ int main() // <== Starting point == auto composition = configure_and_compose( avk::application_name("Auto-Vk-Toolkit Example: Real-Time Ray Tracing with Shadows and AO"), avk::required_device_extensions() - // We need several extensions for ray tracing: - .add_extension(VK_KHR_RAY_TRACING_PIPELINE_EXTENSION_NAME) - .add_extension(VK_KHR_PIPELINE_LIBRARY_EXTENSION_NAME) - .add_extension(VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME) - .add_extension(VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME) - .add_extension(VK_KHR_DEFERRED_HOST_OPERATIONS_EXTENSION_NAME) - .add_extension(VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME), + // We need several extensions for ray tracing: + .add_extension(VK_KHR_ACCELERATION_STRUCTURE_EXTENSION_NAME) + .add_extension(VK_KHR_RAY_TRACING_PIPELINE_EXTENSION_NAME) + .add_extension(VK_KHR_PIPELINE_LIBRARY_EXTENSION_NAME) + .add_extension(VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME) + .add_extension(VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME) + .add_extension(VK_KHR_DEFERRED_HOST_OPERATIONS_EXTENSION_NAME) + .add_extension(VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME), [](vk::PhysicalDeviceVulkan12Features& aVulkan12Featues) { // Also this Vulkan 1.2 feature is required for ray tracing: aVulkan12Featues.setBufferDeviceAddress(VK_TRUE); From db093462e0120c7c90979d37b5189887f8ab43cb Mon Sep 17 00:00:00 2001 From: Johannes Unterguggenberger Date: Thu, 14 Mar 2024 13:32:29 +0100 Subject: [PATCH 5/6] Hotfix: pCallbackData->pMessageIdName can be nullptr (e.g., when debugging with RenderDoc) --- auto_vk_toolkit/src/context_vulkan.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/auto_vk_toolkit/src/context_vulkan.cpp b/auto_vk_toolkit/src/context_vulkan.cpp index 0eb6f23d..2768eac6 100644 --- a/auto_vk_toolkit/src/context_vulkan.cpp +++ b/auto_vk_toolkit/src/context_vulkan.cpp @@ -700,11 +700,12 @@ namespace avk typeDescription = "(" + typeDescription.substr(0, typeDescription.size() - 2) + ") "; } + std::string messageIdName = nullptr == pCallbackData->pMessageIdName ? "(nullptr)" : std::string(pCallbackData->pMessageIdName); if (pMessageSeverity >= VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT) { assert(pCallbackData); LOG_ERROR___(std::format("Debug utils callback with Id[{}|{}] and Message[{}]", pCallbackData->messageIdNumber, - pCallbackData->pMessageIdName, + messageIdName, pCallbackData->pMessage)); return VK_FALSE; } @@ -712,22 +713,22 @@ namespace avk assert(pCallbackData); LOG_WARNING___(std::format("Debug utils callback with Id[{}|{}] and Message[{}]", pCallbackData->messageIdNumber, - pCallbackData->pMessageIdName, + messageIdName, pCallbackData->pMessage)); return VK_FALSE; } else if (pMessageSeverity >= VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT) { assert(pCallbackData); - if (std::string("Loader Message") == pCallbackData->pMessageIdName) { + if (std::string("Loader Message") == messageIdName) { LOG_VERBOSE___(std::format("Debug utils callback with Id[{}|{}] and Message[{}]", pCallbackData->messageIdNumber, - pCallbackData->pMessageIdName, + messageIdName, pCallbackData->pMessage)); } else { LOG_INFO___(std::format("Debug utils callback with Id[{}|{}] and Message[{}]", pCallbackData->messageIdNumber, - pCallbackData->pMessageIdName, + messageIdName, pCallbackData->pMessage)); } return VK_FALSE; @@ -736,7 +737,7 @@ namespace avk assert(pCallbackData); LOG_VERBOSE___(std::format("Debug utils callback with Id[{}|{}] and Message[{}]", pCallbackData->messageIdNumber, - pCallbackData->pMessageIdName, + messageIdName, pCallbackData->pMessage)); return VK_FALSE; } From 3a2507eec2d3524eea48ad7b59a8ad207b37c125 Mon Sep 17 00:00:00 2001 From: Johannes Unterguggenberger Date: Thu, 14 Mar 2024 13:33:31 +0100 Subject: [PATCH 6/6] Better orbit camera zoom behavior (#192) * Better zoom behavior for orbit camera (and much easier implementation :facepalm:) * Made parameters of orbit_camera configurable, fixed lateral speed, cleaned up --- auto_vk_toolkit/include/orbit_camera.hpp | 38 ++++++++++++++---- auto_vk_toolkit/src/orbit_camera.cpp | 49 +++++------------------- 2 files changed, 39 insertions(+), 48 deletions(-) diff --git a/auto_vk_toolkit/include/orbit_camera.hpp b/auto_vk_toolkit/include/orbit_camera.hpp index 8dd7b836..c636c218 100644 --- a/auto_vk_toolkit/include/orbit_camera.hpp +++ b/auto_vk_toolkit/include/orbit_camera.hpp @@ -30,17 +30,41 @@ namespace avk // Invoked every frame to handle input and update the camera's position void update() override; + /** Gets the current pivot distance + * @return The currently used pivot distance. + */ + float pivot_distance() const; + // Gets the current rotation speed + auto rotation_speed() const { return mRotationSpeed; } + // Gets the current pivot distance speed + auto pivot_distance_speed() const { return mPivotDistanceSpeed; } + // Gets the current zoom speed + auto zoom_speed() const { return mZoomSpeed; } + // Gets the current lateral speed + auto lateral_speed() const { return mLateralSpeed; } + // Gets the current fast multiplier, i.e., factor when fast movement is enabled + auto fast_multiplier() const { return mFastMultiplier; } + // Gets the current slow multiplier, i.e., factor when slow movement is enabled + auto slow_multiplier() const { return mSlowMultiplier; } + /** Sets the pivot distance, which is the distance along the front vector * of the camera which this camera orbits around. * Note: The passed value might get clamped to min/max bounds. * @param aDistanceFromCamera The desired distance along the front vector. */ void set_pivot_distance(float aDistanceFromCamera); - - /** Gets the current pivot distance - * @return The currently used pivot distance. - */ - float pivot_distance() const; + // Sets the current rotation speed + void rotation_speed(float value) { mRotationSpeed = value; } + // Sets the current pivot distance speed + void pivot_distance_speed(float value) { mPivotDistanceSpeed = value; } + // Sets the current zoom speed + void zoom_speed(float value) { mZoomSpeed = value; } + // Sets the current lateral speed + void lateral_speed(glm::vec2 value) { mLateralSpeed = value; } + // Sets the current fast multiplier, i.e., factor when fast movement is enabled + void fast_multiplier(float value) { mFastMultiplier = value; } + // Sets the current slow multiplier, i.e., factor when slow movement is enabled + void slow_multiplier(float value) { mSlowMultiplier = value; } private: void calculate_lateral_speed(); @@ -49,9 +73,7 @@ namespace avk float mRotationSpeed; float mPivotDistance; float mPivotDistanceSpeed; - float mMinPivotDistance; - float mMaxPivotDistance; - float mPivotDistanceSlowDownRange; + float mZoomSpeed; glm::vec2 mLateralSpeed; float mFastMultiplier; float mSlowMultiplier; diff --git a/auto_vk_toolkit/src/orbit_camera.cpp b/auto_vk_toolkit/src/orbit_camera.cpp index a09ed66a..9854d7ca 100644 --- a/auto_vk_toolkit/src/orbit_camera.cpp +++ b/auto_vk_toolkit/src/orbit_camera.cpp @@ -10,9 +10,7 @@ namespace avk , mRotationSpeed(0.002f) , mPivotDistance{ 10.f } , mPivotDistanceSpeed{ .5f } - , mMinPivotDistance{ 1.f } - , mMaxPivotDistance{ 50.f } - , mPivotDistanceSlowDownRange{ 3.0f } + , mZoomSpeed{ 0.07f } , mLateralSpeed{ 1.f } , mFastMultiplier(5.0f) , mSlowMultiplier(0.1f) @@ -86,41 +84,14 @@ namespace avk const auto moveCloser = scrollDist > 0.f; const auto moveAway = scrollDist < 0.f; - auto getMoveSpeed = [this](float x) { - x = glm::round(x * 20.f) / 20.f; - auto spd = glm::smoothstep(mMinPivotDistance, mMinPivotDistance + mPivotDistanceSlowDownRange, x) * glm::smoothstep(mMaxPivotDistance, mMaxPivotDistance - mPivotDistanceSlowDownRange, x); - return spd; - }; - - if (moveCloser) { - auto spd = getMoveSpeed(mPivotDistance); - if (mPivotDistance - mMinPivotDistance > mMaxPivotDistance - mPivotDistance) { - // try to match the moveAway speed - auto candidate = mPivotDistance - spd * pivDistSpeed; - for (int safety = 0; safety < 10 && mPivotDistance - candidate - getMoveSpeed(candidate) * pivDistSpeed < -1e-5; ++safety) { - spd = getMoveSpeed(candidate); - candidate = mPivotDistance - spd * pivDistSpeed; - } - } - auto move = front(*this) * spd * pivDistSpeed; - translate(*this, move); - mPivotDistance -= spd * pivDistSpeed; - calculate_lateral_speed(); - } - if (moveAway) { - auto spd = getMoveSpeed(mPivotDistance); - if (mPivotDistance - mMinPivotDistance < mMaxPivotDistance - mPivotDistance) { - // try to match the moveCloser speed - auto candidate = mPivotDistance + spd * pivDistSpeed; - for (int safety = 0; safety < 10 && candidate - getMoveSpeed(candidate) * pivDistSpeed - mPivotDistance < -1e-5; ++safety) { - spd = getMoveSpeed(candidate); - candidate = mPivotDistance + spd * pivDistSpeed; - } - } - auto move = back(*this) * spd * pivDistSpeed; - translate(*this, move); - mPivotDistance += spd * pivDistSpeed; - calculate_lateral_speed(); + if (scrollDist != 0.0f) { + auto moveAwayFactor = 1.f + mZoomSpeed; + auto moveCloserFactor = moveCloser ? 1.f + mZoomSpeed * glm::smoothstep(0.0f, 1.0f, mPivotDistance) : 1.0f; + auto newPos = scrollDist < 0.0 + ? mPivotDistance * moveAwayFactor + : mPivotDistance / moveCloserFactor; + translate(*this, front(*this) * (mPivotDistance - newPos)); + set_pivot_distance(newPos); } } } @@ -129,8 +100,6 @@ namespace avk mPivotDistance = aDistanceFromCamera; calculate_lateral_speed(); mPivotDistanceSpeed = mPivotDistance / 20.f; - mPivotDistanceSlowDownRange = mPivotDistance / 3.f; - mMaxPivotDistance = mPivotDistance * 3.f; } float orbit_camera::pivot_distance() const {