2019-07-08 16:00:47 +00:00
|
|
|
#ifndef __vid_vulkan_h
|
|
|
|
#define __vid_vulkan_h
|
|
|
|
|
|
|
|
#ifndef VK_NO_PROTOTYPES
|
|
|
|
#define VK_NO_PROTOTYPES
|
|
|
|
#endif
|
|
|
|
#include <vulkan/vulkan.h>
|
|
|
|
|
2020-02-18 08:18:37 +00:00
|
|
|
#include "QF/darray.h"
|
2021-04-25 06:47:50 +00:00
|
|
|
#include "QF/simd/types.h"
|
2020-02-16 13:45:27 +00:00
|
|
|
|
2021-02-14 02:35:06 +00:00
|
|
|
typedef struct vulkan_frame_s {
|
2020-02-18 08:18:37 +00:00
|
|
|
VkFramebuffer framebuffer;
|
|
|
|
VkFence fence;
|
|
|
|
VkSemaphore imageAvailableSemaphore;
|
|
|
|
VkSemaphore renderDoneSemaphore;
|
|
|
|
VkCommandBuffer cmdBuffer;
|
2021-01-10 06:52:27 +00:00
|
|
|
|
2021-02-14 02:35:06 +00:00
|
|
|
int cmdSetCount;
|
|
|
|
struct qfv_cmdbufferset_s *cmdSets;
|
2021-02-05 01:22:32 +00:00
|
|
|
} vulkan_frame_t;
|
2020-02-18 08:18:37 +00:00
|
|
|
|
2021-01-12 02:26:20 +00:00
|
|
|
typedef struct vulkan_matrices_s {
|
|
|
|
VkBuffer buffer_2d;
|
|
|
|
VkBuffer buffer_3d;
|
|
|
|
VkDeviceMemory memory;
|
2021-04-25 06:47:50 +00:00
|
|
|
vec4f_t *projection_2d;
|
|
|
|
vec4f_t *projection_3d;
|
|
|
|
vec4f_t *view_3d;
|
|
|
|
vec4f_t *sky_3d;
|
2021-01-12 02:26:20 +00:00
|
|
|
} vulkan_matrices_t;
|
|
|
|
|
2021-02-05 01:22:32 +00:00
|
|
|
typedef struct vulkan_frameset_s
|
|
|
|
DARRAY_TYPE (vulkan_frame_t) vulkan_frameset_t;
|
2020-02-18 08:18:37 +00:00
|
|
|
|
2021-02-23 05:37:48 +00:00
|
|
|
typedef struct clearvalueset_s
|
|
|
|
DARRAY_TYPE (VkClearValue) clearvalueset_t;
|
|
|
|
|
2019-07-08 16:00:47 +00:00
|
|
|
typedef struct vulkan_ctx_s {
|
|
|
|
void (*load_vulkan) (struct vulkan_ctx_s *ctx);
|
|
|
|
void (*unload_vulkan) (struct vulkan_ctx_s *ctx);
|
|
|
|
|
2019-07-09 02:54:23 +00:00
|
|
|
const char **required_extensions;
|
2019-07-08 16:00:47 +00:00
|
|
|
struct vulkan_presentation_s *presentation;
|
|
|
|
int (*get_presentation_support) (struct vulkan_ctx_s *ctx,
|
|
|
|
VkPhysicalDevice physicalDevice,
|
|
|
|
uint32_t queueFamilyIndex);
|
2019-07-09 07:33:44 +00:00
|
|
|
void (*choose_visual) (struct vulkan_ctx_s *ctx);
|
|
|
|
void (*create_window) (struct vulkan_ctx_s *ctx);
|
2019-07-08 16:00:47 +00:00
|
|
|
VkSurfaceKHR (*create_surface) (struct vulkan_ctx_s *ctx);
|
2019-07-09 02:54:23 +00:00
|
|
|
|
2021-01-31 07:01:20 +00:00
|
|
|
struct va_ctx_s *va_ctx;
|
2019-07-12 04:15:25 +00:00
|
|
|
struct qfv_instance_s *instance;
|
|
|
|
struct qfv_device_s *device;
|
|
|
|
struct qfv_swapchain_s *swapchain;
|
2020-12-21 11:17:27 +00:00
|
|
|
VkSampleCountFlagBits msaaSamples; // FIXME not here?
|
2020-12-21 09:38:31 +00:00
|
|
|
struct hashlink_s *hashlinks; //FIXME want per thread
|
2019-07-12 04:15:25 +00:00
|
|
|
VkSurfaceKHR surface; //FIXME surface = window, so "contains" swapchain
|
2021-01-05 08:43:26 +00:00
|
|
|
struct plitem_s *pipelineDef;
|
2021-02-04 08:03:49 +00:00
|
|
|
|
2021-02-14 02:35:06 +00:00
|
|
|
struct plitem_s *renderpassDef;
|
|
|
|
VkRenderPass renderpass;
|
2021-02-23 05:37:48 +00:00
|
|
|
clearvalueset_t *clearValues;
|
2021-02-14 02:35:06 +00:00
|
|
|
struct qfv_imageset_s *attachment_images;
|
|
|
|
struct qfv_imageviewset_s *attachment_views;
|
|
|
|
VkDeviceMemory attachmentMemory;
|
|
|
|
|
|
|
|
uint32_t swapImageIndex;
|
|
|
|
struct qfv_framebufferset_s *framebuffers;
|
|
|
|
|
2021-01-05 05:15:35 +00:00
|
|
|
struct hashtab_s *shaderModules;
|
2021-01-04 08:36:11 +00:00
|
|
|
struct hashtab_s *setLayouts;
|
2021-01-04 23:38:35 +00:00
|
|
|
struct hashtab_s *pipelineLayouts;
|
2021-01-09 16:53:15 +00:00
|
|
|
struct hashtab_s *descriptorPools;
|
2021-01-10 06:52:27 +00:00
|
|
|
struct hashtab_s *samplers;
|
2021-02-14 02:35:06 +00:00
|
|
|
struct hashtab_s *images;
|
|
|
|
struct hashtab_s *imageViews;
|
2021-02-23 05:37:48 +00:00
|
|
|
struct hashtab_s *renderpasses;
|
2020-02-16 13:45:27 +00:00
|
|
|
|
2021-01-26 11:58:24 +00:00
|
|
|
struct aliasctx_s *alias_context;
|
2021-01-19 16:25:54 +00:00
|
|
|
struct bspctx_s *bsp_context;
|
2021-01-16 05:42:25 +00:00
|
|
|
struct drawctx_s *draw_context;
|
2021-02-24 10:58:31 +00:00
|
|
|
struct lightingctx_s *lighting_context;
|
|
|
|
struct composectx_s *compose_context;
|
|
|
|
|
|
|
|
VkBuffer quad_buffer;
|
|
|
|
VkDeviceMemory quad_memory;
|
2021-01-16 05:42:25 +00:00
|
|
|
|
2020-02-17 11:29:35 +00:00
|
|
|
VkCommandPool cmdpool;
|
2020-02-18 05:28:28 +00:00
|
|
|
VkCommandBuffer cmdbuffer;
|
|
|
|
VkFence fence; // for ctx->cmdbuffer only
|
2021-01-16 05:37:16 +00:00
|
|
|
struct qfv_stagebuf_s *staging;
|
2020-02-18 08:18:37 +00:00
|
|
|
size_t curFrame;
|
2021-02-05 01:22:32 +00:00
|
|
|
vulkan_frameset_t frames;
|
2020-02-16 13:45:27 +00:00
|
|
|
|
2021-03-24 10:20:53 +00:00
|
|
|
struct qfv_capture_s *capture;
|
|
|
|
void (*capture_callback) (const byte *data, int width, int height);
|
|
|
|
|
2021-01-23 06:40:31 +00:00
|
|
|
struct qfv_tex_s *default_black;
|
|
|
|
struct qfv_tex_s *default_white;
|
|
|
|
struct qfv_tex_s *default_magenta;
|
|
|
|
|
2021-03-31 14:38:49 +00:00
|
|
|
VkViewport viewport;
|
|
|
|
VkRect2D scissor;
|
2021-01-12 02:26:20 +00:00
|
|
|
// projection and view matrices (model is push constant)
|
|
|
|
vulkan_matrices_t matrices;
|
|
|
|
|
2019-07-08 16:00:47 +00:00
|
|
|
#define EXPORTED_VULKAN_FUNCTION(fname) PFN_##fname fname;
|
|
|
|
#define GLOBAL_LEVEL_VULKAN_FUNCTION(fname) PFN_##fname fname;
|
|
|
|
#include "QF/Vulkan/funclist.h"
|
|
|
|
} vulkan_ctx_t;
|
|
|
|
|
2021-11-30 03:24:45 +00:00
|
|
|
#define qfvPushDebug(ctx, x) \
|
|
|
|
do { \
|
|
|
|
if (developer->int_val & SYS_vulkan) { \
|
|
|
|
DARRAY_APPEND(&(ctx)->instance->debug_stack, (x)); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
#define qfvPopDebug(ctx) \
|
|
|
|
do { \
|
|
|
|
if (developer->int_val & SYS_vulkan) { \
|
|
|
|
__auto_type ds = &(ctx)->instance->debug_stack; \
|
|
|
|
DARRAY_REMOVE_AT(ds, ds->size - 1); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
2019-07-08 16:00:47 +00:00
|
|
|
#endif//__vid_vulkan_h
|