fix vulkan handles width in 32-bit mode; print vk version
This commit is contained in:
parent
3e800fa989
commit
fa683fb882
|
@ -128,9 +128,23 @@ qboolean SW_CreateBuffer( int width, int height, uint *stride, uint *bpp, uint *
|
|||
// Vulkan
|
||||
//
|
||||
|
||||
// FIXME MAXIMUM DUMB
|
||||
// We need to declare this somewhere visible from:
|
||||
// - ref_api.h + ref_dll
|
||||
// - platform.h
|
||||
// Naively including ref_api.h in platform.h leads to weird compilation errors wrt wrong type casts (fwd declaration conflicts?)
|
||||
// Figure this out
|
||||
#if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__) ) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__)
|
||||
typedef void* vulkan_non_dispatchable_handle_t;
|
||||
#else
|
||||
typedef uint64_t vulkan_non_dispatchable_handle_t;
|
||||
#endif
|
||||
typedef void* vulkan_handle_t;
|
||||
// FIXME END MAXIMUM DUMB
|
||||
|
||||
int VK_GetInstanceExtensions( const char ***pNames );
|
||||
void *VK_GetVkGetInstanceProcAddr( void );
|
||||
void *VK_CreateSurface( void *vkInstance );
|
||||
vulkan_non_dispatchable_handle_t VK_CreateSurface( vulkan_handle_t vkInstance );
|
||||
|
||||
//
|
||||
// in_evdev.c
|
||||
|
|
|
@ -989,17 +989,17 @@ void *VK_GetVkGetInstanceProcAddr( void )
|
|||
return SDL_Vulkan_GetVkGetInstanceProcAddr();
|
||||
}
|
||||
|
||||
void *VK_CreateSurface( void *vkInstance )
|
||||
vulkan_non_dispatchable_handle_t VK_CreateSurface( vulkan_handle_t vkInstance )
|
||||
{
|
||||
VkSurfaceKHR surface;
|
||||
|
||||
if (!SDL_Vulkan_CreateSurface(host.hWnd, vkInstance, &surface))
|
||||
{
|
||||
Con_Reportf( S_ERROR "Couldn't create Vulkan surface: %s\n", SDL_GetError());
|
||||
return NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (void*)surface;
|
||||
return surface;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -251,6 +251,14 @@ typedef enum
|
|||
PARM_NUMMODELS = -13, // cl.nummodels
|
||||
} ref_parm_e;
|
||||
|
||||
#if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__) ) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__)
|
||||
typedef void* vulkan_non_dispatchable_handle_t;
|
||||
#else
|
||||
typedef uint64_t vulkan_non_dispatchable_handle_t;
|
||||
#endif
|
||||
|
||||
typedef void* vulkan_handle_t;
|
||||
|
||||
typedef struct ref_api_s
|
||||
{
|
||||
int (*EngineGetParm)( int parm, int arg ); // generic
|
||||
|
@ -436,7 +444,7 @@ typedef struct ref_api_s
|
|||
// Vulkan
|
||||
int (*VK_GetInstanceExtensions)( const char ***pNames );
|
||||
void *(*VK_GetVkGetInstanceProcAddr)( void );
|
||||
void *(*VK_CreateSurface)( void *vkInstance );
|
||||
vulkan_non_dispatchable_handle_t (*VK_CreateSurface)( vulkan_handle_t vkInstance );
|
||||
} ref_api_t;
|
||||
|
||||
struct mip_s;
|
||||
|
|
|
@ -8,8 +8,30 @@
|
|||
#include "crtlib.h"
|
||||
#include "com_strings.h"
|
||||
|
||||
#define VK_NO_PROTOTYPES
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
typedef struct vulkan_core_s {
|
||||
PFN_vkGetInstanceProcAddr get_proc_addr;
|
||||
uint32_t vulkan_version;
|
||||
VkInstance instance;
|
||||
} vulkan_core_t;
|
||||
|
||||
vulkan_core_t vk_core = {0};
|
||||
|
||||
#define XVK_PARSE_VERSION(v) \
|
||||
VK_VERSION_MAJOR(v), \
|
||||
VK_VERSION_MINOR(v), \
|
||||
VK_VERSION_PATCH(v)
|
||||
|
||||
#define XVK_INSTANCE_FUNC(f) \
|
||||
((PFN_ ##f)vk_core.get_proc_addr(vk_core.instance, #f))
|
||||
|
||||
static PFN_vkEnumerateInstanceVersion vkEnumerateInstanceVersion;
|
||||
|
||||
qboolean R_VkInit( void )
|
||||
{
|
||||
|
||||
if( !gEngine.R_Init_Video( REF_VULKAN )) // request Vulkan surface
|
||||
{
|
||||
gEngine.Con_Printf( S_ERROR "Cannot initialize Vulkan video" );
|
||||
|
@ -17,6 +39,25 @@ qboolean R_VkInit( void )
|
|||
}
|
||||
|
||||
// TODO VkInstance create ...
|
||||
vk_core.get_proc_addr = gEngine.VK_GetVkGetInstanceProcAddr();
|
||||
if (!vk_core.get_proc_addr)
|
||||
{
|
||||
gEngine.Con_Printf( S_ERROR "Cannot get vkGetInstanceProcAddr address" );
|
||||
return false;
|
||||
}
|
||||
|
||||
vkEnumerateInstanceVersion = XVK_INSTANCE_FUNC(vkEnumerateInstanceVersion);
|
||||
if (vkEnumerateInstanceVersion)
|
||||
{
|
||||
vkEnumerateInstanceVersion(&vk_core.vulkan_version);
|
||||
}
|
||||
else
|
||||
{
|
||||
vk_core.vulkan_version = VK_MAKE_VERSION(1, 0, 0);
|
||||
}
|
||||
|
||||
gEngine.Con_Printf( "Vulkan version %u.%u.%u\n", XVK_PARSE_VERSION(vk_core.vulkan_version));
|
||||
|
||||
{
|
||||
const char **instance_exts = NULL;
|
||||
const int num_instance_exts = gEngine.VK_GetInstanceExtensions(&instance_exts);
|
||||
|
@ -45,5 +86,6 @@ void R_VkShutdown( void )
|
|||
gEngine.Con_Printf("VK FIXME: %s\n", __FUNCTION__);
|
||||
|
||||
// TODO destroy everything
|
||||
//vkDestroyInstance(vk_core.instance, NULL);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue