learn-vulkan/vk_types.h

83 lines
1.4 KiB
C++

// or project specific include files.
//we will add our main reusable types here
#pragma once
#include <vulkan/vulkan.h>
#include <memory>
#include <optional>
#include <string>
#include <vector>
#include <span>
#include <array>
#include <functional>
#include <deque>
// #include <vulkan/vk_enum_string_helper.h>
#include <vk_mem_alloc.h>
#include <print>
#define GLM_ENABLE_EXPERIMENTAL 1
#include <glm/mat4x4.hpp>
#include <glm/vec4.hpp>
#define VK_CHECK(x)\
do {\
VkResult err = x;\
if (err) {\
std::println("Detected Vulkan error: {}", int(err));\
}\
} while (0)
constexpr unsigned int FRAME_OVERLAP=2;
struct AllocatedBuffer {
VkBuffer buffer;
VmaAllocation allocation;
VmaAllocationInfo info;
};
struct AllocatedImage {
VkImage image;
VkImageView imageView;
VmaAllocation allocation;
VkExtent3D imageExtent;
VkFormat imageFormat;
};
struct ComputePushConstants {
glm::vec4 data1;
glm::vec4 data2;
glm::vec4 data3;
glm::vec4 data4;
};
struct ComputeEffect {
const char *name;
VkPipeline pipeline;
VkPipelineLayout layout;
ComputePushConstants data;
};
struct Vertex {
glm::vec3 position;
float uv_x;
glm::vec3 normal;
float uv_y;
glm::vec4 color;
};
struct GPUMeshBuffers {
AllocatedBuffer indexBuffer;
AllocatedBuffer vertexBuffer;
VkDeviceAddress vertexBufferAddress;
};
struct GPUDrawPushConstants {
glm::mat4 worldMatrix;
VkDeviceAddress vertexBuffer;
};