xash3d-fwgs/ref_vk/vk_buffer.h

34 lines
1.2 KiB
C
Raw Normal View History

2021-01-16 22:22:31 +01:00
#pragma once
#include "vk_core.h"
2021-05-17 19:36:40 +02:00
qboolean createBuffer(const char *debug_name, vk_buffer_t *buf, uint32_t size, VkBufferUsageFlags usage, VkMemoryPropertyFlags flags);
2021-01-16 22:22:31 +01:00
void destroyBuffer(vk_buffer_t *buf);
2021-05-03 20:17:01 +02:00
// v -- begin of ring buffer|permanent_size
// |XXXMAPLIFETME|<......|FRAME1|FRAME2|FRAMEN|......................>|
// busy pos - ^ ^ ^ ^ -- write pos | offset_free
typedef struct {
uint32_t size;
uint32_t permanent_size;
uint32_t offset_free;
uint32_t free;
// TODO per-frame offsets for many frames in flight
} vk_ring_buffer_t;
enum { AllocFailed = 0xffffffffu };
// Marks the entire buffer as free
void VK_RingBuffer_Clear(vk_ring_buffer_t* buf);
// Allocates a new aligned region and returns offset to it (-1 if allocation failed)
uint32_t VK_RingBuffer_Alloc(vk_ring_buffer_t* buf, uint32_t size, uint32_t align);
// Fixes everything that has been allocated since Clear as permanent, ring buffer will operate on the remainder only
// Can be called only once since Clear
void VK_RingBuffer_Fix(vk_ring_buffer_t* buf);
// Clears non-permantent part of the buffer
void VK_RingBuffer_ClearFrame(vk_ring_buffer_t* buf);