-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvulkan_ubo.hpp
More file actions
43 lines (33 loc) · 1.2 KB
/
Copy pathvulkan_ubo.hpp
File metadata and controls
43 lines (33 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/* SimShip by Edouard Halbert
This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License
http://creativecommons.org/licenses/by-nc-nd/4.0/ */
#pragma once
// 1. PROJECT
#include "vulkan_device.hpp"
// 2. LIB
#include <vulkan/vulkan.h>
// 3. WIN
#include <iostream>
#include <fstream>
#include <stdexcept>
using namespace std;
class VulkanUBO
{
public:
VulkanUBO(shared_ptr<VulkanDevice>& vulkanDevice, VkDeviceSize size, VkBufferUsageFlags usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT);
~VulkanUBO();
void Flush();
VkDeviceSize GetSize() const { return mSize; }
shared_ptr<VulkanDevice> mVulkanDevice;
VkDeviceSize mSize;
VkBuffer buffer = nullptr;
VkDeviceMemory memory = nullptr;
void * data = nullptr; // Pointeur mapped
bool hasCoherentMemory = false;
private:
void CreateBuffer(VkBufferUsageFlags usage);
uint32_t FindMemoryType(uint32_t typeFilter, VkMemoryPropertyFlags properties);
void HasCoherentMemory();
uint32_t GetMemoryTypeIndex();
VkDeviceSize GetAlignedSize(VkDeviceSize size);
};