Refactor the CMakeLists for all the samples; use vulkan.hpp/vulkan_raii.hpp as precompiled header.

This commit is contained in:
asuessenbach
2022-08-10 11:19:06 +02:00
parent 1a64b5fcc0
commit 5480d192f5
200 changed files with 299 additions and 2068 deletions

View File

@@ -14,30 +14,15 @@
cmake_minimum_required(VERSION 3.2)
project(RayTracing)
set(HEADERS
CameraManipulator.hpp
)
set(SOURCES
CameraManipulator.cpp
RayTracing.cpp
)
source_group(headers FILES ${HEADERS})
source_group(sources FILES ${SOURCES})
add_executable(RayTracing
${HEADERS}
${SOURCES}
)
set_target_properties(RayTracing PROPERTIES FOLDER "Samples")
target_link_libraries(RayTracing PRIVATE utils)
target_include_directories(RayTracing PUBLIC
${CMAKE_SOURCE_DIR}/samples/RayTracing/common
${CMAKE_SOURCE_DIR}/samples/RayTracing/vulkannv
${CMAKE_SOURCE_DIR}/stb
${CMAKE_SOURCE_DIR}/tinyobjloader
)
vulkan_hpp__setup_sample_dynamic(
NAME RayTracing
INCLUDE_DIRS
${CMAKE_SOURCE_DIR}/samples/RayTracing/common
${CMAKE_SOURCE_DIR}/samples/RayTracing/vulkannv
${CMAKE_SOURCE_DIR}/stb
${CMAKE_SOURCE_DIR}/tinyobjloader
HEADERS
CameraManipulator.hpp
SOURCES
CameraManipulator.cpp
RayTracing.cpp)

View File

@@ -28,9 +28,9 @@
// unknow compiler... just ignore the warnings for yourselves ;)
#endif
// clang-format off
// we need to include vulkan.hpp before glfw3.h, so stop clang-format to reorder them
#include <vulkan/vulkan.hpp>
// clang-format off
#include <GLFW/glfw3.h>
// clang-format on
#include <numeric>
@@ -700,7 +700,25 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::DebugUtilsMessengerEXT debugUtilsMessenger = instance.createDebugUtilsMessengerEXT( vk::su::makeDebugUtilsMessengerCreateInfoEXT() );
#endif
vk::PhysicalDevice physicalDevice = instance.enumeratePhysicalDevices().front();
vk::PhysicalDevice physicalDevice = nullptr;
std::vector<vk::PhysicalDevice> physicalDevices = instance.enumeratePhysicalDevices();
for ( auto pd : physicalDevices )
{
std::vector<vk::ExtensionProperties> ep = pd.enumerateDeviceExtensionProperties();
if ( std::find_if( ep.cbegin(),
ep.cend(),
[]( vk::ExtensionProperties const & prop )
{ return strcmp( prop.extensionName, VK_NV_RAY_TRACING_EXTENSION_NAME ) == 0; } ) != ep.cend() )
{
physicalDevice = pd;
break;
}
}
if ( !physicalDevice )
{
std::cerr << AppName << ": can't find a PhysicalDevice supporting extension <" << VK_NV_RAY_TRACING_EXTENSION_NAME << ">" << std::endl;
return 1;
}
// Create Window Surface (using glfw)
vk::SurfaceKHR surface;