Don't link against the Vulkan loader, load it at runtime.

This commit is contained in:
Yamagi 2020-10-05 19:10:53 +02:00
parent d936bad256
commit 85b9f84b3d
9 changed files with 3177 additions and 12 deletions

View File

@ -595,6 +595,7 @@ set(VK-Source
${REF_SRC_DIR}/vk/vk_validation.c
${REF_SRC_DIR}/vk/vk_warp.c
${REF_SRC_DIR}/vk/vk_util.c
${REF_SRC_DIR}/vk/volk/volk.c
${REF_SRC_DIR}/files/pcx.c
${REF_SRC_DIR}/files/stb.c
${REF_SRC_DIR}/files/wal.c

View File

@ -649,14 +649,14 @@ ref_vk:
@echo "===> Building ref_vk.dll"
$(MAKE) release/ref_vk.dll
release/ref_vk.dll : LDFLAGS += -shared -lvulkan
release/ref_vk.dll : LDFLAGS += -shared
else
ref_vk:
@echo "===> Building ref_vk.so"
$(MAKE) release/ref_vk.so
release/ref_vk.so : CFLAGS += -fPIC
release/ref_vk.so : LDFLAGS += -shared -lvulkan
release/ref_vk.so : LDFLAGS += -shared
endif
build/ref_vk/%.o: %.c
@ -969,6 +969,7 @@ REFVK_OBJS_ := \
src/client/refresh/vk/vk_validation.o \
src/client/refresh/vk/vk_warp.o \
src/client/refresh/vk/vk_util.o \
src/client/refresh/vk/volk/volk.o \
src/client/refresh/files/pcx.o \
src/client/refresh/files/stb.o \
src/client/refresh/files/wal.o \

View File

@ -21,16 +21,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef __VK_LOCAL_H__
#define __VK_LOCAL_H__
#include <math.h>
#include <stdio.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_vulkan.h>
#include <vulkan/vulkan.h>
#include <math.h>
#include "../../ref_shared.h"
#include "../volk/volk.h"
#include "qvk.h"
// verify if VkResult is VK_SUCCESS

View File

@ -29,7 +29,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# include <windows.h>
#endif
#include <vulkan/vulkan.h>
#include "local.h"
#include "util.h"
#include "shaders.h"

View File

@ -19,7 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#ifndef __VK_UTIL_H__
#define __VK_UTIL_H__
#include <vulkan/vulkan.h>
#include "../volk/volk.h"
#define ROUNDUP(a, b) (((a) + ((b)-1)) & ~((b)-1))

View File

@ -1701,6 +1701,8 @@ qboolean QVk_Init(SDL_Window *window)
VkResult res = vkCreateInstance(&createInfo, NULL, &vk_instance);
free(wantedExtensions);
volkLoadInstance(vk_instance);
if (res != VK_SUCCESS)
{
R_Printf(PRINT_ALL, "%s(): Could not create Vulkan instance: %s\n", __func__, QVk_GetError(res));

View File

@ -1601,13 +1601,13 @@ R_IsVsyncActive(void)
static int R_PrepareForWindow(void)
{
#if defined(_WIN32)
if (SDL_Vulkan_LoadLibrary("libvulkan-1.dll"))
if (SDL_Vulkan_LoadLibrary(NULL))
{
R_Printf(PRINT_ALL, "%s() Loader import failed: %s",
__func__, SDL_GetError());
R_Printf(PRINT_ALL, "%s() Loader import failed: %s", __func__, SDL_GetError());
}
#endif
volkInitializeCustom(SDL_Vulkan_GetVkGetInstanceProcAddr());
return SDL_WINDOW_VULKAN;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff