add headless surface extension

pull/1/head
ink-soul 2024-03-26 15:48:30 +08:00
parent efd42bdef7
commit 8a36a4d721
6 changed files with 32 additions and 23 deletions

View File

@ -48,8 +48,15 @@ VkResult VulkanExampleBase::createInstance(bool enableValidation)
appInfo.pEngineName = name.c_str(); appInfo.pEngineName = name.c_str();
appInfo.apiVersion = VK_API_VERSION_1_0; appInfo.apiVersion = VK_API_VERSION_1_0;
std::vector<const char*> instanceExtensions = { VK_KHR_SURFACE_EXTENSION_NAME }; std::vector<const char*> instanceExtensions = { };
if (settings.headless)
{
instanceExtensions.push_back("VK_EXT_headless_surface");
}
else
{
instanceExtensions.push_back(VK_KHR_SURFACE_EXTENSION_NAME);
// Enable surface extensions depending on os // Enable surface extensions depending on os
#if defined(_WIN32) #if defined(_WIN32)
instanceExtensions.push_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME); instanceExtensions.push_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME);
@ -70,6 +77,10 @@ VkResult VulkanExampleBase::createInstance(bool enableValidation)
instanceExtensions.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); instanceExtensions.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
#endif #endif
}
VkInstanceCreateInfo instanceCreateInfo = {}; VkInstanceCreateInfo instanceCreateInfo = {};
instanceCreateInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; instanceCreateInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
instanceCreateInfo.pNext = NULL; instanceCreateInfo.pNext = NULL;
@ -94,6 +105,8 @@ VkResult VulkanExampleBase::createInstance(bool enableValidation)
instanceCreateInfo.ppEnabledLayerNames = validationLayerNames.data(); instanceCreateInfo.ppEnabledLayerNames = validationLayerNames.data();
} }
return vkCreateInstance(&instanceCreateInfo, nullptr, &instance); return vkCreateInstance(&instanceCreateInfo, nullptr, &instance);
} }
void VulkanExampleBase::prepare() void VulkanExampleBase::prepare()
{ {

View File

@ -117,6 +117,12 @@ public:
bool fullscreen = false; bool fullscreen = false;
bool vsync = false; bool vsync = false;
bool multiSampling = true; bool multiSampling = true;
bool rotateModel = true;
bool enableSaveToImageSequeue = false;
bool headless = false;
uint32_t outputFrameCount = 50;
bool takeScreenShot = false;
VkSampleCountFlagBits sampleCount = VK_SAMPLE_COUNT_4_BIT; VkSampleCountFlagBits sampleCount = VK_SAMPLE_COUNT_4_BIT;
} settings; } settings;

View File

@ -34,7 +34,7 @@ function(buildHomework HOMEWORK_NAME)
"render/glTFModel.h" "render/glTFModel.h"
"render/glTFModel.cpp" "render/glTFModel.cpp"
) "render/renderFoundation.h" "render/renderFoundation.cpp")
target_link_libraries(${HOMEWORK_NAME} base ${Vulkan_LIBRARY} ${WINLIBS}) target_link_libraries(${HOMEWORK_NAME} base ${Vulkan_LIBRARY} ${WINLIBS})
else(WIN32) else(WIN32)
add_executable(${HOMEWORK_NAME} ${MAIN_CPP} ${SOURCE} ${MAIN_HEADER} ${SHADERS_GLSL} ${SHADERS_HLSL} ${README_FILES}) add_executable(${HOMEWORK_NAME} ${MAIN_CPP} ${SOURCE} ${MAIN_HEADER} ${SHADERS_GLSL} ${SHADERS_HLSL} ${README_FILES})

View File

@ -216,18 +216,7 @@ public:
VkDescriptorSet tonemappingDescriptorSet = VK_NULL_HANDLE; VkDescriptorSet tonemappingDescriptorSet = VK_NULL_HANDLE;
}; };
struct Settings {
bool validation = true;
bool fullscreen = false;
bool vsync = false;
bool multiSampling = true;
bool rotateModel = true;
bool enableSaveToImageSequeue = false;
uint32_t outputFrameCount = 50;
bool takeScreenShot = false;
VkSampleCountFlagBits sampleCount = VK_SAMPLE_COUNT_4_BIT;
} settings;
struct DescriptorSetLayouts { struct DescriptorSetLayouts {
VkDescriptorSetLayout scene; VkDescriptorSetLayout scene;

View File

View File

@ -0,0 +1 @@
#pragma once