From 5bd007ddb75d9eaf3bff481402832c6c1460126c Mon Sep 17 00:00:00 2001 From: ink-soul Date: Wed, 17 Apr 2024 15:49:31 +0800 Subject: [PATCH] fix linux compile error --- CMakeSettings.json | 14 ++++++++++++++ base/VulkanSwapChain.hpp | 7 +++++-- base/VulkanTools.cpp | 2 +- base/VulkanUtils.hpp | 4 +++- base/vulkanexamplebase.cpp | 5 ++++- src/render/render.cpp | 22 +++++++++++----------- src/render/render.h | 4 ++-- 7 files changed, 40 insertions(+), 18 deletions(-) diff --git a/CMakeSettings.json b/CMakeSettings.json index 57eb7de..3160538 100644 --- a/CMakeSettings.json +++ b/CMakeSettings.json @@ -81,6 +81,20 @@ "rsyncCommandArgs": "-t --delete", "remoteCopyBuildOutput": false, "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": [] } ] } \ No newline at end of file diff --git a/base/VulkanSwapChain.hpp b/base/VulkanSwapChain.hpp index db1d452..13cd805 100644 --- a/base/VulkanSwapChain.hpp +++ b/base/VulkanSwapChain.hpp @@ -53,7 +53,8 @@ public: VkExtent2D extent = {}; 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) void initSurface(void* platformHandle, void* platformWindow) #elif defined(VK_USE_PLATFORM_ANDROID_KHR) @@ -67,6 +68,7 @@ public: #elif defined(_DIRECT2DISPLAY) void initSurface(uint32_t width, uint32_t height) #endif + void initSurface { VkResult err = VK_SUCCESS; @@ -112,6 +114,7 @@ public: err = vkCreateXcbSurfaceKHR(instance, &surfaceCreateInfo, nullptr, &surface); #endif + if (err != VK_SUCCESS) { std::cerr << "Could not create surface!" << std::endl; exit(err); @@ -232,7 +235,7 @@ public: } } - +*/ /** * Set instance, physical and logical device to use for the swapchain and get all required function pointers * diff --git a/base/VulkanTools.cpp b/base/VulkanTools.cpp index f78ad73..ff1cefa 100644 --- a/base/VulkanTools.cpp +++ b/base/VulkanTools.cpp @@ -28,7 +28,7 @@ const std::string getAssetPath() else { - return VK_EXAMPLE_DATA_DIR; + return std::filesystem::path(VK_EXAMPLE_DATA_DIR); } #endif diff --git a/base/VulkanUtils.hpp b/base/VulkanUtils.hpp index 74fd425..a191a73 100644 --- a/base/VulkanUtils.hpp +++ b/base/VulkanUtils.hpp @@ -107,6 +107,7 @@ VkPipelineShaderStageCreateInfo loadShader(VkDevice device, std::string filename return shaderStage; } +/* void readDirectory(const std::string& directory, const std::string &pattern, std::map &filelist, bool recursive) { #if defined(VK_USE_PLATFORM_ANDROID_KHR) @@ -173,4 +174,5 @@ void readDirectory(const std::string& directory, const std::string &pattern, std } closedir(dir); #endif -} \ No newline at end of file +} +*/ \ No newline at end of file diff --git a/base/vulkanexamplebase.cpp b/base/vulkanexamplebase.cpp index 1cb0fd5..5ccee60 100644 --- a/base/vulkanexamplebase.cpp +++ b/base/vulkanexamplebase.cpp @@ -391,7 +391,7 @@ VulkanExampleBase::VulkanExampleBase() VulkanExampleBase::~VulkanExampleBase() { // Clean up Vulkan resources - swapChain.cleanup(); + //swapChain.cleanup(); vkDestroyDescriptorPool(device, descriptorPool, nullptr); vkDestroyRenderPass(device, renderPass, nullptr); for (uint32_t i = 0; i < frameBuffers.size(); i++) { @@ -777,7 +777,10 @@ void VulkanExampleBase::initSwapchain() */ } +/* + void VulkanExampleBase::setupSwapChain() { swapChain.create(&width, &height, settings.vsync); } +*/ diff --git a/src/render/render.cpp b/src/render/render.cpp index b017814..3054655 100644 --- a/src/render/render.cpp +++ b/src/render/render.cpp @@ -223,10 +223,10 @@ PlumageRender::PlumageRender() { 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::cerr << msg << std::endl; - system("pause"); + //system("pause"); //exit(-1); } else { @@ -234,7 +234,7 @@ PlumageRender::PlumageRender() 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); @@ -1847,7 +1847,7 @@ PlumageRender::PlumageRender() removeImageSequence(); } - filePath.deviceSpecFilePath = filePath.imageOutputPath + "/device" + std::to_string(selectedPhysicalDeviceIndex); + filePath.deviceSpecFilePath = filePath.imageOutputPath + "/device" + std::to_string(settings.selectedPhysicalDeviceIndex); if (savedFrameCounter > settings.outputFrameCount) { @@ -1871,7 +1871,7 @@ PlumageRender::PlumageRender() filePath.totalImageOutputPath = filePath.deviceSpecFilePath + fileName; 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()); } @@ -1901,8 +1901,8 @@ PlumageRender::PlumageRender() { return; } - std::string deviceFilePath = filePath.videoOutputPath + "/device" + std::to_string(selectedPhysicalDeviceIndex); - if (_access(deviceFilePath.c_str(), 0) == -1) + std::string deviceFilePath = filePath.videoOutputPath + "/device" + std::to_string(settings.selectedPhysicalDeviceIndex); + if (std::filesystem::exists(deviceFilePath.c_str())) { std::filesystem::create_directories(deviceFilePath.c_str()); } @@ -2076,7 +2076,7 @@ PlumageRender::PlumageRender() buildCommandBuffers(); } - + /* void PlumageRender::updateUIOverlay() { ImGuiIO& io = ImGui::GetIO(); @@ -2290,13 +2290,13 @@ PlumageRender::PlumageRender() } - + */ PlumageRender* plumageRender; // 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(); std::cout << "start to init vulkan" << std::endl; plumageRender->initVulkan(); diff --git a/src/render/render.h b/src/render/render.h index 119bae7..a4e4dad 100644 --- a/src/render/render.h +++ b/src/render/render.h @@ -348,7 +348,7 @@ public: void prepareUniformBuffers(); void updateUniformBuffers(); void updateShaderData(); - void windowResized(); + //void windowResized(); void prepare(); void submitWork(VkCommandBuffer cmdBuffer, VkQueue queue); @@ -359,6 +359,6 @@ public: //void outputScreenShot(); uint32_t getMemoryTypeIndex(uint32_t typeBits, VkMemoryPropertyFlags properties); virtual void render(); - virtual void updateUIOverlay(); + //virtual void updateUIOverlay(); virtual void fileDropped(std::string filename); }; \ No newline at end of file