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.

106 lines
2.5 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>
4 months ago
#include <map>
#include <glm/vec2.hpp>
4 months ago
#include "constraints.hpp"
#include <glm/mat4x4.hpp>
4 months ago
#include <glm/vec3.hpp>
4 months ago
using std::unique_ptr, std::make_unique;
using std::vector;
4 months ago
class SoftBody;
class Instance;
class Swapchain;
class GraphicsPipeline;
class Buffer;
class CommandPool;
4 months ago
class Image;
4 months ago
class ComputePipeline;
4 months ago
class Fence;
class Semaphore;
4 months ago
class Camera;
class DescriptorPool;
class Grabber;
class Application {
public:
explicit Application();
void mainLoop();
~Application();
4 months ago
private:
void imGuiWindows();
struct PerformanceInformation {
float totalUpdateDuration;
float updateDuration;
float frameDuration;
} performanceInformation {};
4 months ago
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;
4 months ago
unique_ptr<Swapchain> swapchain;
unique_ptr<DescriptorPool> descriptorPool;
unique_ptr<GraphicsPipeline> graphicsPipeline;
unique_ptr<Buffer> cameraUniformBuffer;
unique_ptr<Image> firstImage;
4 months ago
unique_ptr<Camera> camera;
unique_ptr<Grabber> grabber;
unique_ptr<Buffer> grabBuffer;
4 months ago
void createMeshBuffers();
size_t currentDrawVertexBuffer = 0;
unique_ptr<Buffer> vertexBuffers[2];
4 months ago
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;
4 months ago
void createComputePipelines();
unique_ptr<ComputePipeline> grabPipeline;
4 months ago
unique_ptr<ComputePipeline> pbdPipeline;
unique_ptr<ComputePipeline> normalPipeline;
void updateCameraBuffer();
void recordDrawCommands(VkCommandBuffer commandBuffer);
void drawFrame(float dt);
4 months ago
void recordGrabCommands(VkCommandBuffer commandBuffer);
void recordPBDCommands(VkCommandBuffer commandBuffer);
void recordNormalCommands(VkCommandBuffer commandBuffer);
void computePipelineBarrier(VkCommandBuffer commandBuffer);
4 months ago
void update();
static uint32_t GetGroupCount(uint32_t threads, uint32_t blockSize);
};