mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-14 17:01:22 +00:00
12c84046f3
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.
123 lines
3.5 KiB
C
123 lines
3.5 KiB
C
#ifndef __vid_vulkan_h
|
|
#define __vid_vulkan_h
|
|
|
|
#ifndef VK_NO_PROTOTYPES
|
|
#define VK_NO_PROTOTYPES
|
|
#endif
|
|
#include <vulkan/vulkan.h>
|
|
|
|
#include "QF/darray.h"
|
|
#include "QF/simd/types.h"
|
|
|
|
//FIXME name
|
|
typedef struct qfv_output_s {
|
|
VkExtent2D extent;
|
|
VkImageView view;
|
|
VkFormat format;
|
|
} qfv_output_t;
|
|
|
|
typedef struct vulkan_frame_s {
|
|
VkFramebuffer framebuffer;
|
|
VkFence fence;
|
|
VkSemaphore imageAvailableSemaphore;
|
|
VkSemaphore renderDoneSemaphore;
|
|
VkCommandBuffer cmdBuffer;
|
|
} vulkan_frame_t;
|
|
|
|
typedef struct vulkan_frameset_s
|
|
DARRAY_TYPE (vulkan_frame_t) vulkan_frameset_t;
|
|
|
|
typedef struct qfv_renderpassset_s
|
|
DARRAY_TYPE (struct qfv_renderpass_s *) qfv_renderpassset_t;
|
|
|
|
typedef struct vulkan_ctx_s {
|
|
void (*load_vulkan) (struct vulkan_ctx_s *ctx);
|
|
void (*unload_vulkan) (struct vulkan_ctx_s *ctx);
|
|
|
|
const char **required_extensions;
|
|
struct vulkan_presentation_s *presentation;
|
|
int (*get_presentation_support) (struct vulkan_ctx_s *ctx,
|
|
VkPhysicalDevice physicalDevice,
|
|
uint32_t queueFamilyIndex);
|
|
void (*choose_visual) (struct vulkan_ctx_s *ctx);
|
|
void (*create_window) (struct vulkan_ctx_s *ctx);
|
|
VkSurfaceKHR (*create_surface) (struct vulkan_ctx_s *ctx);
|
|
|
|
struct va_ctx_s *va_ctx;
|
|
struct qfv_instance_s *instance;
|
|
struct qfv_device_s *device;
|
|
struct qfv_swapchain_s *swapchain;
|
|
VkSampleCountFlagBits msaaSamples; // FIXME not here?
|
|
struct hashlink_s *hashlinks; //FIXME want per thread
|
|
VkSurfaceKHR surface; //FIXME surface = window, so "contains" swapchain
|
|
struct plitem_s *pipelineDef;
|
|
|
|
uint32_t swapImageIndex;
|
|
|
|
struct hashtab_s *shaderModules;
|
|
struct hashtab_s *setLayouts;
|
|
struct hashtab_s *pipelineLayouts;
|
|
struct hashtab_s *descriptorPools;
|
|
struct hashtab_s *samplers;
|
|
struct hashtab_s *images;
|
|
struct hashtab_s *imageViews;
|
|
struct hashtab_s *renderpasses;
|
|
|
|
struct texturectx_s *texture_context;
|
|
struct matrixctx_s *matrix_context;
|
|
struct aliasctx_s *alias_context;
|
|
struct bspctx_s *bsp_context;
|
|
struct particlectx_s *particle_context;
|
|
struct spritectx_s *sprite_context;
|
|
struct drawctx_s *draw_context;
|
|
struct lightingctx_s *lighting_context;
|
|
struct composectx_s *compose_context;
|
|
|
|
VkBuffer quad_buffer;
|
|
VkDeviceMemory quad_memory;
|
|
|
|
VkCommandPool cmdpool;
|
|
VkCommandBuffer cmdbuffer;
|
|
VkFence fence; // for ctx->cmdbuffer only
|
|
struct qfv_stagebuf_s *staging;
|
|
size_t curFrame;
|
|
vulkan_frameset_t frames;
|
|
qfv_renderpassset_t renderPasses;
|
|
|
|
struct qfv_capture_s *capture;
|
|
void (*capture_callback) (const byte *data, int width, int height);
|
|
// make a queue?
|
|
void *capture_complete;// really capfunc_t
|
|
void *capture_complete_data;
|
|
|
|
struct qfv_tex_s *default_black;
|
|
struct qfv_tex_s *default_white;
|
|
struct qfv_tex_s *default_magenta;
|
|
struct qfv_tex_s *default_magenta_array;
|
|
|
|
VkViewport viewport;
|
|
VkRect2D scissor;
|
|
|
|
//FIXME not sure I like it being here (also, type name)
|
|
qfv_output_t output;
|
|
|
|
#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;
|
|
|
|
#define qfvPushDebug(ctx, x) \
|
|
do { \
|
|
if (developer & SYS_vulkan) { \
|
|
DARRAY_APPEND(&(ctx)->instance->debug_stack, (x)); \
|
|
} \
|
|
} while (0)
|
|
#define qfvPopDebug(ctx) \
|
|
do { \
|
|
if (developer & SYS_vulkan) { \
|
|
__auto_type ds = &(ctx)->instance->debug_stack; \
|
|
DARRAY_REMOVE_AT(ds, ds->size - 1); \
|
|
} \
|
|
} while (0)
|
|
|
|
#endif//__vid_vulkan_h
|