clean unused dependency
							parent
							
								
									d8c13ea6ca
								
							
						
					
					
						commit
						befeda7cff
					
				| 
						 | 
				
			
			@ -1,117 +0,0 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Simple command line parse
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (C) 2016-2022 by Sascha Willems - www.saschawillems.de
 | 
			
		||||
 *
 | 
			
		||||
 * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include <vector>
 | 
			
		||||
#include <unordered_map>
 | 
			
		||||
#include <string>
 | 
			
		||||
 | 
			
		||||
class CommandLineParser
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
	struct CommandLineOption {
 | 
			
		||||
		std::vector<std::string> commands;
 | 
			
		||||
		std::string value;
 | 
			
		||||
		bool hasValue = false;
 | 
			
		||||
		std::string help;
 | 
			
		||||
		bool set = false;
 | 
			
		||||
	};
 | 
			
		||||
	std::unordered_map<std::string, CommandLineOption> options;
 | 
			
		||||
 | 
			
		||||
	void add(std::string name, std::vector<std::string> commands, bool hasValue, std::string help)
 | 
			
		||||
	{
 | 
			
		||||
		options[name].commands = commands;
 | 
			
		||||
		options[name].help = help;
 | 
			
		||||
		options[name].set = false;
 | 
			
		||||
		options[name].hasValue = hasValue;
 | 
			
		||||
		options[name].value = "";
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	void printHelp()
 | 
			
		||||
	{
 | 
			
		||||
		std::cout << "Available command line options:\n";
 | 
			
		||||
		for (auto option : options) {
 | 
			
		||||
			std::cout << " ";
 | 
			
		||||
			for (size_t i = 0; i < option.second.commands.size(); i++) {
 | 
			
		||||
				std::cout << option.second.commands[i];
 | 
			
		||||
				if (i < option.second.commands.size() - 1) {
 | 
			
		||||
					std::cout << ", ";
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			std::cout << ": " << option.second.help << "\n";
 | 
			
		||||
		}
 | 
			
		||||
		std::cout << "Press any key to close...";
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	void parse(std::vector<const char*> arguments)
 | 
			
		||||
	{
 | 
			
		||||
		bool printHelp = false;
 | 
			
		||||
		// Known arguments
 | 
			
		||||
		for (auto& option : options) {
 | 
			
		||||
			for (auto& command : option.second.commands) {
 | 
			
		||||
				for (size_t i = 0; i < arguments.size(); i++) {
 | 
			
		||||
					if (strcmp(arguments[i], command.c_str()) == 0) {
 | 
			
		||||
						option.second.set = true;
 | 
			
		||||
						// Get value
 | 
			
		||||
						if (option.second.hasValue) {
 | 
			
		||||
							if (arguments.size() > i + 1) {
 | 
			
		||||
								option.second.value = arguments[i + 1];
 | 
			
		||||
							}
 | 
			
		||||
							if (option.second.value == "") {
 | 
			
		||||
								printHelp = true;
 | 
			
		||||
								break;
 | 
			
		||||
							}
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		// Print help for unknown arguments or missing argument values
 | 
			
		||||
		if (printHelp) {
 | 
			
		||||
			options["help"].set = true;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	void parse(int argc, char* argv[])
 | 
			
		||||
	{
 | 
			
		||||
		std::vector<const char*> args;
 | 
			
		||||
		for (int i = 0; i < argc; i++) { 
 | 
			
		||||
			args.push_back(argv[i]); 
 | 
			
		||||
		};
 | 
			
		||||
		parse(args);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	bool isSet(std::string name)
 | 
			
		||||
	{
 | 
			
		||||
		return ((options.find(name) != options.end()) && options[name].set);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	std::string getValueAsString(std::string name, std::string defaultValue)
 | 
			
		||||
	{
 | 
			
		||||
		assert(options.find(name) != options.end());
 | 
			
		||||
		std::string value = options[name].value;
 | 
			
		||||
		return (value != "") ? value : defaultValue;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	int32_t getValueAsInt(std::string name, int32_t defaultValue)
 | 
			
		||||
	{
 | 
			
		||||
		assert(options.find(name) != options.end());
 | 
			
		||||
		std::string value = options[name].value;
 | 
			
		||||
		if (value != "") {
 | 
			
		||||
			char* numConvPtr;
 | 
			
		||||
			int32_t intVal = strtol(value.c_str(), &numConvPtr, 10);
 | 
			
		||||
			return (intVal > 0) ? intVal : defaultValue;
 | 
			
		||||
		}
 | 
			
		||||
		else {
 | 
			
		||||
			return defaultValue;
 | 
			
		||||
		}
 | 
			
		||||
		return int32_t();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			@ -1,10 +1,3 @@
 | 
			
		|||
/*
 | 
			
		||||
* Assorted commonly used Vulkan helper functions
 | 
			
		||||
*
 | 
			
		||||
* Copyright (C) 2016 by Sascha Willems - www.saschawillems.de
 | 
			
		||||
*
 | 
			
		||||
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#include "VulkanTools.h"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,10 +1,3 @@
 | 
			
		|||
/*
 | 
			
		||||
* Assorted Vulkan helper functions
 | 
			
		||||
*
 | 
			
		||||
* Copyright (C) 2016 by Sascha Willems - www.saschawillems.de
 | 
			
		||||
*
 | 
			
		||||
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,104 +0,0 @@
 | 
			
		|||
/*
 | 
			
		||||
* Benchmark class
 | 
			
		||||
*
 | 
			
		||||
* Copyright (C) 2016-2017 by Sascha Willems - www.saschawillems.de
 | 
			
		||||
*
 | 
			
		||||
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#include <vector>
 | 
			
		||||
#include <string>
 | 
			
		||||
#include <algorithm>
 | 
			
		||||
#include <limits>
 | 
			
		||||
#include <functional>
 | 
			
		||||
#include <chrono>
 | 
			
		||||
#include <iomanip>
 | 
			
		||||
 | 
			
		||||
namespace vks
 | 
			
		||||
{
 | 
			
		||||
	class Benchmark {
 | 
			
		||||
	private:
 | 
			
		||||
		FILE *stream;
 | 
			
		||||
		VkPhysicalDeviceProperties deviceProps;
 | 
			
		||||
	public:
 | 
			
		||||
		bool active = false;
 | 
			
		||||
		bool outputFrameTimes = false;
 | 
			
		||||
		int outputFrames = -1; // -1 means no frames limit
 | 
			
		||||
		uint32_t warmup = 1;
 | 
			
		||||
		uint32_t duration = 10;
 | 
			
		||||
		std::vector<double> frameTimes;
 | 
			
		||||
		std::string filename = "";
 | 
			
		||||
 | 
			
		||||
		double runtime = 0.0;
 | 
			
		||||
		uint32_t frameCount = 0;
 | 
			
		||||
 | 
			
		||||
		void run(std::function<void()> renderFunc, VkPhysicalDeviceProperties deviceProps) {
 | 
			
		||||
			active = true;
 | 
			
		||||
			this->deviceProps = deviceProps;
 | 
			
		||||
#if defined(_WIN32)
 | 
			
		||||
			AttachConsole(ATTACH_PARENT_PROCESS);
 | 
			
		||||
			freopen_s(&stream, "CONOUT$", "w+", stdout);
 | 
			
		||||
			freopen_s(&stream, "CONOUT$", "w+", stderr);
 | 
			
		||||
#endif
 | 
			
		||||
			std::cout << std::fixed << std::setprecision(3);
 | 
			
		||||
 | 
			
		||||
			// Warm up phase to get more stable frame rates
 | 
			
		||||
			{
 | 
			
		||||
				double tMeasured = 0.0;
 | 
			
		||||
				while (tMeasured < (warmup * 1000)) {
 | 
			
		||||
					auto tStart = std::chrono::high_resolution_clock::now();
 | 
			
		||||
					renderFunc();
 | 
			
		||||
					auto tDiff = std::chrono::duration<double, std::milli>(std::chrono::high_resolution_clock::now() - tStart).count();
 | 
			
		||||
					tMeasured += tDiff;
 | 
			
		||||
				};
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			// Benchmark phase
 | 
			
		||||
			{
 | 
			
		||||
				while (runtime < (duration * 1000.0)) {
 | 
			
		||||
					auto tStart = std::chrono::high_resolution_clock::now();
 | 
			
		||||
					renderFunc();
 | 
			
		||||
					auto tDiff = std::chrono::duration<double, std::milli>(std::chrono::high_resolution_clock::now() - tStart).count();
 | 
			
		||||
					runtime += tDiff;
 | 
			
		||||
					frameTimes.push_back(tDiff);
 | 
			
		||||
					frameCount++;
 | 
			
		||||
					if (outputFrames != -1 && outputFrames == frameCount) break;
 | 
			
		||||
				};
 | 
			
		||||
				std::cout << "Benchmark finished" << "\n";
 | 
			
		||||
				std::cout << "device : " << deviceProps.deviceName << " (driver version: " << deviceProps.driverVersion << ")" << "\n";
 | 
			
		||||
				std::cout << "runtime: " << (runtime / 1000.0) << "\n";
 | 
			
		||||
				std::cout << "frames : " << frameCount << "\n";
 | 
			
		||||
				std::cout << "fps    : " << frameCount / (runtime / 1000.0) << "\n";
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		void saveResults() {
 | 
			
		||||
			std::ofstream result(filename, std::ios::out);
 | 
			
		||||
			if (result.is_open()) {
 | 
			
		||||
				result << std::fixed << std::setprecision(4);
 | 
			
		||||
 | 
			
		||||
				result << "device,driverversion,duration (ms),frames,fps" << "\n";
 | 
			
		||||
				result << deviceProps.deviceName << "," << deviceProps.driverVersion << "," << runtime << "," << frameCount << "," << frameCount / (runtime / 1000.0) << "\n";
 | 
			
		||||
 | 
			
		||||
				if (outputFrameTimes) {
 | 
			
		||||
					result << "\n" << "frame,ms" << "\n";
 | 
			
		||||
					for (size_t i = 0; i < frameTimes.size(); i++) {
 | 
			
		||||
						result << i << "," << frameTimes[i] << "\n";
 | 
			
		||||
					}
 | 
			
		||||
					double tMin = *std::min_element(frameTimes.begin(), frameTimes.end());
 | 
			
		||||
					double tMax = *std::max_element(frameTimes.begin(), frameTimes.end());
 | 
			
		||||
					double tAvg = std::accumulate(frameTimes.begin(), frameTimes.end(), 0.0) / (double)frameTimes.size();
 | 
			
		||||
					std::cout << "best   : " << (1000.0 / tMin) << " fps (" << tMin << " ms)" << "\n";
 | 
			
		||||
					std::cout << "worst  : " << (1000.0 / tMax) << " fps (" << tMax << " ms)" << "\n";
 | 
			
		||||
					std::cout << "avg    : " << (1000.0 / tAvg) << " fps (" << tAvg << " ms)" << "\n";
 | 
			
		||||
					std::cout << "\n";
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				result.flush();
 | 
			
		||||
#if defined(_WIN32)
 | 
			
		||||
				FreeConsole();
 | 
			
		||||
#endif
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	};
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,121 +0,0 @@
 | 
			
		|||
/*
 | 
			
		||||
* Basic C++11 based thread pool with per-thread job queues
 | 
			
		||||
*
 | 
			
		||||
* Copyright (C) 2016 by Sascha Willems - www.saschawillems.de
 | 
			
		||||
*
 | 
			
		||||
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#include <vector>
 | 
			
		||||
#include <thread>
 | 
			
		||||
#include <queue>
 | 
			
		||||
#include <mutex>
 | 
			
		||||
#include <condition_variable>
 | 
			
		||||
#include <functional>
 | 
			
		||||
 | 
			
		||||
// make_unique is not available in C++11
 | 
			
		||||
// Taken from Herb Sutter's blog (https://herbsutter.com/gotw/_102/)
 | 
			
		||||
template<typename T, typename ...Args>
 | 
			
		||||
std::unique_ptr<T> make_unique(Args&& ...args)
 | 
			
		||||
{
 | 
			
		||||
	return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
namespace vks
 | 
			
		||||
{
 | 
			
		||||
	class Thread
 | 
			
		||||
	{
 | 
			
		||||
	private:
 | 
			
		||||
		bool destroying = false;
 | 
			
		||||
		std::thread worker;
 | 
			
		||||
		std::queue<std::function<void()>> jobQueue;
 | 
			
		||||
		std::mutex queueMutex;
 | 
			
		||||
		std::condition_variable condition;
 | 
			
		||||
 | 
			
		||||
		// Loop through all remaining jobs
 | 
			
		||||
		void queueLoop()
 | 
			
		||||
		{
 | 
			
		||||
			while (true)
 | 
			
		||||
			{
 | 
			
		||||
				std::function<void()> job;
 | 
			
		||||
				{
 | 
			
		||||
					std::unique_lock<std::mutex> lock(queueMutex);
 | 
			
		||||
					condition.wait(lock, [this] { return !jobQueue.empty() || destroying; });
 | 
			
		||||
					if (destroying)
 | 
			
		||||
					{
 | 
			
		||||
						break;
 | 
			
		||||
					}
 | 
			
		||||
					job = jobQueue.front();
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				job();
 | 
			
		||||
 | 
			
		||||
				{
 | 
			
		||||
					std::lock_guard<std::mutex> lock(queueMutex);
 | 
			
		||||
					jobQueue.pop();
 | 
			
		||||
					condition.notify_one();
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	public:
 | 
			
		||||
		Thread()
 | 
			
		||||
		{
 | 
			
		||||
			worker = std::thread(&Thread::queueLoop, this);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		~Thread()
 | 
			
		||||
		{
 | 
			
		||||
			if (worker.joinable())
 | 
			
		||||
			{
 | 
			
		||||
				wait();
 | 
			
		||||
				queueMutex.lock();
 | 
			
		||||
				destroying = true;
 | 
			
		||||
				condition.notify_one();
 | 
			
		||||
				queueMutex.unlock();
 | 
			
		||||
				worker.join();
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Add a new job to the thread's queue
 | 
			
		||||
		void addJob(std::function<void()> function)
 | 
			
		||||
		{
 | 
			
		||||
			std::lock_guard<std::mutex> lock(queueMutex);
 | 
			
		||||
			jobQueue.push(std::move(function));
 | 
			
		||||
			condition.notify_one();
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Wait until all work items have been finished
 | 
			
		||||
		void wait()
 | 
			
		||||
		{
 | 
			
		||||
			std::unique_lock<std::mutex> lock(queueMutex);
 | 
			
		||||
			condition.wait(lock, [this]() { return jobQueue.empty(); });
 | 
			
		||||
		}
 | 
			
		||||
	};
 | 
			
		||||
	
 | 
			
		||||
	class ThreadPool
 | 
			
		||||
	{
 | 
			
		||||
	public:
 | 
			
		||||
		std::vector<std::unique_ptr<Thread>> threads;
 | 
			
		||||
 | 
			
		||||
		// Sets the number of threads to be allocated in this pool
 | 
			
		||||
		void setThreadCount(uint32_t count)
 | 
			
		||||
		{
 | 
			
		||||
			threads.clear();
 | 
			
		||||
			for (auto i = 0; i < count; i++)
 | 
			
		||||
			{
 | 
			
		||||
				threads.push_back(make_unique<Thread>());
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Wait until all threads have finished their work items
 | 
			
		||||
		void wait()
 | 
			
		||||
		{
 | 
			
		||||
			for (auto &thread : threads)
 | 
			
		||||
			{
 | 
			
		||||
				thread->wait();
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -29,6 +29,7 @@
 | 
			
		|||
	glTFModel::BoundingBox::BoundingBox(glm::vec3 min, glm::vec3 max) : min(min), max(max) {
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	//Axis-Aligned Bounding Box),¼ò³Æ AABB
 | 
			
		||||
	glTFModel::BoundingBox glTFModel::BoundingBox::getAABB(glm::mat4 m) {
 | 
			
		||||
		glm::vec3 min = glm::vec3(m[3]);
 | 
			
		||||
		glm::vec3 max = min;
 | 
			
		||||
| 
						 | 
				
			
			@ -53,7 +54,7 @@
 | 
			
		|||
		max += glm::max(v0, v1);
 | 
			
		||||
 | 
			
		||||
		return BoundingBox(min, max);
 | 
			
		||||
	}
 | 
			
		||||
	} 
 | 
			
		||||
 | 
			
		||||
	// Texture
 | 
			
		||||
	void glTFModel::Texture::updateDescriptor()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -93,7 +93,7 @@ public:
 | 
			
		|||
 | 
			
		||||
	struct FilePath
 | 
			
		||||
	{	//model path
 | 
			
		||||
		std::string glTFModelFilePath = getAssetPath() + "DamagedHelmet/DamagedHelmet.gltf";
 | 
			
		||||
		std::string glTFModelFilePath = getAssetPath() + "models/DamagedHelmet/DamagedHelmet.gltf";
 | 
			
		||||
		std::string modelVertShaderPath = getAssetPath() + "buster_drone/shaders/glsl/mesh.vert.spv";
 | 
			
		||||
		std::string modelFragShaderPath = getAssetPath() + "buster_drone/shaders/glsl/mesh.frag.spv";
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -296,7 +296,7 @@ public:
 | 
			
		|||
	void setupNodeDescriptorSet(glTFModel::Node* node);
 | 
			
		||||
	void setupDescriptors();
 | 
			
		||||
	void         preparePipelines();
 | 
			
		||||
	//void CreateToneMappingPipeline();
 | 
			
		||||
	// void tonemappingPipelin();
 | 
			
		||||
	void generateCubemaps();
 | 
			
		||||
	void generateBRDFLUT();
 | 
			
		||||
	void         prepareUniformBuffers();
 | 
			
		||||
| 
						 | 
				
			
			@ -305,7 +305,6 @@ public:
 | 
			
		|||
	void windowResized();
 | 
			
		||||
	void         prepare();
 | 
			
		||||
	virtual void render();
 | 
			
		||||
	//virtual void viewChanged();
 | 
			
		||||
	virtual void updateUIOverlay();
 | 
			
		||||
	virtual void fileDropped(std::string filename);
 | 
			
		||||
};
 | 
			
		||||
		Loading…
	
		Reference in New Issue