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.
69 lines
1.5 KiB
69 lines
1.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>
|
|
|
|
class Instance;
|
|
class Swapchain;
|
|
class Pipeline;
|
|
class Buffer;
|
|
class CommandPool;
|
|
class Image;
|
|
class ComputePipeline;
|
|
|
|
class Timer {
|
|
public:
|
|
explicit Timer(){
|
|
start = std::chrono::system_clock::now();
|
|
}
|
|
~Timer(){
|
|
size_t nanoseconds = (std::chrono::system_clock::now() - start).count();
|
|
printf("Timer: %zu mus\n", nanoseconds / 1000);
|
|
}
|
|
private:
|
|
std::chrono::time_point<std::chrono::system_clock> start;
|
|
};
|
|
|
|
class Application {
|
|
public:
|
|
explicit Application();
|
|
void mainLoop();
|
|
~Application();
|
|
private:
|
|
Swapchain* swapchain = nullptr;
|
|
Pipeline* graphicsPipeline = nullptr;
|
|
Buffer* vertexBuffer = nullptr;
|
|
Buffer* indexBuffer = nullptr;
|
|
Buffer* uniformBuffer = nullptr;
|
|
CommandPool* commandPool = nullptr;
|
|
|
|
ComputePipeline* computePipeline = nullptr;
|
|
|
|
void* uniformBufferMapped = nullptr;
|
|
|
|
void updateUniformBuffer();
|
|
|
|
void recordCommandBuffer(VkCommandBuffer commandBuffer, uint32_t imageIndex);
|
|
void recordComputeCommandBuffer();
|
|
|
|
VkSemaphore imageAvailableSemaphore = VK_NULL_HANDLE;
|
|
VkSemaphore renderFinishedSemaphore = VK_NULL_HANDLE;
|
|
VkSemaphore computeFinishedSemaphore = VK_NULL_HANDLE;
|
|
VkFence renderInFlightFence = VK_NULL_HANDLE;
|
|
VkFence computeInFlightFence = VK_NULL_HANDLE;
|
|
|
|
void drawFrame();
|
|
void update();
|
|
void createSyncObjects();
|
|
};
|
|
|