Added GLFW_INCLUDE_VULKAN. Added glfwVulkanSupported, glfwGetRequiredInstanceExtensions, glfwGetInstanceProcAddress, glfwGetPhysicalDevicePresentationSupport and glfwCreateWindowSurface. Added port of LunarG SDK tri example.master
parent
c2efe87cff
commit
9b75bffc88
35 changed files with 7823 additions and 51 deletions
@ -0,0 +1,23 @@ |
||||
# Find Vulkan |
||||
# |
||||
# VULKAN_INCLUDE_DIR |
||||
# VULKAN_LIBRARY |
||||
# VULKAN_FOUND |
||||
|
||||
if (WIN32) |
||||
find_path(VULKAN_INCLUDE_DIR NAMES vulkan/vulkan.h HINTS |
||||
"$ENV{VK_SDK_PATH}/Include") |
||||
find_library(VULKAN_LIBRARY NAMES vulkan-1 HINTS |
||||
"$ENV{VK_SDK_PATH}/Bin") |
||||
else() |
||||
find_path(VULKAN_INCLUDE_DIR NAMES vulkan/vulkan.h HINTS |
||||
"$ENV{VULKAN_SDK}/include") |
||||
find_library(VULKAN_LIBRARY NAMES vulkan HINTS |
||||
"$ENV{VULKAN_SDK}/lib") |
||||
endif() |
||||
|
||||
include(FindPackageHandleStandardArgs) |
||||
find_package_handle_standard_args(Vulkan DEFAULT_MSG VULKAN_LIBRARY VULKAN_INCLUDE_DIR) |
||||
|
||||
mark_as_advanced(VULKAN_INCLUDE_DIR VULKAN_LIBRARY) |
||||
|
@ -0,0 +1,127 @@ |
||||
//
|
||||
// File: vk_platform.h
|
||||
//
|
||||
/*
|
||||
** Copyright (c) 2014-2015 The Khronos Group Inc. |
||||
** |
||||
** Permission is hereby granted, free of charge, to any person obtaining a |
||||
** copy of this software and/or associated documentation files (the |
||||
** "Materials"), to deal in the Materials without restriction, including |
||||
** without limitation the rights to use, copy, modify, merge, publish, |
||||
** distribute, sublicense, and/or sell copies of the Materials, and to |
||||
** permit persons to whom the Materials are furnished to do so, subject to |
||||
** the following conditions: |
||||
** |
||||
** The above copyright notice and this permission notice shall be included |
||||
** in all copies or substantial portions of the Materials. |
||||
** |
||||
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
||||
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
||||
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. |
||||
*/ |
||||
|
||||
|
||||
#ifndef __VK_PLATFORM_H__ |
||||
#define __VK_PLATFORM_H__ |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" |
||||
{ |
||||
#endif // __cplusplus
|
||||
|
||||
/*
|
||||
*************************************************************************************************** |
||||
* Platform-specific directives and type declarations |
||||
*************************************************************************************************** |
||||
*/ |
||||
|
||||
/* Platform-specific calling convention macros.
|
||||
* |
||||
* Platforms should define these so that Vulkan clients call Vulkan commands |
||||
* with the same calling conventions that the Vulkan implementation expects. |
||||
* |
||||
* VKAPI_ATTR - Placed before the return type in function declarations. |
||||
* Useful for C++11 and GCC/Clang-style function attribute syntax. |
||||
* VKAPI_CALL - Placed after the return type in function declarations. |
||||
* Useful for MSVC-style calling convention syntax. |
||||
* VKAPI_PTR - Placed between the '(' and '*' in function pointer types. |
||||
* |
||||
* Function declaration: VKAPI_ATTR void VKAPI_CALL vkCommand(void); |
||||
* Function pointer type: typedef void (VKAPI_PTR *PFN_vkCommand)(void); |
||||
*/ |
||||
#if defined(_WIN32) |
||||
// On Windows, Vulkan commands use the stdcall convention
|
||||
#define VKAPI_ATTR |
||||
#define VKAPI_CALL __stdcall |
||||
#define VKAPI_PTR VKAPI_CALL |
||||
#elif defined(__ANDROID__) && defined(__ARM_EABI__) && !defined(__ARM_ARCH_7A__) |
||||
// Android does not support Vulkan in native code using the "armeabi" ABI.
|
||||
#error "Vulkan requires the 'armeabi-v7a' or 'armeabi-v7a-hard' ABI on 32-bit ARM CPUs" |
||||
#elif defined(__ANDROID__) && defined(__ARM_ARCH_7A__) |
||||
// On Android/ARMv7a, Vulkan functions use the armeabi-v7a-hard calling
|
||||
// convention, even if the application's native code is compiled with the
|
||||
// armeabi-v7a calling convention.
|
||||
#define VKAPI_ATTR __attribute__((pcs("aapcs-vfp"))) |
||||
#define VKAPI_CALL |
||||
#define VKAPI_PTR VKAPI_ATTR |
||||
#else |
||||
// On other platforms, use the default calling convention
|
||||
#define VKAPI_ATTR |
||||
#define VKAPI_CALL |
||||
#define VKAPI_PTR |
||||
#endif |
||||
|
||||
#include <stddef.h> |
||||
|
||||
#if !defined(VK_NO_STDINT_H) |
||||
#if defined(_MSC_VER) && (_MSC_VER < 1600) |
||||
typedef signed __int8 int8_t; |
||||
typedef unsigned __int8 uint8_t; |
||||
typedef signed __int16 int16_t; |
||||
typedef unsigned __int16 uint16_t; |
||||
typedef signed __int32 int32_t; |
||||
typedef unsigned __int32 uint32_t; |
||||
typedef signed __int64 int64_t; |
||||
typedef unsigned __int64 uint64_t; |
||||
#else |
||||
#include <stdint.h> |
||||
#endif |
||||
#endif // !defined(VK_NO_STDINT_H)
|
||||
|
||||
#ifdef __cplusplus |
||||
} // extern "C"
|
||||
#endif // __cplusplus
|
||||
|
||||
// Platform-specific headers required by platform window system extensions.
|
||||
// These are enabled prior to #including "vulkan.h". The same enable then
|
||||
// controls inclusion of the extension interfaces in vulkan.h.
|
||||
|
||||
#ifdef VK_USE_PLATFORM_ANDROID_KHR |
||||
#include <android/native_window.h> |
||||
#endif |
||||
|
||||
#ifdef VK_USE_PLATFORM_MIR_KHR |
||||
#include <mir_toolkit/client_types.h> |
||||
#endif |
||||
|
||||
#ifdef VK_USE_PLATFORM_WAYLAND_KHR |
||||
#include <wayland-client.h> |
||||
#endif |
||||
|
||||
#ifdef VK_USE_PLATFORM_WIN32_KHR |
||||
#include <windows.h> |
||||
#endif |
||||
|
||||
#ifdef VK_USE_PLATFORM_XLIB_KHR |
||||
#include <X11/Xlib.h> |
||||
#endif |
||||
|
||||
#ifdef VK_USE_PLATFORM_XCB_KHR |
||||
#include <xcb/xcb.h> |
||||
#endif |
||||
|
||||
#endif // __VK_PLATFORM_H__
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,185 @@ |
||||
/*! |
||||
|
||||
@page vulkan Vulkan guide |
||||
|
||||
@tableofcontents |
||||
|
||||
This guide is intended to fill the gaps between the Vulkan documentation and the |
||||
rest of the GLFW documentation and is not a replacement for either. |
||||
|
||||
To develop for Vulkan you should install an SDK for your platform, for example |
||||
the [LunarG Vulkan SDK](http://lunarg.com/vulkan-sdk/). Apart from the headers |
||||
and libraries, it also provides the validation layers necessary for development. |
||||
|
||||
GLFW itself does not need a Vulkan SDK to enable support for Vulkan. However, |
||||
any Vulkan-specific test and example programs are built only if the CMake files |
||||
find the LunarG SDK. |
||||
|
||||
|
||||
@section vulkan_include Including the Vulkan and GLFW header files |
||||
|
||||
To include the Vulkan header, define `GLFW_INCLUDE_VULKAN` before including the |
||||
GLFW header. |
||||
|
||||
@code |
||||
#define GLFW_INCLUDE_VULKAN |
||||
#include <GLFW/glfw3.h> |
||||
@endcode |
||||
|
||||
If you want to include the Vulkan header from a custom location or use your own |
||||
custom Vulkan header then you need to include them before the GLFW header. |
||||
|
||||
@code |
||||
#include <custom/path/vulkan.h> |
||||
#include <GLFW/glfw3.h> |
||||
@endcode |
||||
|
||||
Unless a Vulkan header is included, either by the GLFW header or above it, any |
||||
GLFW functions that use Vulkan types will not be declared. |
||||
|
||||
The `VK_USE_PLATFORM_*_KHR` macros do not need to be defined for the Vulkan part |
||||
of GLFW to work. |
||||
|
||||
|
||||
@section vulkan_support Querying for Vulkan support |
||||
|
||||
If you are loading the Vulkan loader dynamically instead of linking directly |
||||
against it, you can check for the availability of a loader with @ref |
||||
glfwVulkanSupported. |
||||
|
||||
@code |
||||
if (glfwVulkanSupported()) |
||||
{ |
||||
// Vulkan is available, at least for compute |
||||
} |
||||
@endcode |
||||
|
||||
This function returns `GLFW_TRUE` if the Vulkan loader was found. This check is |
||||
performed by @ref glfwInit. |
||||
|
||||
If no loader was found, calling any other Vulkan related GLFW function will |
||||
generate a @ref GLFW_API_UNAVAILABLE error. |
||||
|
||||
|
||||
@subsection vulkan_proc Querying Vulkan function pointers |
||||
|
||||
To load any Vulkan core or extension function from the found loader, call @ref |
||||
glfwGetInstanceProcAddress. |
||||
|
||||
@code |
||||
PFN_vkCreateDevice pfnCreateDevice = (PFN_vkCreateDevice) |
||||
glfwGetInstanceProcAddress(instance, "vkCreateDevice"); |
||||
@endcode |
||||
|
||||
This is equivalent to calling `vkGetInstanceProcAddr`. If that fails, the |
||||
function falls back to a platform-specific query of the Vulkan loader (i.e. |
||||
`dlsym` or `GetProcAddress`). If that also fails, the function returns `NULL`. |
||||
For more information about `vkGetInstanceProcAddr`, see the Vulkan |
||||
documentation. |
||||
|
||||
Vulkan also provides `vkGetDeviceProcAddr` for loading device-specific versions |
||||
of Vulkan function. This function can be retrieved from an instance with @ref |
||||
glfwGetInstanceProcAddress. |
||||
|
||||
@code |
||||
PFN_vkGetDeviceProcAddr pfnGetDeviceProcAddr = (PFN_vkGetDeviceProcAddr) |
||||
glfwGetInstanceProcAddress(instance, "vkGetDeviceProcAddr"); |
||||
@endcode |
||||
|
||||
Device-specific functions may execute a little bit faster, due to not having to |
||||
dispatch internally based on the device passed to them. For more information |
||||
about `vkGetDeviceProcAddr`, see the Vulkan documentation. |
||||
|
||||
|
||||
@section vulkan_ext Querying required Vulkan extensions |
||||
|
||||
To do anything useful with Vulkan you need to create an instance. If you want |
||||
to use Vulkan to render to a window, you must enable the instance extensions |
||||
GLFW requires to create Vulkan surfaces. |
||||
|
||||
To query the instance extensions required, call @ref |
||||
glfwGetRequiredInstanceExtensions. |
||||
|
||||
@code |
||||
int count; |
||||
const char** extensions = glfwGetRequiredInstanceExtensions(&count); |
||||
@endcode |
||||
|
||||
These extensions must all be enabled when creating instances that are going to |
||||
be passed to @ref glfwGetPhysicalDevicePresentationSupport and @ref |
||||
glfwCreateWindowSurface. The set of extensions will vary depending on platform |
||||
and may also vary depending on graphics drivers and other factors. |
||||
|
||||
If it fails it will return `NULL` and Vulkan window surface creation will not be |
||||
possible. You may still use Vulkan for off-screen rendering and compute work. |
||||
|
||||
The returned array will always contain `VK_KHR_surface`, so if you don't |
||||
require any additional extensions you can pass this list directly to the |
||||
`VkInstanceCreateInfo` struct. |
||||
|
||||
@code |
||||
VkInstanceCreateInfo ici; |
||||
|
||||
memset(&ici, 0, sizeof(ici)); |
||||
ici.enabledExtensionCount = count; |
||||
ici.ppEnabledExtensionNames = extensions; |
||||
... |
||||
@endcode |
||||
|
||||
Additional extensions may be required by future versions of GLFW. You should |
||||
check whether any extensions you wish to enable are already in the returned |
||||
array, as it is an error to specify an extension more than once in the |
||||
`VkInstanceCreateInfo` struct. |
||||
|
||||
|
||||
@section vulkan_present Querying for Vulkan presentation support |
||||
|
||||
Not every Vulkan queue family of every device can present images to surfaces. |
||||
To check whether a specific queue family of a physical device supports image |
||||
presentation without first having to create a window and surface, call @ref |
||||
glfwGetPhysicalDevicePresentationSupport. |
||||
|
||||
@code |
||||
if (glfwGetPhysicalDevicePresentationSupport(instance, physical_device, queue_family_index)) |
||||
{ |
||||
// Queue family supports image presentation |
||||
} |
||||
@endcode |
||||
|
||||
The `VK_KHR_surface` extension also provides the |
||||
`vkGetPhysicalDeviceSurfaceSupportKHR` function, which performs the same test on |
||||
an existing Vulkan surface. |
||||
|
||||
|
||||
@section vulkan_window Creating the window |
||||
|
||||
Unless you will be using OpenGL or OpenGL ES in addition to Vulkan, there is no |
||||
need to create a context for that window. You can disable context creation by |
||||
setting the [GLFW_CLIENT_API](@ref window_hints_ctx) hint to `GLFW_NO_API`. |
||||
|
||||
@code |
||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); |
||||
GLFWwindow* window = glfwCreateWindow(640, 480, "Window Title", NULL, NULL); |
||||
@endcode |
||||
|
||||
See @ref context_less for more information. |
||||
|
||||
|
||||
@section vulkan_surface Creating a Vulkan window surface |
||||
|
||||
You can create a Vulkan surface (as defined by the `VK_KHR_surface` extension) |
||||
for a GLFW window with @ref glfwCreateWindowSurface. |
||||
|
||||
@code |
||||
VkSurfaceKHR surface; |
||||
VkResult err = glfwCreateWindowSurface(instance, window, NULL, &surface); |
||||
if (err) |
||||
{ |
||||
// Window surface creation failed |
||||
} |
||||
@endcode |
||||
|
||||
It is your responsibility to destroy the surface. GLFW does not destroy it for |
||||
you. Call `vkDestroySurfaceKHR` function from the same extension to destroy it. |
||||
|
||||
*/ |
@ -0,0 +1,287 @@ |
||||
//========================================================================
|
||||
// GLFW 3.2 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would
|
||||
// be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such, and must not
|
||||
// be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source
|
||||
// distribution.
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "internal.h" |
||||
|
||||
#include <assert.h> |
||||
#include <string.h> |
||||
#include <stdlib.h> |
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW internal API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void _glfwInitVulkan(void) |
||||
{ |
||||
VkResult err; |
||||
VkExtensionProperties* ep; |
||||
unsigned int i, count; |
||||
#if defined(_GLFW_WIN32) |
||||
const char* name = "vulkan-1.dll"; |
||||
#else |
||||
const char* name = "libvulkan.so.1"; |
||||
#endif |
||||
|
||||
_glfw.vk.handle = _glfw_dlopen(name); |
||||
if (!_glfw.vk.handle) |
||||
return; |
||||
|
||||
_glfw.vk.GetInstanceProcAddr = (PFN_vkGetInstanceProcAddr) |
||||
_glfw_dlsym(_glfw.vk.handle, "vkGetInstanceProcAddr"); |
||||
if (!_glfw.vk.GetInstanceProcAddr) |
||||
{ |
||||
_glfwInputError(GLFW_API_UNAVAILABLE, |
||||
"Vulkan: Loader does not export vkGetInstanceProcAddr"); |
||||
return; |
||||
} |
||||
|
||||
_glfw.vk.EnumerateInstanceExtensionProperties = (PFN_vkEnumerateInstanceExtensionProperties) |
||||
vkGetInstanceProcAddr(0, "vkEnumerateInstanceExtensionProperties"); |
||||
if (!_glfw.vk.EnumerateInstanceExtensionProperties) |
||||
{ |
||||
_glfwInputError(GLFW_API_UNAVAILABLE, |
||||
"Vulkan: Failed to retrieve vkEnumerateInstanceExtensionProperties"); |
||||
return; |
||||
} |
||||
|
||||
err = vkEnumerateInstanceExtensionProperties(NULL, &count, NULL); |
||||
if (err) |
||||
{ |
||||
_glfwInputError(GLFW_PLATFORM_ERROR, |
||||
"Vulkan: Failed to query instance extension count: %s", |
||||
_glfwGetVulkanResultString(err)); |
||||
return; |
||||
} |
||||
|
||||
ep = calloc(count, sizeof(VkExtensionProperties)); |
||||
|
||||
err = vkEnumerateInstanceExtensionProperties(NULL, &count, ep); |
||||
if (err) |
||||
{ |
||||
_glfwInputError(GLFW_PLATFORM_ERROR, |
||||
"Vulkan: Failed to query instance extensions: %s", |
||||
_glfwGetVulkanResultString(err)); |
||||
|
||||
free(ep); |
||||
return; |
||||
} |
||||
|
||||
for (i = 0; i < count; i++) |
||||
{ |
||||
if (strcmp(ep[i].extensionName, "VK_KHR_surface") == 0) |
||||
_glfw.vk.KHR_surface = GLFW_TRUE; |
||||
if (strcmp(ep[i].extensionName, "VK_KHR_win32_surface") == 0) |
||||
_glfw.vk.KHR_win32_surface = GLFW_TRUE; |
||||
if (strcmp(ep[i].extensionName, "VK_KHR_xlib_surface") == 0) |
||||
_glfw.vk.KHR_xlib_surface = GLFW_TRUE; |
||||
if (strcmp(ep[i].extensionName, "VK_KHR_xcb_surface") == 0) |
||||
_glfw.vk.KHR_xcb_surface = GLFW_TRUE; |
||||
if (strcmp(ep[i].extensionName, "VK_KHR_wayland_surface") == 0) |
||||
_glfw.vk.KHR_wayland_surface = GLFW_TRUE; |
||||
if (strcmp(ep[i].extensionName, "VK_KHR_mir_surface") == 0) |
||||
_glfw.vk.KHR_mir_surface = GLFW_TRUE; |
||||
} |
||||
|
||||
free(ep); |
||||
|
||||
_glfw.vk.available = GLFW_TRUE; |
||||
|
||||
if (!_glfw.vk.KHR_surface) |
||||
return; |
||||
|
||||
_glfw.vk.extensions = |
||||
_glfwPlatformGetRequiredInstanceExtensions(&_glfw.vk.extensionCount); |
||||
} |
||||
|
||||
void _glfwTerminateVulkan(void) |
||||
{ |
||||
int i; |
||||
|
||||
for (i = 0; i < _glfw.vk.extensionCount; i++) |
||||
free(_glfw.vk.extensions[i]); |
||||
free(_glfw.vk.extensions); |
||||
|
||||
if (_glfw.vk.handle) |
||||
_glfw_dlclose(_glfw.vk.handle); |
||||
} |
||||
|
||||
const char* _glfwGetVulkanResultString(VkResult result) |
||||
{ |
||||
switch (result) |
||||
{ |
||||
case VK_SUCCESS: |
||||
return "Success"; |
||||
case VK_NOT_READY: |
||||
return "A fence or query has not yet completed"; |
||||
case VK_TIMEOUT: |
||||
return "A wait operation has not completed in the specified time"; |
||||
case VK_EVENT_SET: |
||||
return "An event is signaled"; |
||||
case VK_EVENT_RESET: |
||||
return "An event is unsignaled"; |
||||
case VK_INCOMPLETE: |
||||
return "A return array was too small for the result"; |
||||
case VK_ERROR_OUT_OF_HOST_MEMORY: |
||||
return "A host memory allocation has failed"; |
||||
case VK_ERROR_OUT_OF_DEVICE_MEMORY: |
||||
return "A device memory allocation has failed"; |
||||
case VK_ERROR_INITIALIZATION_FAILED: |
||||
return "Initialization of an object could not be completed for implementation-specific reasons"; |
||||
case VK_ERROR_DEVICE_LOST: |
||||
return "The logical or physical device has been lost"; |
||||
case VK_ERROR_MEMORY_MAP_FAILED: |
||||
return "Mapping of a memory object has failed"; |
||||
case VK_ERROR_LAYER_NOT_PRESENT: |
||||
return "A requested layer is not present or could not be loaded"; |
||||
case VK_ERROR_EXTENSION_NOT_PRESENT: |
||||
return "A requested extension is not supported"; |
||||
case VK_ERROR_FEATURE_NOT_PRESENT: |
||||
return "A requested feature is not supported"; |
||||
case VK_ERROR_INCOMPATIBLE_DRIVER: |
||||
return "The requested version of Vulkan is not supported by the driver or is otherwise incompatible"; |
||||
case VK_ERROR_TOO_MANY_OBJECTS: |
||||
return "Too many objects of the type have already been created"; |
||||
case VK_ERROR_FORMAT_NOT_SUPPORTED: |
||||
return "A requested format is not supported on this device"; |
||||
case VK_ERROR_SURFACE_LOST_KHR: |
||||
return "A surface is no longer available"; |
||||
case VK_SUBOPTIMAL_KHR: |
||||
return "A swapchain no longer matches the surface properties exactly, but can still be used"; |
||||
case VK_ERROR_OUT_OF_DATE_KHR: |
||||
return "A surface has changed in such a way that it is no longer compatible with the swapchain"; |
||||
case VK_ERROR_INCOMPATIBLE_DISPLAY_KHR: |
||||
return "The display used by a swapchain does not use the same presentable image layout"; |
||||
case VK_ERROR_NATIVE_WINDOW_IN_USE_KHR: |
||||
return "The requested window is already connected to a VkSurfaceKHR, or to some other non-Vulkan API"; |
||||
case VK_ERROR_VALIDATION_FAILED_EXT: |
||||
return "A validation layer found an error"; |
||||
default: |
||||
return "ERROR: UNKNOWN VULKAN ERROR TOKEN"; |
||||
} |
||||
} |
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW public API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GLFWAPI int glfwVulkanSupported(void) |
||||
{ |
||||
_GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE); |
||||
return _glfw.vk.available; |
||||
} |
||||
|
||||
GLFWAPI const char** glfwGetRequiredInstanceExtensions(int* count) |
||||
{ |
||||
*count = 0; |
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL); |
||||
|
||||
if (!_glfw.vk.available) |
||||
{ |
||||
_glfwInputError(GLFW_API_UNAVAILABLE, "Vulkan: Loader not found"); |
||||
return NULL; |
||||
} |
||||
|
||||
*count = _glfw.vk.extensionCount; |
||||
return (const char**) _glfw.vk.extensions; |
||||
} |
||||
|
||||
GLFWAPI GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance, |
||||
const char* procname) |
||||
{ |
||||
GLFWvkproc proc; |
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL); |
||||
|
||||
if (!_glfw.vk.available) |
||||
{ |
||||
_glfwInputError(GLFW_API_UNAVAILABLE, "Vulkan: Loader not found"); |
||||
return NULL; |
||||
} |
||||
|
||||
proc = (GLFWvkproc) vkGetInstanceProcAddr(instance, procname); |
||||
if (!proc) |
||||
proc = (GLFWvkproc) _glfw_dlsym(_glfw.vk.handle, procname); |
||||
|
||||
return proc; |
||||
} |
||||
|
||||
GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance, |
||||
VkPhysicalDevice device, |
||||
uint32_t queuefamily) |
||||
{ |
||||
_GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE); |
||||
|
||||
if (!_glfw.vk.available) |
||||
{ |
||||
_glfwInputError(GLFW_API_UNAVAILABLE, "Vulkan: Loader not found"); |
||||
return GLFW_FALSE; |
||||
} |
||||
|
||||
if (!_glfw.vk.extensions) |
||||
{ |
||||
_glfwInputError(GLFW_API_UNAVAILABLE, |
||||
"Vulkan: Window surface creation extensions not found"); |
||||
return GLFW_FALSE; |
||||
} |
||||
|
||||
return _glfwPlatformGetPhysicalDevicePresentationSupport(instance, |
||||
device, |
||||
queuefamily); |
||||
} |
||||
|
||||
GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance, |
||||
GLFWwindow* handle, |
||||
const VkAllocationCallbacks* allocator, |
||||
VkSurfaceKHR* surface) |
||||
{ |
||||
_GLFWwindow* window = (_GLFWwindow*) handle; |
||||
assert(window); |
||||
|
||||
assert(surface); |
||||
*surface = VK_NULL_HANDLE; |
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(VK_ERROR_INITIALIZATION_FAILED); |
||||
|
||||
if (!_glfw.vk.available) |
||||
{ |
||||
_glfwInputError(GLFW_API_UNAVAILABLE, "Vulkan: Loader not found"); |
||||
return VK_ERROR_INITIALIZATION_FAILED; |
||||
} |
||||
|
||||
if (!_glfw.vk.extensions) |
||||
{ |
||||
_glfwInputError(GLFW_API_UNAVAILABLE, |
||||
"Vulkan: Window surface creation extensions not found"); |
||||
return VK_ERROR_EXTENSION_NOT_PRESENT; |
||||
} |
||||
|
||||
return _glfwPlatformCreateWindowSurface(instance, window, allocator, surface); |
||||
} |
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue