add sdl build flag
This commit is contained in:
parent
d6580c58f4
commit
b3726d3627
@ -42,12 +42,12 @@
|
||||
# include "../external/vma/vk_mem_alloc.h"
|
||||
#endif
|
||||
|
||||
#ifndef BUILD_WASM
|
||||
#ifdef BUILD_SDL
|
||||
# include <SDL3/SDL.h>
|
||||
|
||||
#ifdef BUILD_VULKAN
|
||||
# include <SDL3/SDL_vulkan.h>
|
||||
#endif
|
||||
# ifdef BUILD_VULKAN
|
||||
# include <SDL3/SDL_vulkan.h>
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@ -50,7 +50,19 @@ static if(!__traits(compiles, { glActiveTexture(0x84C0); }))
|
||||
PFNGLACTIVETEXTUREPROC glActiveTexture;
|
||||
}
|
||||
|
||||
alias GLLoadProcAddr = SDL_GL_GetProcAddress;
|
||||
static if(__traits(compiles, { SDL_GL_GetProcAddress("Test"); }))
|
||||
{
|
||||
alias GLLoadProcAddr = SDL_GL_GetProcAddress;
|
||||
}
|
||||
else
|
||||
{
|
||||
void* GLLoadProcAddr(const char* name)
|
||||
{
|
||||
assert(false, "Currently requires SDL");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
GLLoadFuncs()
|
||||
|
||||
@ -15,6 +15,8 @@ import core.stdc.stdio : Printf = printf;
|
||||
import std.format : sformat;
|
||||
import std.math.rounding : Ceil = ceil;
|
||||
|
||||
enum bool SDL_ENABLED = __traits(compiles, { u32 count; SDL_Vulkan_GetInstanceExtensions(&count); });
|
||||
|
||||
version(VULKAN_DEBUG)
|
||||
{
|
||||
const BUILD_DEBUG = true;
|
||||
@ -68,8 +70,11 @@ version(Windows)
|
||||
|
||||
struct PlatformHandles
|
||||
{
|
||||
bool sdl;
|
||||
SDL_Window* sdl_window;
|
||||
bool sdl;
|
||||
static if(SDL_ENABLED)
|
||||
{
|
||||
SDL_Window* sdl_window;
|
||||
}
|
||||
version(linux)
|
||||
{
|
||||
Display* display;
|
||||
@ -2768,55 +2773,62 @@ Init(VulkanBuildInfo build_info, u64 permanent_mem, u64 frame_mem)
|
||||
char*[] instance_ext = instance_ext_base;
|
||||
if(build_info.platform_handles.sdl)
|
||||
{
|
||||
u32 total_extension_count = cast(u32)instance_ext.length;
|
||||
|
||||
u32 sdl_extension_count;
|
||||
const char** sdl_extensions_ptr = SDL_Vulkan_GetInstanceExtensions(&sdl_extension_count);
|
||||
const char*[] sdl_extensions = sdl_extensions_ptr[0 .. sdl_extension_count];
|
||||
if(sdl_extensions == null)
|
||||
static if(SDL_ENABLED)
|
||||
{
|
||||
Errf("Failed to query Vulkan extensions for SDL, make sure the SDL_WINDOW_VULKAN flag is passed to SDL_CreateWindow [%s]", SDL_GetError());
|
||||
assert(false);
|
||||
}
|
||||
u32 total_extension_count = cast(u32)instance_ext.length;
|
||||
|
||||
foreach(i; 0 .. sdl_extensions.length)
|
||||
{
|
||||
bool exists;
|
||||
foreach(j; 0 .. instance_ext.length)
|
||||
u32 sdl_extension_count;
|
||||
const char** sdl_extensions_ptr = SDL_Vulkan_GetInstanceExtensions(&sdl_extension_count);
|
||||
const char*[] sdl_extensions = sdl_extensions_ptr[0 .. sdl_extension_count];
|
||||
if(sdl_extensions == null)
|
||||
{
|
||||
if(strcmp(sdl_extensions[i], instance_ext[i]) == 0)
|
||||
Errf("Failed to query Vulkan extensions for SDL, make sure the SDL_WINDOW_VULKAN flag is passed to SDL_CreateWindow [%s]", SDL_GetError());
|
||||
assert(false);
|
||||
}
|
||||
|
||||
foreach(i; 0 .. sdl_extensions.length)
|
||||
{
|
||||
bool exists;
|
||||
foreach(j; 0 .. instance_ext.length)
|
||||
{
|
||||
exists = true;
|
||||
break;
|
||||
if(strcmp(sdl_extensions[i], instance_ext[i]) == 0)
|
||||
{
|
||||
exists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!exists)
|
||||
{
|
||||
total_extension_count += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if(!exists)
|
||||
{
|
||||
total_extension_count += 1;
|
||||
}
|
||||
}
|
||||
instance_ext = Alloc!(char*)(arena, total_extension_count);
|
||||
instance_ext[0 .. instance_ext.length] = instance_ext_base[0 .. $];
|
||||
|
||||
instance_ext = Alloc!(char*)(arena, total_extension_count);
|
||||
instance_ext[0 .. instance_ext.length] = instance_ext_base[0 .. $];
|
||||
|
||||
u32 ext_count = cast(u32)instance_ext_base.length;
|
||||
foreach(i; 0 .. sdl_extensions.length)
|
||||
{
|
||||
bool exists;
|
||||
foreach(j; 0 .. instance_ext_base.length)
|
||||
u32 ext_count = cast(u32)instance_ext_base.length;
|
||||
foreach(i; 0 .. sdl_extensions.length)
|
||||
{
|
||||
if(strcmp(sdl_extensions[i], instance_ext_base[i]) == 0)
|
||||
bool exists;
|
||||
foreach(j; 0 .. instance_ext_base.length)
|
||||
{
|
||||
exists = true;
|
||||
break;
|
||||
if(strcmp(sdl_extensions[i], instance_ext_base[i]) == 0)
|
||||
{
|
||||
exists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!exists)
|
||||
{
|
||||
instance_ext[ext_count++] = cast(char*)sdl_extensions[i];
|
||||
}
|
||||
}
|
||||
|
||||
if(!exists)
|
||||
{
|
||||
instance_ext[ext_count++] = cast(char*)sdl_extensions[i];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(false, "Must be built with SDL or have the SDL flag disabled");
|
||||
}
|
||||
}
|
||||
|
||||
@ -2902,10 +2914,13 @@ Init(VulkanBuildInfo build_info, u64 permanent_mem, u64 frame_mem)
|
||||
{
|
||||
if(g_vk.platform_handles.sdl)
|
||||
{
|
||||
if(!SDL_Vulkan_CreateSurface(g_vk.platform_handles.sdl_window, g_vk.instance, null, &g_vk.surface))
|
||||
static if(SDL_ENABLED)
|
||||
{
|
||||
Errf("Failed to initialize Vulkan surface through SDL [%s]", Str(SDL_GetError()));
|
||||
assert(false);
|
||||
if(!SDL_Vulkan_CreateSurface(g_vk.platform_handles.sdl_window, g_vk.instance, null, &g_vk.surface))
|
||||
{
|
||||
Errf("Failed to initialize Vulkan surface through SDL [%s]", Str(SDL_GetError()));
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user