2019-07-12 04:15:25 +00:00
|
|
|
/*
|
|
|
|
init.c
|
|
|
|
|
|
|
|
Copyright (C) 2019 Bill Currie <bill@taniwha.org>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2022-03-30 06:54:07 +00:00
|
|
|
#include <string.h>
|
2019-07-12 04:15:25 +00:00
|
|
|
|
|
|
|
#include "QF/cvar.h"
|
2020-02-18 08:18:37 +00:00
|
|
|
#include "QF/mathlib.h"
|
2022-03-30 06:54:07 +00:00
|
|
|
|
2019-07-12 04:15:25 +00:00
|
|
|
#include "QF/Vulkan/instance.h"
|
|
|
|
|
|
|
|
#include "vid_vulkan.h"
|
|
|
|
|
|
|
|
#include "util.h"
|
|
|
|
|
[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
|
|
|
int vulkan_use_validation;
|
2019-07-12 04:15:25 +00:00
|
|
|
|
|
|
|
static uint32_t numLayers;
|
|
|
|
static VkLayerProperties *instanceLayerProperties;
|
|
|
|
static strset_t *instanceLayers;
|
|
|
|
|
|
|
|
static uint32_t numExtensions;
|
|
|
|
static VkExtensionProperties *instanceExtensionProperties;
|
|
|
|
static strset_t *instanceExtensions;
|
|
|
|
|
|
|
|
const char * const vulkanValidationLayers[] = {
|
2021-01-05 08:46:03 +00:00
|
|
|
"VK_LAYER_KHRONOS_validation",
|
2019-07-12 04:15:25 +00:00
|
|
|
0,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char * const debugExtensions[] = {
|
|
|
|
VK_EXT_DEBUG_UTILS_EXTENSION_NAME,
|
|
|
|
0,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
get_instance_layers_and_extensions (vulkan_ctx_t *ctx)
|
|
|
|
{
|
|
|
|
uint32_t i;
|
|
|
|
VkLayerProperties *layers;
|
|
|
|
VkExtensionProperties *extensions;
|
|
|
|
|
|
|
|
ctx->vkEnumerateInstanceLayerProperties (&numLayers, 0);
|
|
|
|
layers = malloc (numLayers * sizeof (VkLayerProperties));
|
|
|
|
ctx->vkEnumerateInstanceLayerProperties (&numLayers, layers);
|
|
|
|
instanceLayers = new_strset (0);
|
|
|
|
for (i = 0; i < numLayers; i++) {
|
|
|
|
strset_add (instanceLayers, layers[i].layerName);
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx->vkEnumerateInstanceExtensionProperties (0, &numExtensions, 0);
|
|
|
|
extensions = malloc (numExtensions * sizeof (VkLayerProperties));
|
|
|
|
ctx->vkEnumerateInstanceExtensionProperties (0, &numExtensions,
|
|
|
|
extensions);
|
|
|
|
instanceExtensions = new_strset (0);
|
|
|
|
for (i = 0; i < numExtensions; i++) {
|
|
|
|
strset_add (instanceExtensions, extensions[i].extensionName);
|
|
|
|
}
|
|
|
|
|
[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) {
|
2019-07-12 04:15:25 +00:00
|
|
|
for (i = 0; i < numLayers; i++) {
|
|
|
|
Sys_Printf ("%s %x %u %s\n",
|
|
|
|
layers[i].layerName,
|
|
|
|
layers[i].specVersion,
|
|
|
|
layers[i].implementationVersion,
|
|
|
|
layers[i].description);
|
|
|
|
}
|
|
|
|
for (i = 0; i < numExtensions; i++) {
|
|
|
|
Sys_Printf ("%d %s\n",
|
|
|
|
extensions[i].specVersion,
|
|
|
|
extensions[i].extensionName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
instanceLayerProperties = layers;
|
|
|
|
instanceExtensionProperties = extensions;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
instance_extension_enabled (qfv_instance_t *inst, const char *ext)
|
|
|
|
{
|
|
|
|
return strset_contains (inst->enabled_extensions, ext);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int message_severities =
|
2021-11-29 04:44:10 +00:00
|
|
|
VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT |
|
2019-07-12 04:15:25 +00:00
|
|
|
VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT |
|
|
|
|
VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT |
|
|
|
|
VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT;
|
|
|
|
static int message_types =
|
|
|
|
VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT |
|
|
|
|
VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT |
|
|
|
|
VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT;
|
|
|
|
|
2021-01-27 07:16:28 +00:00
|
|
|
static void
|
|
|
|
debug_breakpoint (VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity)
|
|
|
|
{
|
2022-05-13 12:20:53 +00:00
|
|
|
if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT) {
|
|
|
|
exit(1);
|
|
|
|
}
|
2021-01-27 07:16:28 +00:00
|
|
|
}
|
|
|
|
|
2019-07-12 04:15:25 +00:00
|
|
|
static VKAPI_ATTR VkBool32 VKAPI_CALL
|
|
|
|
debug_callback (VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
|
|
|
|
VkDebugUtilsMessageTypeFlagsEXT messageType,
|
|
|
|
const VkDebugUtilsMessengerCallbackDataEXT* callbackData,
|
|
|
|
void *data)
|
|
|
|
{
|
2021-11-30 03:24:45 +00:00
|
|
|
qfv_instance_t *instance = data;
|
[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 (!(messageSeverity & vulkan_use_validation)) {
|
2021-11-29 04:44:10 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2019-07-12 04:15:25 +00:00
|
|
|
const char *msgSev = "";
|
|
|
|
if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT) {
|
|
|
|
msgSev = "verbose: ";
|
|
|
|
}
|
|
|
|
if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT) {
|
|
|
|
msgSev = "info: ";
|
|
|
|
}
|
|
|
|
if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT) {
|
|
|
|
msgSev = "warning: ";
|
|
|
|
}
|
|
|
|
if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT) {
|
|
|
|
msgSev = "error: ";
|
|
|
|
}
|
2021-01-27 07:16:28 +00:00
|
|
|
fprintf (stderr, "validation layer: %s%s\n", msgSev,
|
|
|
|
callbackData->pMessage);
|
2021-11-30 03:24:45 +00:00
|
|
|
for (size_t i = instance->debug_stack.size; i-- > 0; ) {
|
|
|
|
fprintf (stderr, " %s\n", instance->debug_stack.a[i]);
|
|
|
|
}
|
2021-01-27 07:16:28 +00:00
|
|
|
debug_breakpoint (messageSeverity);
|
2019-07-12 04:15:25 +00:00
|
|
|
return VK_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
setup_debug_callback (qfv_instance_t *instance)
|
|
|
|
{
|
2019-07-12 16:11:34 +00:00
|
|
|
VkDebugUtilsMessengerEXT debug_handle;
|
2019-07-12 04:15:25 +00:00
|
|
|
VkDebugUtilsMessengerCreateInfoEXT createInfo = {
|
|
|
|
.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT,
|
|
|
|
.messageSeverity = message_severities,
|
|
|
|
.messageType = message_types,
|
|
|
|
.pfnUserCallback = debug_callback,
|
|
|
|
.pUserData = instance,
|
|
|
|
};
|
2021-03-30 11:09:13 +00:00
|
|
|
if (!instance->funcs->vkCreateDebugUtilsMessengerEXT) {
|
|
|
|
Sys_Printf ("Cound not set up Vulkan validation debug callback\n");
|
|
|
|
return;
|
|
|
|
}
|
2019-07-12 04:15:25 +00:00
|
|
|
instance->funcs->vkCreateDebugUtilsMessengerEXT(instance->instance,
|
|
|
|
&createInfo, 0,
|
2019-07-12 16:11:34 +00:00
|
|
|
&debug_handle);
|
|
|
|
instance->debug_handle = debug_handle;
|
2019-07-12 04:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
load_instance_funcs (vulkan_ctx_t *ctx)
|
|
|
|
{
|
|
|
|
qfv_instance_t *instance = ctx->instance;
|
|
|
|
qfv_instfuncs_t *funcs = instance->funcs;
|
|
|
|
VkInstance inst = instance->instance;
|
|
|
|
#define INSTANCE_LEVEL_VULKAN_FUNCTION(name) \
|
|
|
|
funcs->name = (PFN_##name) ctx->vkGetInstanceProcAddr (inst, #name); \
|
|
|
|
if (!funcs->name) { \
|
|
|
|
Sys_Error ("Couldn't find instance level function %s", #name); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define INSTANCE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION(name, ext) \
|
|
|
|
if (instance->extension_enabled (instance, ext)) { \
|
|
|
|
funcs->name = (PFN_##name) ctx->vkGetInstanceProcAddr (inst, #name); \
|
|
|
|
if (!funcs->name) { \
|
|
|
|
Sys_Error ("Couldn't find instance level function %s", #name); \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
#include "QF/Vulkan/funclist.h"
|
|
|
|
}
|
|
|
|
|
|
|
|
qfv_instance_t *
|
|
|
|
QFV_CreateInstance (vulkan_ctx_t *ctx,
|
|
|
|
const char *appName, uint32_t appVersion,
|
|
|
|
const char **layers, const char **extensions)
|
|
|
|
{
|
|
|
|
VkApplicationInfo appInfo = {
|
|
|
|
VK_STRUCTURE_TYPE_APPLICATION_INFO, 0,
|
|
|
|
appName, appVersion,
|
|
|
|
PACKAGE_STRING, 0x000702ff, //FIXME version
|
2021-03-31 14:38:49 +00:00
|
|
|
VK_API_VERSION_1_1,
|
2019-07-12 04:15:25 +00:00
|
|
|
};
|
|
|
|
VkInstanceCreateInfo createInfo = {
|
|
|
|
VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, 0, 0,
|
|
|
|
&appInfo,
|
|
|
|
0, 0,
|
|
|
|
0, 0,
|
|
|
|
};
|
|
|
|
VkResult res;
|
|
|
|
VkInstance instance;
|
|
|
|
|
|
|
|
if (!instanceLayerProperties) {
|
|
|
|
get_instance_layers_and_extensions (ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t nlay = count_strings (layers) + 1;
|
|
|
|
uint32_t next = count_strings (extensions)
|
|
|
|
+ count_strings (ctx->required_extensions) + 1;
|
[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 (vulkan_use_validation) {
|
2019-07-12 04:15:25 +00:00
|
|
|
nlay += count_strings (vulkanValidationLayers);
|
|
|
|
next += count_strings (debugExtensions);
|
|
|
|
}
|
|
|
|
const char **lay = alloca (nlay * sizeof (const char *));
|
|
|
|
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 *));
|
|
|
|
merge_strings (lay, layers, 0);
|
|
|
|
merge_strings (ext, extensions, ctx->required_extensions);
|
[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 (vulkan_use_validation) {
|
2019-07-12 04:15:25 +00:00
|
|
|
merge_strings (lay, lay, vulkanValidationLayers);
|
|
|
|
merge_strings (ext, ext, debugExtensions);
|
|
|
|
}
|
|
|
|
prune_strings (instanceLayers, lay, &nlay);
|
|
|
|
prune_strings (instanceExtensions, ext, &next);
|
|
|
|
lay[nlay] = 0;
|
|
|
|
ext[next] = 0;
|
|
|
|
createInfo.enabledLayerCount = nlay;
|
|
|
|
createInfo.ppEnabledLayerNames = lay;
|
|
|
|
createInfo.enabledExtensionCount = next;
|
|
|
|
createInfo.ppEnabledExtensionNames = ext;
|
|
|
|
|
|
|
|
res = ctx->vkCreateInstance (&createInfo, 0, &instance);
|
|
|
|
if (res != VK_SUCCESS) {
|
|
|
|
Sys_Error ("unable to create vulkan instance\n");
|
|
|
|
}
|
2019-07-12 16:11:34 +00:00
|
|
|
qfv_instance_t *inst = calloc (1, sizeof(qfv_instance_t)
|
2019-07-12 04:15:25 +00:00
|
|
|
+ sizeof (qfv_instfuncs_t));
|
|
|
|
inst->instance = instance;
|
|
|
|
inst->funcs = (qfv_instfuncs_t *)(inst + 1);
|
|
|
|
inst->enabled_extensions = new_strset (ext);
|
|
|
|
inst->extension_enabled = instance_extension_enabled;
|
2021-11-30 03:24:45 +00:00
|
|
|
DARRAY_INIT (&inst->debug_stack, 8);
|
2019-07-12 04:15:25 +00:00
|
|
|
ctx->instance = inst;
|
|
|
|
load_instance_funcs (ctx);
|
|
|
|
|
[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 (vulkan_use_validation) {
|
2019-07-12 04:15:25 +00:00
|
|
|
setup_debug_callback (inst);
|
|
|
|
}
|
|
|
|
|
2020-02-06 10:04:28 +00:00
|
|
|
qfv_instfuncs_t *ifunc = inst->funcs;
|
|
|
|
ifunc->vkEnumeratePhysicalDevices (instance, &inst->numDevices, 0);
|
|
|
|
inst->devices = malloc (inst->numDevices * sizeof (*inst->devices));
|
|
|
|
VkPhysicalDevice *devices = alloca (inst->numDevices * sizeof (*devices));
|
|
|
|
ifunc->vkEnumeratePhysicalDevices (instance, &inst->numDevices, devices);
|
|
|
|
for (uint32_t i = 0; i < inst->numDevices; i++) {
|
|
|
|
VkPhysicalDevice physDev = devices[i];
|
|
|
|
qfv_physdev_t *dev = &inst->devices[i];
|
2020-02-17 11:29:35 +00:00
|
|
|
dev->instance = inst;
|
2020-02-06 10:04:28 +00:00
|
|
|
dev->dev = physDev;
|
2022-05-29 13:13:36 +00:00
|
|
|
dev->properties2 = (VkPhysicalDeviceProperties2) {
|
|
|
|
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2,
|
|
|
|
.pNext = &dev->multiViewProperties,
|
|
|
|
};
|
|
|
|
dev->multiViewProperties = (VkPhysicalDeviceMultiviewProperties) {
|
|
|
|
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_PROPERTIES,
|
|
|
|
};
|
|
|
|
ifunc->vkGetPhysicalDeviceProperties2 (physDev, &dev->properties2);
|
|
|
|
dev->properties = &dev->properties2.properties;
|
2020-02-06 10:04:28 +00:00
|
|
|
ifunc->vkGetPhysicalDeviceMemoryProperties (physDev,
|
|
|
|
&dev->memory_properties);
|
|
|
|
}
|
2019-07-12 04:15:25 +00:00
|
|
|
return inst;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
QFV_DestroyInstance (qfv_instance_t *instance)
|
|
|
|
{
|
2019-07-12 16:11:34 +00:00
|
|
|
qfv_instfuncs_t *ifunc = instance->funcs;
|
2021-03-21 10:56:17 +00:00
|
|
|
|
2019-07-12 16:11:34 +00:00
|
|
|
if (instance->debug_handle) {
|
|
|
|
ifunc->vkDestroyDebugUtilsMessengerEXT (instance->instance,
|
|
|
|
instance->debug_handle, 0);
|
|
|
|
}
|
2019-07-12 04:15:25 +00:00
|
|
|
instance->funcs->vkDestroyInstance (instance->instance, 0);
|
2021-03-21 10:56:17 +00:00
|
|
|
del_strset (instance->enabled_extensions);
|
|
|
|
free (instance->devices);
|
2019-07-12 04:15:25 +00:00
|
|
|
free (instance);
|
|
|
|
}
|
2020-02-18 08:18:37 +00:00
|
|
|
|
|
|
|
VkSampleCountFlagBits
|
|
|
|
QFV_GetMaxSampleCount (qfv_physdev_t *physdev)
|
|
|
|
{
|
|
|
|
VkSampleCountFlagBits maxSamples = VK_SAMPLE_COUNT_64_BIT;
|
|
|
|
VkSampleCountFlagBits counts;
|
2022-05-29 13:13:36 +00:00
|
|
|
counts = min (physdev->properties->limits.framebufferColorSampleCounts,
|
|
|
|
physdev->properties->limits.framebufferDepthSampleCounts);
|
2020-02-18 08:18:37 +00:00
|
|
|
while (maxSamples && maxSamples > counts) {
|
|
|
|
maxSamples >>= 1;
|
|
|
|
}
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_vulkan, "Max samples: %x (%d)\n", maxSamples, counts);
|
2020-02-18 08:18:37 +00:00
|
|
|
return maxSamples;
|
|
|
|
}
|