2022-04-28 09:16:25 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "vk_core.h"
|
|
|
|
|
|
|
|
qboolean R_VkStagingInit(void);
|
|
|
|
void R_VkStagingShutdown(void);
|
|
|
|
|
2022-05-04 18:23:37 +02:00
|
|
|
typedef int staging_handle_t;
|
|
|
|
|
2022-04-28 09:16:25 +02:00
|
|
|
typedef struct {
|
|
|
|
void *ptr;
|
2022-05-04 18:23:37 +02:00
|
|
|
staging_handle_t handle;
|
2022-04-28 09:16:25 +02:00
|
|
|
} vk_staging_region_t;
|
|
|
|
|
2022-06-04 23:04:44 +02:00
|
|
|
// Allocate region for uploadting to buffer
|
|
|
|
typedef struct {
|
|
|
|
VkBuffer buffer;
|
|
|
|
uint32_t offset;
|
|
|
|
uint32_t size;
|
|
|
|
uint32_t alignment;
|
|
|
|
} vk_staging_buffer_args_t;
|
|
|
|
vk_staging_region_t R_VkStagingLockForBuffer(vk_staging_buffer_args_t args);
|
|
|
|
|
|
|
|
// Allocate region for uploading to image
|
|
|
|
typedef struct {
|
|
|
|
VkImage image;
|
|
|
|
VkImageLayout layout;
|
2022-06-04 23:27:12 +02:00
|
|
|
VkBufferImageCopy region;
|
2022-06-04 23:04:44 +02:00
|
|
|
uint32_t size;
|
|
|
|
uint32_t alignment;
|
|
|
|
} vk_staging_image_args_t;
|
|
|
|
vk_staging_region_t R_VkStagingLockForImage(vk_staging_image_args_t args);
|
|
|
|
|
|
|
|
// Mark allocated region as ready for upload
|
|
|
|
void R_VkStagingUnlock(staging_handle_t handle);
|
|
|
|
|
2022-09-11 20:38:51 +02:00
|
|
|
// Append copy commands to command buffer.
|
|
|
|
VkCommandBuffer R_VkStagingCommit(void);
|
2022-04-28 09:16:25 +02:00
|
|
|
|
2022-09-11 20:38:51 +02:00
|
|
|
// Mark previous frame data as uploaded and safe to use.
|
|
|
|
void R_VkStagingFrameBegin(void);
|
2022-05-04 18:23:37 +02:00
|
|
|
|
2022-09-11 20:38:51 +02:00
|
|
|
// Uploads staging contents and returns the command buffer ready to be submitted.
|
|
|
|
// Can return NULL if there's nothing to upload.
|
|
|
|
VkCommandBuffer R_VkStagingFrameEnd(void);
|
|
|
|
|
|
|
|
// Gets the current command buffer.
|
|
|
|
// WARNING: Can be invalidated by any of the Lock calls
|
|
|
|
VkCommandBuffer R_VkStagingGetCommandBuffer(void);
|
2023-03-04 19:36:47 +01:00
|
|
|
|
|
|
|
// Commit all staging data into current cmdbuf, submit it and wait for completion.
|
|
|
|
// Needed for CPU-GPU sync
|
|
|
|
void R_VkStagingFlushSync( void );
|