mirror of
https://github.com/w23/xash3d-fwgs
synced 2024-12-14 04:59:58 +01:00
d24961db15
The intent is to manage long-vs-single-frame allocations better. Previously long allocations were map-long bump allocations, and couldn't be freed mid-map, as there was neither a reference to the allocated range, nor a way to actully free it. Add a two-mode block allocator (similar to previous debuffer alloc) that allows making long and once allocations. But now long allocations are backed by "pool" allocator and return references to the range. This commit doesn't do the deallocation yet, so map chaning doesn't yet work.
34 lines
875 B
C
34 lines
875 B
C
#pragma once
|
|
|
|
#include "vk_core.h"
|
|
#include "vk_devmem.h"
|
|
#include "r_flipping.h"
|
|
#include "alolcator.h"
|
|
|
|
typedef struct vk_buffer_s {
|
|
vk_devmem_t devmem;
|
|
VkBuffer buffer;
|
|
|
|
void *mapped;
|
|
uint32_t size;
|
|
} vk_buffer_t;
|
|
|
|
qboolean VK_BufferCreate(const char *debug_name, vk_buffer_t *buf, uint32_t size, VkBufferUsageFlags usage, VkMemoryPropertyFlags flags);
|
|
void VK_BufferDestroy(vk_buffer_t *buf);
|
|
|
|
VkDeviceAddress R_VkBufferGetDeviceAddress(VkBuffer buffer);
|
|
|
|
typedef struct {
|
|
r_flipping_buffer_t dynamic;
|
|
uint32_t static_size;
|
|
uint32_t static_offset;
|
|
} r_debuffer_t;
|
|
|
|
typedef enum {
|
|
LifetimeStatic, LifetimeDynamic,
|
|
} r_lifetime_t;
|
|
|
|
void R_DEBuffer_Init(r_debuffer_t *debuf, uint32_t static_size, uint32_t dynamic_size);
|
|
uint32_t R_DEBuffer_Alloc(r_debuffer_t* debuf, r_lifetime_t lifetime, uint32_t size, uint32_t align);
|
|
void R_DEBuffer_Flip(r_debuffer_t* debuf);
|