63 lines
1.7 KiB
C
63 lines
1.7 KiB
C
////////////////////////////////
|
|
//~ Transient buffer types
|
|
|
|
Struct(GPU_SubmittedResourceNode)
|
|
{
|
|
GPU_SubmittedResourceNode *next;
|
|
|
|
/* Set during transient upload */
|
|
GPU_Resource *resource;
|
|
|
|
/* Set during transient reset */
|
|
i64 fence_target; /* Once the buffer's queue reaches the target, the resource can be freed or reused */
|
|
};
|
|
|
|
Struct(GPU_TransientBuffer)
|
|
{
|
|
GPU_QueueKind queue_kind;
|
|
u32 element_size;
|
|
|
|
GPU_SubmittedResourceNode *uploaded;
|
|
GPU_SubmittedResourceNode *first_submitted;
|
|
GPU_SubmittedResourceNode *last_submitted;
|
|
u32 max_in_flight;
|
|
};
|
|
|
|
|
|
////////////////////////////////
|
|
//~ State types
|
|
|
|
Struct(GPU_SharedUtilState)
|
|
{
|
|
/* Common shared resources */
|
|
GPU_Resource *pt_sampler;
|
|
GPU_Resource *quad_indices;
|
|
GPU_Resource *noise;
|
|
|
|
/* Transient buffer pool */
|
|
Mutex submitted_transient_buffers_mutex;
|
|
GPU_SubmittedResourceNode *first_free_submitted_transient_buffer;
|
|
} extern GPU_shared_util_state;
|
|
|
|
////////////////////////////////
|
|
//~ Startup
|
|
|
|
void GPU_StartupUtils(void);
|
|
|
|
////////////////////////////////
|
|
//~ Common resource helpers
|
|
|
|
GPU_Resource *GPU_GetCommonPointSampler(void);
|
|
GPU_Resource *GPU_GetCommonQuadIndices(void);
|
|
GPU_Resource *GPU_GetCommonNoise(void);
|
|
|
|
////////////////////////////////
|
|
//~ Transient buffer operations
|
|
|
|
GPU_TransientBuffer GPU_AcquireTransientBuffer(GPU_QueueKind queue_kind, u32 element_size);
|
|
void GPU_ReleaseTransientBuffer(GPU_TransientBuffer *tbuff);
|
|
|
|
GPU_Resource *GPU_UploadTransientBuffer(GPU_TransientBuffer *tbuff, void *src, u64 src_size);
|
|
GPU_Resource *GPU_UploadTransientBufferFromArena(GPU_TransientBuffer *tbuff, Arena *arena);
|
|
void GPU_ResetTransientBuffer(GPU_TransientBuffer *tbuff, i64 queue_fence_target);
|