Skip to content

Commit

Permalink
Merge branch 'development' into dynamic_rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
johannesugb committed Apr 12, 2024
2 parents 61435c2 + 3a2507e commit 8d9e703
Show file tree
Hide file tree
Showing 20 changed files with 95 additions and 93 deletions.
16 changes: 11 additions & 5 deletions .github/workflows/cross-platform-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 `
Expand All @@ -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
Expand Down Expand Up @@ -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 `
Expand All @@ -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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
38 changes: 30 additions & 8 deletions auto_vk_toolkit/include/orbit_camera.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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;
Expand Down
19 changes: 10 additions & 9 deletions auto_vk_toolkit/src/context_vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<vk::Result>(err), "check_vk_result");
#else
createResultValue(static_cast<vk::Result>(err), inst, "check_vk_result");
Expand Down Expand Up @@ -621,8 +621,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;
Expand Down Expand Up @@ -708,34 +708,35 @@ 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;
}
else if (pMessageSeverity >= VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT) {
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;
Expand All @@ -744,7 +745,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;
}
Expand Down
49 changes: 9 additions & 40 deletions auto_vk_toolkit/src/orbit_camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}
}
}
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion auto_vk_toolkit/src/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion examples/framebuffer/source/framebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion examples/hello_world/source/hello_world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion examples/model_loader/source/model_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion examples/multiple_queues/source/multiple_queues.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion examples/orca_loader/source/orca_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading

0 comments on commit 8d9e703

Please sign in to comment.