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.

104 lines
2.4 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:
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;
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;
3 months ago
struct SimulationUniformData {
4 months ago
glm::vec3 gravity;
// Delta time in seconds
4 months ago
float dt;
uint32_t k;
};
unique_ptr<Buffer> propertiesBuffer;
3 months ago
SimulationUniformData simulationUniformData {};
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 cmdBuffer);
void drawFrame(float dt);
4 months ago
void recordGrabCommands(VkCommandBuffer cmdBuffer);
void recordPBDCommands(VkCommandBuffer cmdBuffer);
void recordNormalCommands(VkCommandBuffer cmdBuffer);
4 months ago
void update();
static uint32_t GetGroupCount(uint32_t threads, uint32_t blockSize);
};