#ifndef __QF_Vulkan_capture_h
#define __QF_Vulkan_capture_h

#ifndef VK_NO_PROTOTYPES
#define VK_NO_PROTOTYPES
#endif
#include <vulkan/vulkan.h>

#include "QF/darray.h"
#include "QF/qtypes.h"

typedef struct qfv_capture_image_s {
	VkCommandBuffer cmd;
	VkBuffer    buffer;
	byte       *data;
} qfv_capture_image_t;

typedef struct qfv_capture_image_set_s
	DARRAY_TYPE (qfv_capture_image_t) qfv_capture_image_set_t;

#define QFV_AllocCaptureImageSet(num, allocator) \
	DARRAY_ALLOCFIXED (qfv_capture_image_set_t, num, allocator)

typedef struct qfv_capture_s {
	struct qfv_device_s *device;

	VkExtent2D  extent;
	qfv_capture_image_set_t *image_set;
	size_t      imgsize;
	size_t      memsize;
	byte       *data;
	VkDeviceMemory memory;
} qfv_capture_t;

struct qfv_swapchain_s;

qfv_capture_t *QFV_CreateCapture (struct qfv_device_s *device, int numframes,
								  struct qfv_swapchain_s *swapchain,
								  VkCommandPool cmdPool);
void QFV_RenewCapture (qfv_capture_t *capture,
					   struct qfv_swapchain_s *swapchain);
void QFV_DestroyCapture (qfv_capture_t *capture);

VkCommandBuffer QFV_CaptureImage (qfv_capture_t *capture, VkImage scImage,
								  int frame);
const byte *QFV_CaptureData (qfv_capture_t *capture, int frame) __attribute__((pure));

#endif//__QF_Vulkan_capture_h
