mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 23:32:09 +00:00
Implement buffer view creation
And rename memory allocation as it's buffer-specific.
This commit is contained in:
parent
2f9ad73f78
commit
f4c0d0ebcf
3 changed files with 41 additions and 5 deletions
|
@ -27,14 +27,23 @@ typedef struct qfv_bufferbarrierset_s {
|
|||
VkBufferMemoryBarrier *barriers;
|
||||
} qfv_bufferbarrierset_t;
|
||||
|
||||
typedef struct qfv_bufferview_s {
|
||||
struct qfv_device_s *device;
|
||||
VkBufferView view;
|
||||
qfv_buffer_t *buffer;
|
||||
VkFormat format;
|
||||
VkDeviceSize offset;
|
||||
VkDeviceSize size;
|
||||
} qfv_bufferview_t;
|
||||
|
||||
struct qfv_device_s;
|
||||
qfv_buffer_t *QFV_CreateBuffer (struct qfv_device_s *device,
|
||||
VkDeviceSize size,
|
||||
VkBufferUsageFlags usage);
|
||||
|
||||
qfv_memory_t *QFV_AllocMemory (qfv_buffer_t *buffer,
|
||||
VkMemoryPropertyFlags properties,
|
||||
VkDeviceSize size, VkDeviceSize offset);
|
||||
qfv_memory_t *QFV_AllocBufferMemory (qfv_buffer_t *buffer,
|
||||
VkMemoryPropertyFlags properties,
|
||||
VkDeviceSize size, VkDeviceSize offset);
|
||||
|
||||
int QFV_BindBufferMemory (qfv_buffer_t *buffer, qfv_memory_t *memory,
|
||||
VkDeviceSize offset);
|
||||
|
@ -43,5 +52,7 @@ qfv_bufferbarrierset_t *
|
|||
QFV_CreateBufferTransitionSet (qfv_buffertransition_t **transitions,
|
||||
int numTransitions);
|
||||
|
||||
qfv_bufferview_t *QFV_CreateBufferView (qfv_buffer_t *buffer, VkFormat format,
|
||||
VkDeviceSize offset, VkDeviceSize size);
|
||||
|
||||
#endif//__QF_Vulkan_buffer_h
|
||||
|
|
|
@ -111,6 +111,7 @@ DEVICE_LEVEL_VULKAN_FUNCTION (vkCreateBuffer)
|
|||
DEVICE_LEVEL_VULKAN_FUNCTION (vkGetBufferMemoryRequirements)
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION (vkAllocateMemory)
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION (vkBindBufferMemory)
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION (vkCreateBufferView)
|
||||
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION (vkCmdPipelineBarrier)
|
||||
|
||||
|
|
|
@ -79,8 +79,8 @@ QFV_CreateBuffer (qfv_device_t *device, VkDeviceSize size,
|
|||
}
|
||||
|
||||
qfv_memory_t *
|
||||
QFV_AllocMemory (qfv_buffer_t *buffer, VkMemoryPropertyFlags properties,
|
||||
VkDeviceSize size, VkDeviceSize offset)
|
||||
QFV_AllocBufferMemory (qfv_buffer_t *buffer, VkMemoryPropertyFlags properties,
|
||||
VkDeviceSize size, VkDeviceSize offset)
|
||||
{
|
||||
qfv_device_t *device = buffer->device;
|
||||
VkDevice dev = device->dev;
|
||||
|
@ -159,3 +159,27 @@ QFV_CreateBufferTransitionSet (qfv_buffertransition_t **transitions,
|
|||
}
|
||||
return barrierset;
|
||||
}
|
||||
|
||||
qfv_bufferview_t *
|
||||
QFV_CreateBufferView (qfv_buffer_t *buffer, VkFormat format,
|
||||
VkDeviceSize offset, VkDeviceSize size)
|
||||
{
|
||||
qfv_device_t *device = buffer->device;
|
||||
VkDevice dev = device->dev;
|
||||
qfv_devfuncs_t *dfunc = device->funcs;
|
||||
|
||||
VkBufferViewCreateInfo createInfo = {
|
||||
VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO, 0,
|
||||
0,
|
||||
buffer->buffer, format, offset, size,
|
||||
};
|
||||
|
||||
qfv_bufferview_t *view = malloc (sizeof (*view));
|
||||
view->device = device;
|
||||
view->buffer = buffer;
|
||||
view->format = format;
|
||||
view->offset = offset;
|
||||
view->size = size;
|
||||
dfunc->vkCreateBufferView (dev, &createInfo, 0, &view->view);
|
||||
return view;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue