mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-05-31 08:41:11 +00:00
Correct extension handling
I had missed a critical bit from the cookbook.
This commit is contained in:
parent
ed3c5cb9ec
commit
2771e9c573
7 changed files with 91 additions and 42 deletions
|
@ -48,6 +48,13 @@
|
|||
|
||||
static vulkan_ctx_t *vulkan_ctx;
|
||||
|
||||
static void
|
||||
vulkan_R_Init (void)
|
||||
{
|
||||
if (vulkan_ctx)
|
||||
Sys_Quit ();
|
||||
}
|
||||
|
||||
static vid_model_funcs_t model_funcs = {
|
||||
0,//vulkan_Mod_LoadExternalTextures,
|
||||
0,//vulkan_Mod_LoadLighting,
|
||||
|
@ -108,7 +115,7 @@ vid_render_funcs_t vulkan_vid_render_funcs = {
|
|||
0,//vulkan_Fog_Update,
|
||||
0,//vulkan_Fog_ParseWorldspawn,
|
||||
|
||||
0,//vulkan_R_Init,
|
||||
vulkan_R_Init,
|
||||
0,//vulkan_R_ClearState,
|
||||
0,//vulkan_R_LoadSkys,
|
||||
0,//vulkan_R_NewMap,
|
||||
|
@ -151,6 +158,7 @@ vulkan_vid_render_create_context (void)
|
|||
{
|
||||
vulkan_ctx->create_window (vulkan_ctx);
|
||||
vulkan_ctx->dev->surface = vulkan_ctx->create_surface (vulkan_ctx);
|
||||
Sys_Printf ("%p\n", vulkan_ctx->dev->surface);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -198,6 +198,12 @@ init_physdev (VulkanInstance_t *instance, VkPhysicalDevice dev, VulkanPhysDevice
|
|||
}
|
||||
}
|
||||
|
||||
static int
|
||||
instance_extension_enabled (VulkanInstance_t *inst, const char *ext)
|
||||
{
|
||||
return strset_contains (inst->enabled_extensions, ext);
|
||||
}
|
||||
|
||||
static int message_severities =
|
||||
VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT |
|
||||
VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT |
|
||||
|
@ -242,10 +248,13 @@ load_instance_funcs (vulkan_ctx_t *ctx)
|
|||
Sys_Error ("Couldn't find instance level function %s", #name); \
|
||||
}
|
||||
|
||||
#define INSTANCE_LEVEL_VULKAN_FUNCTION_EXTENSION(name) \
|
||||
vtx->name = (PFN_##name) ctx->vkGetInstanceProcAddr (instance, #name); \
|
||||
if (!vtx->name) { \
|
||||
Sys_Printf ("Couldn't find instance level function %s", #name); \
|
||||
#define INSTANCE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION(name, ext) \
|
||||
if (vtx->extension_enabled (vtx, ext)) { \
|
||||
vtx->name = (PFN_##name) ctx->vkGetInstanceProcAddr (instance, \
|
||||
#name); \
|
||||
if (!vtx->name) { \
|
||||
Sys_Error ("Couldn't find instance level function %s", #name); \
|
||||
} \
|
||||
}
|
||||
|
||||
#include "QF/Vulkan/funclist.h"
|
||||
|
@ -278,9 +287,9 @@ Vulkan_CreateInstance (vulkan_ctx_t *ctx,
|
|||
get_instance_layers_and_extensions (ctx);
|
||||
}
|
||||
|
||||
uint32_t nlay = count_strings (layers);
|
||||
uint32_t nlay = count_strings (layers) + 1;
|
||||
uint32_t next = count_strings (extensions)
|
||||
+ count_strings (ctx->required_extensions);
|
||||
+ count_strings (ctx->required_extensions) + 1;
|
||||
if (vulkan_use_validation->int_val) {
|
||||
nlay += count_strings (vulkanValidationLayers);
|
||||
next += count_strings (debugExtensions);
|
||||
|
@ -289,8 +298,8 @@ Vulkan_CreateInstance (vulkan_ctx_t *ctx,
|
|||
const char **ext = alloca (next * sizeof (const char *));
|
||||
// ensure there are null pointers so merge_strings can act as append
|
||||
// since it does not add a null
|
||||
memset (lay, 0, nlay * sizeof (const char *));
|
||||
memset (ext, 0, next * sizeof (const char *));
|
||||
memset (lay, 0, nlay-- * sizeof (const char *));
|
||||
memset (ext, 0, next-- * sizeof (const char *));
|
||||
merge_strings (lay, layers, 0);
|
||||
merge_strings (ext, extensions, ctx->required_extensions);
|
||||
if (vulkan_use_validation->int_val) {
|
||||
|
@ -299,6 +308,8 @@ Vulkan_CreateInstance (vulkan_ctx_t *ctx,
|
|||
}
|
||||
prune_strings (instanceLayerNames, lay, &nlay);
|
||||
prune_strings (instanceExtensionNames, ext, &next);
|
||||
lay[nlay] = 0;
|
||||
ext[next] = 0;
|
||||
createInfo.enabledLayerCount = nlay;
|
||||
createInfo.ppEnabledLayerNames = lay;
|
||||
createInfo.enabledExtensionCount = next;
|
||||
|
@ -310,6 +321,9 @@ Vulkan_CreateInstance (vulkan_ctx_t *ctx,
|
|||
}
|
||||
inst = malloc (sizeof(VulkanInstance_t));
|
||||
inst->instance = instance;
|
||||
inst->enabled_extensions = new_strset (ext);
|
||||
inst->extension_enabled = instance_extension_enabled;
|
||||
ctx->extension_enabled = instance_extension_enabled;
|
||||
ctx->vtx = inst;
|
||||
load_instance_funcs (ctx);
|
||||
|
||||
|
|
|
@ -117,10 +117,13 @@ load_device_funcs (VulkanInstance_t *inst, VulkanDevice_t *dev)
|
|||
Sys_Error ("Couldn't find device level function %s", #name); \
|
||||
}
|
||||
|
||||
#define DEVICE_LEVEL_VULKAN_FUNCTION_EXTENSION(name) \
|
||||
dev->name = (PFN_##name) inst->vkGetDeviceProcAddr (dev->device, #name); \
|
||||
if (!dev->name) { \
|
||||
Sys_Printf ("Couldn't find device level function %s", #name); \
|
||||
#define DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION(name, ext) \
|
||||
if (inst->extension_enabled (vtx, ext)) { \
|
||||
dev->name = (PFN_##name) inst->vkGetDeviceProcAddr (dev->device, \
|
||||
#name); \
|
||||
if (!dev->name) { \
|
||||
Sys_Printf ("Couldn't find device level function %s", #name); \
|
||||
} \
|
||||
}
|
||||
|
||||
#include "QF/Vulkan/funclist.h"
|
||||
|
@ -204,6 +207,7 @@ Vulkan_CreateDevice (vulkan_ctx_t *ctx)
|
|||
0, &device->queue);
|
||||
ctx->dev = device;
|
||||
ctx->device = device->device;
|
||||
ctx->physDevice = phys->device;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
static cvar_t *vulkan_library_name;
|
||||
|
||||
typedef struct vulkan_presentation_s {
|
||||
#define INSTANCE_LEVEL_VULKAN_FUNCTION(name) PFN_##name name;
|
||||
#define INSTANCE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION(name,ext) PFN_##name name;
|
||||
#include "QF/Vulkan/funclist.h"
|
||||
|
||||
Display *display;
|
||||
|
@ -117,10 +117,13 @@ x11_vulkan_init_presentation (vulkan_ctx_t *ctx)
|
|||
vulkan_presentation_t *pres = ctx->presentation;
|
||||
VkInstance instance = ctx->instance;
|
||||
|
||||
#define INSTANCE_LEVEL_VULKAN_FUNCTION(name) \
|
||||
pres->name = (PFN_##name) ctx->vkGetInstanceProcAddr (instance, #name); \
|
||||
if (!pres->name) { \
|
||||
Sys_Error ("Couldn't find instance-level function %s", #name); \
|
||||
#define INSTANCE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION(name, ext) \
|
||||
if (ctx->extension_enabled (ctx->vtx, ext)) { \
|
||||
pres->name = (PFN_##name) ctx->vkGetInstanceProcAddr (instance, \
|
||||
#name); \
|
||||
if (!pres->name) { \
|
||||
Sys_Error ("Couldn't find instance-level function %s", #name); \
|
||||
} \
|
||||
}
|
||||
#include "QF/Vulkan/funclist.h"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue