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"
|
2023-01-30 04:19:53 +00:00
|
|
|
#include "QF/qtypes.h"
|
2021-04-25 06:47:50 +00:00
|
|
|
#include "QF/simd/types.h"
|
2020-02-16 13:45:27 +00:00
|
|
|
|
2023-07-03 10:53:53 +00:00
|
|
|
#define VA_CTX_COUNT 64
|
|
|
|
|
2021-12-02 12:58:29 +00:00
|
|
|
typedef struct qfv_renderpassset_s
|
2023-06-15 04:13:52 +00:00
|
|
|
DARRAY_TYPE (struct qfv_orenderpass_s *) qfv_renderpassset_t;
|
2021-02-23 05:37:48 +00:00
|
|
|
|
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?
|
2019-07-12 04:15:25 +00:00
|
|
|
VkSurfaceKHR surface; //FIXME surface = window, so "contains" swapchain
|
2021-02-04 08:03:49 +00:00
|
|
|
|
2021-02-14 02:35:06 +00:00
|
|
|
uint32_t swapImageIndex;
|
|
|
|
|
2022-11-24 14:44:07 +00:00
|
|
|
struct scriptctx_s *script_context;
|
2023-02-13 08:45:36 +00:00
|
|
|
struct qfv_renderctx_s *render_context;
|
2023-06-25 12:01:34 +00:00
|
|
|
struct qfv_capturectx_s *capture_context;
|
2021-12-17 03:20:32 +00:00
|
|
|
struct texturectx_s *texture_context;
|
2021-12-08 06:28:21 +00:00
|
|
|
struct matrixctx_s *matrix_context;
|
2022-11-30 18:00:47 +00:00
|
|
|
struct translucentctx_s *translucent_context;
|
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;
|
2022-05-04 05:07:27 +00:00
|
|
|
struct iqmctx_s *iqm_context;
|
2022-05-24 15:17:57 +00:00
|
|
|
struct scenectx_s *scene_context;
|
2022-11-15 00:26:17 +00:00
|
|
|
struct palettectx_s *palette_context;
|
2021-12-16 14:17:01 +00:00
|
|
|
struct particlectx_s *particle_context;
|
2023-07-21 02:59:25 +00:00
|
|
|
struct planesctx_s *planes_context;
|
2021-12-14 16:22:05 +00:00
|
|
|
struct spritectx_s *sprite_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;
|
2022-11-22 08:47:36 +00:00
|
|
|
struct outputctx_s *output_context;
|
2021-02-24 10:58:31 +00:00
|
|
|
|
2020-02-17 11:29:35 +00:00
|
|
|
VkCommandPool cmdpool;
|
2021-01-16 05:37:16 +00:00
|
|
|
struct qfv_stagebuf_s *staging;
|
2022-11-25 07:02:39 +00:00
|
|
|
uint32_t curFrame;
|
2021-12-02 12:58:29 +00:00
|
|
|
qfv_renderpassset_t renderPasses;
|
2020-02-16 13:45:27 +00:00
|
|
|
|
2021-03-24 10:20:53 +00:00
|
|
|
|
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-12-08 12:08:37 +00:00
|
|
|
struct qfv_tex_s *default_magenta_array;
|
2021-01-23 06:40:31 +00:00
|
|
|
|
2022-04-01 11:34:41 +00:00
|
|
|
// size of window
|
|
|
|
int window_width;
|
|
|
|
int window_height;
|
2022-11-13 13:23:56 +00:00
|
|
|
int twod_scale;
|
2021-01-12 02:26:20 +00:00
|
|
|
|
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 { \
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (developer & SYS_vulkan) { \
|
2021-11-30 03:24:45 +00:00
|
|
|
DARRAY_APPEND(&(ctx)->instance->debug_stack, (x)); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
#define qfvPopDebug(ctx) \
|
|
|
|
do { \
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (developer & SYS_vulkan) { \
|
2021-11-30 03:24:45 +00:00
|
|
|
__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
|