Add vulkan feature as for tizen, wayland and x11.
Tizen backend is tested and work fine.
But, wayland and x11 does not test yet.
These backend will be implemented and tested.
Change-Id: I42b7f0659ad4923f0e342f56db7e9687f68f0383
set_option(VIDEO_DUMMY "Use dummy video driver" ON)
set_option(VIDEO_OPENGL "Include OpenGL support" ON)
set_option(VIDEO_OPENGLES "Include OpenGL ES support" ON)
+set_option(VIDEO_VULKAN "Include vulkan support" ON)
set_option(PTHREADS "Use POSIX threads for multi-threading" ${SDL_PTHREADS_ENABLED_BY_DEFAULT})
dep_option(PTHREADS_SEM "Use pthread semaphores" ON "PTHREADS" OFF)
set_option(SDL_DLOPEN "Use dlopen for shared object loading" ${SDL_DLOPEN_ENABLED_BY_DEFAULT})
endif()
CheckPTHREAD()
+elseif(TIZEN)
+ if(SDL_VIDEO)
+ if(VIDEO_VULKAN)
+ set(SDL_VIDEO_VULKAN 1)
+ set(HAVE_VIDEO_VULKAN TRUE)
+ set(SDL_CFLAGS "${SDL_CFLAGS} -I/usr/include")
+ list(APPEND SDL_LIBS "-lvulkan")
+ endif()
+ endif()
endif()
# Dummies
macro(CheckTizen)
if(VIDEO_TIZEN)
- pkg_check_modules(TIZEN wayland-client wayland-egl ecore ecore-wayland evas eina capi-appfw-application capi-appfw-application dlog)
+ pkg_check_modules(TIZEN wayland-client wayland-egl ecore ecore-wayland eina capi-appfw-application capi-appfw-application dlog ecore-imf)
if(TIZEN_FOUND)
link_directories(
${TIZEN_LIBRARY_DIRS}
FindLibraryAndSONAME(wayland-egl)
FindLibraryAndSONAME(ecore)
FindLibraryAndSONAME(ecore-wayland)
- FindLibraryAndSONAME(evas)
FindLibraryAndSONAME(eina)
FindLibraryAndSONAME(capi-appfw-application)
FindLibraryAndSONAME(capi-system-system-settings)
endif()
endmacro()
+macro(CheckVulkan)
+ if(VIDEO_VULKAN)
+ check_c_source_compiles("
+ #include <vulkan/vulkan.h>
+ int main (int argc, char** argv) {}" HAVE_VIDEO_VULKAN)
+ if(HAVE_VIDEO_VULKAN)
+ set(SDL_VIDEO_VULKAN 1)
+ set(VULKAN_LDFLAGS "-lvulkan")
+ list(APPEND EXTRA_LDFLAGS ${VULKAN_LDFLAGS})
+ list(APPEND SDL_LIBS ${VULKAN_LDFLAGS})
+ endif()
+
+ endif()
+endmacro()
+
# Requires:
# - nada
# Optional:
enable_video_opengles
enable_video_opengles1
enable_video_opengles2
+enable_video_vulkan
enable_libudev
enable_dbus
enable_ibus
include OpenGL ES 1.1 support [[default=yes]]
--enable-video-opengles2
include OpenGL ES 2.0 support [[default=yes]]
+ --enable-video-vulkan include Vulkan support [[default=yes]]
--enable-libudev enable libudev support [[default=yes]]
--enable-dbus enable D-Bus support [[default=yes]]
--enable-ibus enable IBus support [[default=yes]]
if test x$PKG_CONFIG != xno && \
test x$video_opengl_egl = xyes && \
test x$video_opengles_v2 = xyes; then
- if $PKG_CONFIG --exists wayland-client wayland-egl ecore ecore-wayland evas eina capi-appfw-application capi-system-system-settings ecore-input dlog ecore-imf; then
- TIZEN_CFLAGS=`$PKG_CONFIG --cflags wayland-client wayland-egl ecore ecore-wayland evas eina capi-appfw-application capi-system-system-settings ecore-input dlog ecore-imf`
- TIZEN_LIBS=`$PKG_CONFIG --libs wayland-client wayland-egl ecore ecore-wayland evas eina capi-appfw-application capi-system-system-settings ecore-input dlog ecore-imf`
+ if $PKG_CONFIG --exists wayland-client wayland-egl ecore ecore-wayland eina capi-appfw-application capi-system-system-settings ecore-input dlog ecore-imf; then
+ TIZEN_CFLAGS=`$PKG_CONFIG --cflags wayland-client wayland-egl ecore ecore-wayland eina capi-appfw-application capi-system-system-settings ecore-input dlog ecore-imf`
+ TIZEN_LIBS=`$PKG_CONFIG --libs wayland-client wayland-egl ecore ecore-wayland eina capi-appfw-application capi-system-system-settings ecore-input dlog ecore-imf`
video_tizen=yes
fi
fi
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $video_tizen" >&5
$as_echo "$video_tizen" >&6; }
enable_video_opengles2=yes
fi
+# Check whether --enable-video-vulkan was given.
+if test "${enable_video_vulkan+set}" = set; then :
+ enableval=$enable_video_vulkan;
+else
+ enable_video_vulkan=yes
+fi
+
+
CheckOpenGLESX11()
{
fi
}
+CheckVulkanTizen()
+{
+ if test x$enable_video = xyes -a x$enable_video_vulkan = xyes; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Vulkan support" >&5
+$as_echo_n "checking for Vulkan support... " >&6; }
+ video_vulkan=no
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+ #include <vulkan/vulkan.h>
+
+int
+main ()
+{
+
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+ video_vulkan=yes
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $video_vulkan" >&5
+$as_echo "$video_vulkan" >&6; }
+ if test x$video_vulkan = xyes; then
+
+$as_echo "#define SDL_VIDEO_VULKAN 1" >>confdefs.h
+
+ SUMMARY_video="${SUMMARY_video} vulkan"
+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvulkan"
+ fi
+ fi
+}
+
CheckInputEvents()
{
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Linux 2.4 unified input interface" >&5
CheckFusionSound
CheckOpenGLX11
CheckOpenGLESX11
+ CheckVulkanTizen
CheckMir
CheckWayland
CheckTizen
if test x$PKG_CONFIG != xno && \
test x$video_opengl_egl = xyes && \
test x$video_opengles_v2 = xyes; then
- if $PKG_CONFIG --exists wayland-client wayland-egl ecore ecore-wayland evas eina capi-appfw-application capi-system-system-settings ecore-input dlog ecore-imf; then
- TIZEN_CFLAGS=`$PKG_CONFIG --cflags wayland-client wayland-egl ecore ecore-wayland evas eina capi-appfw-application capi-system-system-settings ecore-input dlog ecore-imf`
- TIZEN_LIBS=`$PKG_CONFIG --libs wayland-client wayland-egl ecore ecore-wayland evas eina capi-appfw-application capi-system-system-settings ecore-input dlog ecore-imf`
+ if $PKG_CONFIG --exists wayland-client wayland-egl ecore ecore-wayland eina capi-appfw-application capi-system-system-settings ecore-input dlog ecore-imf; then
+ TIZEN_CFLAGS=`$PKG_CONFIG --cflags wayland-client wayland-egl ecore ecore-wayland eina capi-appfw-application capi-system-system-settings ecore-input dlog ecore-imf`
+ TIZEN_LIBS=`$PKG_CONFIG --libs wayland-client wayland-egl ecore ecore-wayland eina capi-appfw-application capi-system-system-settings ecore-input dlog ecore-imf`
video_tizen=yes
fi
fi
+
AC_MSG_RESULT($video_tizen)
if test x$video_tizen = xyes; then
AC_ARG_ENABLE(video-opengles2,
AC_HELP_STRING([--enable-video-opengles2], [include OpenGL ES 2.0 support [[default=yes]]]),
, enable_video_opengles2=yes)
+AC_ARG_ENABLE(video-vulkan,
+AC_HELP_STRING([--enable-video-vulkan], [include Vulkan support [[default=yes]]]),
+ , enable_video_vulkan=yes)
+
dnl Find OpenGL ES
CheckOpenGLESX11()
fi
}
+dnl Check for Tizen Vulkan
+CheckVulkanTizen()
+{
+ if test x$enable_video = xyes -a x$enable_video_vulkan = xyes; then
+ AC_MSG_CHECKING(for Vulkan support)
+ video_vulkan=no
+ AC_TRY_COMPILE([
+ #include <vulkan/vulkan.h>
+ ],[
+ ],[
+ video_vulkan=yes
+ ])
+ AC_MSG_RESULT($video_vulkan)
+ if test x$video_vulkan = xyes; then
+ AC_DEFINE(SDL_VIDEO_VULKAN, 1, [ ])
+ SUMMARY_video="${SUMMARY_video} vulkan"
+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvulkan"
+ fi
+ fi
+}
+
dnl See if we can use the new unified event interface in Linux 2.4
CheckInputEvents()
{
CheckFusionSound
CheckOpenGLX11
CheckOpenGLESX11
+ CheckVulkanTizen
CheckMir
CheckWayland
CheckTizen
#cmakedefine SDL_VIDEO_OPENGL_EGL @SDL_VIDEO_OPENGL_EGL@
#cmakedefine SDL_VIDEO_OPENGL_OSMESA @SDL_VIDEO_OPENGL_OSMESA@
#cmakedefine SDL_VIDEO_OPENGL_OSMESA_DYNAMIC @SDL_VIDEO_OPENGL_OSMESA_DYNAMIC@
+#cmakedefine SDL_VIDEO_VULKAN @SDL_VIDEO_VULKAN@
/* Enable system power support */
#cmakedefine SDL_POWER_ANDROID @SDL_POWER_ANDROID@
#undef SDL_ASSEMBLY_ROUTINES
#undef SDL_ALTIVEC_BLITTERS
+#undef SDL_VIDEO_VULKAN
#endif /* _SDL_config_h */
GLuint resolveFramebuffer; /* The Framebuffer Object which holds the resolve color Renderbuffer, when MSAA is used. */
} uikit;
#endif
-#if defined(SDL_VIDEO_DRIVER_WAYLAND) || defined(SDL_VIDEO_DRIVER_TIZEN)
+#if defined(SDL_VIDEO_DRIVER_WAYLAND)
struct
{
struct wl_display *display; /**< Wayland display */
EGLSurface surface;
} android;
#endif
+#if defined(SDL_VIDEO_DRIVER_TIZEN)
+ struct
+ {
+// struct wl_display *display; /**< Wayland display */
+// struct wl_surface *surface; /**< Wayland surface */
+// struct wl_shell_surface *shell_surface; /**< Wayland shell_surface (window manager handle) */
+
+ /* For GLES */
+ void* egl_display; /**< EGLDispaly when OPENGLES is enabled */
+ void* egl_surface; /**< EGLSurface when OPENGLES is enabled for this wl_surface */
+ } tizen;
+#endif
/* Can't have an empty union */
int dummy;
SDL_WINDOW_FULLSCREEN_DESKTOP = ( SDL_WINDOW_FULLSCREEN | 0x00001000 ),
SDL_WINDOW_FOREIGN = 0x00000800, /**< window not created by SDL */
SDL_WINDOW_ALLOW_HIGHDPI = 0x00002000, /**< window should be created in high-DPI mode if supported */
- SDL_WINDOW_MOUSE_CAPTURE = 0x00004000 /**< window has mouse captured (unrelated to INPUT_GRABBED) */
+ SDL_WINDOW_MOUSE_CAPTURE = 0x00004000, /**< window has mouse captured (unrelated to INPUT_GRABBED) */
+ SDL_WINDOW_VULKAN = 0x10000000 /**< window usable with Vulkan */
} SDL_WindowFlags;
/**
} SDL_GLcontextReleaseFlag;
+/**
+ * \brief An opaque handle to an Vulkan instance.
+ */
+typedef void *SDL_vulkanInstance;
+
+/**
+ * \brief An opaque handle to an Vulkan instance.
+ */
+typedef void *SDL_vulkanSurface;
+
/* Function prototypes */
/**
/* @} *//* OpenGL support functions */
+/**
+ * \name Vulkan support functions
+ */
+/* @{ */
+
+extern DECLSPEC SDL_bool SDLCALL SDL_Vulkan_GetInstanceExtensions(SDL_Window* window, unsigned* count, char** names);
+extern DECLSPEC SDL_bool SDLCALL SDL_Vulkan_CreateSurface(SDL_Window* window, SDL_vulkanInstance instance, SDL_vulkanSurface* surface);
+
+/* @} *//* Vulkan support functions */
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
BuildRequires: binutils-devel
BuildRequires: which
BuildRequires: autoconf
+#BuildRequires: Vulkan-LoaderAndValidationLayers
+#BuildRequires: Vulkan-LoaderAndValidationLayers-devel
BuildRequires: pkgconfig(ecore)
-BuildRequires: pkgconfig(evas)
BuildRequires: pkgconfig(ecore-wayland)
BuildRequires: pkgconfig(capi-appfw-application)
BuildRequires: pkgconfig(capi-system-system-settings)
%build
%ifos linux
-CFLAGS="$RPM_OPT_FLAGS -D__TIZEN__" ./configure --prefix=%{prefix} --disable-video-directfb --enable-video-wayland
+CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=%{prefix} --disable-video-directfb --enable-video-tizen
%else
%configure
%endif
#define SDL_GameControllerFromInstanceID SDL_GameControllerFromInstanceID_REAL
#define SDL_JoystickFromInstanceID SDL_JoystickFromInstanceID_REAL
#define SDL_tizen_app_init SDL_tizen_app_init_REAL
+#define SDL_Vulkan_GetInstanceExtensions SDL_Vulkan_GetInstanceExtensions_REAL
+#define SDL_Vulkan_CreateSurface SDL_Vulkan_CreateSurface_REAL
#ifdef __TIZEN__
SDL_DYNAPI_PROC(int,SDL_tizen_app_init,(int a, char *b[]),(a,b),return)
#endif
+SDL_DYNAPI_PROC(SDL_bool,SDL_Vulkan_GetInstanceExtensions,(SDL_Window* a, unsigned int* b, char** c),(a,b,c),return)
+SDL_DYNAPI_PROC(SDL_bool,SDL_Vulkan_CreateSurface,(SDL_Window* a, SDL_vulkanInstance b, SDL_vulkanSurface* c),(a,b,c),return)
/* * * */
/* The function used to dispose of this structure */
void (*free) (_THIS);
+
+ SDL_bool (*vulkan_GetInstanceExtensions) (const char* driver, unsigned int* count, char** names);
+ SDL_bool (*vulkan_CreateSurface) (_THIS, SDL_Window* window, SDL_vulkanInstance instance, SDL_vulkanSurface* surface);
};
typedef struct VideoBootStrap
}
#define CREATE_FLAGS \
- (SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI)
+ (SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_VULKAN)
static void
SDL_FinishWindowCreation(SDL_Window *window, Uint32 flags)
}
}
+#if (SDL_VIDEO_VULKAN)
+ if (flags & SDL_WINDOW_VULKAN) {
+ if (!_this->vulkan_GetInstanceExtensions) {
+ SDL_SetError("No Vulkan support in video driver");
+ return NULL;
+ }
+ }
+
+ if ((flags & SDL_WINDOW_OPENGL) && (flags & SDL_WINDOW_VULKAN)) {
+ SDL_SetError("Don't use both OPENGL and VULKAN");
+ return NULL;
+ }
+#endif
+
/* Unless the user has specified the high-DPI disabling hint, respect the
* SDL_WINDOW_ALLOW_HIGHDPI flag.
*/
window->y = bounds.y + (bounds.h - h) / 2;
}
}
+
window->flags = ((flags & CREATE_FLAGS) | SDL_WINDOW_HIDDEN);
window->last_fullscreen_flags = window->flags;
window->brightness = 1.0f;
SDL_sqrt((double)den2));
}
+SDL_bool
+SDL_Vulkan_GetInstanceExtensions(SDL_Window* window, unsigned int* count, char** names)
+{
+ if (!count) {
+ SDL_SetError("count ptr is null");
+ return SDL_FALSE;
+ }
+
+ if (!(window->flags & SDL_WINDOW_VULKAN)) {
+ SDL_SetError("Not setup with SDL_WINDOW_VULKAN flags");
+ return SDL_FALSE;
+ }
+
+ const char *driver = SDL_GetCurrentVideoDriver();
+ if (!driver) {
+ SDL_SetError("Current video driveer is NULL");
+ return SDL_FALSE;
+ }
+
+ return _this->vulkan_GetInstanceExtensions(driver, count, names);
+}
+
+SDL_bool
+SDL_Vulkan_CreateSurface(SDL_Window* window, SDL_vulkanInstance instance, SDL_vulkanSurface* surface)
+{
+ if (!window) {
+ SDL_SetError("'window' is null");
+ return SDL_FALSE;
+ }
+
+ if (instance == 0) {
+ SDL_SetError("'instance' is null");
+ return SDL_FALSE;
+ }
+
+ return _this->vulkan_CreateSurface(_this, window, instance, surface);
+}
+
/* vi: set ts=4 sw=4 expandtab: */
*/
#include "../../SDL_internal.h"
-#if SDL_VIDEO_DRIVER_TIZEN && SDL_VIDEO_OPENGL_EGL
+#if SDL_VIDEO_OPENGL_EGL
#include "SDL_tizenvideo.h"
#include "SDL_tizenopengles.h"
int ret;
ret = SDL_EGL_LoadLibrary(_this, path, (NativeDisplayType)ecore_wl_display_get());
-
return ret;
}
Tizen_GLES_CreateContext(_THIS, SDL_Window *window)
{
SDL_GLContext context;
- context = SDL_EGL_CreateContext(_this, ((SDL_WindowData *) window->driverdata)->egl_surface);
+ context = SDL_EGL_CreateContext(_this, ((SDL_WindowData *) window->driverdata)->egl_surface);
return context;
}
#include "../SDL_sysvideo.h"
#include "../SDL_egl_c.h"
+#if SDL_VIDEO_OPENGL_EGL
+
typedef struct SDL_PrivateGLESData {
} SDL_PrivateGLESData;
extern void Tizen_GLES_SwapWindow(_THIS, SDL_Window *window);
extern int Tizen_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context);
extern void Tizen_GLES_DeleteContext(_THIS, SDL_GLContext context);
+#endif
#endif /* _SDL_tizenopengles_h */
#include "SDL_tizenmouse.h"
#include "SDL_tizentouch.h"
#include "SDL_tizenkeyboard.h"
+#include "SDL_tizenvulkan.h"
#define TIZENVID_DRIVER_NAME "tizen"
Tizen_VideoQuit(_THIS);
static void
-__tizen_add_display(SDL_VideoData *d, uint32_t id)
+_tizen_add_display(SDL_VideoData *d, uint32_t id)
{
SDL_VideoDisplay display;
SDL_DisplayMode mode;
device->free = Tizen_DeleteDevice;
device->PumpEvents = Tizen_PumpEvents;
-
+#if SDL_VIDEO_OPENGL_EGL
device->GL_SwapWindow = Tizen_GLES_SwapWindow;
device->GL_GetSwapInterval = Tizen_GLES_GetSwapInterval;
device->GL_SetSwapInterval = Tizen_GLES_SetSwapInterval;
device->GL_UnloadLibrary = Tizen_GLES_UnloadLibrary;
device->GL_GetProcAddress = Tizen_GLES_GetProcAddress;
device->GL_DeleteContext = Tizen_GLES_DeleteContext;
-
+#endif
device->CreateWindow = Tizen_CreateWindow;
device->ShowWindow = Tizen_ShowWindow;
device->SetWindowFullscreen = Tizen_SetWindowFullscreen;
//device->HideScreenKeyboard = Tizen_HideScreenKeyboard;
device->IsScreenKeyboardShown = Tizen_IsScreenKeyboardShown;
+#if SDL_VIDEO_VULKAN
+ device->vulkan_GetInstanceExtensions = Tizen_vulkan_GetInstanceExtensions;
+ device->vulkan_CreateSurface = Tizen_vulkan_CreateSurface;
+#endif
+
return device;
}
_this->driverdata = data;
ecore_wl_init(NULL);
- __tizen_add_display(data, 0);
+ _tizen_add_display(data, 0);
+ data->display = ecore_wl_display_get();
Tizen_InitWindow(_this);
Tizen_InitMouse();
static void
Tizen_GetDisplayModes(_THIS, SDL_VideoDisplay *sdl_display)
{
-
+ SDL_Unsupported();
}
static int
#include <Ecore_Wayland.h>
typedef struct {
+ struct wl_display *display;
+
EGLDisplay edpy;
EGLContext context;
EGLConfig econf;
--- /dev/null
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
+ Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
+
+ 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 "../../SDL_internal.h"
+
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.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 "../../SDL_internal.h"
+
+#if SDL_VIDEO_VULKAN
+#include <SDL_syswm.h>
+#include "../SDL_sysvideo.h"
+#include "SDL_video.h"
+#include "SDL_tizenwindow.h"
+#include "SDL_tizenvideo.h"
+#include "SDL_tizenvideo.h"
+#include "SDL_tizenvulkan.h"
+
+SDL_bool
+Tizen_vulkan_GetInstanceExtensions(const char* driver, unsigned int* count, char** names)
+{
+ uint32_t instance_extension_count = 0;
+ uint32_t enabled_extension_count = 0;
+ VkBool32 surfaceExtFound = 0;
+ VkBool32 platformSurfaceExtFound = 0;
+ VkResult err;
+
+ if (strcmp(driver, "tizen")) {
+ SDL_SetError("Unsupported video driver '%s'", driver);
+ return SDL_FALSE;
+ }
+
+ err = vkEnumerateInstanceExtensionProperties(NULL, &instance_extension_count, NULL);
+ if (err < 0) {
+ SDL_SetError("Fail to get Instance extension");
+ return SDL_FALSE;
+ }
+
+ if (instance_extension_count > 0) {
+ uint32_t i;
+ VkExtensionProperties *instance_extensions =
+ malloc(sizeof(VkExtensionProperties) * instance_extension_count);
+ err = vkEnumerateInstanceExtensionProperties(
+ NULL, &instance_extension_count, instance_extensions);
+ for (i = 0; i < instance_extension_count; i++) {
+ if (!strcmp(VK_KHR_SURFACE_EXTENSION_NAME,instance_extensions[i].extensionName)) {
+ names[enabled_extension_count++] = VK_KHR_SURFACE_EXTENSION_NAME;
+ }
+
+ if (!strcmp(VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME,instance_extensions[i].extensionName)) {
+ names[enabled_extension_count++] = VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME;
+ }
+
+ if (enabled_extension_count > 64) {
+ SDL_SetError("Insufficient capacity for extension names");
+ free(instance_extensions);
+ return SDL_FALSE;
+ }
+ }
+ free(instance_extensions);
+ }
+ *count = enabled_extension_count;
+ return SDL_TRUE;
+}
+
+SDL_bool
+Tizen_vulkan_CreateSurface(_THIS, SDL_Window* window, SDL_vulkanInstance instance, SDL_vulkanSurface* surface)
+{
+ SDL_SysWMinfo wminfo;
+ SDL_WindowData *wmdata = (SDL_WindowData *)window->driverdata;
+ SDL_VideoData *video_data = (SDL_VideoData *)_this->driverdata;
+
+ if (!SDL_GetWindowWMInfo(window, &wminfo))
+ return SDL_FALSE;
+
+ switch (wminfo.subsystem)
+ {
+ case SDL_SYSWM_TIZEN:
+ {
+ VkWaylandSurfaceCreateInfoKHR createInfo;
+ VkResult ret;
+ createInfo.sType = VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR;
+ createInfo.pNext = NULL;
+ createInfo.flags = 0;
+ createInfo.display = video_data->display;
+ createInfo.surface = wmdata->surface;
+
+ ret = vkCreateWaylandSurfaceKHR((VkInstance)instance, &createInfo, NULL, (VkSurfaceKHR*)surface);
+ if (ret != VK_SUCCESS) {
+ SDL_SetError("fail to vkCreateWaylandSurfaceKHR : %i", (int)ret);
+ return SDL_FALSE;
+ }
+ return SDL_TRUE;
+ }
+ default:
+ (void)surface;
+ SDL_SetError("Unsupported subsystem %i", (int)wminfo.subsystem);
+ return SDL_FALSE;
+ }
+}
+
+#endif
--- /dev/null
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
+ Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
+
+ 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 "../../SDL_internal.h"
+
+#ifndef _SDL_tizenvulkan_h
+#define _SDL_tizenvulkan_h
+
+#if SDL_VIDEO_VULKAN
+#define VK_USE_PLATFORM_WAYLAND_KHR
+#include <vulkan/vulkan.h>
+#include "../SDL_sysvideo.h"
+
+extern SDL_bool Tizen_vulkan_GetInstanceExtensions(const char* driver, unsigned int* count, char** names);
+extern SDL_bool Tizen_vulkan_CreateSurface(_THIS, SDL_Window* window, SDL_vulkanInstance instance, SDL_vulkanSurface* surface);
+#endif
+#endif /* _SDL_tizenvulkan_h */
#include "../../SDL_internal.h"
-#if SDL_VIDEO_DRIVER_TIZEN && SDL_VIDEO_OPENGL_EGL
+#if SDL_VIDEO_DRIVER_TIZEN
#include "../SDL_sysvideo.h"
#include "../../events/SDL_windowevents_c.h"
SDL_bool
Tizen_GetWindowWMInfo(_THIS, SDL_Window *window, SDL_SysWMinfo *info)
{
+ SDL_WindowData *wmdata = (SDL_WindowData *)window->driverdata;
+ SDL_VideoData *video_data = (SDL_VideoData *)_this->driverdata;
+
+// info->info.tizen.display = video_data->display;
+// info->info.tizen.surface = wmdata->surface;
+// info->info.tizen.shell_surface = NULL;
+ info->info.tizen.egl_display = NULL;
+ info->info.tizen.egl_surface = NULL;
+#if SDL_VIDEO_OPENGL_EGL
+ if (_this->egl_data)
+ {
+ info->info.tizen.egl_display = (void*)_this->egl_data->egl_display;
+ }
+ info->info.tizen.egl_surface = (void*)wmdata->egl_surface;
+#endif
+ info->subsystem = SDL_SYSWM_TIZEN;
return SDL_TRUE;
}
SDL_WindowData *wind;
wind = calloc(1, sizeof * wind);
- if (wind == NULL)
+ if (!wind)
return SDL_OutOfMemory();
window->driverdata = wind;
- if (!(window->flags & SDL_WINDOW_OPENGL)) {
+#if SDL_VIDEO_OPENGL_EGL
+ if (window->flags & SDL_WINDOW_OPENGL) {
SDL_GL_LoadLibrary(NULL);
- window->flags |= SDL_WINDOW_OPENGL;
}
+#endif
if (window->x == SDL_WINDOWPOS_UNDEFINED) {
window->x = 0;
wind->window = ecore_wl_window_new(NULL,
window->x, window->y, window->w, window->h,
ECORE_WL_WINDOW_BUFFER_TYPE_SHM);
- ecore_wl_window_surface_create(wind->window);
-
- wind->egl_window = wl_egl_window_create(ecore_wl_window_surface_get(wind->window), window->w, window->h);
-
- /* Create the GLES window surface */
- wind->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) wind->egl_window);
- if (wind->egl_surface == EGL_NO_SURFACE) {
- return SDL_SetError("failed to create a window surface");
+ wind->surface = ecore_wl_window_surface_create(wind->window);
+#if SDL_VIDEO_OPENGL_EGL
+ if (window->flags & SDL_WINDOW_OPENGL) {
+ wind->egl_window = wl_egl_window_create(ecore_wl_window_surface_get(wind->window), window->w, window->h);
+
+ /* Create the GLES window surface */
+ wind->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) wind->egl_window);
+ if (wind->egl_surface == EGL_NO_SURFACE) {
+ return SDL_SetError("failed to create a window surface");
+ }
}
+#endif
wind->id = ecore_wl_window_id_get(wind->window);
eina_hash_add(data->windows, &wind->id, window);
Tizen_SetWindowSize(_THIS, SDL_Window *window)
{
SDL_WindowData *wind = window->driverdata;
-
- wl_egl_window_resize(wind->egl_window, window->w, window->h, 0, 0);
+#if SDL_VIDEO_OPENGL_EGL
+ if (window->flags & SDL_WINDOW_OPENGL) {
+ wl_egl_window_resize(wind->egl_window, window->w, window->h, 0, 0);
+ }
+#endif
}
void
if (data) {
eina_hash_del(data->windows, &wind->id, window);
-
+#if SDL_VIDEO_OPENGL_EGL
+ if (window->flags & SDL_WINDOW_OPENGL) {
SDL_EGL_DestroySurface(_this, wind->egl_surface);
wl_egl_window_destroy(wind->egl_window);
+ }
+#endif
ecore_wl_window_free(wind->window);
-
SDL_free(wind);
}
__tizen_cb_event_keyup_change, NULL);
ecore_event_handler_add(ECORE_EVENT_KEY_DOWN,
__tizen_cb_event_keydown_change, NULL);
-
ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN,
__tizen_cb_event_mousedown_change, _this);
ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP,
eina_hash_free(data->windows);
}
-#endif /* SDL_VIDEO_DRIVER_TIZEN && SDL_VIDEO_OPENGL_EGL */
+#endif /* SDL_VIDEO_DRIVER_TIZEN */
/* vi: set ts=4 sw=4 expandtab: */
uint32_t id;
Ecore_Wl_Window *window;
+ struct wl_surface *surface;
+ struct wl_shell_surface *shell_surface;
struct wl_egl_window *egl_window;
EGLSurface egl_surface;
} SDL_WindowData;
#include "SDL_waylandopengles.h"
#include "SDL_waylandmouse.h"
#include "SDL_waylandtouch.h"
+#include "SDL_waylandvulkan.h"
#include <fcntl.h>
#include <xkbcommon/xkbcommon.h>
device->free = Wayland_DeleteDevice;
+#if SDL_VIDEO_VULKAN
+ device->vulkan_GetInstanceExtensions = Wayland_vulkan_GetInstanceExtensions;
+ device->vulkan_CreateSurface = Wayland_vulkan_CreateSurface;
+#endif
return device;
}
--- /dev/null
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.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 "../../SDL_internal.h"
+
+#if SDL_VIDEO_VULKAN
+#include <SDL_syswm.h>
+#include "SDL_video.h"
+#include "../SDL_sysvideo.h"
+#include "SDL_waylandwindow.h"
+#include "SDL_waylandvideo.h"
+#include "SDL_waylandvulkan.h"
+
+SDL_bool
+Wayland_vulkan_GetInstanceExtensions(const char* driver, unsigned int* count, char** names)
+{
+ uint32_t instance_extension_count = 0;
+ uint32_t enabled_extension_count = 0;
+ VkBool32 surfaceExtFound = 0;
+ VkBool32 platformSurfaceExtFound = 0;
+ VkResult err;
+
+ if (strcmp(driver, "wayland")) {
+ SDL_SetError("Unsupported video driver '%s'", driver);
+ return SDL_FALSE;
+ }
+
+ err = vkEnumerateInstanceExtensionProperties(NULL, &instance_extension_count, NULL);
+ if (err < 0) {
+ SDL_SetError("Fail to get Instance extension");
+ return SDL_FALSE;
+ }
+
+ if (instance_extension_count > 0) {
+ uint32_t i;
+ VkExtensionProperties *instance_extensions =
+ malloc(sizeof(VkExtensionProperties) * instance_extension_count);
+ err = vkEnumerateInstanceExtensionProperties(
+ NULL, &instance_extension_count, instance_extensions);
+ for (i = 0; i < instance_extension_count; i++) {
+ if (!strcmp(VK_KHR_SURFACE_EXTENSION_NAME,instance_extensions[i].extensionName)) {
+ names[enabled_extension_count++] = VK_KHR_SURFACE_EXTENSION_NAME;
+ }
+
+ if (!strcmp(VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME,instance_extensions[i].extensionName)) {
+ names[enabled_extension_count++] = VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME;
+ }
+
+ if (enabled_extension_count > 64) {
+ SDL_SetError("Insufficient capacity for extension names");
+ free(instance_extensions);
+ return SDL_FALSE;
+ }
+ }
+ free(instance_extensions);
+ }
+ *count = enabled_extension_count;
+ return SDL_TRUE;
+}
+
+SDL_bool
+Wayland_vulkan_CreateSurface(_THIS, SDL_Window* window, SDL_vulkanInstance instance, SDL_vulkanSurface* surface)
+{
+ SDL_SysWMinfo wminfo;
+ SDL_WindowData *wmdata = (SDL_WindowData *)window->driverdata;
+ SDL_VideoData *video_data = (SDL_VideoData *)_this->driverdata;
+ if (!SDL_GetWindowWMInfo(window, &wminfo))
+ return SDL_FALSE;
+
+ switch (wminfo.subsystem)
+ {
+ case SDL_SYSWM_WAYLAND:
+ {
+ VkWaylandSurfaceCreateInfoKHR createInfo;
+ VkResult ret;
+ createInfo.sType = VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR;
+ createInfo.pNext = NULL;
+ createInfo.flags = 0;
+ createInfo.display = video_data->display;
+ createInfo.surface = wmdata->surface;
+
+ ret = vkCreateWaylandSurfaceKHR((VkInstance)instance, &createInfo, NULL, (VkSurfaceKHR*)surface);
+ if (ret != VK_SUCCESS) {
+ SDL_SetError("fail to vkCreateWaylandSurfaceKHR : %i", (int)ret);
+ return SDL_FALSE;
+ }
+ return SDL_TRUE;
+ }
+ default:
+ (void)surface;
+ SDL_SetError("Unsupported subsystem %i", (int)wminfo.subsystem);
+ return SDL_FALSE;
+ }
+}
+
+#endif
--- /dev/null
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.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 "../../SDL_internal.h"
+
+#ifndef _SDL_waylandvulkan_h
+#define _SDL_waylandvulkan_h
+
+#if SDL_VIDEO_VULKAN
+#define VK_USE_PLATFORM_WAYLAND_KHR
+#include <vulkan/vulkan.h>
+#include "../SDL_sysvideo.h"
+
+extern SDL_bool Wayland_vulkan_GetInstanceExtensions(const char* driver, unsigned int* count, char** names);
+extern SDL_bool Wayland_vulkan_CreateSurface(_THIS, SDL_Window* window, SDL_vulkanInstance instance, SDL_vulkanSurface* surface);
+
+#endif
+#endif /* _SDL_waylandvulkan_h */
device->free = X11_DeleteDevice;
+#if SDL_VIDEO_VULKAN
+ device->vulkan_GetInstanceExtensions = X11_vulkan_GetInstanceExtensions;
+ device->vulkan_CreateSurface = X11_vulkan_CreateSurface;
+#endif
+
return device;
}
--- /dev/null
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.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 "../../SDL_internal.h"
+
+#if SDL_VIDEO_DRIVER_X11 && SDL_VIDEO_VULKAN
+
+#define VK_USE_PLATFORM_XCB_KHR
+#include <X11/Xlib-xcb.h>
+
+#include <vulkan/vulkan.h>
+#include <SDL_syswm.h>
+#include "SDL_x11video.h"
+#include "SDL_x11vulkan.h"
+
+SDL_bool
+X11_vulkan_GetInstanceExtensions(const char* driver, unsigned int* count, char** names)
+{
+ uint32_t instance_extension_count = 0;
+ uint32_t enabled_extension_count = 0;
+ VkBool32 surfaceExtFound = 0;
+ VkBool32 platformSurfaceExtFound = 0;
+ VkResult err;
+
+ if (strcmp(driver, "x11")) {
+ SDL_SetError("Unsupported video driver '%s'", driver);
+ return SDL_FALSE;
+ }
+
+ err = vkEnumerateInstanceExtensionProperties(NULL, &instance_extension_count, NULL);
+ if (err < 0) {
+ SDL_SetError("Fail to get Instance extension");
+ return SDL_FALSE;
+ }
+
+ if (instance_extension_count > 0) {
+ uint32_t i;
+ VkExtensionProperties *instance_extensions =
+ malloc(sizeof(VkExtensionProperties) * instance_extension_count);
+ err = vkEnumerateInstanceExtensionProperties(
+ NULL, &instance_extension_count, instance_extensions);
+ for (i = 0; i < instance_extension_count; i++) {
+ if (!strcmp(VK_KHR_SURFACE_EXTENSION_NAME,instance_extensions[i].extensionName)) {
+ names[enabled_extension_count++] = VK_KHR_SURFACE_EXTENSION_NAME;
+ }
+
+ if (!strcmp(VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME,instance_extensions[i].extensionName)) {
+ names[enabled_extension_count++] = VK_KHR_XCB_SURFACE_EXTENSION_NAME;
+ }
+
+ if (enabled_extension_count > 64) {
+ SDL_SetError("Insufficient capacity for extension names");
+ free(instance_extensions);
+ return SDL_FALSE;
+ }
+ }
+ free(instance_extensions);
+ }
+ *count = enabled_extension_count;
+ return SDL_TRUE;
+}
+
+SDL_bool
+X11_vulkan_CreateSurface(_THIS, SDL_Window* window, SDL_vulkanInstance instance, SDL_vulkanSurface* surface)
+{
+ SDL_SysWMinfo wminfo;
+ if (!SDL_GetWindowWMInfo(window, &wminfo))
+ return SDL_FALSE;
+
+ switch (wminfo.subsystem)
+ {
+ case SDL_SYSWM_X11:
+ {
+ VkXcbSurfaceCreateInfoKHR createInfo;
+ VkResult ret;
+ createInfo.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR;
+ createInfo.pNext = NULL;
+ createInfo.flags = 0;
+ createInfo.connection = XGetXCBConnection(wminfo.info.x11.display);
+ createInfo.window = wminfo.info.x11.window;
+
+ ret = vkCreateXcbSurfaceKHR((VkInstance)instance, &createInfo, NULL, (VkSurfaceKHR*)surface);
+ if (ret != VK_SUCCESS) {
+ SDL_SetError("fail to vkCreateXcbSurfaceKHR : %i", (int)ret);
+ return SDL_FALSE;
+ }
+ return SDL_TRUE;
+ }
+ default:
+ (void)surface;
+ SDL_SetError("Unsupported subsystem %i", (int)wminfo.subsystem);
+ return SDL_FALSE;
+ }
+}
+
+#endif
--- /dev/null
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.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 "../../SDL_internal.h"
+
+#ifndef _SDL_x11vulkan_h
+#define _SDL_x11vulkan_h
+
+#if SDL_VIDEO_VULKAN
+extern SDL_bool X11_vulkan_GetInstanceExtensions(const char* driver, unsigned int* count, char** names);
+extern SDL_bool X11_vulkan_CreateSurface(_THIS, SDL_Window* window,SDL_vulkanInstance instance, SDL_vulkanSurface* surface);
+#endif
+
+#endif /* _SDL_x11vulkan_h */