/* vid_common_vulkan.c Common Vulkan video driver functions Copyright (C) 1996-1997 Id Software, Inc. Copyright (C) 2019 Bill Currie 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 #ifdef HAVE_MATH_H # include #endif #ifdef HAVE_STRING_H # include #endif #ifdef HAVE_STRINGS_H # include #endif #include "QF/cvar.h" #include "QF/dstring.h" #include "QF/input.h" #include "QF/mathlib.h" #include "QF/qargs.h" #include "QF/quakefs.h" #include "QF/sys.h" #include "QF/va.h" #include "QF/vid.h" #include "QF/Vulkan/qf_vid.h" #include "QF/Vulkan/device.h" #include "QF/Vulkan/instance.h" #include "compat.h" #include "d_iface.h" #include "r_internal.h" #include "vid_vulkan.h" #include "util.h" cvar_t *vulkan_presentation_mode; static void vulkan_presentation_mode_f (cvar_t *var) { if (!strcmp (var->string, "immediate")) { var->int_val = VK_PRESENT_MODE_IMMEDIATE_KHR; } else if (!strcmp (var->string, "fifo")) { var->int_val = VK_PRESENT_MODE_FIFO_KHR; } else if (!strcmp (var->string, "relaxed")) { var->int_val = VK_PRESENT_MODE_FIFO_RELAXED_KHR; } else if (!strcmp (var->string, "mailbox")) { var->int_val = VK_PRESENT_MODE_MAILBOX_KHR; } else { Sys_Printf ("Invalid presentation mode, using fifo\n"); var->int_val = VK_PRESENT_MODE_FIFO_KHR; } } static void Vulkan_Init_Cvars (void) { vulkan_use_validation = Cvar_Get ("vulkan_use_validation", "1", CVAR_NONE, 0, "enable LunarG Standard Validation " "Layer if available (requires instance " "restart)."); // FIXME implement fallback choices (instead of just fifo) vulkan_presentation_mode = Cvar_Get ("vulkan_presentation_mode", "mailbox", CVAR_NONE, vulkan_presentation_mode_f, "desired presentation mode (may fall " "back to fifo)."); } static const char *instance_extensions[] = { VK_KHR_SURFACE_EXTENSION_NAME, 0, }; static const char *device_extensions[] = { VK_KHR_SWAPCHAIN_EXTENSION_NAME, 0, }; void Vulkan_Init_Common (vulkan_ctx_t *ctx) { Sys_Printf ("Vulkan_Init_Common\n"); Vulkan_Init_Cvars (); ctx->instance = QFV_CreateInstance (ctx, PACKAGE_STRING, 0x000702ff, 0, instance_extensions);//FIXME version } void Vulkan_Shutdown_Common (vulkan_ctx_t *ctx) { QFV_DestroyInstance (ctx->instance); ctx->instance = 0; ctx->unload_vulkan (ctx); } void Vulkan_CreateDevice (vulkan_ctx_t *ctx) { ctx->device = QFV_CreateDevice (ctx, device_extensions); } void Vulkan_CreateSwapchain (vulkan_ctx_t *ctx) { }