You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

109 lines
2.6 KiB

#pragma once
#include <GLFW/glfw3.h>
#include <iostream>
#include <vector>
#include <cstring>
#include <optional>
#include <set>
#include <fstream>
#include <numeric>
#include <chrono>
#include <array>
#include <memory>
#include <vulkan/vulkan_core.h>
#include <map>
#include <glm/vec2.hpp>
#include "constraints.hpp"
#include "fixed_list.hpp"
#include <glm/mat4x4.hpp>
#include <glm/vec3.hpp>
#include <list>
using std::unique_ptr, std::make_unique;
using std::vector;
class SoftBody;
class Instance;
class Swapchain;
class GraphicsPipeline;
class Buffer;
class CommandPool;
class Image;
class ComputePipeline;
class Fence;
class Semaphore;
class Camera;
class DescriptorPool;
class Grabber;
class Application {
public:
explicit Application();
void mainLoop();
~Application();
private:
void imGuiWindows();
struct PerformanceInformation {
static const size_t saves = 30;
FixedList recentTotalUpdateDurations = FixedList(saves);
float updateDuration;
FixedList recentFrameDurations = FixedList(saves);
} performanceInformation;
void createSyncObjects();
unique_ptr<Semaphore> imageAvailable;
unique_ptr<Semaphore> renderSemaphore;
unique_ptr<Semaphore> computeSemaphore;
unique_ptr<Semaphore> transferSemaphore;
unique_ptr<Fence> renderFence;
unique_ptr<Fence> computeFence;
unique_ptr<Fence> transferFence;
std::mutex submitMutex;
unique_ptr<Swapchain> swapchain;
unique_ptr<DescriptorPool> descriptorPool;
unique_ptr<GraphicsPipeline> graphicsPipeline;
unique_ptr<Buffer> cameraUniformBuffer;
unique_ptr<Image> firstImage;
unique_ptr<Camera> camera;
unique_ptr<Grabber> grabber;
unique_ptr<Buffer> grabBuffer;
void createMeshBuffers();
size_t currentDrawVertexBuffer = 0;
unique_ptr<Buffer> vertexBuffers[2];
unique_ptr<Buffer> faceBuffer;
unique_ptr<Buffer> edgeBuffer;
unique_ptr<Buffer> triangleBuffer;
unique_ptr<Buffer> tetrahedronBuffer;
ConstraintData constraintData {};
vector<unique_ptr<SoftBody>> softBodies;
unique_ptr<Buffer> sizeInformationBuffer;
unique_ptr<Buffer> simulationPropertiesBuffer;
void createComputePipelines();
unique_ptr<ComputePipeline> grabPipeline;
unique_ptr<ComputePipeline> pbdPipeline;
unique_ptr<ComputePipeline> normalPipeline;
void updateCameraBuffer();
void recordDrawCommands(VkCommandBuffer commandBuffer);
void drawFrame(float dt);
void recordGrabCommands(VkCommandBuffer commandBuffer);
void recordPBDCommands(VkCommandBuffer commandBuffer);
void recordNormalCommands(VkCommandBuffer commandBuffer);
void computePipelineBarrier(VkCommandBuffer commandBuffer);
void update();
static uint32_t GetGroupCount(uint32_t threads, uint32_t blockSize);
};