mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-26 22:40:50 +00:00
vk: use os independent SDL_Vulkan_GetInstanceExtensions
This commit is contained in:
parent
eefcec35e9
commit
8b70b55e17
5 changed files with 35 additions and 58 deletions
|
@ -266,7 +266,7 @@ extern PFN_vkCmdEndDebugUtilsLabelEXT qvkCmdEndDebugUtilsLabelEXT;
|
|||
extern PFN_vkCmdInsertDebugUtilsLabelEXT qvkInsertDebugUtilsLabelEXT;
|
||||
|
||||
// The Interface Functions (tm)
|
||||
qboolean QVk_Init(void);
|
||||
qboolean QVk_Init(SDL_Window *window);
|
||||
void QVk_Shutdown(void);
|
||||
void QVk_CreateValidationLayers(void);
|
||||
void QVk_DestroyValidationLayers(void);
|
||||
|
|
|
@ -21,21 +21,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#ifndef __VK_LOCAL_H__
|
||||
#define __VK_LOCAL_H__
|
||||
|
||||
#ifdef _WIN32
|
||||
# include <windows.h>
|
||||
# define VK_USE_PLATFORM_WIN32_KHR
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
# define VK_USE_PLATFORM_XLIB_KHR
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
# define VK_USE_PLATFORM_MACOS_MVK
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL2/SDL_vulkan.h>
|
||||
|
||||
#include <vulkan/vulkan.h>
|
||||
#include <math.h>
|
||||
|
||||
|
@ -341,8 +331,6 @@ IMPLEMENTATION SPECIFIC FUNCTIONS
|
|||
====================================================================
|
||||
*/
|
||||
|
||||
void Vkimp_Shutdown( void );
|
||||
void Vkimp_GetSurfaceExtensions(char **extensions, uint32_t *extCount);
|
||||
qboolean Vkimp_CreateSurface(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1490,25 +1490,13 @@ void QVk_Shutdown( void )
|
|||
}
|
||||
}
|
||||
|
||||
void Vkimp_GetSurfaceExtensions(char **extensions, uint32_t *extCount)
|
||||
{
|
||||
if (extensions)
|
||||
{
|
||||
extensions[0] = VK_KHR_SURFACE_EXTENSION_NAME;
|
||||
extensions[1] = VK_KHR_XLIB_SURFACE_EXTENSION_NAME;
|
||||
}
|
||||
|
||||
if (extCount)
|
||||
*extCount = 2;
|
||||
}
|
||||
|
||||
/*
|
||||
** QVk_Init
|
||||
**
|
||||
** This is responsible for initializing Vulkan.
|
||||
**
|
||||
*/
|
||||
qboolean QVk_Init()
|
||||
qboolean QVk_Init(SDL_Window *window)
|
||||
{
|
||||
PFN_vkEnumerateInstanceVersion vkEnumerateInstanceVersion = (PFN_vkEnumerateInstanceVersion)vkGetInstanceProcAddr(NULL, "vkEnumerateInstanceVersion");
|
||||
uint32_t instanceVersion = VK_API_VERSION_1_0;
|
||||
|
@ -1529,7 +1517,7 @@ qboolean QVk_Init()
|
|||
};
|
||||
|
||||
uint32_t extCount;
|
||||
char **wantedExtensions;
|
||||
const char **wantedExtensions;
|
||||
memset(vk_config.supported_present_modes, 0, sizeof(vk_config.supported_present_modes));
|
||||
memset(vk_config.extensions, 0, sizeof(vk_config.extensions));
|
||||
memset(vk_config.layers, 0, sizeof(vk_config.layers));
|
||||
|
@ -1547,7 +1535,12 @@ qboolean QVk_Init()
|
|||
vk_config.triangle_fan_index_max_usage = 0;
|
||||
vk_config.triangle_fan_index_count = TRIANGLE_FAN_INDEX_CNT;
|
||||
|
||||
Vkimp_GetSurfaceExtensions(NULL, &extCount);
|
||||
if (!SDL_Vulkan_GetInstanceExtensions(window, &extCount, NULL))
|
||||
{
|
||||
ri.Sys_Error(ERR_FATAL, "%s() SDL_Vulkan_GetInstanceExtensions failed: %s",
|
||||
__func__, SDL_GetError());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (vk_validation->value)
|
||||
extCount++;
|
||||
|
@ -1556,8 +1549,13 @@ qboolean QVk_Init()
|
|||
extCount++;
|
||||
#endif
|
||||
|
||||
wantedExtensions = (char **)malloc(extCount * sizeof(const char *));
|
||||
Vkimp_GetSurfaceExtensions(wantedExtensions, NULL);
|
||||
wantedExtensions = malloc(extCount * sizeof(const char *));
|
||||
if (!SDL_Vulkan_GetInstanceExtensions(window, &extCount, wantedExtensions))
|
||||
{
|
||||
ri.Sys_Error(ERR_FATAL, "%s() SDL_Vulkan_GetInstanceExtensions failed: %s",
|
||||
__func__, SDL_GetError());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (vk_validation->value)
|
||||
wantedExtensions[extCount - 1] = VK_EXT_DEBUG_UTILS_EXTENSION_NAME;
|
||||
|
|
|
@ -1003,7 +1003,6 @@ void R_FloodFillSkin( byte *skin, int skinwidth, int skinheight )
|
|||
// can't fill to filled color or to transparent color (used as visited marker)
|
||||
if ((fillcolor == filledcolor) || (fillcolor == 255))
|
||||
{
|
||||
//printf( "not filling skin from %d to %d\n", fillcolor, filledcolor );
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,9 +20,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
// vk_rmain.c
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL2/SDL_vulkan.h>
|
||||
|
||||
#include "header/vk_local.h"
|
||||
|
||||
// world rendered and ready to render 2d elements
|
||||
|
@ -1192,6 +1189,8 @@ qboolean R_SetMode (void)
|
|||
return true;
|
||||
}
|
||||
|
||||
static SDL_Window *window = NULL;
|
||||
|
||||
/*
|
||||
===============
|
||||
R_Init
|
||||
|
@ -1215,7 +1214,7 @@ qboolean R_Init( void )
|
|||
ri.Vid_MenuInit();
|
||||
|
||||
// window is ready, initialize Vulkan now
|
||||
if (!QVk_Init())
|
||||
if (!QVk_Init(window))
|
||||
{
|
||||
R_Printf(PRINT_ALL, "%s() - could not initialize Vulkan!\n", __func__);
|
||||
return false;
|
||||
|
@ -1233,6 +1232,18 @@ qboolean R_Init( void )
|
|||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
** R_ShutdownContext
|
||||
**
|
||||
** This routine does all OS specific shutdown procedures for the Vulkan
|
||||
** subsystem.
|
||||
**
|
||||
*/
|
||||
static void R_ShutdownContext( void )
|
||||
{
|
||||
window = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
R_Shutdown
|
||||
|
@ -1256,7 +1267,7 @@ void R_Shutdown (void)
|
|||
// Shutdown Vulkan subsystem
|
||||
QVk_Shutdown();
|
||||
// shut down OS specific Vulkan stuff (in our case: window)
|
||||
Vkimp_Shutdown();
|
||||
R_ShutdownContext();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1467,8 +1478,6 @@ void Draw_TileClear (int x, int y, int w, int h, char *name);
|
|||
void Draw_Fill (int x, int y, int w, int h, int c);
|
||||
void Draw_FadeScreen (void);
|
||||
|
||||
static SDL_Window *window = NULL;
|
||||
|
||||
static int
|
||||
R_InitContext(void *win)
|
||||
{
|
||||
|
@ -1489,18 +1498,6 @@ R_InitContext(void *win)
|
|||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
** Vkimp_Shutdown
|
||||
**
|
||||
** This routine does all OS specific shutdown procedures for the Vulkan
|
||||
** subsystem.
|
||||
**
|
||||
*/
|
||||
void Vkimp_Shutdown( void )
|
||||
{
|
||||
window = NULL;
|
||||
}
|
||||
|
||||
qboolean Vkimp_CreateSurface()
|
||||
{
|
||||
if (!SDL_Vulkan_CreateSurface(window, vk_instance, &vk_surface))
|
||||
|
@ -1512,11 +1509,6 @@ qboolean Vkimp_CreateSurface()
|
|||
return true;
|
||||
}
|
||||
|
||||
static void
|
||||
R_ShutdownContext(void)
|
||||
{
|
||||
}
|
||||
|
||||
static qboolean
|
||||
R_IsVsyncActive(void)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue