Merge branch 'main-headless' into test-headless

test-headless
ink-soul 2024-04-17 16:17:11 +08:00
commit d0dee05a1c
9 changed files with 49 additions and 38 deletions

View File

@ -81,6 +81,20 @@
"rsyncCommandArgs": "-t --delete", "rsyncCommandArgs": "-t --delete",
"remoteCopyBuildOutput": false, "remoteCopyBuildOutput": false,
"remoteCopySourcesMethod": "rsync" "remoteCopySourcesMethod": "rsync"
},
{
"name": "WSL-Clang-Release",
"generator": "Ninja",
"configurationType": "RelWithDebInfo",
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeExecutable": "cmake",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"inheritEnvironments": [ "linux_clang_x64" ],
"wslPath": "${defaultWSLPath}",
"variables": []
} }
] ]
} }

View File

@ -53,7 +53,8 @@ public:
VkExtent2D extent = {}; VkExtent2D extent = {};
uint32_t queueNodeIndex = UINT32_MAX; uint32_t queueNodeIndex = UINT32_MAX;
/** @brief Creates the platform specific surface abstraction of the native platform window used for presentation */ /* @brief Creates the platform specific surface abstraction of the native platform window used for presentation */
/*
#if defined(VK_USE_PLATFORM_WIN32_KHR) #if defined(VK_USE_PLATFORM_WIN32_KHR)
void initSurface(void* platformHandle, void* platformWindow) void initSurface(void* platformHandle, void* platformWindow)
#elif defined(VK_USE_PLATFORM_ANDROID_KHR) #elif defined(VK_USE_PLATFORM_ANDROID_KHR)
@ -67,6 +68,7 @@ public:
#elif defined(_DIRECT2DISPLAY) #elif defined(_DIRECT2DISPLAY)
void initSurface(uint32_t width, uint32_t height) void initSurface(uint32_t width, uint32_t height)
#endif #endif
void initSurface
{ {
VkResult err = VK_SUCCESS; VkResult err = VK_SUCCESS;
@ -112,6 +114,7 @@ public:
err = vkCreateXcbSurfaceKHR(instance, &surfaceCreateInfo, nullptr, &surface); err = vkCreateXcbSurfaceKHR(instance, &surfaceCreateInfo, nullptr, &surface);
#endif #endif
if (err != VK_SUCCESS) { if (err != VK_SUCCESS) {
std::cerr << "Could not create surface!" << std::endl; std::cerr << "Could not create surface!" << std::endl;
exit(err); exit(err);
@ -232,7 +235,7 @@ public:
} }
} }
*/
/** /**
* Set instance, physical and logical device to use for the swapchain and get all required function pointers * Set instance, physical and logical device to use for the swapchain and get all required function pointers
* *

View File

@ -10,17 +10,17 @@ const std::string getAssetPath()
return ""; return "";
#elif defined(VK_EXAMPLE_DATA_DIR) #elif defined(VK_EXAMPLE_DATA_DIR)
if (_access("./../data/", 0) != -1) if (std::filesystem::exists("./../data/"))
{ {
return "./../data/"; return "./../data/";
} }
else if (_access("./data/", 0) != -1) else if (std::filesystem::exists("./data/"))
{ {
return "./data/"; return "./data/";
} }
else if (_access("./../../data/", 0) != -1) else if (std::filesystem::exists("./../../data/"))
{ {
return "../../data/"; return "../../data/";
@ -28,7 +28,7 @@ const std::string getAssetPath()
else else
{ {
return VK_EXAMPLE_DATA_DIR; return std::filesystem::path(VK_EXAMPLE_DATA_DIR);
} }
#endif #endif

View File

@ -16,6 +16,7 @@
#include <stdexcept> #include <stdexcept>
#include <fstream> #include <fstream>
#include <algorithm> #include <algorithm>
#include <filesystem>
#if defined(_WIN32) #if defined(_WIN32)
#include <windows.h> #include <windows.h>
#include <fcntl.h> #include <fcntl.h>

View File

@ -107,6 +107,7 @@ VkPipelineShaderStageCreateInfo loadShader(VkDevice device, std::string filename
return shaderStage; return shaderStage;
} }
/*
void readDirectory(const std::string& directory, const std::string &pattern, std::map<std::string, std::string> &filelist, bool recursive) void readDirectory(const std::string& directory, const std::string &pattern, std::map<std::string, std::string> &filelist, bool recursive)
{ {
#if defined(VK_USE_PLATFORM_ANDROID_KHR) #if defined(VK_USE_PLATFORM_ANDROID_KHR)
@ -174,3 +175,4 @@ void readDirectory(const std::string& directory, const std::string &pattern, std
closedir(dir); closedir(dir);
#endif #endif
} }
*/

View File

@ -482,24 +482,12 @@ void VulkanExampleBase::initVulkan()
std::cerr << "Could not enumerate physical devices!" << std::endl; std::cerr << "Could not enumerate physical devices!" << std::endl;
exit(err); exit(err);
} }
uint32_t selectedDevice = 0; uint32_t selectedDevice = settings.selectedPhysicalDeviceIndex;
#if !defined(VK_USE_PLATFORM_ANDROID_KHR) if (settings.selectedPhysicalDeviceIndex > gpuCount)
for (size_t i = 0; i < args.size(); i++) { {
if ((args[i] == std::string("-g")) || (args[i] == std::string("--gpu"))) { std::cerr << "wrong GPU selection,check selectedPhysicalDeviceIndex in config file,fallback to 0" << std::endl;
char* endptr; selectedDevice = 0;
selectedPhysicalDeviceIndex = strtol(args[i + 1], &endptr, 10);
if (endptr != args[i + 1]) {
if (selectedPhysicalDeviceIndex > gpuCount - 1) {
std::cerr << "Selected device index " << selectedPhysicalDeviceIndex << " is out of range, reverting to device 0 (use -listgpus to show available Vulkan devices)" << std::endl;
} else {
std::cout << "Selected Vulkan device " << selectedPhysicalDeviceIndex << std::endl;
selectedDevice = selectedPhysicalDeviceIndex;
}
};
break;
}
} }
#endif
physicalDevice = physicalDevices[selectedDevice]; physicalDevice = physicalDevices[selectedDevice];
@ -790,7 +778,10 @@ void VulkanExampleBase::initSwapchain()
*/ */
} }
/*
void VulkanExampleBase::setupSwapChain() void VulkanExampleBase::setupSwapChain()
{ {
//swapChain.create(&width, &height, settings.vsync); //swapChain.create(&width, &height, settings.vsync);
} }
*/

BIN
render 100644

Binary file not shown.

View File

@ -223,10 +223,10 @@ PlumageRender::PlumageRender()
{ {
const std::string assetpath = getAssetPath(); const std::string assetpath = getAssetPath();
if (_access(assetpath.c_str(),0) != 0) { if (!std::filesystem::exists(assetpath.c_str())) {
std::string msg = "Could not locate asset path in \"" + assetpath + "\".\nMake sure binary is running from correct relative directory!"; std::string msg = "Could not locate asset path in \"" + assetpath + "\".\nMake sure binary is running from correct relative directory!";
std::cerr << msg << std::endl; std::cerr << msg << std::endl;
system("pause"); //system("pause");
//exit(-1); //exit(-1);
} }
else { else {
@ -234,7 +234,7 @@ PlumageRender::PlumageRender()
std::cout << msg << std::endl; std::cout << msg << std::endl;
} }
readDirectory(assetpath + "environments", "*.ktx", environments, false); //readDirectory(assetpath + "environments", "*.ktx", environments, false);
textures.empty.loadFromFile(PlumageRender::filePath.emptyEnvmapFilePath, VK_FORMAT_R8G8B8A8_UNORM, vulkanDevice, queue); textures.empty.loadFromFile(PlumageRender::filePath.emptyEnvmapFilePath, VK_FORMAT_R8G8B8A8_UNORM, vulkanDevice, queue);
@ -1847,7 +1847,7 @@ PlumageRender::PlumageRender()
removeImageSequence(); removeImageSequence();
} }
filePath.deviceSpecFilePath = filePath.imageOutputPath + "/device" + std::to_string(selectedPhysicalDeviceIndex); filePath.deviceSpecFilePath = filePath.imageOutputPath + "/device" + std::to_string(settings.selectedPhysicalDeviceIndex);
if (savedFrameCounter > settings.endFrameIndex) if (savedFrameCounter > settings.endFrameIndex)
{ {
@ -1871,7 +1871,7 @@ PlumageRender::PlumageRender()
filePath.totalImageOutputPath = filePath.deviceSpecFilePath + fileName; filePath.totalImageOutputPath = filePath.deviceSpecFilePath + fileName;
return; return;
} }
if (_access(filePath.deviceSpecFilePath.c_str(), 0) == -1) if (std::filesystem::exists(filePath.deviceSpecFilePath.c_str()))
{ {
std::filesystem::create_directories(filePath.deviceSpecFilePath.c_str()); std::filesystem::create_directories(filePath.deviceSpecFilePath.c_str());
} }
@ -1901,8 +1901,8 @@ PlumageRender::PlumageRender()
{ {
return; return;
} }
std::string deviceFilePath = filePath.videoOutputPath + "/device" + std::to_string(selectedPhysicalDeviceIndex); std::string deviceFilePath = filePath.videoOutputPath + "/device" + std::to_string(settings.selectedPhysicalDeviceIndex);
if (_access(deviceFilePath.c_str(), 0) == -1) if (std::filesystem::exists(deviceFilePath.c_str()))
{ {
std::filesystem::create_directories(deviceFilePath.c_str()); std::filesystem::create_directories(deviceFilePath.c_str());
} }
@ -2076,7 +2076,7 @@ PlumageRender::PlumageRender()
buildCommandBuffers(); buildCommandBuffers();
} }
/*
void PlumageRender::updateUIOverlay() void PlumageRender::updateUIOverlay()
{ {
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
@ -2290,13 +2290,13 @@ PlumageRender::PlumageRender()
} }
*/
PlumageRender* plumageRender; PlumageRender* plumageRender;
// OS specific macros for the example main entry points // OS specific macros for the example main entry points
int main() int main(int argc, char* argv[])
{ {
for (int32_t i = 0; i < __argc; i++) { PlumageRender::args.push_back(__argv[i]); }; for (int32_t i = 0; i < argc; i++) { PlumageRender::args.push_back(argv[i]); };
plumageRender = new PlumageRender(); plumageRender = new PlumageRender();
std::cout << "start to init vulkan" << std::endl; std::cout << "start to init vulkan" << std::endl;
plumageRender->initVulkan(); plumageRender->initVulkan();

View File

@ -296,7 +296,7 @@ public:
void prepareUniformBuffers(); void prepareUniformBuffers();
void updateUniformBuffers(); void updateUniformBuffers();
void updateShaderData(); void updateShaderData();
void windowResized(); //void windowResized();
void prepare(); void prepare();
void submitWork(VkCommandBuffer cmdBuffer, VkQueue queue); void submitWork(VkCommandBuffer cmdBuffer, VkQueue queue);
@ -307,6 +307,6 @@ public:
//void outputScreenShot(); //void outputScreenShot();
uint32_t getMemoryTypeIndex(uint32_t typeBits, VkMemoryPropertyFlags properties); uint32_t getMemoryTypeIndex(uint32_t typeBits, VkMemoryPropertyFlags properties);
virtual void render(); virtual void render();
virtual void updateUIOverlay(); //virtual void updateUIOverlay();
virtual void fileDropped(std::string filename); virtual void fileDropped(std::string filename);
}; };