10#define GLM_FORCE_RADIANS
12#define GLM_FORCE_DEFAULT_ALIGNED_GENTYPES
14#include <glm/gtc/matrix_transform.hpp>
85 VkVertexInputRate rate,
96 VkDeviceSize bufferSize =
sizeof(T)*data.size();
102 VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
103 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT
115 buffer = std::make_unique<Buffer>
119 VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT,
120 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT
123 buffer->copy(stagingBuffer, command);
134 VkDeviceSize bufferSize =
sizeof(T)*data.size();
136 if (bufferSize >
buffer->getVkDeviceSize())
138 buffer = std::make_unique<Buffer>
142 VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT,
143 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT
151 VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
152 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT
162 buffer->copy(stagingBuffer, command);
184 std::vector<glm::vec4> data,
185 VkVertexInputRate rate,
198 VkDeviceSize bufferSize =
sizeof(glm::vec4)*data.size();
204 VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
205 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT
217 buffer = std::make_unique<Buffer>
221 VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT,
222 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT
225 buffer->copy(stagingBuffer, command);
232 std::vector<glm::vec4> data
236 VkDeviceSize bufferSize =
sizeof(glm::vec4)*data.size();
238 if (bufferSize >
buffer->getVkDeviceSize())
240 buffer = std::make_unique<Buffer>
244 VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT,
245 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT
253 VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
254 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT
264 buffer->copy(stagingBuffer, command);
270 std::vector<VkVertexInputBindingDescription> bindingDescription{};
271 bindingDescription.resize(1);
272 bindingDescription[0].binding =
binding;
273 bindingDescription[0].stride =
sizeof(glm::vec4);
274 bindingDescription[0].inputRate =
inputRate;
275 return bindingDescription;
280 std::vector<VkVertexInputAttributeDescription> attributeDescriptions{};
281 attributeDescriptions.resize(1);
283 attributeDescriptions[0].binding =
binding;
285 attributeDescriptions[0].location =
location;
287 attributeDescriptions[0].format = VK_FORMAT_R32G32B32A32_SFLOAT;
289 attributeDescriptions[0].offset = 0;
291 return attributeDescriptions;
306 std::vector<glm::vec2> data,
307 VkVertexInputRate rate,
320 VkDeviceSize bufferSize =
sizeof(glm::vec2)*data.size();
326 VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
327 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT
339 buffer = std::make_unique<Buffer>
343 VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT,
344 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT
347 buffer->copy(stagingBuffer, command);
354 std::vector<glm::vec2> data
358 VkDeviceSize bufferSize =
sizeof(glm::vec2)*data.size();
360 if (bufferSize >
buffer->getVkDeviceSize())
362 buffer = std::make_unique<Buffer>
366 VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT,
367 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT
375 VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
376 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT
386 buffer->copy(stagingBuffer, command);
392 std::vector<VkVertexInputBindingDescription> bindingDescription{};
393 bindingDescription.resize(1);
394 bindingDescription[0].binding =
binding;
395 bindingDescription[0].stride =
sizeof(glm::vec2);
396 bindingDescription[0].inputRate =
inputRate;
397 return bindingDescription;
402 std::vector<VkVertexInputAttributeDescription> attributeDescriptions{};
403 attributeDescriptions.resize(1);
405 attributeDescriptions[0].binding =
binding;
407 attributeDescriptions[0].location =
location;
409 attributeDescriptions[0].format = VK_FORMAT_R32G32_SFLOAT;
411 attributeDescriptions[0].offset = 0;
413 return attributeDescriptions;
void copyMemory(const VkDeviceSize offset, const VkDeviceSize size, void *data, const VkMemoryMapFlags=0)
Definition buffer.cpp:12
Definition vertexBuffer.h:20
void setLocation(uint32_t l)
Definition vertexBuffer.h:58
uint32_t binding
Definition vertexBuffer.h:68
void setBinding(uint32_t b)
Definition vertexBuffer.h:57
virtual std::vector< VkVertexInputAttributeDescription > getArrtibuteDescriptions()=0
const VkBuffer & getVkBuffer() const
Definition vertexBuffer.h:60
std::unique_ptr< Buffer > buffer
Definition vertexBuffer.h:70
virtual std::vector< VkVertexInputBindingDescription > getBindingDescription()=0
VertexBufferObject(const Device &device)
Definition vertexBuffer.h:48
uint32_t location
Definition vertexBuffer.h:68
const Device & device
Definition vertexBuffer.h:64
VkVertexInputRate inputRate
Definition vertexBuffer.h:66
void subData(const Device &device, const Command &command, std::vector< glm::vec2 > data)
Definition vertexBuffer.h:351
std::vector< VkVertexInputBindingDescription > getBindingDescription()
Definition vertexBuffer.h:390
std::vector< VkVertexInputAttributeDescription > getArrtibuteDescriptions()
Definition vertexBuffer.h:400
std::vector< VkVertexInputAttributeDescription > getArrtibuteDescriptions()
Definition vertexBuffer.h:278
std::vector< VkVertexInputBindingDescription > getBindingDescription()
Definition vertexBuffer.h:268
void subData(const Device &device, const Command &command, std::vector< glm::vec4 > data)
Definition vertexBuffer.h:229
Definition vertexBuffer.h:76
std::vector< VkVertexInputBindingDescription > getBindingDescription()
std::vector< VkVertexInputAttributeDescription > getArrtibuteDescriptions()
VertexBuffer(const Device &device, const Command &command, std::vector< T > data, VkVertexInputRate rate, uint32_t binding=0, uint32_t location=0)
Definition vertexBuffer.h:81
void subData(const Device &device, const Command &command, std::vector< T > data)
Definition vertexBuffer.h:127