mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-27 22:52:21 +00:00
25559243ae
When allocating memory for multiple objects that have alignment requirements, it gets tedious keeping track of the offset and the alignment. This is a simple function for walking the offset respecting size and alignment requirements, and doubles as a size calculator.
52 lines
1.6 KiB
C
52 lines
1.6 KiB
C
#ifndef __QF_Vulkan_buffer_h
|
|
#define __QF_Vulkan_buffer_h
|
|
|
|
#include "QF/darray.h"
|
|
|
|
typedef struct qfv_buffertransition_s {
|
|
VkBuffer buffer;
|
|
VkAccessFlags srcAccess;
|
|
VkAccessFlags dstAccess;
|
|
uint32_t srcQueueFamily;
|
|
uint32_t dstQueueFamily;
|
|
VkDeviceSize offset;
|
|
VkDeviceSize size;
|
|
} qfv_buffertransition_t;
|
|
|
|
typedef struct qfv_buffertransitionset_s
|
|
DARRAY_TYPE (qfv_buffertransition_t) qfv_buffertransitionset_t;
|
|
typedef struct qfv_bufferbarrierset_s
|
|
DARRAY_TYPE (VkBufferMemoryBarrier) qfv_bufferbarrierset_t;
|
|
|
|
typedef struct qfv_bufferset_s
|
|
DARRAY_TYPE (VkBuffer) qfv_bufferset_t;
|
|
#define QFV_AllocBufferSet(num, allocator) \
|
|
DARRAY_ALLOCFIXED (qfv_bufferset_t, num, allocator)
|
|
|
|
struct qfv_device_s;
|
|
VkBuffer QFV_CreateBuffer (struct qfv_device_s *device,
|
|
VkDeviceSize size,
|
|
VkBufferUsageFlags usage);
|
|
|
|
VkDeviceMemory QFV_AllocBufferMemory (struct qfv_device_s *device,
|
|
VkBuffer buffer,
|
|
VkMemoryPropertyFlags properties,
|
|
VkDeviceSize size, VkDeviceSize offset);
|
|
|
|
int QFV_BindBufferMemory (struct qfv_device_s *device,
|
|
VkBuffer buffer, VkDeviceMemory object,
|
|
VkDeviceSize offset);
|
|
|
|
qfv_bufferbarrierset_t *
|
|
QFV_CreateBufferTransitions (qfv_buffertransition_t *transitions,
|
|
int numTransitions);
|
|
|
|
VkBufferView QFV_CreateBufferView (struct qfv_device_s *device,
|
|
VkBuffer buffer, VkFormat format,
|
|
VkDeviceSize offset, VkDeviceSize size);
|
|
|
|
VkDeviceSize QFV_NextOffset (VkDeviceSize current, VkDeviceSize count,
|
|
const VkMemoryRequirements *requirements)
|
|
__attribute__((pure));
|
|
|
|
#endif//__QF_Vulkan_buffer_h
|