early-access version 1617
This commit is contained in:
2
externals/SDL/src/video/SDL_RLEaccel.c
vendored
2
externals/SDL/src/video/SDL_RLEaccel.c
vendored
@@ -27,7 +27,7 @@
|
||||
*
|
||||
* Original version by Sam Lantinga
|
||||
*
|
||||
* Mattias Engdeg<EFBFBD>rd (Yorick): Rewrite. New encoding format, encoder and
|
||||
* Mattias Engdegård (Yorick): Rewrite. New encoding format, encoder and
|
||||
* decoder. Added per-surface alpha blitter. Added per-pixel alpha
|
||||
* format, encoder and blitter.
|
||||
*
|
||||
|
11
externals/SDL/src/video/SDL_blit_N.c
vendored
11
externals/SDL/src/video/SDL_blit_N.c
vendored
@@ -27,7 +27,6 @@
|
||||
#include "SDL_cpuinfo.h"
|
||||
#include "SDL_blit.h"
|
||||
|
||||
#include "SDL_assert.h"
|
||||
|
||||
/* General optimized routines that write char by char */
|
||||
#define HAVE_FAST_WRITE_INT8 1
|
||||
@@ -2183,7 +2182,7 @@ Blit4to4MaskAlpha(SDL_BlitInfo * info)
|
||||
|
||||
if (dstfmt->Amask) {
|
||||
/* RGB->RGBA, SET_ALPHA */
|
||||
Uint32 mask = (info->a >> dstfmt->Aloss) << dstfmt->Ashift;
|
||||
Uint32 mask = ((Uint32)info->a >> dstfmt->Aloss) << dstfmt->Ashift;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
@@ -2632,7 +2631,7 @@ BlitNtoNKey(SDL_BlitInfo * info)
|
||||
|
||||
if (dstfmt->Amask) {
|
||||
/* RGB->RGBA, SET_ALPHA */
|
||||
Uint32 mask = info->a << dstfmt->Ashift;
|
||||
Uint32 mask = ((Uint32)info->a) << dstfmt->Ashift;
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
@@ -3059,7 +3058,7 @@ Blit_3or4_to_3or4__same_rgb(SDL_BlitInfo * info)
|
||||
|
||||
if (dstfmt->Amask) {
|
||||
/* SET_ALPHA */
|
||||
Uint32 mask = info->a << dstfmt->Ashift;
|
||||
Uint32 mask = ((Uint32)info->a) << dstfmt->Ashift;
|
||||
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
||||
int i0 = 0, i1 = 1, i2 = 2;
|
||||
#else
|
||||
@@ -3148,7 +3147,7 @@ Blit_3or4_to_3or4__inversed_rgb(SDL_BlitInfo * info)
|
||||
Uint8 s0 = src[i0];
|
||||
Uint8 s1 = src[i1];
|
||||
Uint8 s2 = src[i2];
|
||||
Uint32 alphashift = src[i3] << dstfmt->Ashift;
|
||||
Uint32 alphashift = ((Uint32)src[i3]) << dstfmt->Ashift;
|
||||
/* inversed, compared to Blit_3or4_to_3or4__same_rgb */
|
||||
*dst32 = (s0 << 16) | (s1 << 8) | (s2) | alphashift;
|
||||
dst += 4;
|
||||
@@ -3160,7 +3159,7 @@ Blit_3or4_to_3or4__inversed_rgb(SDL_BlitInfo * info)
|
||||
}
|
||||
} else {
|
||||
/* SET_ALPHA */
|
||||
Uint32 mask = info->a << dstfmt->Ashift;
|
||||
Uint32 mask = ((Uint32)info->a) << dstfmt->Ashift;
|
||||
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
||||
int i0 = 0, i1 = 1, i2 = 2;
|
||||
#else
|
||||
|
1
externals/SDL/src/video/SDL_bmp.c
vendored
1
externals/SDL/src/video/SDL_bmp.c
vendored
@@ -34,7 +34,6 @@
|
||||
|
||||
#include "SDL_hints.h"
|
||||
#include "SDL_video.h"
|
||||
#include "SDL_assert.h"
|
||||
#include "SDL_endian.h"
|
||||
#include "SDL_pixels_c.h"
|
||||
|
||||
|
79
externals/SDL/src/video/SDL_egl.c
vendored
79
externals/SDL/src/video/SDL_egl.c
vendored
@@ -31,7 +31,6 @@
|
||||
#endif
|
||||
|
||||
#include "SDL_sysvideo.h"
|
||||
#include "SDL_log.h"
|
||||
#include "SDL_egl_c.h"
|
||||
#include "SDL_loadso.h"
|
||||
#include "SDL_hints.h"
|
||||
@@ -73,6 +72,13 @@
|
||||
#define DEFAULT_OGL_ES_PVR "libGLES_CM.dylib" //???
|
||||
#define DEFAULT_OGL_ES "libGLESv1_CM.dylib" //???
|
||||
|
||||
#elif defined(__OpenBSD__)
|
||||
#define DEFAULT_OGL "libGL.so"
|
||||
#define DEFAULT_EGL "libEGL.so"
|
||||
#define DEFAULT_OGL_ES2 "libGLESv2.so"
|
||||
#define DEFAULT_OGL_ES_PVR "libGLES_CM.so"
|
||||
#define DEFAULT_OGL_ES "libGLESv1_CM.so"
|
||||
|
||||
#else
|
||||
/* Desktop Linux */
|
||||
#define DEFAULT_OGL "libGL.so.1"
|
||||
@@ -82,6 +88,10 @@
|
||||
#define DEFAULT_OGL_ES "libGLESv1_CM.so.1"
|
||||
#endif /* SDL_VIDEO_DRIVER_RPI */
|
||||
|
||||
#if SDL_VIDEO_OPENGL
|
||||
#include "SDL_opengl.h"
|
||||
#endif
|
||||
|
||||
/** If we happen to not have this defined because of an older EGL version, just define it 0x0
|
||||
as eglGetPlatformDisplayEXT will most likely be NULL if this is missing
|
||||
*/
|
||||
@@ -142,12 +152,8 @@ int SDL_EGL_SetErrorEx(const char * message, const char * eglFunctionName, EGLin
|
||||
}
|
||||
|
||||
/* EGL implementation of SDL OpenGL ES support */
|
||||
typedef enum {
|
||||
SDL_EGL_DISPLAY_EXTENSION,
|
||||
SDL_EGL_CLIENT_EXTENSION
|
||||
} SDL_EGL_ExtensionType;
|
||||
|
||||
static SDL_bool SDL_EGL_HasExtension(_THIS, SDL_EGL_ExtensionType type, const char *ext)
|
||||
SDL_bool SDL_EGL_HasExtension(_THIS, SDL_EGL_ExtensionType type, const char *ext)
|
||||
{
|
||||
size_t ext_len;
|
||||
const char *ext_override;
|
||||
@@ -231,6 +237,7 @@ SDL_EGL_GetProcAddress(_THIS, const char *proc)
|
||||
retval = _this->egl_data->eglGetProcAddress(proc);
|
||||
}
|
||||
|
||||
#ifndef __EMSCRIPTEN__ /* LoadFunction isn't needed on Emscripten and will call dlsym(), causing other problems. */
|
||||
/* Try SDL_LoadFunction() first for EGL <= 1.4, or as a fallback for >= 1.5. */
|
||||
if (!retval) {
|
||||
static char procname[64];
|
||||
@@ -242,8 +249,9 @@ SDL_EGL_GetProcAddress(_THIS, const char *proc)
|
||||
retval = SDL_LoadFunction(_this->egl_data->egl_dll_handle, procname);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Try eglGetProcAddress if we on <= 1.4 and still searching... */
|
||||
/* Try eglGetProcAddress if we're on <= 1.4 and still searching... */
|
||||
if (!retval && !is_egl_15_or_later && _this->egl_data->eglGetProcAddress) {
|
||||
retval = _this->egl_data->eglGetProcAddress(proc);
|
||||
if (retval) {
|
||||
@@ -432,8 +440,13 @@ SDL_EGL_LoadLibraryOnly(_THIS, const char *egl_path)
|
||||
LOAD_FUNC(eglGetError);
|
||||
LOAD_FUNC_EGLEXT(eglQueryDevicesEXT);
|
||||
LOAD_FUNC_EGLEXT(eglGetPlatformDisplayEXT);
|
||||
|
||||
_this->gl_config.driver_loaded = 1;
|
||||
/* Atomic functions */
|
||||
LOAD_FUNC_EGLEXT(eglCreateSyncKHR);
|
||||
LOAD_FUNC_EGLEXT(eglDestroySyncKHR);
|
||||
LOAD_FUNC_EGLEXT(eglDupNativeFenceFDANDROID);
|
||||
LOAD_FUNC_EGLEXT(eglWaitSyncKHR);
|
||||
LOAD_FUNC_EGLEXT(eglClientWaitSyncKHR);
|
||||
/* Atomic functions end */
|
||||
|
||||
if (path) {
|
||||
SDL_strlcpy(_this->gl_config.driver_path, path, sizeof(_this->gl_config.driver_path) - 1);
|
||||
@@ -678,6 +691,7 @@ SDL_EGL_ChooseConfig(_THIS)
|
||||
EGLint found_configs = 0, value;
|
||||
/* 128 seems even nicer here */
|
||||
EGLConfig configs[128];
|
||||
SDL_bool has_matching_format = SDL_FALSE;
|
||||
int i, j, best_bitdiff = -1, bitdiff;
|
||||
|
||||
if (!_this->egl_data) {
|
||||
@@ -761,11 +775,24 @@ SDL_EGL_ChooseConfig(_THIS)
|
||||
return SDL_EGL_SetError("Couldn't find matching EGL config", "eglChooseConfig");
|
||||
}
|
||||
|
||||
/* first ensure that a found config has a matching format, or the function will fall through. */
|
||||
for (i = 0; i < found_configs; i++ ) {
|
||||
if (_this->egl_data->egl_required_visual_id)
|
||||
{
|
||||
EGLint format;
|
||||
_this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display,
|
||||
configs[i],
|
||||
EGL_NATIVE_VISUAL_ID, &format);
|
||||
if (_this->egl_data->egl_required_visual_id == format)
|
||||
has_matching_format = SDL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* eglChooseConfig returns a number of configurations that match or exceed the requested attribs. */
|
||||
/* From those, we select the one that matches our requirements more closely via a makeshift algorithm */
|
||||
|
||||
for (i = 0; i < found_configs; i++ ) {
|
||||
if (_this->egl_data->egl_required_visual_id)
|
||||
if (has_matching_format && _this->egl_data->egl_required_visual_id)
|
||||
{
|
||||
EGLint format;
|
||||
_this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display,
|
||||
@@ -942,6 +969,36 @@ SDL_EGL_CreateContext(_THIS, EGLSurface egl_surface)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Check whether making contexts current without a surface is supported.
|
||||
* First condition: EGL must support it. That's the case for EGL 1.5
|
||||
* or later, or if the EGL_KHR_surfaceless_context extension is present. */
|
||||
if ((_this->egl_data->egl_version_major > 1) ||
|
||||
((_this->egl_data->egl_version_major == 1) && (_this->egl_data->egl_version_minor >= 5)) ||
|
||||
SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_KHR_surfaceless_context"))
|
||||
{
|
||||
/* Secondary condition: The client API must support it. */
|
||||
if (profile_es) {
|
||||
/* On OpenGL ES, the GL_OES_surfaceless_context extension must be
|
||||
* present. */
|
||||
if (SDL_GL_ExtensionSupported("GL_OES_surfaceless_context")) {
|
||||
_this->gl_allow_no_surface = SDL_TRUE;
|
||||
}
|
||||
#if SDL_VIDEO_OPENGL
|
||||
} else {
|
||||
/* Desktop OpenGL supports it by default from version 3.0 on. */
|
||||
void (APIENTRY * glGetIntegervFunc) (GLenum pname, GLint * params);
|
||||
glGetIntegervFunc = SDL_GL_GetProcAddress("glGetIntegerv");
|
||||
if (glGetIntegervFunc) {
|
||||
GLint v = 0;
|
||||
glGetIntegervFunc(GL_MAJOR_VERSION, &v);
|
||||
if (v >= 3) {
|
||||
_this->gl_allow_no_surface = SDL_TRUE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
return (SDL_GLContext) egl_context;
|
||||
}
|
||||
|
||||
@@ -957,7 +1014,7 @@ SDL_EGL_MakeCurrent(_THIS, EGLSurface egl_surface, SDL_GLContext context)
|
||||
/* The android emulator crashes badly if you try to eglMakeCurrent
|
||||
* with a valid context and invalid surface, so we have to check for both here.
|
||||
*/
|
||||
if (!egl_context || !egl_surface) {
|
||||
if (!egl_context || (!egl_surface && !_this->gl_allow_no_surface)) {
|
||||
_this->egl_data->eglMakeCurrent(_this->egl_data->egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
} else {
|
||||
if (!_this->egl_data->eglMakeCurrent(_this->egl_data->egl_display,
|
||||
|
29
externals/SDL/src/video/SDL_egl_c.h
vendored
29
externals/SDL/src/video/SDL_egl_c.h
vendored
@@ -101,12 +101,34 @@ typedef struct SDL_EGL_VideoData
|
||||
void **devices,
|
||||
EGLint *num_devices);
|
||||
|
||||
/* Atomic functions */
|
||||
|
||||
EGLSyncKHR(EGLAPIENTRY *eglCreateSyncKHR)(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list);
|
||||
|
||||
EGLBoolean(EGLAPIENTRY *eglDestroySyncKHR)(EGLDisplay dpy, EGLSyncKHR sync);
|
||||
|
||||
EGLint(EGLAPIENTRY *eglDupNativeFenceFDANDROID)(EGLDisplay dpy, EGLSyncKHR sync);
|
||||
|
||||
EGLint(EGLAPIENTRY *eglWaitSyncKHR)(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags);
|
||||
|
||||
EGLint(EGLAPIENTRY *eglClientWaitSyncKHR)(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout);
|
||||
|
||||
/* Atomic functions end */
|
||||
|
||||
|
||||
/* whether EGL display was offscreen */
|
||||
int is_offscreen;
|
||||
|
||||
} SDL_EGL_VideoData;
|
||||
|
||||
/* OpenGLES functions */
|
||||
typedef enum SDL_EGL_ExtensionType {
|
||||
SDL_EGL_DISPLAY_EXTENSION,
|
||||
SDL_EGL_CLIENT_EXTENSION
|
||||
} SDL_EGL_ExtensionType;
|
||||
|
||||
extern SDL_bool SDL_EGL_HasExtension(_THIS, SDL_EGL_ExtensionType type, const char *ext);
|
||||
|
||||
extern int SDL_EGL_GetAttribute(_THIS, SDL_GLattr attrib, int *value);
|
||||
/* SDL_EGL_LoadLibrary can get a display for a specific platform (EGL_PLATFORM_*)
|
||||
* or, if 0 is passed, let the implementation decide.
|
||||
@@ -147,12 +169,7 @@ BACKEND ## _GLES_SwapWindow(_THIS, SDL_Window * window) \
|
||||
#define SDL_EGL_MakeCurrent_impl(BACKEND) int \
|
||||
BACKEND ## _GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) \
|
||||
{\
|
||||
if (window && context) { \
|
||||
return SDL_EGL_MakeCurrent(_this, ((SDL_WindowData *) window->driverdata)->egl_surface, context); \
|
||||
}\
|
||||
else {\
|
||||
return SDL_EGL_MakeCurrent(_this, NULL, NULL);\
|
||||
}\
|
||||
return SDL_EGL_MakeCurrent(_this, window ? ((SDL_WindowData *) window->driverdata)->egl_surface : EGL_NO_SURFACE, context);\
|
||||
}
|
||||
|
||||
#define SDL_EGL_CreateContext_impl(BACKEND) SDL_GLContext \
|
||||
|
5
externals/SDL/src/video/SDL_fillrect.c
vendored
5
externals/SDL/src/video/SDL_fillrect.c
vendored
@@ -314,6 +314,11 @@ SDL_FillRects(SDL_Surface * dst, const SDL_Rect * rects, int count,
|
||||
return SDL_SetError("SDL_FillRect(): Unsupported surface format");
|
||||
}
|
||||
|
||||
/* Nothing to do */
|
||||
if (dst->w == 0 || dst->h == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Perform software fill */
|
||||
if (!dst->pixels) {
|
||||
return SDL_SetError("SDL_FillRect(): You must lock the surface");
|
||||
|
120
externals/SDL/src/video/SDL_pixels.c
vendored
120
externals/SDL/src/video/SDL_pixels.c
vendored
@@ -801,6 +801,54 @@ SDL_FindColor(SDL_Palette * pal, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
return (pixel);
|
||||
}
|
||||
|
||||
/* Tell whether palette is opaque, and if it has an alpha_channel */
|
||||
void
|
||||
SDL_DetectPalette(SDL_Palette *pal, SDL_bool *is_opaque, SDL_bool *has_alpha_channel)
|
||||
{
|
||||
int i;
|
||||
|
||||
{
|
||||
SDL_bool all_opaque = SDL_TRUE;
|
||||
for (i = 0; i < pal->ncolors; i++) {
|
||||
Uint8 alpha_value = pal->colors[i].a;
|
||||
if (alpha_value != SDL_ALPHA_OPAQUE) {
|
||||
all_opaque = SDL_FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (all_opaque) {
|
||||
/* Palette is opaque, with an alpha channel */
|
||||
*is_opaque = SDL_TRUE;
|
||||
*has_alpha_channel = SDL_TRUE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
SDL_bool all_transparent = SDL_TRUE;
|
||||
for (i = 0; i < pal->ncolors; i++) {
|
||||
Uint8 alpha_value = pal->colors[i].a;
|
||||
if (alpha_value != SDL_ALPHA_TRANSPARENT) {
|
||||
all_transparent = SDL_FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (all_transparent) {
|
||||
/* Palette is opaque, without an alpha channel */
|
||||
*is_opaque = SDL_TRUE;
|
||||
*has_alpha_channel = SDL_FALSE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Palette has alpha values */
|
||||
*is_opaque = SDL_FALSE;
|
||||
*has_alpha_channel = SDL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/* Find the opaque pixel value corresponding to an RGB triple */
|
||||
Uint32
|
||||
SDL_MapRGB(const SDL_PixelFormat * format, Uint8 r, Uint8 g, Uint8 b)
|
||||
@@ -975,6 +1023,62 @@ SDL_AllocBlitMap(void)
|
||||
return (map);
|
||||
}
|
||||
|
||||
|
||||
typedef struct SDL_ListNode
|
||||
{
|
||||
void *entry;
|
||||
struct SDL_ListNode *next;
|
||||
} SDL_ListNode;
|
||||
|
||||
void
|
||||
SDL_InvalidateAllBlitMap(SDL_Surface *surface)
|
||||
{
|
||||
SDL_ListNode *l = surface->list_blitmap;
|
||||
|
||||
surface->list_blitmap = NULL;
|
||||
|
||||
while (l) {
|
||||
SDL_ListNode *tmp = l;
|
||||
SDL_InvalidateMap((SDL_BlitMap *)l->entry);
|
||||
l = l->next;
|
||||
SDL_free(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
static void SDL_ListAdd(SDL_ListNode **head, void *ent);
|
||||
static void SDL_ListRemove(SDL_ListNode **head, void *ent);
|
||||
|
||||
void
|
||||
SDL_ListAdd(SDL_ListNode **head, void *ent)
|
||||
{
|
||||
SDL_ListNode *node = SDL_malloc(sizeof (*node));
|
||||
|
||||
if (node == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return;
|
||||
}
|
||||
|
||||
node->entry = ent;
|
||||
node->next = *head;
|
||||
*head = node;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_ListRemove(SDL_ListNode **head, void *ent)
|
||||
{
|
||||
SDL_ListNode **ptr = head;
|
||||
|
||||
while (*ptr) {
|
||||
if ((*ptr)->entry == ent) {
|
||||
SDL_ListNode *tmp = *ptr;
|
||||
*ptr = (*ptr)->next;
|
||||
SDL_free(tmp);
|
||||
return;
|
||||
}
|
||||
ptr = &(*ptr)->next;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SDL_InvalidateMap(SDL_BlitMap * map)
|
||||
{
|
||||
@@ -982,10 +1086,8 @@ SDL_InvalidateMap(SDL_BlitMap * map)
|
||||
return;
|
||||
}
|
||||
if (map->dst) {
|
||||
/* Release our reference to the surface - see the note below */
|
||||
if (--map->dst->refcount <= 0) {
|
||||
SDL_FreeSurface(map->dst);
|
||||
}
|
||||
/* Un-register from the destination surface */
|
||||
SDL_ListRemove((SDL_ListNode **)&(map->dst->list_blitmap), map);
|
||||
}
|
||||
map->dst = NULL;
|
||||
map->src_palette_version = 0;
|
||||
@@ -1056,14 +1158,8 @@ SDL_MapSurface(SDL_Surface * src, SDL_Surface * dst)
|
||||
map->dst = dst;
|
||||
|
||||
if (map->dst) {
|
||||
/* Keep a reference to this surface so it doesn't get deleted
|
||||
while we're still pointing at it.
|
||||
|
||||
A better method would be for the destination surface to keep
|
||||
track of surfaces that are mapped to it and automatically
|
||||
invalidate them when it is freed, but this will do for now.
|
||||
*/
|
||||
++map->dst->refcount;
|
||||
/* Register BlitMap to the destination surface, to be invalidated when needed */
|
||||
SDL_ListAdd((SDL_ListNode **)&(map->dst->list_blitmap), map);
|
||||
}
|
||||
|
||||
if (dstfmt->palette) {
|
||||
|
3
externals/SDL/src/video/SDL_pixels_c.h
vendored
3
externals/SDL/src/video/SDL_pixels_c.h
vendored
@@ -37,9 +37,12 @@ extern void SDL_InvalidateMap(SDL_BlitMap * map);
|
||||
extern int SDL_MapSurface(SDL_Surface * src, SDL_Surface * dst);
|
||||
extern void SDL_FreeBlitMap(SDL_BlitMap * map);
|
||||
|
||||
extern void SDL_InvalidateAllBlitMap(SDL_Surface *surface);
|
||||
|
||||
/* Miscellaneous functions */
|
||||
extern void SDL_DitherColors(SDL_Color * colors, int bpp);
|
||||
extern Uint8 SDL_FindColor(SDL_Palette * pal, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
extern void SDL_DetectPalette(SDL_Palette *pal, SDL_bool *is_opaque, SDL_bool *has_alpha_channel);
|
||||
|
||||
#endif /* SDL_pixels_c_h_ */
|
||||
|
||||
|
1
externals/SDL/src/video/SDL_rect.c
vendored
1
externals/SDL/src/video/SDL_rect.c
vendored
@@ -22,7 +22,6 @@
|
||||
|
||||
#include "SDL_rect.h"
|
||||
#include "SDL_rect_c.h"
|
||||
#include "SDL_assert.h"
|
||||
|
||||
SDL_bool
|
||||
SDL_HasIntersection(const SDL_Rect * A, const SDL_Rect * B)
|
||||
|
1
externals/SDL/src/video/SDL_shape.c
vendored
1
externals/SDL/src/video/SDL_shape.c
vendored
@@ -21,7 +21,6 @@
|
||||
#include "../SDL_internal.h"
|
||||
|
||||
#include "SDL.h"
|
||||
#include "SDL_assert.h"
|
||||
#include "SDL_video.h"
|
||||
#include "SDL_sysvideo.h"
|
||||
#include "SDL_pixels.h"
|
||||
|
@@ -35,6 +35,8 @@ extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
struct SDL_ShapeTree;
|
||||
|
||||
typedef struct {
|
||||
struct SDL_ShapeTree *upleft,*upright,*downleft,*downright;
|
||||
} SDL_QuadTreeChildren;
|
||||
@@ -46,7 +48,7 @@ typedef union {
|
||||
|
||||
typedef enum { QuadShape,TransparentShape,OpaqueShape } SDL_ShapeKind;
|
||||
|
||||
typedef struct {
|
||||
typedef struct SDL_ShapeTree {
|
||||
SDL_ShapeKind kind;
|
||||
SDL_ShapeUnion data;
|
||||
} SDL_ShapeTree;
|
||||
|
77
externals/SDL/src/video/SDL_surface.c
vendored
77
externals/SDL/src/video/SDL_surface.c
vendored
@@ -37,15 +37,15 @@ SDL_COMPILE_TIME_ASSERT(surface_size_assumptions,
|
||||
/*
|
||||
* Calculate the pad-aligned scanline width of a surface
|
||||
*/
|
||||
static int
|
||||
static Sint64
|
||||
SDL_CalculatePitch(Uint32 format, int width)
|
||||
{
|
||||
int pitch;
|
||||
Sint64 pitch;
|
||||
|
||||
if (SDL_ISPIXELFORMAT_FOURCC(format) || SDL_BITSPERPIXEL(format) >= 8) {
|
||||
pitch = (width * SDL_BYTESPERPIXEL(format));
|
||||
pitch = ((Sint64)width * SDL_BYTESPERPIXEL(format));
|
||||
} else {
|
||||
pitch = ((width * SDL_BITSPERPIXEL(format)) + 7) / 8;
|
||||
pitch = (((Sint64)width * SDL_BITSPERPIXEL(format)) + 7) / 8;
|
||||
}
|
||||
pitch = (pitch + 3) & ~3; /* 4-byte aligning for speed */
|
||||
return pitch;
|
||||
@@ -59,11 +59,19 @@ SDL_Surface *
|
||||
SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height, int depth,
|
||||
Uint32 format)
|
||||
{
|
||||
Sint64 pitch;
|
||||
SDL_Surface *surface;
|
||||
|
||||
/* The flags are no longer used, make the compiler happy */
|
||||
(void)flags;
|
||||
|
||||
pitch = SDL_CalculatePitch(format, width);
|
||||
if (pitch < 0 || pitch > SDL_MAX_SINT32) {
|
||||
/* Overflow... */
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Allocate the surface */
|
||||
surface = (SDL_Surface *) SDL_calloc(1, sizeof(*surface));
|
||||
if (surface == NULL) {
|
||||
@@ -78,7 +86,7 @@ SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height, int depth,
|
||||
}
|
||||
surface->w = width;
|
||||
surface->h = height;
|
||||
surface->pitch = SDL_CalculatePitch(format, width);
|
||||
surface->pitch = (int)pitch;
|
||||
SDL_SetClipRect(surface, NULL);
|
||||
|
||||
if (SDL_ISPIXELFORMAT_INDEXED(surface->format->format)) {
|
||||
@@ -241,6 +249,20 @@ SDL_SetSurfaceRLE(SDL_Surface * surface, int flag)
|
||||
return 0;
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
SDL_HasSurfaceRLE(SDL_Surface * surface)
|
||||
{
|
||||
if (!surface) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
if (!(surface->map->info.flags & SDL_COPY_RLE_DESIRED)) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SetColorKey(SDL_Surface * surface, int flag, Uint32 key)
|
||||
{
|
||||
@@ -1018,7 +1040,7 @@ SDL_ConvertSurface(SDL_Surface * surface, const SDL_PixelFormat * format,
|
||||
surface->map->info.g = 0xFF;
|
||||
surface->map->info.b = 0xFF;
|
||||
surface->map->info.a = 0xFF;
|
||||
surface->map->info.flags = 0;
|
||||
surface->map->info.flags = (copy_flags & (SDL_COPY_RLE_COLORKEY | SDL_COPY_RLE_ALPHAKEY));
|
||||
SDL_InvalidateMap(surface->map);
|
||||
|
||||
/* Copy over the image data */
|
||||
@@ -1032,22 +1054,16 @@ SDL_ConvertSurface(SDL_Surface * surface, const SDL_PixelFormat * format,
|
||||
* -> set alpha channel to be opaque */
|
||||
if (surface->format->palette && format->Amask) {
|
||||
SDL_bool set_opaque = SDL_FALSE;
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < surface->format->palette->ncolors; i++) {
|
||||
Uint8 alpha_value = surface->format->palette->colors[i].a;
|
||||
|
||||
if (alpha_value != 0 && alpha_value != SDL_ALPHA_OPAQUE) {
|
||||
/* Palette has at least one alpha value. Don't do anything */
|
||||
set_opaque = SDL_FALSE;
|
||||
palette_has_alpha = SDL_TRUE;
|
||||
break;
|
||||
}
|
||||
SDL_bool is_opaque, has_alpha_channel;
|
||||
SDL_DetectPalette(surface->format->palette, &is_opaque, &has_alpha_channel);
|
||||
|
||||
if (alpha_value == 0) {
|
||||
set_opaque = SDL_TRUE;
|
||||
}
|
||||
if (is_opaque) {
|
||||
if (!has_alpha_channel) {
|
||||
set_opaque = SDL_TRUE;
|
||||
}
|
||||
} else {
|
||||
palette_has_alpha = SDL_TRUE;
|
||||
}
|
||||
|
||||
/* Set opaque and backup palette alpha values */
|
||||
@@ -1112,6 +1128,7 @@ SDL_ConvertSurface(SDL_Surface * surface, const SDL_PixelFormat * format,
|
||||
|
||||
if (copy_flags & SDL_COPY_COLORKEY) {
|
||||
SDL_bool set_colorkey_by_color = SDL_FALSE;
|
||||
SDL_bool convert_colorkey = SDL_TRUE;
|
||||
|
||||
if (surface->format->palette) {
|
||||
if (format->palette &&
|
||||
@@ -1121,7 +1138,13 @@ SDL_ConvertSurface(SDL_Surface * surface, const SDL_PixelFormat * format,
|
||||
/* The palette is identical, just set the same colorkey */
|
||||
SDL_SetColorKey(convert, 1, surface->map->info.colorkey);
|
||||
} else if (!format->palette) {
|
||||
/* Was done by 'palette_ck_transform' */
|
||||
if (format->Amask) {
|
||||
/* No need to add the colorkey, transparency is in the alpha channel*/
|
||||
} else {
|
||||
/* Only set the colorkey information */
|
||||
set_colorkey_by_color = SDL_TRUE;
|
||||
convert_colorkey = SDL_FALSE;
|
||||
}
|
||||
} else {
|
||||
set_colorkey_by_color = SDL_TRUE;
|
||||
}
|
||||
@@ -1162,7 +1185,9 @@ SDL_ConvertSurface(SDL_Surface * surface, const SDL_PixelFormat * format,
|
||||
SDL_SetColorKey(convert, 1, converted_colorkey);
|
||||
|
||||
/* This is needed when converting for 3D texture upload */
|
||||
SDL_ConvertColorkeyToAlpha(convert, SDL_TRUE);
|
||||
if (convert_colorkey) {
|
||||
SDL_ConvertColorkeyToAlpha(convert, SDL_TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
SDL_SetClipRect(convert, &surface->clip_rect);
|
||||
@@ -1248,6 +1273,7 @@ int SDL_ConvertPixels(int width, int height,
|
||||
SDL_BlitMap src_blitmap, dst_blitmap;
|
||||
SDL_Rect rect;
|
||||
void *nonconst_src = (void *) src;
|
||||
int ret;
|
||||
|
||||
/* Check to make sure we are blitting somewhere, so we don't crash */
|
||||
if (!dst) {
|
||||
@@ -1300,7 +1326,12 @@ int SDL_ConvertPixels(int width, int height,
|
||||
rect.y = 0;
|
||||
rect.w = width;
|
||||
rect.h = height;
|
||||
return SDL_LowerBlit(&src_surface, &rect, &dst_surface, &rect);
|
||||
ret = SDL_LowerBlit(&src_surface, &rect, &dst_surface, &rect);
|
||||
|
||||
/* Free blitmap reference, after blitting between stack'ed surfaces */
|
||||
SDL_InvalidateMap(src_surface.map);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1317,6 +1348,8 @@ SDL_FreeSurface(SDL_Surface * surface)
|
||||
}
|
||||
SDL_InvalidateMap(surface->map);
|
||||
|
||||
SDL_InvalidateAllBlitMap(surface);
|
||||
|
||||
if (--surface->refcount > 0) {
|
||||
return;
|
||||
}
|
||||
|
14
externals/SDL/src/video/SDL_sysvideo.h
vendored
14
externals/SDL/src/video/SDL_sysvideo.h
vendored
@@ -281,6 +281,8 @@ struct SDL_VideoDevice
|
||||
*/
|
||||
SDL_MetalView (*Metal_CreateView) (_THIS, SDL_Window * window);
|
||||
void (*Metal_DestroyView) (_THIS, SDL_MetalView view);
|
||||
void *(*Metal_GetLayer) (_THIS, SDL_MetalView view);
|
||||
void (*Metal_GetDrawableSize) (_THIS, SDL_Window * window, int *w, int *h);
|
||||
|
||||
/* * * */
|
||||
/*
|
||||
@@ -373,6 +375,11 @@ struct SDL_VideoDevice
|
||||
SDL_TLSID current_glwin_tls;
|
||||
SDL_TLSID current_glctx_tls;
|
||||
|
||||
/* Flag that stores whether it's allowed to call SDL_GL_MakeCurrent()
|
||||
* with a NULL window, but a non-NULL context. (Not allowed in most cases,
|
||||
* except on EGL under some circumstances.) */
|
||||
SDL_bool gl_allow_no_surface;
|
||||
|
||||
/* * * */
|
||||
/* Data used by the Vulkan drivers */
|
||||
struct
|
||||
@@ -406,7 +413,6 @@ typedef struct VideoBootStrap
|
||||
{
|
||||
const char *name;
|
||||
const char *desc;
|
||||
int (*available) (void);
|
||||
SDL_VideoDevice *(*create) (int devindex);
|
||||
} VideoBootStrap;
|
||||
|
||||
@@ -423,6 +429,7 @@ extern VideoBootStrap Android_bootstrap;
|
||||
extern VideoBootStrap PSP_bootstrap;
|
||||
extern VideoBootStrap RPI_bootstrap;
|
||||
extern VideoBootStrap KMSDRM_bootstrap;
|
||||
extern VideoBootStrap KMSDRM_LEGACY_bootstrap;
|
||||
extern VideoBootStrap DUMMY_bootstrap;
|
||||
extern VideoBootStrap Wayland_bootstrap;
|
||||
extern VideoBootStrap NACL_bootstrap;
|
||||
@@ -430,10 +437,13 @@ extern VideoBootStrap VIVANTE_bootstrap;
|
||||
extern VideoBootStrap Emscripten_bootstrap;
|
||||
extern VideoBootStrap QNX_bootstrap;
|
||||
extern VideoBootStrap OFFSCREEN_bootstrap;
|
||||
extern VideoBootStrap OS2DIVE_bootstrap;
|
||||
extern VideoBootStrap OS2VMAN_bootstrap;
|
||||
|
||||
extern SDL_VideoDevice *SDL_GetVideoDevice(void);
|
||||
extern int SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode);
|
||||
extern int SDL_AddVideoDisplay(const SDL_VideoDisplay * display);
|
||||
extern int SDL_AddVideoDisplay(const SDL_VideoDisplay * display, SDL_bool send_event);
|
||||
extern void SDL_DelVideoDisplay(int index);
|
||||
extern SDL_bool SDL_AddDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode * mode);
|
||||
extern int SDL_GetIndexOfDisplay(SDL_VideoDisplay *display);
|
||||
extern SDL_VideoDisplay *SDL_GetDisplay(int displayIndex);
|
||||
|
244
externals/SDL/src/video/SDL_video.c
vendored
244
externals/SDL/src/video/SDL_video.c
vendored
@@ -96,6 +96,7 @@ static VideoBootStrap *bootstrap[] = {
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_KMSDRM
|
||||
&KMSDRM_bootstrap,
|
||||
&KMSDRM_LEGACY_bootstrap,
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_RPI
|
||||
&RPI_bootstrap,
|
||||
@@ -112,6 +113,10 @@ static VideoBootStrap *bootstrap[] = {
|
||||
#if SDL_VIDEO_DRIVER_OFFSCREEN
|
||||
&OFFSCREEN_bootstrap,
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_OS2
|
||||
&OS2DIVE_bootstrap,
|
||||
&OS2VMAN_bootstrap,
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_DUMMY
|
||||
&DUMMY_bootstrap,
|
||||
#endif
|
||||
@@ -493,19 +498,15 @@ SDL_VideoInit(const char *driver_name)
|
||||
if (driver_name != NULL) {
|
||||
for (i = 0; bootstrap[i]; ++i) {
|
||||
if (SDL_strncasecmp(bootstrap[i]->name, driver_name, SDL_strlen(driver_name)) == 0) {
|
||||
if (bootstrap[i]->available()) {
|
||||
video = bootstrap[i]->create(index);
|
||||
break;
|
||||
}
|
||||
video = bootstrap[i]->create(index);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (i = 0; bootstrap[i]; ++i) {
|
||||
if (bootstrap[i]->available()) {
|
||||
video = bootstrap[i]->create(index);
|
||||
if (video != NULL) {
|
||||
break;
|
||||
}
|
||||
video = bootstrap[i]->create(index);
|
||||
if (video != NULL) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -599,11 +600,11 @@ SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode)
|
||||
}
|
||||
display.current_mode = display.desktop_mode;
|
||||
|
||||
return SDL_AddVideoDisplay(&display);
|
||||
return SDL_AddVideoDisplay(&display, SDL_FALSE);
|
||||
}
|
||||
|
||||
int
|
||||
SDL_AddVideoDisplay(const SDL_VideoDisplay * display)
|
||||
SDL_AddVideoDisplay(const SDL_VideoDisplay * display, SDL_bool send_event)
|
||||
{
|
||||
SDL_VideoDisplay *displays;
|
||||
int index = -1;
|
||||
@@ -625,12 +626,31 @@ SDL_AddVideoDisplay(const SDL_VideoDisplay * display)
|
||||
SDL_itoa(index, name, 10);
|
||||
displays[index].name = SDL_strdup(name);
|
||||
}
|
||||
|
||||
if (send_event) {
|
||||
SDL_SendDisplayEvent(&_this->displays[index], SDL_DISPLAYEVENT_CONNECTED, 0);
|
||||
}
|
||||
} else {
|
||||
SDL_OutOfMemory();
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_DelVideoDisplay(int index)
|
||||
{
|
||||
if (index < 0 || index >= _this->num_displays) {
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_SendDisplayEvent(&_this->displays[index], SDL_DISPLAYEVENT_DISCONNECTED, 0);
|
||||
|
||||
if (index < (_this->num_displays - 1)) {
|
||||
SDL_memmove(&_this->displays[index], &_this->displays[index+1], (_this->num_displays - index - 1)*sizeof(_this->displays[index]));
|
||||
}
|
||||
--_this->num_displays;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_GetNumVideoDisplays(void)
|
||||
{
|
||||
@@ -1366,7 +1386,7 @@ SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen)
|
||||
}
|
||||
|
||||
#define CREATE_FLAGS \
|
||||
(SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_ALWAYS_ON_TOP | SDL_WINDOW_SKIP_TASKBAR | SDL_WINDOW_POPUP_MENU | SDL_WINDOW_UTILITY | SDL_WINDOW_TOOLTIP | SDL_WINDOW_VULKAN | SDL_WINDOW_MINIMIZED)
|
||||
(SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_ALWAYS_ON_TOP | SDL_WINDOW_SKIP_TASKBAR | SDL_WINDOW_POPUP_MENU | SDL_WINDOW_UTILITY | SDL_WINDOW_TOOLTIP | SDL_WINDOW_VULKAN | SDL_WINDOW_MINIMIZED | SDL_WINDOW_METAL)
|
||||
|
||||
static SDL_INLINE SDL_bool
|
||||
IsAcceptingDragAndDrop(void)
|
||||
@@ -1429,7 +1449,7 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
|
||||
|
||||
if (!_this) {
|
||||
/* Initialize the video system if needed */
|
||||
if (SDL_VideoInit(NULL) < 0) {
|
||||
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -1455,7 +1475,7 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
|
||||
|
||||
/* Some platforms have OpenGL enabled by default */
|
||||
#if (SDL_VIDEO_OPENGL && __MACOSX__) || __IPHONEOS__ || __ANDROID__ || __NACL__
|
||||
if (!_this->is_dummy && !(flags & SDL_WINDOW_VULKAN) && !SDL_IsVideoContextExternal()) {
|
||||
if (!_this->is_dummy && !(flags & SDL_WINDOW_VULKAN) && !(flags & SDL_WINDOW_METAL) && !SDL_IsVideoContextExternal()) {
|
||||
flags |= SDL_WINDOW_OPENGL;
|
||||
}
|
||||
#endif
|
||||
@@ -1487,6 +1507,24 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
|
||||
}
|
||||
}
|
||||
|
||||
if (flags & SDL_WINDOW_METAL) {
|
||||
if (!_this->Metal_CreateView) {
|
||||
SDL_SetError("Metal support is either not configured in SDL "
|
||||
"or not available in current SDL video driver "
|
||||
"(%s) or platform", _this->name);
|
||||
return NULL;
|
||||
}
|
||||
if (flags & SDL_WINDOW_OPENGL) {
|
||||
SDL_SetError("Metal and OpenGL not supported on same window");
|
||||
return NULL;
|
||||
}
|
||||
if (flags & SDL_WINDOW_VULKAN) {
|
||||
SDL_SetError("Metal and Vulkan not supported on same window. "
|
||||
"To use MoltenVK, set SDL_WINDOW_VULKAN only.");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Unless the user has specified the high-DPI disabling hint, respect the
|
||||
* SDL_WINDOW_ALLOW_HIGHDPI flag.
|
||||
*/
|
||||
@@ -1635,6 +1673,11 @@ int
|
||||
SDL_RecreateWindow(SDL_Window * window, Uint32 flags)
|
||||
{
|
||||
SDL_bool loaded_opengl = SDL_FALSE;
|
||||
SDL_bool need_gl_unload = SDL_FALSE;
|
||||
SDL_bool need_gl_load = SDL_FALSE;
|
||||
SDL_bool loaded_vulkan = SDL_FALSE;
|
||||
SDL_bool need_vulkan_unload = SDL_FALSE;
|
||||
SDL_bool need_vulkan_load = SDL_FALSE;
|
||||
|
||||
if ((flags & SDL_WINDOW_OPENGL) && !_this->GL_CreateContext) {
|
||||
return SDL_SetError("OpenGL support is either not configured in SDL "
|
||||
@@ -1668,29 +1711,72 @@ SDL_RecreateWindow(SDL_Window * window, Uint32 flags)
|
||||
|
||||
if ((window->flags & SDL_WINDOW_OPENGL) != (flags & SDL_WINDOW_OPENGL)) {
|
||||
if (flags & SDL_WINDOW_OPENGL) {
|
||||
if (SDL_GL_LoadLibrary(NULL) < 0) {
|
||||
return -1;
|
||||
}
|
||||
loaded_opengl = SDL_TRUE;
|
||||
need_gl_load = SDL_TRUE;
|
||||
} else {
|
||||
SDL_GL_UnloadLibrary();
|
||||
need_gl_unload = SDL_TRUE;
|
||||
}
|
||||
} else if (window->flags & SDL_WINDOW_OPENGL) {
|
||||
need_gl_unload = SDL_TRUE;
|
||||
need_gl_load = SDL_TRUE;
|
||||
}
|
||||
|
||||
if ((window->flags & SDL_WINDOW_METAL) != (flags & SDL_WINDOW_METAL)) {
|
||||
if (flags & SDL_WINDOW_METAL) {
|
||||
need_gl_load = SDL_TRUE;
|
||||
} else {
|
||||
need_gl_unload = SDL_TRUE;
|
||||
}
|
||||
} else if (window->flags & SDL_WINDOW_METAL) {
|
||||
need_gl_unload = SDL_TRUE;
|
||||
need_gl_load = SDL_TRUE;
|
||||
}
|
||||
|
||||
if ((window->flags & SDL_WINDOW_VULKAN) != (flags & SDL_WINDOW_VULKAN)) {
|
||||
if (flags & SDL_WINDOW_VULKAN) {
|
||||
need_vulkan_load = SDL_TRUE;
|
||||
} else {
|
||||
need_vulkan_unload = SDL_TRUE;
|
||||
}
|
||||
} else if (window->flags & SDL_WINDOW_VULKAN) {
|
||||
need_vulkan_unload = SDL_TRUE;
|
||||
need_vulkan_load = SDL_TRUE;
|
||||
}
|
||||
|
||||
if ((flags & SDL_WINDOW_VULKAN) && (flags & SDL_WINDOW_OPENGL)) {
|
||||
SDL_SetError("Vulkan and OpenGL not supported on same window");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((flags & SDL_WINDOW_METAL) && (flags & SDL_WINDOW_OPENGL)) {
|
||||
SDL_SetError("Metal and OpenGL not supported on same window");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((flags & SDL_WINDOW_METAL) && (flags & SDL_WINDOW_VULKAN)) {
|
||||
SDL_SetError("Metal and Vulkan not supported on same window");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (need_gl_unload) {
|
||||
SDL_GL_UnloadLibrary();
|
||||
}
|
||||
|
||||
if (need_vulkan_unload) {
|
||||
SDL_Vulkan_UnloadLibrary();
|
||||
}
|
||||
|
||||
if (need_gl_load) {
|
||||
if (SDL_GL_LoadLibrary(NULL) < 0) {
|
||||
return -1;
|
||||
}
|
||||
loaded_opengl = SDL_TRUE;
|
||||
}
|
||||
|
||||
if ((window->flags & SDL_WINDOW_VULKAN) != (flags & SDL_WINDOW_VULKAN)) {
|
||||
SDL_SetError("Can't change SDL_WINDOW_VULKAN window flag");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((window->flags & SDL_WINDOW_VULKAN) && (flags & SDL_WINDOW_OPENGL)) {
|
||||
SDL_SetError("Vulkan and OpenGL not supported on same window");
|
||||
return -1;
|
||||
if (need_vulkan_load) {
|
||||
if (SDL_Vulkan_LoadLibrary(NULL) < 0) {
|
||||
return -1;
|
||||
}
|
||||
loaded_vulkan = SDL_TRUE;
|
||||
}
|
||||
|
||||
window->flags = ((flags & CREATE_FLAGS) | SDL_WINDOW_HIDDEN);
|
||||
@@ -1703,6 +1789,10 @@ SDL_RecreateWindow(SDL_Window * window, Uint32 flags)
|
||||
SDL_GL_UnloadLibrary();
|
||||
window->flags &= ~SDL_WINDOW_OPENGL;
|
||||
}
|
||||
if (loaded_vulkan) {
|
||||
SDL_Vulkan_UnloadLibrary();
|
||||
window->flags &= ~SDL_WINDOW_VULKAN;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -2098,8 +2188,8 @@ SDL_SetWindowMinimumSize(SDL_Window * window, int min_w, int min_h)
|
||||
return;
|
||||
}
|
||||
|
||||
if ((window->max_w && min_w >= window->max_w) ||
|
||||
(window->max_h && min_h >= window->max_h)) {
|
||||
if ((window->max_w && min_w > window->max_w) ||
|
||||
(window->max_h && min_h > window->max_h)) {
|
||||
SDL_SetError("SDL_SetWindowMinimumSize(): Tried to set minimum size larger than maximum size");
|
||||
return;
|
||||
}
|
||||
@@ -2141,7 +2231,7 @@ SDL_SetWindowMaximumSize(SDL_Window * window, int max_w, int max_h)
|
||||
return;
|
||||
}
|
||||
|
||||
if (max_w <= window->min_w || max_h <= window->min_h) {
|
||||
if (max_w < window->min_w || max_h < window->min_h) {
|
||||
SDL_SetError("SDL_SetWindowMaximumSize(): Tried to set maximum size smaller than minimum size");
|
||||
return;
|
||||
}
|
||||
@@ -2319,6 +2409,10 @@ SDL_CreateWindowFramebuffer(SDL_Window * window)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (window->surface) {
|
||||
return window->surface;
|
||||
}
|
||||
|
||||
if (!SDL_PixelFormatEnumToMasks(format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -2335,6 +2429,7 @@ SDL_GetWindowSurface(SDL_Window * window)
|
||||
if (window->surface) {
|
||||
window->surface->flags &= ~SDL_DONTFREE;
|
||||
SDL_FreeSurface(window->surface);
|
||||
window->surface = NULL;
|
||||
}
|
||||
window->surface = SDL_CreateWindowFramebuffer(window);
|
||||
if (window->surface) {
|
||||
@@ -2694,7 +2789,7 @@ ShouldMinimizeOnFocusLoss(SDL_Window * window)
|
||||
}
|
||||
#endif
|
||||
|
||||
return SDL_GetHintBoolean(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, SDL_TRUE);
|
||||
return SDL_GetHintBoolean(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, SDL_FALSE);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2759,6 +2854,8 @@ SDL_DestroyWindow(SDL_Window * window)
|
||||
if (window->surface) {
|
||||
window->surface->flags &= ~SDL_DONTFREE;
|
||||
SDL_FreeSurface(window->surface);
|
||||
window->surface = NULL;
|
||||
window->surface_valid = SDL_FALSE;
|
||||
}
|
||||
if (_this->DestroyWindowFramebuffer) {
|
||||
_this->DestroyWindowFramebuffer(_this, window);
|
||||
@@ -3111,24 +3208,24 @@ SDL_GL_ResetAttributes()
|
||||
_this->gl_config.retained_backing = 1;
|
||||
_this->gl_config.accelerated = -1; /* accelerated or not, both are fine */
|
||||
|
||||
#if SDL_VIDEO_OPENGL
|
||||
_this->gl_config.major_version = 2;
|
||||
_this->gl_config.minor_version = 1;
|
||||
_this->gl_config.profile_mask = 0;
|
||||
#elif SDL_VIDEO_OPENGL_ES2
|
||||
_this->gl_config.major_version = 2;
|
||||
_this->gl_config.minor_version = 0;
|
||||
_this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES;
|
||||
#elif SDL_VIDEO_OPENGL_ES
|
||||
_this->gl_config.major_version = 1;
|
||||
_this->gl_config.minor_version = 1;
|
||||
_this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES;
|
||||
#endif
|
||||
|
||||
if (_this->GL_DefaultProfileConfig) {
|
||||
_this->GL_DefaultProfileConfig(_this, &_this->gl_config.profile_mask,
|
||||
&_this->gl_config.major_version,
|
||||
&_this->gl_config.minor_version);
|
||||
} else {
|
||||
#if SDL_VIDEO_OPENGL
|
||||
_this->gl_config.major_version = 2;
|
||||
_this->gl_config.minor_version = 1;
|
||||
_this->gl_config.profile_mask = 0;
|
||||
#elif SDL_VIDEO_OPENGL_ES2
|
||||
_this->gl_config.major_version = 2;
|
||||
_this->gl_config.minor_version = 0;
|
||||
_this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES;
|
||||
#elif SDL_VIDEO_OPENGL_ES
|
||||
_this->gl_config.major_version = 1;
|
||||
_this->gl_config.minor_version = 1;
|
||||
_this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES;
|
||||
#endif
|
||||
}
|
||||
|
||||
_this->gl_config.flags = 0;
|
||||
@@ -3546,12 +3643,14 @@ SDL_GL_MakeCurrent(SDL_Window * window, SDL_GLContext ctx)
|
||||
|
||||
if (!ctx) {
|
||||
window = NULL;
|
||||
} else {
|
||||
} else if (window) {
|
||||
CHECK_WINDOW_MAGIC(window, -1);
|
||||
|
||||
if (!(window->flags & SDL_WINDOW_OPENGL)) {
|
||||
return SDL_SetError("The specified window isn't an OpenGL window");
|
||||
}
|
||||
} else if (!_this->gl_allow_no_surface) {
|
||||
return SDL_SetError("Use of OpenGL without a window is not supported on this platform");
|
||||
}
|
||||
|
||||
retval = _this->GL_MakeCurrent(_this, window, ctx);
|
||||
@@ -3867,9 +3966,11 @@ SDL_IsScreenKeyboardShown(SDL_Window *window)
|
||||
#if SDL_VIDEO_DRIVER_HAIKU
|
||||
#include "haiku/SDL_bmessagebox.h"
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_OS2
|
||||
#include "os2/SDL_os2messagebox.h"
|
||||
#endif
|
||||
|
||||
|
||||
#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_WINRT || SDL_VIDEO_DRIVER_COCOA || SDL_VIDEO_DRIVER_UIKIT || SDL_VIDEO_DRIVER_X11 || SDL_VIDEO_DRIVER_HAIKU
|
||||
#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_WINRT || SDL_VIDEO_DRIVER_COCOA || SDL_VIDEO_DRIVER_UIKIT || SDL_VIDEO_DRIVER_X11 || SDL_VIDEO_DRIVER_HAIKU || SDL_VIDEO_DRIVER_OS2
|
||||
static SDL_bool SDL_MessageboxValidForDriver(const SDL_MessageBoxData *messageboxdata, SDL_SYSWM_TYPE drivertype)
|
||||
{
|
||||
SDL_SysWMinfo info;
|
||||
@@ -3897,6 +3998,7 @@ SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
||||
int show_cursor_prev;
|
||||
SDL_bool mouse_captured;
|
||||
SDL_Window *current_window;
|
||||
SDL_MessageBoxData mbdata;
|
||||
|
||||
if (!messageboxdata) {
|
||||
return SDL_InvalidParamError("messageboxdata");
|
||||
@@ -3916,6 +4018,11 @@ SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
||||
buttonid = &dummybutton;
|
||||
}
|
||||
|
||||
SDL_memcpy(&mbdata, messageboxdata, sizeof(*messageboxdata));
|
||||
if (!mbdata.title) mbdata.title = "";
|
||||
if (!mbdata.message) mbdata.message = "";
|
||||
messageboxdata = &mbdata;
|
||||
|
||||
if (_this && _this->ShowMessageBox) {
|
||||
retval = _this->ShowMessageBox(_this, messageboxdata, buttonid);
|
||||
}
|
||||
@@ -3968,6 +4075,13 @@ SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
||||
HAIKU_ShowMessageBox(messageboxdata, buttonid) == 0) {
|
||||
retval = 0;
|
||||
}
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_OS2
|
||||
if (retval == -1 &&
|
||||
SDL_MessageboxValidForDriver(messageboxdata, SDL_SYSWM_OS2) &&
|
||||
OS2_ShowMessageBox(messageboxdata, buttonid) == 0) {
|
||||
retval = 0;
|
||||
}
|
||||
#endif
|
||||
if (retval == -1) {
|
||||
SDL_SetError("No message system available");
|
||||
@@ -3994,6 +4108,8 @@ SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, const char *message, S
|
||||
/* Web browsers don't (currently) have an API for a custom message box
|
||||
that can block, but for the most common case (SDL_ShowSimpleMessageBox),
|
||||
we can use the standard Javascript alert() function. */
|
||||
if (!title) title = "";
|
||||
if (!message) message = "";
|
||||
EM_ASM_({
|
||||
alert(UTF8ToString($0) + "\n\n" + UTF8ToString($1));
|
||||
}, title, message);
|
||||
@@ -4219,6 +4335,11 @@ SDL_Metal_CreateView(SDL_Window * window)
|
||||
{
|
||||
CHECK_WINDOW_MAGIC(window, NULL);
|
||||
|
||||
if (!(window->flags & SDL_WINDOW_METAL)) {
|
||||
SDL_SetError("The specified window isn't a Metal window");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (_this->Metal_CreateView) {
|
||||
return _this->Metal_CreateView(_this, window);
|
||||
} else {
|
||||
@@ -4235,4 +4356,31 @@ SDL_Metal_DestroyView(SDL_MetalView view)
|
||||
}
|
||||
}
|
||||
|
||||
void *
|
||||
SDL_Metal_GetLayer(SDL_MetalView view)
|
||||
{
|
||||
if (_this && _this->Metal_GetLayer) {
|
||||
if (view) {
|
||||
return _this->Metal_GetLayer(_this, view);
|
||||
} else {
|
||||
SDL_InvalidParamError("view");
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
SDL_SetError("Metal is not supported.");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void SDL_Metal_GetDrawableSize(SDL_Window * window, int *w, int *h)
|
||||
{
|
||||
CHECK_WINDOW_MAGIC(window,);
|
||||
|
||||
if (_this->Metal_GetDrawableSize) {
|
||||
_this->Metal_GetDrawableSize(_this, window, w, h);
|
||||
} else {
|
||||
SDL_GetWindowSize(window, w, h);
|
||||
}
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
@@ -38,6 +38,9 @@
|
||||
#if SDL_VIDEO_DRIVER_COCOA
|
||||
#define VK_USE_PLATFORM_MACOS_MVK
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_DIRECTFB
|
||||
#define VK_USE_PLATFORM_DIRECTFB_EXT
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_UIKIT
|
||||
#define VK_USE_PLATFORM_IOS_MVK
|
||||
#endif
|
||||
|
34
externals/SDL/src/video/SDL_vulkan_utils.c
vendored
34
externals/SDL/src/video/SDL_vulkan_utils.c
vendored
@@ -22,7 +22,6 @@
|
||||
|
||||
#include "SDL_vulkan_internal.h"
|
||||
#include "SDL_error.h"
|
||||
#include "SDL_log.h"
|
||||
|
||||
/* !!! FIXME: this file doesn't match coding standards for SDL (brace position, etc). */
|
||||
|
||||
@@ -68,6 +67,16 @@ const char *SDL_Vulkan_GetResultString(VkResult result)
|
||||
return "VK_ERROR_FORMAT_NOT_SUPPORTED";
|
||||
case VK_ERROR_FRAGMENTED_POOL:
|
||||
return "VK_ERROR_FRAGMENTED_POOL";
|
||||
case VK_ERROR_UNKNOWN:
|
||||
return "VK_ERROR_UNKNOWN";
|
||||
case VK_ERROR_OUT_OF_POOL_MEMORY:
|
||||
return "VK_ERROR_OUT_OF_POOL_MEMORY";
|
||||
case VK_ERROR_INVALID_EXTERNAL_HANDLE:
|
||||
return "VK_ERROR_INVALID_EXTERNAL_HANDLE";
|
||||
case VK_ERROR_FRAGMENTATION:
|
||||
return "VK_ERROR_FRAGMENTATION";
|
||||
case VK_ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS:
|
||||
return "VK_ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS";
|
||||
case VK_ERROR_SURFACE_LOST_KHR:
|
||||
return "VK_ERROR_SURFACE_LOST_KHR";
|
||||
case VK_ERROR_NATIVE_WINDOW_IN_USE_KHR:
|
||||
@@ -80,12 +89,27 @@ const char *SDL_Vulkan_GetResultString(VkResult result)
|
||||
return "VK_ERROR_INCOMPATIBLE_DISPLAY_KHR";
|
||||
case VK_ERROR_VALIDATION_FAILED_EXT:
|
||||
return "VK_ERROR_VALIDATION_FAILED_EXT";
|
||||
case VK_ERROR_OUT_OF_POOL_MEMORY_KHR:
|
||||
return "VK_ERROR_OUT_OF_POOL_MEMORY_KHR";
|
||||
case VK_ERROR_INVALID_SHADER_NV:
|
||||
return "VK_ERROR_INVALID_SHADER_NV";
|
||||
case VK_RESULT_MAX_ENUM:
|
||||
case VK_RESULT_RANGE_SIZE:
|
||||
case VK_ERROR_INCOMPATIBLE_VERSION_KHR:
|
||||
return "VK_ERROR_INCOMPATIBLE_VERSION_KHR";
|
||||
case VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT:
|
||||
return "VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT";
|
||||
case VK_ERROR_NOT_PERMITTED_EXT:
|
||||
return "VK_ERROR_NOT_PERMITTED_EXT";
|
||||
case VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT:
|
||||
return "VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT";
|
||||
case VK_THREAD_IDLE_KHR:
|
||||
return "VK_THREAD_IDLE_KHR";
|
||||
case VK_THREAD_DONE_KHR:
|
||||
return "VK_THREAD_DONE_KHR";
|
||||
case VK_OPERATION_DEFERRED_KHR:
|
||||
return "VK_OPERATION_DEFERRED_KHR";
|
||||
case VK_OPERATION_NOT_DEFERRED_KHR:
|
||||
return "VK_OPERATION_NOT_DEFERRED_KHR";
|
||||
case VK_PIPELINE_COMPILE_REQUIRED_EXT:
|
||||
return "VK_PIPELINE_COMPILE_REQUIRED_EXT";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if(result < 0)
|
||||
|
@@ -175,8 +175,10 @@ Android_PumpEvents_NonBlocking(_THIS)
|
||||
SDL_UnlockMutex(Android_ActivityMutex);
|
||||
}
|
||||
|
||||
ANDROIDAUDIO_PauseDevices();
|
||||
openslES_PauseDevices();
|
||||
if (videodata->pauseAudio) {
|
||||
ANDROIDAUDIO_PauseDevices();
|
||||
openslES_PauseDevices();
|
||||
}
|
||||
|
||||
backup_context = 0;
|
||||
}
|
||||
@@ -191,8 +193,10 @@ Android_PumpEvents_NonBlocking(_THIS)
|
||||
SDL_SendAppEvent(SDL_APP_DIDENTERFOREGROUND);
|
||||
SDL_SendWindowEvent(Android_Window, SDL_WINDOWEVENT_RESTORED, 0, 0);
|
||||
|
||||
ANDROIDAUDIO_ResumeDevices();
|
||||
openslES_ResumeDevices();
|
||||
if (videodata->pauseAudio) {
|
||||
ANDROIDAUDIO_ResumeDevices();
|
||||
openslES_ResumeDevices();
|
||||
}
|
||||
|
||||
/* Restore the GL Context from here, as this operation is thread dependent */
|
||||
if (!isContextExternal && !SDL_HasEvent(SDL_QUIT)) {
|
||||
|
@@ -26,7 +26,6 @@
|
||||
|
||||
#include "SDL_hints.h"
|
||||
#include "SDL_events.h"
|
||||
#include "SDL_log.h"
|
||||
#include "SDL_androidtouch.h"
|
||||
#include "../../events/SDL_mouse_c.h"
|
||||
#include "../../events/SDL_touch_c.h"
|
||||
|
@@ -70,12 +70,6 @@ SDL_sem *Android_PauseSem = NULL;
|
||||
SDL_sem *Android_ResumeSem = NULL;
|
||||
SDL_mutex *Android_ActivityMutex = NULL;
|
||||
|
||||
static int
|
||||
Android_Available(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
Android_SuspendScreenSaver(_THIS)
|
||||
{
|
||||
@@ -173,7 +167,7 @@ Android_CreateDevice(int devindex)
|
||||
|
||||
VideoBootStrap Android_bootstrap = {
|
||||
ANDROID_VID_DRIVER_NAME, "SDL Android video driver",
|
||||
Android_Available, Android_CreateDevice
|
||||
Android_CreateDevice
|
||||
};
|
||||
|
||||
|
||||
@@ -187,6 +181,7 @@ Android_VideoInit(_THIS)
|
||||
|
||||
videodata->isPaused = SDL_FALSE;
|
||||
videodata->isPausing = SDL_FALSE;
|
||||
videodata->pauseAudio = SDL_GetHintBoolean(SDL_HINT_ANDROID_BLOCK_ON_PAUSE_PAUSEAUDIO, SDL_TRUE);
|
||||
|
||||
mode.format = Android_ScreenFormat;
|
||||
mode.w = Android_DeviceWidth;
|
||||
|
@@ -38,6 +38,7 @@ typedef struct SDL_VideoData
|
||||
SDL_Rect textRect;
|
||||
int isPaused;
|
||||
int isPausing;
|
||||
int pauseAudio;
|
||||
} SDL_VideoData;
|
||||
|
||||
extern int Android_SurfaceWidth;
|
||||
|
@@ -30,7 +30,6 @@
|
||||
|
||||
#include "SDL_androidvideo.h"
|
||||
#include "SDL_androidwindow.h"
|
||||
#include "SDL_assert.h"
|
||||
|
||||
#include "SDL_loadso.h"
|
||||
#include "SDL_androidvulkan.h"
|
||||
|
35
externals/SDL/src/video/cocoa/SDL_cocoaevents.m
vendored
35
externals/SDL/src/video/cocoa/SDL_cocoaevents.m
vendored
@@ -26,13 +26,15 @@
|
||||
|
||||
#include "SDL_cocoavideo.h"
|
||||
#include "../../events/SDL_events_c.h"
|
||||
#include "SDL_assert.h"
|
||||
#include "SDL_hints.h"
|
||||
|
||||
/* This define was added in the 10.9 SDK. */
|
||||
#ifndef kIOPMAssertPreventUserIdleDisplaySleep
|
||||
#define kIOPMAssertPreventUserIdleDisplaySleep kIOPMAssertionTypePreventUserIdleDisplaySleep
|
||||
#endif
|
||||
#ifndef NSAppKitVersionNumber10_8
|
||||
#define NSAppKitVersionNumber10_8 1187
|
||||
#endif
|
||||
|
||||
@interface SDLApplication : NSApplication
|
||||
|
||||
@@ -117,6 +119,7 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent)
|
||||
}
|
||||
|
||||
- (id)init;
|
||||
- (void)localeDidChange:(NSNotification *)notification;
|
||||
@end
|
||||
|
||||
@implementation SDLAppDelegate : NSObject
|
||||
@@ -137,6 +140,11 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent)
|
||||
selector:@selector(focusSomeWindow:)
|
||||
name:NSApplicationDidBecomeActiveNotification
|
||||
object:nil];
|
||||
|
||||
[center addObserver:self
|
||||
selector:@selector(localeDidChange:)
|
||||
name:NSCurrentLocaleDidChangeNotification
|
||||
object:nil];
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -148,6 +156,7 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent)
|
||||
|
||||
[center removeObserver:self name:NSWindowWillCloseNotification object:nil];
|
||||
[center removeObserver:self name:NSApplicationDidBecomeActiveNotification object:nil];
|
||||
[center removeObserver:self name:NSCurrentLocaleDidChangeNotification object:nil];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
@@ -226,6 +235,11 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent)
|
||||
}
|
||||
}
|
||||
|
||||
- (void)localeDidChange:(NSNotification *)notification;
|
||||
{
|
||||
SDL_SendLocaleChangedEvent();
|
||||
}
|
||||
|
||||
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
|
||||
{
|
||||
return (BOOL)SDL_SendDropFile(NULL, [filename UTF8String]) && SDL_SendDropComplete(NULL);
|
||||
@@ -248,10 +262,24 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent)
|
||||
[NSApp activateIgnoringOtherApps:YES];
|
||||
}
|
||||
|
||||
[[NSAppleEventManager sharedAppleEventManager]
|
||||
setEventHandler:self
|
||||
andSelector:@selector(handleURLEvent:withReplyEvent:)
|
||||
forEventClass:kInternetEventClass
|
||||
andEventID:kAEGetURL];
|
||||
|
||||
/* If we call this before NSApp activation, macOS might print a complaint
|
||||
* about ApplePersistenceIgnoreState. */
|
||||
[SDLApplication registerUserDefaults];
|
||||
}
|
||||
|
||||
- (void)handleURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent
|
||||
{
|
||||
NSString* path = [[event paramDescriptorForKeyword:keyDirectObject] stringValue];
|
||||
SDL_SendDropFile(NULL, [path UTF8String]);
|
||||
SDL_SendDropComplete(NULL);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
static SDLAppDelegate *appDelegate = nil;
|
||||
@@ -280,7 +308,10 @@ LoadMainMenuNibIfAvailable(void)
|
||||
NSDictionary *infoDict;
|
||||
NSString *mainNibFileName;
|
||||
bool success = false;
|
||||
|
||||
|
||||
if (floor(NSAppKitVersionNumber) < NSAppKitVersionNumber10_8) {
|
||||
return false;
|
||||
}
|
||||
infoDict = [[NSBundle mainBundle] infoDictionary];
|
||||
if (infoDict) {
|
||||
mainNibFileName = [infoDict valueForKey:@"NSMainNibFile"];
|
||||
|
@@ -113,7 +113,7 @@ Cocoa_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
||||
int i;
|
||||
for (i = 0; i < messageboxdata->numbuttons; ++i) {
|
||||
const SDL_MessageBoxButtonData *sdlButton;
|
||||
NSButton *button;
|
||||
NSButton *button;
|
||||
|
||||
if (messageboxdata->flags & SDL_MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT) {
|
||||
sdlButton = &messageboxdata->buttons[messageboxdata->numbuttons - 1 - i];
|
||||
@@ -142,8 +142,8 @@ Cocoa_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
||||
if (clicked >= NSAlertFirstButtonReturn) {
|
||||
clicked -= NSAlertFirstButtonReturn;
|
||||
if (messageboxdata->flags & SDL_MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT) {
|
||||
clicked = messageboxdata->numbuttons - 1 - clicked;
|
||||
}
|
||||
clicked = messageboxdata->numbuttons - 1 - clicked;
|
||||
}
|
||||
*buttonid = buttons[clicked].buttonid;
|
||||
} else {
|
||||
returnValue = SDL_SetError("Did not get a valid `clicked button' id: %ld", (long)clicked);
|
||||
|
@@ -48,6 +48,7 @@
|
||||
windowID:(Uint32)windowID;
|
||||
|
||||
- (void)updateDrawableSize;
|
||||
- (NSView *)hitTest:(NSPoint)point;
|
||||
|
||||
/* Override superclass tag so this class can set it. */
|
||||
@property (assign, readonly) NSInteger tag;
|
||||
@@ -59,8 +60,8 @@
|
||||
|
||||
SDL_MetalView Cocoa_Metal_CreateView(_THIS, SDL_Window * window);
|
||||
void Cocoa_Metal_DestroyView(_THIS, SDL_MetalView view);
|
||||
|
||||
void Cocoa_Metal_GetDrawableSize(SDL_Window * window, int * w, int * h);
|
||||
void *Cocoa_Metal_GetLayer(_THIS, SDL_MetalView view);
|
||||
void Cocoa_Metal_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h);
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_COCOA && (SDL_VIDEO_VULKAN || SDL_VIDEO_METAL) */
|
||||
|
||||
|
@@ -24,12 +24,12 @@
|
||||
* Thanks to Alex Szpakowski, @slime73 on GitHub, for his gist showing
|
||||
* how to add a CAMetalLayer backed view.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#import "SDL_cocoametalview.h"
|
||||
|
||||
#if SDL_VIDEO_DRIVER_COCOA && (SDL_VIDEO_VULKAN || SDL_VIDEO_METAL)
|
||||
|
||||
#include "SDL_assert.h"
|
||||
#include "SDL_events.h"
|
||||
|
||||
static int SDLCALL
|
||||
@@ -123,6 +123,10 @@ SDL_MetalViewEventWatch(void *userdata, SDL_Event *event)
|
||||
metalLayer.drawableSize = NSSizeToCGSize(backingSize);
|
||||
}
|
||||
|
||||
- (NSView *)hitTest:(NSPoint)point {
|
||||
return nil;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
SDL_MetalView
|
||||
@@ -157,8 +161,15 @@ Cocoa_Metal_DestroyView(_THIS, SDL_MetalView view)
|
||||
[metalview removeFromSuperview];
|
||||
}}
|
||||
|
||||
void *
|
||||
Cocoa_Metal_GetLayer(_THIS, SDL_MetalView view)
|
||||
{ @autoreleasepool {
|
||||
SDL_cocoametalview *cocoaview = (__bridge SDL_cocoametalview *)view;
|
||||
return (__bridge void *)cocoaview.layer;
|
||||
}}
|
||||
|
||||
void
|
||||
Cocoa_Metal_GetDrawableSize(SDL_Window * window, int * w, int * h)
|
||||
Cocoa_Metal_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h)
|
||||
{ @autoreleasepool {
|
||||
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
|
||||
NSView *view = data->nswindow.contentView;
|
||||
|
@@ -19,7 +19,6 @@
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
#include "SDL_assert.h"
|
||||
|
||||
#if SDL_VIDEO_DRIVER_COCOA
|
||||
|
||||
@@ -198,8 +197,9 @@ GetDisplayMode(_THIS, CGDisplayModeRef vidmode, CFArrayRef modelist, CVDisplayLi
|
||||
int pixelH = (int) CGDisplayModeGetPixelHeight(vidmode);
|
||||
|
||||
CFIndex modescount = CFArrayGetCount(modelist);
|
||||
int i;
|
||||
|
||||
for (int i = 0; i < modescount; i++) {
|
||||
for (i = 0; i < modescount; i++) {
|
||||
CGDisplayModeRef othermode = (CGDisplayModeRef) CFArrayGetValueAtIndex(modelist, i);
|
||||
uint32_t otherioflags = CGDisplayModeGetIOFlags(othermode);
|
||||
|
||||
@@ -389,7 +389,7 @@ Cocoa_InitModes(_THIS)
|
||||
display.desktop_mode = mode;
|
||||
display.current_mode = mode;
|
||||
display.driverdata = displaydata;
|
||||
SDL_AddVideoDisplay(&display);
|
||||
SDL_AddVideoDisplay(&display, SDL_FALSE);
|
||||
SDL_free(display.name);
|
||||
}
|
||||
}
|
||||
|
@@ -22,7 +22,6 @@
|
||||
|
||||
#if SDL_VIDEO_DRIVER_COCOA
|
||||
|
||||
#include "SDL_assert.h"
|
||||
#include "SDL_events.h"
|
||||
#include "SDL_cocoamouse.h"
|
||||
#include "SDL_cocoamousetap.h"
|
||||
|
@@ -49,6 +49,8 @@ struct SDL_GLDriverData
|
||||
- (void)scheduleUpdate;
|
||||
- (void)updateIfNeeded;
|
||||
- (void)setWindow:(SDL_Window *)window;
|
||||
- (SDL_Window*)window;
|
||||
- (void)explicitUpdate;
|
||||
|
||||
@end
|
||||
|
||||
|
47
externals/SDL/src/video/cocoa/SDL_cocoaopengl.m
vendored
47
externals/SDL/src/video/cocoa/SDL_cocoaopengl.m
vendored
@@ -63,10 +63,10 @@
|
||||
/* This should only be called on the thread on which a user is using the context. */
|
||||
- (void)updateIfNeeded
|
||||
{
|
||||
int value = SDL_AtomicSet(&self->dirty, 0);
|
||||
const int value = SDL_AtomicSet(&self->dirty, 0);
|
||||
if (value > 0) {
|
||||
/* We call the real underlying update here, since -[SDLOpenGLContext update] just calls us. */
|
||||
[super update];
|
||||
[self explicitUpdate];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,17 +97,6 @@
|
||||
SDL_WindowData *windowdata = (SDL_WindowData *)newWindow->driverdata;
|
||||
NSView *contentview = windowdata->sdlContentView;
|
||||
|
||||
/* This should never be nil since sdlContentView is only nil if the
|
||||
window was created via SDL_CreateWindowFrom, and SDL doesn't allow
|
||||
OpenGL contexts to be created in that case. However, it doesn't hurt
|
||||
to check. */
|
||||
if (contentview == nil) {
|
||||
/* Prefer to access the cached content view above instead of this,
|
||||
since as of Xcode 11 + SDK 10.15, [window contentView] causes
|
||||
Apple's Main Thread Checker to output a warning. */
|
||||
contentview = [windowdata->nswindow contentView];
|
||||
}
|
||||
|
||||
/* Now sign up for scheduled updates for the new window. */
|
||||
NSMutableArray *contexts = windowdata->nscontexts;
|
||||
@synchronized (contexts) {
|
||||
@@ -115,9 +104,13 @@
|
||||
}
|
||||
|
||||
if ([self view] != contentview) {
|
||||
[self setView:contentview];
|
||||
if ([NSThread isMainThread]) {
|
||||
[self setView:contentview];
|
||||
} else {
|
||||
dispatch_sync(dispatch_get_main_queue(), ^{ [self setView:contentview]; });
|
||||
}
|
||||
if (self == [NSOpenGLContext currentContext]) {
|
||||
[self update];
|
||||
[self explicitUpdate];
|
||||
} else {
|
||||
[self scheduleUpdate];
|
||||
}
|
||||
@@ -125,13 +118,27 @@
|
||||
} else {
|
||||
[self clearDrawable];
|
||||
if (self == [NSOpenGLContext currentContext]) {
|
||||
[self update];
|
||||
[self explicitUpdate];
|
||||
} else {
|
||||
[self scheduleUpdate];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (SDL_Window*)window
|
||||
{
|
||||
return self->window;
|
||||
}
|
||||
|
||||
- (void)explicitUpdate
|
||||
{
|
||||
if ([NSThread isMainThread]) {
|
||||
[super update];
|
||||
} else {
|
||||
dispatch_sync(dispatch_get_main_queue(), ^{ [super update]; });
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -348,8 +355,10 @@ Cocoa_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
|
||||
{
|
||||
if (context) {
|
||||
SDLOpenGLContext *nscontext = (SDLOpenGLContext *)context;
|
||||
[nscontext setWindow:window];
|
||||
[nscontext updateIfNeeded];
|
||||
if ([nscontext window] != window) {
|
||||
[nscontext setWindow:window];
|
||||
[nscontext updateIfNeeded];
|
||||
}
|
||||
[nscontext makeCurrentContext];
|
||||
} else {
|
||||
[NSOpenGLContext clearCurrentContext];
|
||||
@@ -362,7 +371,7 @@ void
|
||||
Cocoa_GL_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h)
|
||||
{
|
||||
SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
|
||||
NSView *contentView = [windata->nswindow contentView];
|
||||
NSView *contentView = windata->sdlContentView;
|
||||
NSRect viewport = [contentView bounds];
|
||||
|
||||
if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) {
|
||||
|
@@ -25,7 +25,6 @@
|
||||
#include "SDL_cocoavideo.h"
|
||||
#include "SDL_cocoaopengles.h"
|
||||
#include "SDL_cocoaopengl.h"
|
||||
#include "SDL_log.h"
|
||||
|
||||
/* EGL implementation of SDL OpenGL support */
|
||||
|
||||
@@ -110,10 +109,12 @@ Cocoa_GLES_SetupWindow(_THIS, SDL_Window * window)
|
||||
|
||||
|
||||
if (_this->egl_data == NULL) {
|
||||
SDL_assert(!_this->gl_config.driver_loaded);
|
||||
if (SDL_EGL_LoadLibrary(_this, NULL, EGL_DEFAULT_DISPLAY, 0) < 0) {
|
||||
SDL_EGL_UnloadLibrary(_this);
|
||||
return -1;
|
||||
}
|
||||
_this->gl_config.driver_loaded = 1;
|
||||
}
|
||||
|
||||
/* Create the GLES window surface */
|
||||
|
10
externals/SDL/src/video/cocoa/SDL_cocoashape.m
vendored
10
externals/SDL/src/video/cocoa/SDL_cocoashape.m
vendored
@@ -18,7 +18,6 @@
|
||||
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_COCOA
|
||||
@@ -27,7 +26,6 @@
|
||||
#include "SDL_shape.h"
|
||||
#include "SDL_cocoashape.h"
|
||||
#include "../SDL_sysvideo.h"
|
||||
#include "SDL_assert.h"
|
||||
|
||||
SDL_WindowShaper*
|
||||
Cocoa_CreateShaper(SDL_Window* window)
|
||||
@@ -37,14 +35,14 @@ Cocoa_CreateShaper(SDL_Window* window)
|
||||
|
||||
[windata->nswindow setStyleMask:NSWindowStyleMaskBorderless];
|
||||
|
||||
SDL_WindowShaper* result = result = malloc(sizeof(SDL_WindowShaper));
|
||||
SDL_WindowShaper* result = (SDL_WindowShaper *)SDL_malloc(sizeof(SDL_WindowShaper));
|
||||
result->window = window;
|
||||
result->mode.mode = ShapeModeDefault;
|
||||
result->mode.parameters.binarizationCutoff = 1;
|
||||
result->userx = result->usery = 0;
|
||||
window->shaper = result;
|
||||
|
||||
SDL_ShapeData* data = malloc(sizeof(SDL_ShapeData));
|
||||
SDL_ShapeData* data = (SDL_ShapeData *)SDL_malloc(sizeof(SDL_ShapeData));
|
||||
result->driverdata = data;
|
||||
data->context = [windata->nswindow graphicsContext];
|
||||
data->saved = SDL_FALSE;
|
||||
@@ -88,10 +86,10 @@ Cocoa_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowSha
|
||||
[NSGraphicsContext setCurrentContext:data->context];
|
||||
|
||||
[[NSColor clearColor] set];
|
||||
NSRectFill([[windata->nswindow contentView] frame]);
|
||||
NSRectFill([windata->sdlContentView frame]);
|
||||
data->shape = SDL_CalculateShapeTree(*shape_mode,shape);
|
||||
|
||||
closure.view = [windata->nswindow contentView];
|
||||
closure.view = windata->sdlContentView;
|
||||
closure.path = [NSBezierPath bezierPath];
|
||||
closure.window = shaper->window;
|
||||
SDL_TraverseShapeTree(data->shape,&ConvertRects,&closure);
|
||||
|
11
externals/SDL/src/video/cocoa/SDL_cocoavideo.m
vendored
11
externals/SDL/src/video/cocoa/SDL_cocoavideo.m
vendored
@@ -28,7 +28,6 @@
|
||||
#include "SDL_cocoashape.h"
|
||||
#include "SDL_cocoavulkan.h"
|
||||
#include "SDL_cocoametalview.h"
|
||||
#include "SDL_assert.h"
|
||||
|
||||
/* Initialization/Query functions */
|
||||
static int Cocoa_VideoInit(_THIS);
|
||||
@@ -36,12 +35,6 @@ static void Cocoa_VideoQuit(_THIS);
|
||||
|
||||
/* Cocoa driver bootstrap functions */
|
||||
|
||||
static int
|
||||
Cocoa_Available(void)
|
||||
{
|
||||
return (1);
|
||||
}
|
||||
|
||||
static void
|
||||
Cocoa_DeleteDevice(SDL_VideoDevice * device)
|
||||
{
|
||||
@@ -146,6 +139,8 @@ Cocoa_CreateDevice(int devindex)
|
||||
#if SDL_VIDEO_METAL
|
||||
device->Metal_CreateView = Cocoa_Metal_CreateView;
|
||||
device->Metal_DestroyView = Cocoa_Metal_DestroyView;
|
||||
device->Metal_GetLayer = Cocoa_Metal_GetLayer;
|
||||
device->Metal_GetDrawableSize = Cocoa_Metal_GetDrawableSize;
|
||||
#endif
|
||||
|
||||
device->StartTextInput = Cocoa_StartTextInput;
|
||||
@@ -163,7 +158,7 @@ Cocoa_CreateDevice(int devindex)
|
||||
|
||||
VideoBootStrap COCOA_bootstrap = {
|
||||
"cocoa", "SDL Cocoa video driver",
|
||||
Cocoa_Available, Cocoa_CreateDevice
|
||||
Cocoa_CreateDevice
|
||||
};
|
||||
|
||||
|
||||
|
@@ -29,7 +29,6 @@
|
||||
|
||||
#include "SDL_cocoavideo.h"
|
||||
#include "SDL_cocoawindow.h"
|
||||
#include "SDL_assert.h"
|
||||
|
||||
#include "SDL_loadso.h"
|
||||
#include "SDL_cocoametalview.h"
|
||||
@@ -236,7 +235,7 @@ SDL_bool Cocoa_Vulkan_CreateSurface(_THIS,
|
||||
|
||||
void Cocoa_Vulkan_GetDrawableSize(_THIS, SDL_Window *window, int *w, int *h)
|
||||
{
|
||||
Cocoa_Metal_GetDrawableSize(window, w, h);
|
||||
Cocoa_Metal_GetDrawableSize(_this, window, w, h);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -113,7 +113,7 @@ struct SDL_WindowData
|
||||
{
|
||||
SDL_Window *window;
|
||||
NSWindow *nswindow;
|
||||
NSView *sdlContentView; /* nil if window is created via CreateWindowFrom */
|
||||
NSView *sdlContentView;
|
||||
NSMutableArray *nscontexts;
|
||||
SDL_bool created;
|
||||
SDL_bool inWindowFullscreenTransition;
|
||||
|
74
externals/SDL/src/video/cocoa/SDL_cocoawindow.m
vendored
74
externals/SDL/src/video/cocoa/SDL_cocoawindow.m
vendored
@@ -41,7 +41,6 @@
|
||||
#include "SDL_cocoamousetap.h"
|
||||
#include "SDL_cocoaopengl.h"
|
||||
#include "SDL_cocoaopengles.h"
|
||||
#include "SDL_assert.h"
|
||||
|
||||
/* #define DEBUG_COCOAWINDOW */
|
||||
|
||||
@@ -57,6 +56,9 @@
|
||||
#ifndef MAC_OS_X_VERSION_10_12
|
||||
#define NSEventModifierFlagCapsLock NSAlphaShiftKeyMask
|
||||
#endif
|
||||
#ifndef NSAppKitVersionNumber10_14
|
||||
#define NSAppKitVersionNumber10_14 1671
|
||||
#endif
|
||||
|
||||
@interface SDLWindow : NSWindow <NSDraggingDestination>
|
||||
/* These are needed for borderless/fullscreen windows */
|
||||
@@ -297,15 +299,15 @@ SetWindowStyle(SDL_Window * window, NSUInteger style)
|
||||
NSWindow *nswindow = data->nswindow;
|
||||
|
||||
/* The view responder chain gets messed with during setStyleMask */
|
||||
if ([[nswindow contentView] nextResponder] == data->listener) {
|
||||
[[nswindow contentView] setNextResponder:nil];
|
||||
if ([data->sdlContentView nextResponder] == data->listener) {
|
||||
[data->sdlContentView setNextResponder:nil];
|
||||
}
|
||||
|
||||
[nswindow setStyleMask:style];
|
||||
|
||||
/* The view responder chain gets messed with during setStyleMask */
|
||||
if ([[nswindow contentView] nextResponder] != data->listener) {
|
||||
[[nswindow contentView] setNextResponder:data->listener];
|
||||
if ([data->sdlContentView nextResponder] != data->listener) {
|
||||
[data->sdlContentView setNextResponder:data->listener];
|
||||
}
|
||||
|
||||
return SDL_TRUE;
|
||||
@@ -318,7 +320,7 @@ SetWindowStyle(SDL_Window * window, NSUInteger style)
|
||||
{
|
||||
NSNotificationCenter *center;
|
||||
NSWindow *window = data->nswindow;
|
||||
NSView *view = [window contentView];
|
||||
NSView *view = data->sdlContentView;
|
||||
|
||||
_data = data;
|
||||
observingVisible = YES;
|
||||
@@ -912,11 +914,9 @@ SetWindowStyle(SDL_Window * window, NSUInteger style)
|
||||
keypresses; it won't toggle the mod state if you send a keyrelease. */
|
||||
const SDL_bool osenabled = ([theEvent modifierFlags] & NSEventModifierFlagCapsLock) ? SDL_TRUE : SDL_FALSE;
|
||||
const SDL_bool sdlenabled = (SDL_GetModState() & KMOD_CAPS) ? SDL_TRUE : SDL_FALSE;
|
||||
if (!osenabled && sdlenabled) {
|
||||
SDL_ToggleModState(KMOD_CAPS, SDL_FALSE);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_CAPSLOCK);
|
||||
} else if (osenabled && !sdlenabled) {
|
||||
if (osenabled ^ sdlenabled) {
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_CAPSLOCK);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_CAPSLOCK);
|
||||
}
|
||||
}
|
||||
- (void)keyDown:(NSEvent *)theEvent
|
||||
@@ -1360,7 +1360,7 @@ SetWindowStyle(SDL_Window * window, NSUInteger style)
|
||||
@end
|
||||
|
||||
static int
|
||||
SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created)
|
||||
SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, NSView *nsview, SDL_bool created)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
|
||||
@@ -1376,11 +1376,7 @@ SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created
|
||||
data->created = created;
|
||||
data->videodata = videodata;
|
||||
data->nscontexts = [[NSMutableArray alloc] init];
|
||||
|
||||
/* Only store this for windows created by us since the content view might
|
||||
* get replaced from under us otherwise, and we only need it when the
|
||||
* window is guaranteed to be created by us (OpenGL contexts). */
|
||||
data->sdlContentView = created ? [nswindow contentView] : nil;
|
||||
data->sdlContentView = nsview;
|
||||
|
||||
/* Create an event listener for the window */
|
||||
data->listener = [[Cocoa_WindowListener alloc] init];
|
||||
@@ -1541,7 +1537,7 @@ Cocoa_CreateWindow(_THIS, SDL_Window * window)
|
||||
[nswindow setContentView:contentView];
|
||||
[contentView release];
|
||||
|
||||
if (SetupWindowData(_this, window, nswindow, SDL_TRUE) < 0) {
|
||||
if (SetupWindowData(_this, window, nswindow, contentView, SDL_TRUE) < 0) {
|
||||
[nswindow release];
|
||||
return -1;
|
||||
}
|
||||
@@ -1571,7 +1567,19 @@ int
|
||||
Cocoa_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
NSWindow *nswindow = (NSWindow *) data;
|
||||
NSView* nsview = nil;
|
||||
NSWindow *nswindow = nil;
|
||||
|
||||
if ([(id)data isKindOfClass:[NSWindow class]]) {
|
||||
nswindow = (NSWindow*)data;
|
||||
nsview = [nswindow contentView];
|
||||
} else if ([(id)data isKindOfClass:[NSView class]]) {
|
||||
nsview = (NSView*)data;
|
||||
nswindow = [nsview window];
|
||||
} else {
|
||||
SDL_assert(false);
|
||||
}
|
||||
|
||||
NSString *title;
|
||||
|
||||
/* Query the title from the existing window */
|
||||
@@ -1580,7 +1588,22 @@ Cocoa_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
|
||||
window->title = SDL_strdup([title UTF8String]);
|
||||
}
|
||||
|
||||
return SetupWindowData(_this, window, nswindow, SDL_FALSE);
|
||||
/* We still support OpenGL as long as Apple offers it, deprecated or not, so disable deprecation warnings about it. */
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
/* Note: as of the macOS 10.15 SDK, this defaults to YES instead of NO when
|
||||
* the NSHighResolutionCapable boolean is set in Info.plist. */
|
||||
if ([nsview respondsToSelector:@selector(setWantsBestResolutionOpenGLSurface:)]) {
|
||||
BOOL highdpi = (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) != 0;
|
||||
[nsview setWantsBestResolutionOpenGLSurface:highdpi];
|
||||
}
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
return SetupWindowData(_this, window, nswindow, nsview, SDL_FALSE);
|
||||
}}
|
||||
|
||||
void
|
||||
@@ -1795,8 +1818,8 @@ Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display
|
||||
NSRect rect;
|
||||
|
||||
/* The view responder chain gets messed with during setStyleMask */
|
||||
if ([[nswindow contentView] nextResponder] == data->listener) {
|
||||
[[nswindow contentView] setNextResponder:nil];
|
||||
if ([data->sdlContentView nextResponder] == data->listener) {
|
||||
[data->sdlContentView setNextResponder:nil];
|
||||
}
|
||||
|
||||
if (fullscreen) {
|
||||
@@ -1812,10 +1835,7 @@ Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display
|
||||
/* Hack to fix origin on Mac OS X 10.4
|
||||
This is no longer needed as of Mac OS X 10.15, according to bug 4822.
|
||||
*/
|
||||
NSProcessInfo *processInfo = [NSProcessInfo processInfo];
|
||||
NSOperatingSystemVersion version = { 10, 15, 0 };
|
||||
if (![processInfo respondsToSelector:@selector(isOperatingSystemAtLeastVersion:)] ||
|
||||
![processInfo isOperatingSystemAtLeastVersion:version]) {
|
||||
if (floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_14) {
|
||||
NSRect screenRect = [[nswindow screen] frame];
|
||||
if (screenRect.size.height >= 1.0f) {
|
||||
rect.origin.y += (screenRect.size.height - rect.size.height);
|
||||
@@ -1845,8 +1865,8 @@ Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display
|
||||
}
|
||||
|
||||
/* The view responder chain gets messed with during setStyleMask */
|
||||
if ([[nswindow contentView] nextResponder] != data->listener) {
|
||||
[[nswindow contentView] setNextResponder:data->listener];
|
||||
if ([data->sdlContentView nextResponder] != data->listener) {
|
||||
[data->sdlContentView setNextResponder:data->listener];
|
||||
}
|
||||
|
||||
s_moveHack = 0;
|
||||
|
@@ -258,7 +258,7 @@ DirectFB_InitModes(_THIS)
|
||||
|
||||
SDL_DFB_CHECKERR(layer->SetCooperativeLevel(layer, DLSCL_SHARED));
|
||||
|
||||
SDL_AddVideoDisplay(&display);
|
||||
SDL_AddVideoDisplay(&display, SDL_FALSE);
|
||||
}
|
||||
SDL_DFB_FREE(screencbdata);
|
||||
return;
|
||||
|
@@ -22,7 +22,6 @@
|
||||
|
||||
#if SDL_VIDEO_DRIVER_DIRECTFB
|
||||
|
||||
#include "SDL_assert.h"
|
||||
|
||||
#include "SDL_DirectFB_video.h"
|
||||
#include "SDL_DirectFB_mouse.h"
|
||||
|
@@ -198,11 +198,10 @@ SetBlendMode(DirectFB_RenderData * data, int blendMode,
|
||||
SDL_DFB_CHECK(destsurf->SetDstBlendFunction(destsurf, DSBF_SRCCOLOR));
|
||||
|
||||
break;
|
||||
}
|
||||
case SDL_BLENDMODE_MUL:
|
||||
data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL;
|
||||
data->drawFlags = DSDRAW_BLEND;
|
||||
SDL_DFB_CHECK(destsurf->SetSrcBlendFunction(destsurf, DSBF_DSTCOLOR));
|
||||
SDL_DFB_CHECK(destsurf->SetSrcBlendFunction(destsurf, DSBF_DESTCOLOR));
|
||||
SDL_DFB_CHECK(destsurf->SetDstBlendFunction(destsurf, DSBF_INVSRCALPHA));
|
||||
|
||||
break;
|
||||
@@ -627,7 +626,7 @@ DirectFB_QueueFillRects(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const S
|
||||
}
|
||||
|
||||
cmd->data.draw.count = count;
|
||||
SDL_memcpy(verts, rects, count);
|
||||
SDL_memcpy(verts, rects, len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -22,7 +22,6 @@
|
||||
|
||||
#if SDL_VIDEO_DRIVER_DIRECTFB
|
||||
|
||||
#include "SDL_assert.h"
|
||||
#include "SDL_DirectFB_video.h"
|
||||
#include "SDL_DirectFB_shape.h"
|
||||
#include "SDL_DirectFB_window.h"
|
||||
|
@@ -27,6 +27,7 @@
|
||||
*/
|
||||
#include "SDL_DirectFB_modes.h"
|
||||
#include "SDL_DirectFB_opengl.h"
|
||||
#include "SDL_DirectFB_vulkan.h"
|
||||
#include "SDL_DirectFB_window.h"
|
||||
#include "SDL_DirectFB_WM.h"
|
||||
|
||||
@@ -60,12 +61,11 @@
|
||||
static int DirectFB_VideoInit(_THIS);
|
||||
static void DirectFB_VideoQuit(_THIS);
|
||||
|
||||
static int DirectFB_Available(void);
|
||||
static SDL_VideoDevice *DirectFB_CreateDevice(int devindex);
|
||||
|
||||
VideoBootStrap DirectFB_bootstrap = {
|
||||
"directfb", "DirectFB",
|
||||
DirectFB_Available, DirectFB_CreateDevice
|
||||
DirectFB_CreateDevice
|
||||
};
|
||||
|
||||
static const DirectFBSurfaceDrawingFlagsNames(drawing_flags);
|
||||
@@ -74,15 +74,6 @@ static const DirectFBAccelerationMaskNames(acceleration_mask);
|
||||
|
||||
/* DirectFB driver bootstrap functions */
|
||||
|
||||
static int
|
||||
DirectFB_Available(void)
|
||||
{
|
||||
if (!SDL_DirectFB_LoadLibrary())
|
||||
return 0;
|
||||
SDL_DirectFB_UnLoadLibrary();
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
DirectFB_DeleteDevice(SDL_VideoDevice * device)
|
||||
{
|
||||
@@ -146,6 +137,13 @@ DirectFB_CreateDevice(int devindex)
|
||||
device->shape_driver.SetWindowShape = DirectFB_SetWindowShape;
|
||||
device->shape_driver.ResizeWindowShape = DirectFB_ResizeWindowShape;
|
||||
|
||||
#if SDL_VIDEO_VULKAN
|
||||
device->Vulkan_LoadLibrary = DirectFB_Vulkan_LoadLibrary;
|
||||
device->Vulkan_UnloadLibrary = DirectFB_Vulkan_UnloadLibrary;
|
||||
device->Vulkan_GetInstanceExtensions = DirectFB_Vulkan_GetInstanceExtensions;
|
||||
device->Vulkan_CreateSurface = DirectFB_Vulkan_CreateSurface;
|
||||
#endif
|
||||
|
||||
device->free = DirectFB_DeleteDevice;
|
||||
|
||||
return device;
|
||||
@@ -324,7 +322,9 @@ static const struct {
|
||||
{ DSPF_YUY2, SDL_PIXELFORMAT_YUY2 }, /* 16 bit YUV (4 byte/ 2 pixel, macropixel contains CbYCrY [31:0]) */
|
||||
{ DSPF_UYVY, SDL_PIXELFORMAT_UYVY }, /* 16 bit YUV (4 byte/ 2 pixel, macropixel contains YCbYCr [31:0]) */
|
||||
{ DSPF_RGB555, SDL_PIXELFORMAT_RGB555 }, /* 16 bit RGB (2 byte, nothing @15, red 5@10, green 5@5, blue 5@0) */
|
||||
#if (DFB_VERSION_ATLEAST(1,5,0))
|
||||
{ DSPF_ABGR, SDL_PIXELFORMAT_ABGR8888 }, /* 32 bit ABGR (4 byte, alpha 8@24, blue 8@16, green 8@8, red 8@0) */
|
||||
#endif
|
||||
#if (ENABLE_LUT8)
|
||||
{ DSPF_LUT8, SDL_PIXELFORMAT_INDEX8 }, /* 8 bit LUT (8 bit color and alpha lookup from palette) */
|
||||
#endif
|
||||
|
@@ -31,7 +31,6 @@
|
||||
#include "SDL_scancode.h"
|
||||
#include "SDL_render.h"
|
||||
|
||||
#include "SDL_log.h"
|
||||
|
||||
#define DFB_VERSIONNUM(X, Y, Z) \
|
||||
((X)*1000 + (Y)*100 + (Z))
|
||||
|
169
externals/SDL/src/video/directfb/SDL_DirectFB_vulkan.c
vendored
Executable file
169
externals/SDL/src/video/directfb/SDL_DirectFB_vulkan.c
vendored
Executable file
@@ -0,0 +1,169 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 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 && SDL_VIDEO_DRIVER_DIRECTFB
|
||||
|
||||
#include "SDL_DirectFB_window.h"
|
||||
|
||||
#include "SDL_loadso.h"
|
||||
#include "SDL_DirectFB_vulkan.h"
|
||||
|
||||
int DirectFB_Vulkan_LoadLibrary(_THIS, const char *path)
|
||||
{
|
||||
VkExtensionProperties *extensions = NULL;
|
||||
Uint32 i, extensionCount = 0;
|
||||
SDL_bool hasSurfaceExtension = SDL_FALSE;
|
||||
SDL_bool hasDirectFBSurfaceExtension = SDL_FALSE;
|
||||
PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = NULL;
|
||||
if(_this->vulkan_config.loader_handle)
|
||||
return SDL_SetError("Vulkan already loaded");
|
||||
|
||||
/* Load the Vulkan loader library */
|
||||
if(!path)
|
||||
path = SDL_getenv("SDL_VULKAN_LIBRARY");
|
||||
if(!path)
|
||||
path = "libvulkan.so.1";
|
||||
_this->vulkan_config.loader_handle = SDL_LoadObject(path);
|
||||
if(!_this->vulkan_config.loader_handle)
|
||||
return -1;
|
||||
SDL_strlcpy(_this->vulkan_config.loader_path, path,
|
||||
SDL_arraysize(_this->vulkan_config.loader_path));
|
||||
vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)SDL_LoadFunction(
|
||||
_this->vulkan_config.loader_handle, "vkGetInstanceProcAddr");
|
||||
if(!vkGetInstanceProcAddr)
|
||||
goto fail;
|
||||
_this->vulkan_config.vkGetInstanceProcAddr = (void *)vkGetInstanceProcAddr;
|
||||
_this->vulkan_config.vkEnumerateInstanceExtensionProperties =
|
||||
(void *)((PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr)(
|
||||
VK_NULL_HANDLE, "vkEnumerateInstanceExtensionProperties");
|
||||
if(!_this->vulkan_config.vkEnumerateInstanceExtensionProperties)
|
||||
goto fail;
|
||||
extensions = SDL_Vulkan_CreateInstanceExtensionsList(
|
||||
(PFN_vkEnumerateInstanceExtensionProperties)
|
||||
_this->vulkan_config.vkEnumerateInstanceExtensionProperties,
|
||||
&extensionCount);
|
||||
if(!extensions)
|
||||
goto fail;
|
||||
for(i = 0; i < extensionCount; i++)
|
||||
{
|
||||
if(SDL_strcmp(VK_KHR_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0)
|
||||
hasSurfaceExtension = SDL_TRUE;
|
||||
else if(SDL_strcmp(VK_EXT_DIRECTFB_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0)
|
||||
hasDirectFBSurfaceExtension = SDL_TRUE;
|
||||
}
|
||||
SDL_free(extensions);
|
||||
if(!hasSurfaceExtension)
|
||||
{
|
||||
SDL_SetError("Installed Vulkan doesn't implement the "
|
||||
VK_KHR_SURFACE_EXTENSION_NAME " extension");
|
||||
goto fail;
|
||||
}
|
||||
else if(!hasDirectFBSurfaceExtension)
|
||||
{
|
||||
SDL_SetError("Installed Vulkan doesn't implement the "
|
||||
VK_EXT_DIRECTFB_SURFACE_EXTENSION_NAME "extension");
|
||||
goto fail;
|
||||
}
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
SDL_UnloadObject(_this->vulkan_config.loader_handle);
|
||||
_this->vulkan_config.loader_handle = NULL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
void DirectFB_Vulkan_UnloadLibrary(_THIS)
|
||||
{
|
||||
if(_this->vulkan_config.loader_handle)
|
||||
{
|
||||
SDL_UnloadObject(_this->vulkan_config.loader_handle);
|
||||
_this->vulkan_config.loader_handle = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
SDL_bool DirectFB_Vulkan_GetInstanceExtensions(_THIS,
|
||||
SDL_Window *window,
|
||||
unsigned *count,
|
||||
const char **names)
|
||||
{
|
||||
static const char *const extensionsForDirectFB[] = {
|
||||
VK_KHR_SURFACE_EXTENSION_NAME, VK_EXT_DIRECTFB_SURFACE_EXTENSION_NAME
|
||||
};
|
||||
if(!_this->vulkan_config.loader_handle)
|
||||
{
|
||||
SDL_SetError("Vulkan is not loaded");
|
||||
return SDL_FALSE;
|
||||
}
|
||||
return SDL_Vulkan_GetInstanceExtensions_Helper(
|
||||
count, names, SDL_arraysize(extensionsForDirectFB),
|
||||
extensionsForDirectFB);
|
||||
}
|
||||
|
||||
SDL_bool DirectFB_Vulkan_CreateSurface(_THIS,
|
||||
SDL_Window *window,
|
||||
VkInstance instance,
|
||||
VkSurfaceKHR *surface)
|
||||
{
|
||||
SDL_DFB_DEVICEDATA(_this);
|
||||
SDL_DFB_WINDOWDATA(window);
|
||||
PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr =
|
||||
(PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr;
|
||||
PFN_vkCreateDirectFBSurfaceEXT vkCreateDirectFBSurfaceEXT =
|
||||
(PFN_vkCreateDirectFBSurfaceEXT)vkGetInstanceProcAddr(
|
||||
instance,
|
||||
"vkCreateDirectFBSurfaceEXT");
|
||||
VkDirectFBSurfaceCreateInfoEXT createInfo;
|
||||
VkResult result;
|
||||
|
||||
if(!_this->vulkan_config.loader_handle)
|
||||
{
|
||||
SDL_SetError("Vulkan is not loaded");
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
if(!vkCreateDirectFBSurfaceEXT)
|
||||
{
|
||||
SDL_SetError(VK_EXT_DIRECTFB_SURFACE_EXTENSION_NAME
|
||||
" extension is not enabled in the Vulkan instance.");
|
||||
return SDL_FALSE;
|
||||
}
|
||||
SDL_zero(createInfo);
|
||||
createInfo.sType = VK_STRUCTURE_TYPE_DIRECTFB_SURFACE_CREATE_INFO_EXT;
|
||||
createInfo.pNext = NULL;
|
||||
createInfo.flags = 0;
|
||||
createInfo.dfb = devdata->dfb;
|
||||
createInfo.surface = windata->surface;
|
||||
result = vkCreateDirectFBSurfaceEXT(instance, &createInfo,
|
||||
NULL, surface);
|
||||
if(result != VK_SUCCESS)
|
||||
{
|
||||
SDL_SetError("vkCreateDirectFBSurfaceEXT failed: %s",
|
||||
SDL_Vulkan_GetResultString(result));
|
||||
return SDL_FALSE;
|
||||
}
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* vim: set ts=4 sw=4 expandtab: */
|
47
externals/SDL/src/video/directfb/SDL_DirectFB_vulkan.h
vendored
Executable file
47
externals/SDL/src/video/directfb/SDL_DirectFB_vulkan.h
vendored
Executable file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 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_DirectFB_vulkan_h_
|
||||
#define SDL_DirectFB_vulkan_h_
|
||||
|
||||
#include "../SDL_vulkan_internal.h"
|
||||
#include "../SDL_sysvideo.h"
|
||||
|
||||
#if SDL_VIDEO_VULKAN && SDL_VIDEO_DRIVER_DIRECTFB
|
||||
|
||||
int DirectFB_Vulkan_LoadLibrary(_THIS, const char *path);
|
||||
void DirectFB_Vulkan_UnloadLibrary(_THIS);
|
||||
SDL_bool DirectFB_Vulkan_GetInstanceExtensions(_THIS,
|
||||
SDL_Window *window,
|
||||
unsigned *count,
|
||||
const char **names);
|
||||
SDL_bool DirectFB_Vulkan_CreateSurface(_THIS,
|
||||
SDL_Window *window,
|
||||
VkInstance instance,
|
||||
VkSurfaceKHR *surface);
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* SDL_DirectFB_vulkan_h_ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
@@ -78,6 +78,10 @@ DUMMY_CreateDevice(int devindex)
|
||||
{
|
||||
SDL_VideoDevice *device;
|
||||
|
||||
if (!DUMMY_Available()) {
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Initialize all variables that we clean on shutdown */
|
||||
device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
|
||||
if (!device) {
|
||||
@@ -102,7 +106,7 @@ DUMMY_CreateDevice(int devindex)
|
||||
|
||||
VideoBootStrap DUMMY_bootstrap = {
|
||||
DUMMYVID_DRIVER_NAME, "SDL dummy video driver",
|
||||
DUMMY_Available, DUMMY_CreateDevice
|
||||
DUMMY_CreateDevice
|
||||
};
|
||||
|
||||
|
||||
|
@@ -55,7 +55,7 @@ static const SDL_Scancode emscripten_scancode_table[] = {
|
||||
/* 9 */ SDL_SCANCODE_TAB,
|
||||
/* 10 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 11 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 12 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 12 */ SDL_SCANCODE_KP_5,
|
||||
/* 13 */ SDL_SCANCODE_RETURN,
|
||||
/* 14 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 15 */ SDL_SCANCODE_UNKNOWN,
|
||||
@@ -103,10 +103,10 @@ static const SDL_Scancode emscripten_scancode_table[] = {
|
||||
/* 57 */ SDL_SCANCODE_9,
|
||||
/* 58 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 59 */ SDL_SCANCODE_SEMICOLON,
|
||||
/* 60 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 60 */ SDL_SCANCODE_NONUSBACKSLASH,
|
||||
/* 61 */ SDL_SCANCODE_EQUALS,
|
||||
/* 62 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 63 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 63 */ SDL_SCANCODE_MINUS,
|
||||
/* 64 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 65 */ SDL_SCANCODE_A,
|
||||
/* 66 */ SDL_SCANCODE_B,
|
||||
@@ -203,7 +203,7 @@ static const SDL_Scancode emscripten_scancode_table[] = {
|
||||
/* 157 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 158 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 159 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 160 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 160 */ SDL_SCANCODE_GRAVE,
|
||||
/* 161 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 162 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 163 */ SDL_SCANCODE_KP_HASH, /*KaiOS phone keypad*/
|
||||
@@ -214,7 +214,7 @@ static const SDL_Scancode emscripten_scancode_table[] = {
|
||||
/* 168 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 169 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 170 */ SDL_SCANCODE_KP_MULTIPLY, /*KaiOS phone keypad*/
|
||||
/* 171 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 171 */ SDL_SCANCODE_RIGHTBRACKET,
|
||||
/* 172 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 173 */ SDL_SCANCODE_MINUS, /*FX*/
|
||||
/* 174 */ SDL_SCANCODE_VOLUMEDOWN, /*IE, Chrome*/
|
||||
@@ -363,7 +363,7 @@ Emscripten_HandleMouseButton(int eventType, const EmscriptenMouseEvent *mouseEve
|
||||
|
||||
if (eventType == EMSCRIPTEN_EVENT_MOUSEDOWN) {
|
||||
if (SDL_GetMouse()->relative_mode && !window_data->has_pointer_lock) {
|
||||
emscripten_request_pointerlock(NULL, 0); /* try to regrab lost pointer lock. */
|
||||
emscripten_request_pointerlock(window_data->canvas_id, 0); /* try to regrab lost pointer lock. */
|
||||
}
|
||||
sdl_button_state = SDL_PRESSED;
|
||||
sdl_event_type = SDL_MOUSEBUTTONDOWN;
|
||||
@@ -485,6 +485,16 @@ Emscripten_HandleKey(int eventType, const EmscriptenKeyboardEvent *keyEvent, voi
|
||||
if (keyEvent->keyCode < SDL_arraysize(emscripten_scancode_table)) {
|
||||
scancode = emscripten_scancode_table[keyEvent->keyCode];
|
||||
|
||||
if (keyEvent->keyCode == 0) {
|
||||
/* KaiOS Left Soft Key and Right Soft Key, they act as OK/Next/Menu and Cancel/Back/Clear */
|
||||
if (SDL_strncmp(keyEvent->key, "SoftLeft", 9) == 0) {
|
||||
scancode = SDL_SCANCODE_AC_FORWARD;
|
||||
}
|
||||
if (SDL_strncmp(keyEvent->key, "SoftRight", 10) == 0) {
|
||||
scancode = SDL_SCANCODE_AC_BACK;
|
||||
}
|
||||
}
|
||||
|
||||
if (scancode != SDL_SCANCODE_UNKNOWN) {
|
||||
|
||||
if (keyEvent->location == DOM_KEY_LOCATION_RIGHT) {
|
||||
@@ -503,6 +513,55 @@ Emscripten_HandleKey(int eventType, const EmscriptenKeyboardEvent *keyEvent, voi
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (keyEvent->location == DOM_KEY_LOCATION_NUMPAD) {
|
||||
switch (scancode) {
|
||||
case SDL_SCANCODE_0:
|
||||
case SDL_SCANCODE_INSERT:
|
||||
scancode = SDL_SCANCODE_KP_0;
|
||||
break;
|
||||
case SDL_SCANCODE_1:
|
||||
case SDL_SCANCODE_END:
|
||||
scancode = SDL_SCANCODE_KP_1;
|
||||
break;
|
||||
case SDL_SCANCODE_2:
|
||||
case SDL_SCANCODE_DOWN:
|
||||
scancode = SDL_SCANCODE_KP_2;
|
||||
break;
|
||||
case SDL_SCANCODE_3:
|
||||
case SDL_SCANCODE_PAGEDOWN:
|
||||
scancode = SDL_SCANCODE_KP_3;
|
||||
break;
|
||||
case SDL_SCANCODE_4:
|
||||
case SDL_SCANCODE_LEFT:
|
||||
scancode = SDL_SCANCODE_KP_4;
|
||||
break;
|
||||
case SDL_SCANCODE_5:
|
||||
scancode = SDL_SCANCODE_KP_5;
|
||||
break;
|
||||
case SDL_SCANCODE_6:
|
||||
case SDL_SCANCODE_RIGHT:
|
||||
scancode = SDL_SCANCODE_KP_6;
|
||||
break;
|
||||
case SDL_SCANCODE_7:
|
||||
case SDL_SCANCODE_HOME:
|
||||
scancode = SDL_SCANCODE_KP_7;
|
||||
break;
|
||||
case SDL_SCANCODE_8:
|
||||
case SDL_SCANCODE_UP:
|
||||
scancode = SDL_SCANCODE_KP_8;
|
||||
break;
|
||||
case SDL_SCANCODE_9:
|
||||
case SDL_SCANCODE_PAGEUP:
|
||||
scancode = SDL_SCANCODE_KP_9;
|
||||
break;
|
||||
case SDL_SCANCODE_RETURN:
|
||||
scancode = SDL_SCANCODE_KP_ENTER;
|
||||
break;
|
||||
case SDL_SCANCODE_DELETE:
|
||||
scancode = SDL_SCANCODE_KP_PERIOD;
|
||||
break;
|
||||
}
|
||||
}
|
||||
SDL_SendKeyboardKey(eventType == EMSCRIPTEN_EVENT_KEYDOWN ? SDL_PRESSED : SDL_RELEASED, scancode);
|
||||
}
|
||||
}
|
||||
@@ -548,7 +607,7 @@ Emscripten_HandleFullscreenChange(int eventType, const EmscriptenFullscreenChang
|
||||
window_data->requested_fullscreen_mode = 0;
|
||||
|
||||
if(!window_data->requested_fullscreen_mode)
|
||||
window_data->window->flags |= SDL_WINDOW_FULLSCREEN; /*we didn't reqest fullscreen*/
|
||||
window_data->window->flags |= SDL_WINDOW_FULLSCREEN; /*we didn't request fullscreen*/
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -635,6 +694,16 @@ Emscripten_HandleVisibilityChange(int eventType, const EmscriptenVisibilityChang
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char*
|
||||
Emscripten_HandleBeforeUnload(int eventType, const void *reserved, void *userData)
|
||||
{
|
||||
/* This event will need to be handled synchronously, e.g. using
|
||||
SDL_AddEventWatch, as the page is being closed *now*. */
|
||||
/* No need to send a SDL_QUIT, the app won't get control again. */
|
||||
SDL_SendAppEvent(SDL_APP_TERMINATING);
|
||||
return ""; /* don't trigger confirmation dialog */
|
||||
}
|
||||
|
||||
void
|
||||
Emscripten_RegisterEventHandlers(SDL_WindowData *data)
|
||||
{
|
||||
@@ -674,6 +743,8 @@ Emscripten_RegisterEventHandlers(SDL_WindowData *data)
|
||||
emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, data, 0, Emscripten_HandleResize);
|
||||
|
||||
emscripten_set_visibilitychange_callback(data, 0, Emscripten_HandleVisibilityChange);
|
||||
|
||||
emscripten_set_beforeunload_callback(data, Emscripten_HandleBeforeUnload);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -716,6 +787,8 @@ Emscripten_UnregisterEventHandlers(SDL_WindowData *data)
|
||||
emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, 0, NULL);
|
||||
|
||||
emscripten_set_visibilitychange_callback(NULL, 0, NULL);
|
||||
|
||||
emscripten_set_beforeunload_callback(NULL, NULL);
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_EMSCRIPTEN */
|
||||
|
@@ -24,6 +24,7 @@
|
||||
|
||||
#include "SDL_emscriptenvideo.h"
|
||||
#include "SDL_emscriptenframebuffer.h"
|
||||
#include "SDL_hints.h"
|
||||
|
||||
|
||||
int Emscripten_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch)
|
||||
@@ -162,6 +163,12 @@ int Emscripten_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rec
|
||||
SDL_GetWindowID(window), ++frame_number);
|
||||
SDL_SaveBMP(surface, file);
|
||||
}*/
|
||||
|
||||
if (emscripten_has_asyncify() && SDL_GetHintBoolean(SDL_HINT_EMSCRIPTEN_ASYNCIFY, SDL_TRUE)) {
|
||||
/* give back control to browser for screen refresh */
|
||||
emscripten_sleep(0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -18,8 +18,6 @@
|
||||
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_EMSCRIPTEN
|
||||
@@ -28,9 +26,9 @@
|
||||
#include <emscripten/html5.h>
|
||||
|
||||
#include "SDL_emscriptenmouse.h"
|
||||
#include "SDL_emscriptenvideo.h"
|
||||
|
||||
#include "../../events/SDL_mouse_c.h"
|
||||
#include "SDL_assert.h"
|
||||
|
||||
static SDL_Cursor*
|
||||
Emscripten_CreateCursorFromString(const char* cursor_str, SDL_bool is_custom)
|
||||
@@ -236,9 +234,19 @@ Emscripten_WarpMouse(SDL_Window* window, int x, int y)
|
||||
static int
|
||||
Emscripten_SetRelativeMouseMode(SDL_bool enabled)
|
||||
{
|
||||
SDL_Window *window;
|
||||
SDL_WindowData *window_data;
|
||||
|
||||
/* TODO: pointer lock isn't actually enabled yet */
|
||||
if(enabled) {
|
||||
if(emscripten_request_pointerlock(NULL, 1) >= EMSCRIPTEN_RESULT_SUCCESS) {
|
||||
window = SDL_GetMouseFocus();
|
||||
if (window == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
window_data = (SDL_WindowData *) window->driverdata;
|
||||
|
||||
if(emscripten_request_pointerlock(window_data->canvas_id, 1) >= EMSCRIPTEN_RESULT_SUCCESS) {
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
|
@@ -27,6 +27,7 @@
|
||||
|
||||
#include "SDL_emscriptenvideo.h"
|
||||
#include "SDL_emscriptenopengles.h"
|
||||
#include "SDL_hints.h"
|
||||
|
||||
#define LOAD_FUNC(NAME) _this->egl_data->NAME = NAME;
|
||||
|
||||
@@ -82,9 +83,19 @@ Emscripten_GLES_LoadLibrary(_THIS, const char *path) {
|
||||
}
|
||||
|
||||
SDL_EGL_CreateContext_impl(Emscripten)
|
||||
SDL_EGL_SwapWindow_impl(Emscripten)
|
||||
SDL_EGL_MakeCurrent_impl(Emscripten)
|
||||
|
||||
int
|
||||
Emscripten_GLES_SwapWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
EGLBoolean ret = SDL_EGL_SwapBuffers(_this, ((SDL_WindowData *) window->driverdata)->egl_surface);
|
||||
if (emscripten_has_asyncify() && SDL_GetHintBoolean(SDL_HINT_EMSCRIPTEN_ASYNCIFY, SDL_TRUE)) {
|
||||
/* give back control to browser for screen refresh */
|
||||
emscripten_sleep(0);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
Emscripten_GLES_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h)
|
||||
{
|
||||
|
@@ -42,6 +42,7 @@
|
||||
static int Emscripten_VideoInit(_THIS);
|
||||
static int Emscripten_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
|
||||
static void Emscripten_VideoQuit(_THIS);
|
||||
static int Emscripten_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect);
|
||||
|
||||
static int Emscripten_CreateWindow(_THIS, SDL_Window * window);
|
||||
static void Emscripten_SetWindowSize(_THIS, SDL_Window * window);
|
||||
@@ -53,12 +54,6 @@ static void Emscripten_SetWindowTitle(_THIS, SDL_Window * window);
|
||||
|
||||
/* Emscripten driver bootstrap functions */
|
||||
|
||||
static int
|
||||
Emscripten_Available(void)
|
||||
{
|
||||
return (1);
|
||||
}
|
||||
|
||||
static void
|
||||
Emscripten_DeleteDevice(SDL_VideoDevice * device)
|
||||
{
|
||||
@@ -86,6 +81,7 @@ Emscripten_CreateDevice(int devindex)
|
||||
/* Set the function pointers */
|
||||
device->VideoInit = Emscripten_VideoInit;
|
||||
device->VideoQuit = Emscripten_VideoQuit;
|
||||
device->GetDisplayUsableBounds = Emscripten_GetDisplayUsableBounds;
|
||||
device->SetDisplayMode = Emscripten_SetDisplayMode;
|
||||
|
||||
|
||||
@@ -130,7 +126,7 @@ Emscripten_CreateDevice(int devindex)
|
||||
|
||||
VideoBootStrap Emscripten_bootstrap = {
|
||||
EMSCRIPTENVID_DRIVER_NAME, "SDL emscripten video driver",
|
||||
Emscripten_Available, Emscripten_CreateDevice
|
||||
Emscripten_CreateDevice
|
||||
};
|
||||
|
||||
|
||||
@@ -177,6 +173,22 @@ Emscripten_VideoQuit(_THIS)
|
||||
Emscripten_FiniMouse();
|
||||
}
|
||||
|
||||
static int
|
||||
Emscripten_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect)
|
||||
{
|
||||
if (rect) {
|
||||
rect->x = 0;
|
||||
rect->y = 0;
|
||||
rect->w = EM_ASM_INT_V({
|
||||
return window.innerWidth;
|
||||
});
|
||||
rect->h = EM_ASM_INT_V({
|
||||
return window.innerHeight;
|
||||
});
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
Emscripten_PumpEvents(_THIS)
|
||||
{
|
||||
@@ -348,8 +360,8 @@ Emscripten_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * di
|
||||
static void
|
||||
Emscripten_SetWindowTitle(_THIS, SDL_Window * window) {
|
||||
EM_ASM_INT({
|
||||
if (typeof Module['setWindowTitle'] !== 'undefined') {
|
||||
Module['setWindowTitle'](UTF8ToString($0));
|
||||
if (typeof setWindowTitle !== 'undefined') {
|
||||
setWindowTitle(UTF8ToString($0));
|
||||
}
|
||||
return 0;
|
||||
}, window->title);
|
||||
|
@@ -154,9 +154,9 @@ class HAIKU_SDL_MessageBox : public BAlert
|
||||
ApplyAndParseColorScheme(aMessageBoxData->colorScheme);
|
||||
}
|
||||
|
||||
(aMessageBoxData->title != NULL) ?
|
||||
(aMessageBoxData->title[0]) ?
|
||||
SetTitle(aMessageBoxData->title) : SetTitle(HAIKU_SDL_DefTitle);
|
||||
(aMessageBoxData->message != NULL) ?
|
||||
(aMessageBoxData->message[0]) ?
|
||||
SetMessageText(aMessageBoxData->message) : SetMessageText(HAIKU_SDL_DefMessage);
|
||||
|
||||
SetType(ConvertMessageBoxType(static_cast<SDL_MessageBoxFlags>(aMessageBoxData->flags)));
|
||||
|
2
externals/SDL/src/video/haiku/SDL_bmodes.cc
vendored
2
externals/SDL/src/video/haiku/SDL_bmodes.cc
vendored
@@ -228,7 +228,7 @@ static void _AddDisplay(BScreen *screen) {
|
||||
display.desktop_mode = *mode;
|
||||
display.current_mode = *mode;
|
||||
|
||||
SDL_AddVideoDisplay(&display);
|
||||
SDL_AddVideoDisplay(&display, SDL_FALSE);
|
||||
}
|
||||
|
||||
/*
|
||||
|
18
externals/SDL/src/video/haiku/SDL_bvideo.cc
vendored
18
externals/SDL/src/video/haiku/SDL_bvideo.cc
vendored
@@ -37,6 +37,8 @@ extern "C" {
|
||||
#include "SDL_bframebuffer.h"
|
||||
#include "SDL_bevents.h"
|
||||
|
||||
#include <Url.h>
|
||||
|
||||
/* FIXME: Undefined functions */
|
||||
// #define HAIKU_PumpEvents NULL
|
||||
#define HAIKU_StartTextInput NULL
|
||||
@@ -124,7 +126,7 @@ HAIKU_CreateDevice(int devindex)
|
||||
|
||||
VideoBootStrap HAIKU_bootstrap = {
|
||||
"haiku", "Haiku graphics",
|
||||
HAIKU_Available, HAIKU_CreateDevice
|
||||
HAIKU_CreateDevice
|
||||
};
|
||||
|
||||
void HAIKU_DeleteDevice(SDL_VideoDevice * device)
|
||||
@@ -185,11 +187,6 @@ int HAIKU_VideoInit(_THIS)
|
||||
return (0);
|
||||
}
|
||||
|
||||
int HAIKU_Available(void)
|
||||
{
|
||||
return (1);
|
||||
}
|
||||
|
||||
void HAIKU_VideoQuit(_THIS)
|
||||
{
|
||||
|
||||
@@ -198,6 +195,15 @@ void HAIKU_VideoQuit(_THIS)
|
||||
SDL_QuitBeApp();
|
||||
}
|
||||
|
||||
// just sticking this function in here so it's in a C++ source file.
|
||||
extern "C" { int HAIKU_OpenURL(const char *url); }
|
||||
int HAIKU_OpenURL(const char *url)
|
||||
{
|
||||
BUrl burl(url);
|
||||
const status_t rc = burl.OpenWithPreferredApplication(false);
|
||||
return (rc == B_NO_ERROR) ? 0 : SDL_SetError("URL open failed (err=%d)", (int) rc);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
1
externals/SDL/src/video/haiku/SDL_bvideo.h
vendored
1
externals/SDL/src/video/haiku/SDL_bvideo.h
vendored
@@ -33,7 +33,6 @@ extern "C" {
|
||||
extern void HAIKU_VideoQuit(_THIS);
|
||||
extern int HAIKU_VideoInit(_THIS);
|
||||
extern void HAIKU_DeleteDevice(_THIS);
|
||||
extern int HAIKU_Available(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
64
externals/SDL/src/video/khronos/vulkan/vk_icd.h
vendored
64
externals/SDL/src/video/khronos/vulkan/vk_icd.h
vendored
@@ -41,17 +41,45 @@
|
||||
// that if the loader is older, it should automatically fail a
|
||||
// call for any API version > 1.0. Otherwise, the loader will
|
||||
// manually determine if it can support the expected version.
|
||||
#define CURRENT_LOADER_ICD_INTERFACE_VERSION 5
|
||||
// Version 6 - Add support for vk_icdEnumerateAdapterPhysicalDevices.
|
||||
#define CURRENT_LOADER_ICD_INTERFACE_VERSION 6
|
||||
#define MIN_SUPPORTED_LOADER_ICD_INTERFACE_VERSION 0
|
||||
#define MIN_PHYS_DEV_EXTENSION_ICD_INTERFACE_VERSION 4
|
||||
typedef VkResult(VKAPI_PTR *PFN_vkNegotiateLoaderICDInterfaceVersion)(uint32_t *pVersion);
|
||||
|
||||
// Old typedefs that don't follow a proper naming convention but are preserved for compatibility
|
||||
typedef VkResult(VKAPI_PTR *PFN_vkNegotiateLoaderICDInterfaceVersion)(uint32_t *pVersion);
|
||||
// This is defined in vk_layer.h which will be found by the loader, but if an ICD is building against this
|
||||
// file directly, it won't be found.
|
||||
#ifndef PFN_GetPhysicalDeviceProcAddr
|
||||
typedef PFN_vkVoidFunction(VKAPI_PTR *PFN_GetPhysicalDeviceProcAddr)(VkInstance instance, const char *pName);
|
||||
#endif
|
||||
|
||||
// Typedefs for loader/ICD interface
|
||||
typedef VkResult (VKAPI_PTR *PFN_vk_icdNegotiateLoaderICDInterfaceVersion)(uint32_t* pVersion);
|
||||
typedef PFN_vkVoidFunction (VKAPI_PTR *PFN_vk_icdGetInstanceProcAddr)(VkInstance instance, const char* pName);
|
||||
typedef PFN_vkVoidFunction (VKAPI_PTR *PFN_vk_icdGetPhysicalDeviceProcAddr)(VkInstance instance, const char* pName);
|
||||
#if defined(VK_USE_PLATFORM_WIN32_KHR)
|
||||
typedef VkResult (VKAPI_PTR *PFN_vk_icdEnumerateAdapterPhysicalDevices)(VkInstance instance, LUID adapterLUID,
|
||||
uint32_t* pPhysicalDeviceCount, VkPhysicalDevice* pPhysicalDevices);
|
||||
#endif
|
||||
|
||||
// Prototypes for loader/ICD interface
|
||||
#if !defined(VK_NO_PROTOTYPES)
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vk_icdNegotiateLoaderICDInterfaceVersion(uint32_t* pVersion);
|
||||
VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_icdGetInstanceProcAddr(VkInstance instance, const char* pName);
|
||||
VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_icdGetPhysicalDeviceProcAddr(VkInstance isntance, const char* pName);
|
||||
#if defined(VK_USE_PLATFORM_WIN32_KHR)
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vk_icdEnumerateAdapterPhysicalDevices(VkInstance instance, LUID adapterLUID,
|
||||
uint32_t* pPhysicalDeviceCount, VkPhysicalDevice* pPhysicalDevices);
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The ICD must reserve space for a pointer for the loader's dispatch
|
||||
* table, at the start of <each object>.
|
||||
@@ -88,7 +116,11 @@ typedef enum {
|
||||
VK_ICD_WSI_PLATFORM_ANDROID,
|
||||
VK_ICD_WSI_PLATFORM_MACOS,
|
||||
VK_ICD_WSI_PLATFORM_IOS,
|
||||
VK_ICD_WSI_PLATFORM_DISPLAY
|
||||
VK_ICD_WSI_PLATFORM_DISPLAY,
|
||||
VK_ICD_WSI_PLATFORM_HEADLESS,
|
||||
VK_ICD_WSI_PLATFORM_METAL,
|
||||
VK_ICD_WSI_PLATFORM_DIRECTFB,
|
||||
VK_ICD_WSI_PLATFORM_VI,
|
||||
} VkIcdWsiPlatform;
|
||||
|
||||
typedef struct {
|
||||
@@ -135,6 +167,14 @@ typedef struct {
|
||||
} VkIcdSurfaceXlib;
|
||||
#endif // VK_USE_PLATFORM_XLIB_KHR
|
||||
|
||||
#ifdef VK_USE_PLATFORM_DIRECTFB_EXT
|
||||
typedef struct {
|
||||
VkIcdSurfaceBase base;
|
||||
IDirectFB *dfb;
|
||||
IDirectFBSurface *surface;
|
||||
} VkIcdSurfaceDirectFB;
|
||||
#endif // VK_USE_PLATFORM_DIRECTFB_EXT
|
||||
|
||||
#ifdef VK_USE_PLATFORM_ANDROID_KHR
|
||||
typedef struct {
|
||||
VkIcdSurfaceBase base;
|
||||
@@ -167,4 +207,22 @@ typedef struct {
|
||||
VkExtent2D imageExtent;
|
||||
} VkIcdSurfaceDisplay;
|
||||
|
||||
typedef struct {
|
||||
VkIcdSurfaceBase base;
|
||||
} VkIcdSurfaceHeadless;
|
||||
|
||||
#ifdef VK_USE_PLATFORM_METAL_EXT
|
||||
typedef struct {
|
||||
VkIcdSurfaceBase base;
|
||||
const CAMetalLayer *pLayer;
|
||||
} VkIcdSurfaceMetal;
|
||||
#endif // VK_USE_PLATFORM_METAL_EXT
|
||||
|
||||
#ifdef VK_USE_PLATFORM_VI_NN
|
||||
typedef struct {
|
||||
VkIcdSurfaceBase base;
|
||||
void *window;
|
||||
} VkIcdSurfaceVi;
|
||||
#endif // VK_USE_PLATFORM_VI_NN
|
||||
|
||||
#endif // VKICD_H
|
||||
|
@@ -82,7 +82,9 @@ typedef VkResult(VKAPI_PTR *PFN_PhysDevExt)(VkPhysicalDevice phys_device);
|
||||
*/
|
||||
typedef enum VkLayerFunction_ {
|
||||
VK_LAYER_LINK_INFO = 0,
|
||||
VK_LOADER_DATA_CALLBACK = 1
|
||||
VK_LOADER_DATA_CALLBACK = 1,
|
||||
VK_LOADER_LAYER_CREATE_DEVICE_CALLBACK = 2,
|
||||
VK_LOADER_FEATURES = 3,
|
||||
} VkLayerFunction;
|
||||
|
||||
typedef struct VkLayerInstanceLink_ {
|
||||
@@ -107,6 +109,14 @@ typedef VkResult (VKAPI_PTR *PFN_vkSetInstanceLoaderData)(VkInstance instance,
|
||||
void *object);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkSetDeviceLoaderData)(VkDevice device,
|
||||
void *object);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkLayerCreateDevice)(VkInstance instance, VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
|
||||
const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, PFN_vkGetInstanceProcAddr layerGIPA, PFN_vkGetDeviceProcAddr *nextGDPA);
|
||||
typedef void (VKAPI_PTR *PFN_vkLayerDestroyDevice)(VkDevice physicalDevice, const VkAllocationCallbacks *pAllocator, PFN_vkDestroyDevice destroyFunction);
|
||||
|
||||
typedef enum VkLoaderFeastureFlagBits {
|
||||
VK_LOADER_FEATURE_PHYSICAL_DEVICE_SORTING = 0x00000001,
|
||||
} VkLoaderFlagBits;
|
||||
typedef VkFlags VkLoaderFeatureFlags;
|
||||
|
||||
typedef struct {
|
||||
VkStructureType sType; // VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO
|
||||
@@ -115,6 +125,11 @@ typedef struct {
|
||||
union {
|
||||
VkLayerInstanceLink *pLayerInfo;
|
||||
PFN_vkSetInstanceLoaderData pfnSetInstanceLoaderData;
|
||||
struct {
|
||||
PFN_vkLayerCreateDevice pfnLayerCreateDevice;
|
||||
PFN_vkLayerDestroyDevice pfnLayerDestroyDevice;
|
||||
} layerDevice;
|
||||
VkLoaderFeatureFlags loaderFeatures;
|
||||
} u;
|
||||
} VkLayerInstanceCreateInfo;
|
||||
|
||||
|
@@ -2,19 +2,9 @@
|
||||
// File: vk_platform.h
|
||||
//
|
||||
/*
|
||||
** Copyright (c) 2014-2017 The Khronos Group Inc.
|
||||
** Copyright (c) 2014-2020 The Khronos Group Inc.
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
|
||||
|
34
externals/SDL/src/video/khronos/vulkan/vulkan.h
vendored
34
externals/SDL/src/video/khronos/vulkan/vulkan.h
vendored
@@ -2,19 +2,9 @@
|
||||
#define VULKAN_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright (c) 2015-2018 The Khronos Group Inc.
|
||||
** Copyright (c) 2015-2020 The Khronos Group Inc.
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "vk_platform.h"
|
||||
@@ -38,6 +28,9 @@
|
||||
#include "vulkan_macos.h"
|
||||
#endif
|
||||
|
||||
#ifdef VK_USE_PLATFORM_METAL_EXT
|
||||
#include "vulkan_metal.h"
|
||||
#endif
|
||||
|
||||
#ifdef VK_USE_PLATFORM_VI_NN
|
||||
#include "vulkan_vi.h"
|
||||
@@ -68,10 +61,27 @@
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef VK_USE_PLATFORM_DIRECTFB_EXT
|
||||
#include <directfb.h>
|
||||
#include "vulkan_directfb.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/extensions/Xrandr.h>
|
||||
#include "vulkan_xlib_xrandr.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef VK_USE_PLATFORM_GGP
|
||||
#include <ggp_c/vulkan_types.h>
|
||||
#include "vulkan_ggp.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef VK_ENABLE_BETA_EXTENSIONS
|
||||
#include "vulkan_beta.h"
|
||||
#endif
|
||||
|
||||
#endif // VULKAN_H_
|
||||
|
136377
externals/SDL/src/video/khronos/vulkan/vulkan.hpp
vendored
136377
externals/SDL/src/video/khronos/vulkan/vulkan.hpp
vendored
File diff suppressed because one or more lines are too long
@@ -1,24 +1,10 @@
|
||||
#ifndef VULKAN_ANDROID_H_
|
||||
#define VULKAN_ANDROID_H_ 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Copyright (c) 2015-2018 The Khronos Group Inc.
|
||||
** Copyright (c) 2015-2020 The Khronos Group Inc.
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -27,14 +13,17 @@ extern "C" {
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define VK_KHR_android_surface 1
|
||||
struct ANativeWindow;
|
||||
|
||||
#define VK_KHR_ANDROID_SURFACE_SPEC_VERSION 6
|
||||
#define VK_KHR_ANDROID_SURFACE_EXTENSION_NAME "VK_KHR_android_surface"
|
||||
|
||||
typedef VkFlags VkAndroidSurfaceCreateFlagsKHR;
|
||||
|
||||
typedef struct VkAndroidSurfaceCreateInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
@@ -42,7 +31,6 @@ typedef struct VkAndroidSurfaceCreateInfoKHR {
|
||||
struct ANativeWindow* window;
|
||||
} VkAndroidSurfaceCreateInfoKHR;
|
||||
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkCreateAndroidSurfaceKHR)(VkInstance instance, const VkAndroidSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
@@ -53,12 +41,11 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateAndroidSurfaceKHR(
|
||||
VkSurfaceKHR* pSurface);
|
||||
#endif
|
||||
|
||||
|
||||
#define VK_ANDROID_external_memory_android_hardware_buffer 1
|
||||
struct AHardwareBuffer;
|
||||
|
||||
#define VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_SPEC_VERSION 3
|
||||
#define VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_EXTENSION_NAME "VK_ANDROID_external_memory_android_hardware_buffer"
|
||||
|
||||
typedef struct VkAndroidHardwareBufferUsageANDROID {
|
||||
VkStructureType sType;
|
||||
void* pNext;
|
||||
@@ -103,7 +90,6 @@ typedef struct VkExternalFormatANDROID {
|
||||
uint64_t externalFormat;
|
||||
} VkExternalFormatANDROID;
|
||||
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkGetAndroidHardwareBufferPropertiesANDROID)(VkDevice device, const struct AHardwareBuffer* buffer, VkAndroidHardwareBufferPropertiesANDROID* pProperties);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryAndroidHardwareBufferANDROID)(VkDevice device, const VkMemoryGetAndroidHardwareBufferInfoANDROID* pInfo, struct AHardwareBuffer** pBuffer);
|
||||
|
||||
|
459
externals/SDL/src/video/khronos/vulkan/vulkan_beta.h
vendored
Executable file
459
externals/SDL/src/video/khronos/vulkan/vulkan_beta.h
vendored
Executable file
@@ -0,0 +1,459 @@
|
||||
#ifndef VULKAN_BETA_H_
|
||||
#define VULKAN_BETA_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright (c) 2015-2020 The Khronos Group Inc.
|
||||
**
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
** This header is generated from the Khronos Vulkan XML API Registry.
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define VK_KHR_portability_subset 1
|
||||
#define VK_KHR_PORTABILITY_SUBSET_SPEC_VERSION 1
|
||||
#define VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME "VK_KHR_portability_subset"
|
||||
typedef struct VkPhysicalDevicePortabilitySubsetFeaturesKHR {
|
||||
VkStructureType sType;
|
||||
void* pNext;
|
||||
VkBool32 constantAlphaColorBlendFactors;
|
||||
VkBool32 events;
|
||||
VkBool32 imageViewFormatReinterpretation;
|
||||
VkBool32 imageViewFormatSwizzle;
|
||||
VkBool32 imageView2DOn3DImage;
|
||||
VkBool32 multisampleArrayImage;
|
||||
VkBool32 mutableComparisonSamplers;
|
||||
VkBool32 pointPolygons;
|
||||
VkBool32 samplerMipLodBias;
|
||||
VkBool32 separateStencilMaskRef;
|
||||
VkBool32 shaderSampleRateInterpolationFunctions;
|
||||
VkBool32 tessellationIsolines;
|
||||
VkBool32 tessellationPointMode;
|
||||
VkBool32 triangleFans;
|
||||
VkBool32 vertexAttributeAccessBeyondStride;
|
||||
} VkPhysicalDevicePortabilitySubsetFeaturesKHR;
|
||||
|
||||
typedef struct VkPhysicalDevicePortabilitySubsetPropertiesKHR {
|
||||
VkStructureType sType;
|
||||
void* pNext;
|
||||
uint32_t minVertexInputBindingStrideAlignment;
|
||||
} VkPhysicalDevicePortabilitySubsetPropertiesKHR;
|
||||
|
||||
|
||||
|
||||
#define VK_KHR_deferred_host_operations 1
|
||||
VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDeferredOperationKHR)
|
||||
#define VK_KHR_DEFERRED_HOST_OPERATIONS_SPEC_VERSION 3
|
||||
#define VK_KHR_DEFERRED_HOST_OPERATIONS_EXTENSION_NAME "VK_KHR_deferred_host_operations"
|
||||
typedef struct VkDeferredOperationInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkDeferredOperationKHR operationHandle;
|
||||
} VkDeferredOperationInfoKHR;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkCreateDeferredOperationKHR)(VkDevice device, const VkAllocationCallbacks* pAllocator, VkDeferredOperationKHR* pDeferredOperation);
|
||||
typedef void (VKAPI_PTR *PFN_vkDestroyDeferredOperationKHR)(VkDevice device, VkDeferredOperationKHR operation, const VkAllocationCallbacks* pAllocator);
|
||||
typedef uint32_t (VKAPI_PTR *PFN_vkGetDeferredOperationMaxConcurrencyKHR)(VkDevice device, VkDeferredOperationKHR operation);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkGetDeferredOperationResultKHR)(VkDevice device, VkDeferredOperationKHR operation);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkDeferredOperationJoinKHR)(VkDevice device, VkDeferredOperationKHR operation);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkCreateDeferredOperationKHR(
|
||||
VkDevice device,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkDeferredOperationKHR* pDeferredOperation);
|
||||
|
||||
VKAPI_ATTR void VKAPI_CALL vkDestroyDeferredOperationKHR(
|
||||
VkDevice device,
|
||||
VkDeferredOperationKHR operation,
|
||||
const VkAllocationCallbacks* pAllocator);
|
||||
|
||||
VKAPI_ATTR uint32_t VKAPI_CALL vkGetDeferredOperationMaxConcurrencyKHR(
|
||||
VkDevice device,
|
||||
VkDeferredOperationKHR operation);
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkGetDeferredOperationResultKHR(
|
||||
VkDevice device,
|
||||
VkDeferredOperationKHR operation);
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkDeferredOperationJoinKHR(
|
||||
VkDevice device,
|
||||
VkDeferredOperationKHR operation);
|
||||
#endif
|
||||
|
||||
|
||||
#define VK_KHR_pipeline_library 1
|
||||
#define VK_KHR_PIPELINE_LIBRARY_SPEC_VERSION 1
|
||||
#define VK_KHR_PIPELINE_LIBRARY_EXTENSION_NAME "VK_KHR_pipeline_library"
|
||||
typedef struct VkPipelineLibraryCreateInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
uint32_t libraryCount;
|
||||
const VkPipeline* pLibraries;
|
||||
} VkPipelineLibraryCreateInfoKHR;
|
||||
|
||||
|
||||
|
||||
#define VK_KHR_ray_tracing 1
|
||||
#define VK_KHR_RAY_TRACING_SPEC_VERSION 8
|
||||
#define VK_KHR_RAY_TRACING_EXTENSION_NAME "VK_KHR_ray_tracing"
|
||||
|
||||
typedef enum VkAccelerationStructureBuildTypeKHR {
|
||||
VK_ACCELERATION_STRUCTURE_BUILD_TYPE_HOST_KHR = 0,
|
||||
VK_ACCELERATION_STRUCTURE_BUILD_TYPE_DEVICE_KHR = 1,
|
||||
VK_ACCELERATION_STRUCTURE_BUILD_TYPE_HOST_OR_DEVICE_KHR = 2,
|
||||
VK_ACCELERATION_STRUCTURE_BUILD_TYPE_MAX_ENUM_KHR = 0x7FFFFFFF
|
||||
} VkAccelerationStructureBuildTypeKHR;
|
||||
typedef union VkDeviceOrHostAddressKHR {
|
||||
VkDeviceAddress deviceAddress;
|
||||
void* hostAddress;
|
||||
} VkDeviceOrHostAddressKHR;
|
||||
|
||||
typedef union VkDeviceOrHostAddressConstKHR {
|
||||
VkDeviceAddress deviceAddress;
|
||||
const void* hostAddress;
|
||||
} VkDeviceOrHostAddressConstKHR;
|
||||
|
||||
typedef struct VkAccelerationStructureBuildOffsetInfoKHR {
|
||||
uint32_t primitiveCount;
|
||||
uint32_t primitiveOffset;
|
||||
uint32_t firstVertex;
|
||||
uint32_t transformOffset;
|
||||
} VkAccelerationStructureBuildOffsetInfoKHR;
|
||||
|
||||
typedef struct VkRayTracingShaderGroupCreateInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkRayTracingShaderGroupTypeKHR type;
|
||||
uint32_t generalShader;
|
||||
uint32_t closestHitShader;
|
||||
uint32_t anyHitShader;
|
||||
uint32_t intersectionShader;
|
||||
const void* pShaderGroupCaptureReplayHandle;
|
||||
} VkRayTracingShaderGroupCreateInfoKHR;
|
||||
|
||||
typedef struct VkRayTracingPipelineInterfaceCreateInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
uint32_t maxPayloadSize;
|
||||
uint32_t maxAttributeSize;
|
||||
uint32_t maxCallableSize;
|
||||
} VkRayTracingPipelineInterfaceCreateInfoKHR;
|
||||
|
||||
typedef struct VkRayTracingPipelineCreateInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkPipelineCreateFlags flags;
|
||||
uint32_t stageCount;
|
||||
const VkPipelineShaderStageCreateInfo* pStages;
|
||||
uint32_t groupCount;
|
||||
const VkRayTracingShaderGroupCreateInfoKHR* pGroups;
|
||||
uint32_t maxRecursionDepth;
|
||||
VkPipelineLibraryCreateInfoKHR libraries;
|
||||
const VkRayTracingPipelineInterfaceCreateInfoKHR* pLibraryInterface;
|
||||
VkPipelineLayout layout;
|
||||
VkPipeline basePipelineHandle;
|
||||
int32_t basePipelineIndex;
|
||||
} VkRayTracingPipelineCreateInfoKHR;
|
||||
|
||||
typedef struct VkAccelerationStructureGeometryTrianglesDataKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkFormat vertexFormat;
|
||||
VkDeviceOrHostAddressConstKHR vertexData;
|
||||
VkDeviceSize vertexStride;
|
||||
VkIndexType indexType;
|
||||
VkDeviceOrHostAddressConstKHR indexData;
|
||||
VkDeviceOrHostAddressConstKHR transformData;
|
||||
} VkAccelerationStructureGeometryTrianglesDataKHR;
|
||||
|
||||
typedef struct VkAccelerationStructureGeometryAabbsDataKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkDeviceOrHostAddressConstKHR data;
|
||||
VkDeviceSize stride;
|
||||
} VkAccelerationStructureGeometryAabbsDataKHR;
|
||||
|
||||
typedef struct VkAccelerationStructureGeometryInstancesDataKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkBool32 arrayOfPointers;
|
||||
VkDeviceOrHostAddressConstKHR data;
|
||||
} VkAccelerationStructureGeometryInstancesDataKHR;
|
||||
|
||||
typedef union VkAccelerationStructureGeometryDataKHR {
|
||||
VkAccelerationStructureGeometryTrianglesDataKHR triangles;
|
||||
VkAccelerationStructureGeometryAabbsDataKHR aabbs;
|
||||
VkAccelerationStructureGeometryInstancesDataKHR instances;
|
||||
} VkAccelerationStructureGeometryDataKHR;
|
||||
|
||||
typedef struct VkAccelerationStructureGeometryKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkGeometryTypeKHR geometryType;
|
||||
VkAccelerationStructureGeometryDataKHR geometry;
|
||||
VkGeometryFlagsKHR flags;
|
||||
} VkAccelerationStructureGeometryKHR;
|
||||
|
||||
typedef struct VkAccelerationStructureBuildGeometryInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkAccelerationStructureTypeKHR type;
|
||||
VkBuildAccelerationStructureFlagsKHR flags;
|
||||
VkBool32 update;
|
||||
VkAccelerationStructureKHR srcAccelerationStructure;
|
||||
VkAccelerationStructureKHR dstAccelerationStructure;
|
||||
VkBool32 geometryArrayOfPointers;
|
||||
uint32_t geometryCount;
|
||||
const VkAccelerationStructureGeometryKHR* const* ppGeometries;
|
||||
VkDeviceOrHostAddressKHR scratchData;
|
||||
} VkAccelerationStructureBuildGeometryInfoKHR;
|
||||
|
||||
typedef struct VkAccelerationStructureCreateGeometryTypeInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkGeometryTypeKHR geometryType;
|
||||
uint32_t maxPrimitiveCount;
|
||||
VkIndexType indexType;
|
||||
uint32_t maxVertexCount;
|
||||
VkFormat vertexFormat;
|
||||
VkBool32 allowsTransforms;
|
||||
} VkAccelerationStructureCreateGeometryTypeInfoKHR;
|
||||
|
||||
typedef struct VkAccelerationStructureCreateInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkDeviceSize compactedSize;
|
||||
VkAccelerationStructureTypeKHR type;
|
||||
VkBuildAccelerationStructureFlagsKHR flags;
|
||||
uint32_t maxGeometryCount;
|
||||
const VkAccelerationStructureCreateGeometryTypeInfoKHR* pGeometryInfos;
|
||||
VkDeviceAddress deviceAddress;
|
||||
} VkAccelerationStructureCreateInfoKHR;
|
||||
|
||||
typedef struct VkAccelerationStructureMemoryRequirementsInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkAccelerationStructureMemoryRequirementsTypeKHR type;
|
||||
VkAccelerationStructureBuildTypeKHR buildType;
|
||||
VkAccelerationStructureKHR accelerationStructure;
|
||||
} VkAccelerationStructureMemoryRequirementsInfoKHR;
|
||||
|
||||
typedef struct VkPhysicalDeviceRayTracingFeaturesKHR {
|
||||
VkStructureType sType;
|
||||
void* pNext;
|
||||
VkBool32 rayTracing;
|
||||
VkBool32 rayTracingShaderGroupHandleCaptureReplay;
|
||||
VkBool32 rayTracingShaderGroupHandleCaptureReplayMixed;
|
||||
VkBool32 rayTracingAccelerationStructureCaptureReplay;
|
||||
VkBool32 rayTracingIndirectTraceRays;
|
||||
VkBool32 rayTracingIndirectAccelerationStructureBuild;
|
||||
VkBool32 rayTracingHostAccelerationStructureCommands;
|
||||
VkBool32 rayQuery;
|
||||
VkBool32 rayTracingPrimitiveCulling;
|
||||
} VkPhysicalDeviceRayTracingFeaturesKHR;
|
||||
|
||||
typedef struct VkPhysicalDeviceRayTracingPropertiesKHR {
|
||||
VkStructureType sType;
|
||||
void* pNext;
|
||||
uint32_t shaderGroupHandleSize;
|
||||
uint32_t maxRecursionDepth;
|
||||
uint32_t maxShaderGroupStride;
|
||||
uint32_t shaderGroupBaseAlignment;
|
||||
uint64_t maxGeometryCount;
|
||||
uint64_t maxInstanceCount;
|
||||
uint64_t maxPrimitiveCount;
|
||||
uint32_t maxDescriptorSetAccelerationStructures;
|
||||
uint32_t shaderGroupHandleCaptureReplaySize;
|
||||
} VkPhysicalDeviceRayTracingPropertiesKHR;
|
||||
|
||||
typedef struct VkAccelerationStructureDeviceAddressInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkAccelerationStructureKHR accelerationStructure;
|
||||
} VkAccelerationStructureDeviceAddressInfoKHR;
|
||||
|
||||
typedef struct VkAccelerationStructureVersionKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
const uint8_t* versionData;
|
||||
} VkAccelerationStructureVersionKHR;
|
||||
|
||||
typedef struct VkStridedBufferRegionKHR {
|
||||
VkBuffer buffer;
|
||||
VkDeviceSize offset;
|
||||
VkDeviceSize stride;
|
||||
VkDeviceSize size;
|
||||
} VkStridedBufferRegionKHR;
|
||||
|
||||
typedef struct VkTraceRaysIndirectCommandKHR {
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t depth;
|
||||
} VkTraceRaysIndirectCommandKHR;
|
||||
|
||||
typedef struct VkCopyAccelerationStructureToMemoryInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkAccelerationStructureKHR src;
|
||||
VkDeviceOrHostAddressKHR dst;
|
||||
VkCopyAccelerationStructureModeKHR mode;
|
||||
} VkCopyAccelerationStructureToMemoryInfoKHR;
|
||||
|
||||
typedef struct VkCopyMemoryToAccelerationStructureInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkDeviceOrHostAddressConstKHR src;
|
||||
VkAccelerationStructureKHR dst;
|
||||
VkCopyAccelerationStructureModeKHR mode;
|
||||
} VkCopyMemoryToAccelerationStructureInfoKHR;
|
||||
|
||||
typedef struct VkCopyAccelerationStructureInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkAccelerationStructureKHR src;
|
||||
VkAccelerationStructureKHR dst;
|
||||
VkCopyAccelerationStructureModeKHR mode;
|
||||
} VkCopyAccelerationStructureInfoKHR;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkCreateAccelerationStructureKHR)(VkDevice device, const VkAccelerationStructureCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkAccelerationStructureKHR* pAccelerationStructure);
|
||||
typedef void (VKAPI_PTR *PFN_vkGetAccelerationStructureMemoryRequirementsKHR)(VkDevice device, const VkAccelerationStructureMemoryRequirementsInfoKHR* pInfo, VkMemoryRequirements2* pMemoryRequirements);
|
||||
typedef void (VKAPI_PTR *PFN_vkCmdBuildAccelerationStructureKHR)(VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR* pInfos, const VkAccelerationStructureBuildOffsetInfoKHR* const* ppOffsetInfos);
|
||||
typedef void (VKAPI_PTR *PFN_vkCmdBuildAccelerationStructureIndirectKHR)(VkCommandBuffer commandBuffer, const VkAccelerationStructureBuildGeometryInfoKHR* pInfo, VkBuffer indirectBuffer, VkDeviceSize indirectOffset, uint32_t indirectStride);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkBuildAccelerationStructureKHR)(VkDevice device, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR* pInfos, const VkAccelerationStructureBuildOffsetInfoKHR* const* ppOffsetInfos);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkCopyAccelerationStructureKHR)(VkDevice device, const VkCopyAccelerationStructureInfoKHR* pInfo);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkCopyAccelerationStructureToMemoryKHR)(VkDevice device, const VkCopyAccelerationStructureToMemoryInfoKHR* pInfo);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkCopyMemoryToAccelerationStructureKHR)(VkDevice device, const VkCopyMemoryToAccelerationStructureInfoKHR* pInfo);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkWriteAccelerationStructuresPropertiesKHR)(VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR* pAccelerationStructures, VkQueryType queryType, size_t dataSize, void* pData, size_t stride);
|
||||
typedef void (VKAPI_PTR *PFN_vkCmdCopyAccelerationStructureKHR)(VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR* pInfo);
|
||||
typedef void (VKAPI_PTR *PFN_vkCmdCopyAccelerationStructureToMemoryKHR)(VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR* pInfo);
|
||||
typedef void (VKAPI_PTR *PFN_vkCmdCopyMemoryToAccelerationStructureKHR)(VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR* pInfo);
|
||||
typedef void (VKAPI_PTR *PFN_vkCmdTraceRaysKHR)(VkCommandBuffer commandBuffer, const VkStridedBufferRegionKHR* pRaygenShaderBindingTable, const VkStridedBufferRegionKHR* pMissShaderBindingTable, const VkStridedBufferRegionKHR* pHitShaderBindingTable, const VkStridedBufferRegionKHR* pCallableShaderBindingTable, uint32_t width, uint32_t height, uint32_t depth);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkCreateRayTracingPipelinesKHR)(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, const VkRayTracingPipelineCreateInfoKHR* pCreateInfos, const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines);
|
||||
typedef VkDeviceAddress (VKAPI_PTR *PFN_vkGetAccelerationStructureDeviceAddressKHR)(VkDevice device, const VkAccelerationStructureDeviceAddressInfoKHR* pInfo);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkGetRayTracingCaptureReplayShaderGroupHandlesKHR)(VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void* pData);
|
||||
typedef void (VKAPI_PTR *PFN_vkCmdTraceRaysIndirectKHR)(VkCommandBuffer commandBuffer, const VkStridedBufferRegionKHR* pRaygenShaderBindingTable, const VkStridedBufferRegionKHR* pMissShaderBindingTable, const VkStridedBufferRegionKHR* pHitShaderBindingTable, const VkStridedBufferRegionKHR* pCallableShaderBindingTable, VkBuffer buffer, VkDeviceSize offset);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkGetDeviceAccelerationStructureCompatibilityKHR)(VkDevice device, const VkAccelerationStructureVersionKHR* version);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkCreateAccelerationStructureKHR(
|
||||
VkDevice device,
|
||||
const VkAccelerationStructureCreateInfoKHR* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkAccelerationStructureKHR* pAccelerationStructure);
|
||||
|
||||
VKAPI_ATTR void VKAPI_CALL vkGetAccelerationStructureMemoryRequirementsKHR(
|
||||
VkDevice device,
|
||||
const VkAccelerationStructureMemoryRequirementsInfoKHR* pInfo,
|
||||
VkMemoryRequirements2* pMemoryRequirements);
|
||||
|
||||
VKAPI_ATTR void VKAPI_CALL vkCmdBuildAccelerationStructureKHR(
|
||||
VkCommandBuffer commandBuffer,
|
||||
uint32_t infoCount,
|
||||
const VkAccelerationStructureBuildGeometryInfoKHR* pInfos,
|
||||
const VkAccelerationStructureBuildOffsetInfoKHR* const* ppOffsetInfos);
|
||||
|
||||
VKAPI_ATTR void VKAPI_CALL vkCmdBuildAccelerationStructureIndirectKHR(
|
||||
VkCommandBuffer commandBuffer,
|
||||
const VkAccelerationStructureBuildGeometryInfoKHR* pInfo,
|
||||
VkBuffer indirectBuffer,
|
||||
VkDeviceSize indirectOffset,
|
||||
uint32_t indirectStride);
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkBuildAccelerationStructureKHR(
|
||||
VkDevice device,
|
||||
uint32_t infoCount,
|
||||
const VkAccelerationStructureBuildGeometryInfoKHR* pInfos,
|
||||
const VkAccelerationStructureBuildOffsetInfoKHR* const* ppOffsetInfos);
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkCopyAccelerationStructureKHR(
|
||||
VkDevice device,
|
||||
const VkCopyAccelerationStructureInfoKHR* pInfo);
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkCopyAccelerationStructureToMemoryKHR(
|
||||
VkDevice device,
|
||||
const VkCopyAccelerationStructureToMemoryInfoKHR* pInfo);
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkCopyMemoryToAccelerationStructureKHR(
|
||||
VkDevice device,
|
||||
const VkCopyMemoryToAccelerationStructureInfoKHR* pInfo);
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkWriteAccelerationStructuresPropertiesKHR(
|
||||
VkDevice device,
|
||||
uint32_t accelerationStructureCount,
|
||||
const VkAccelerationStructureKHR* pAccelerationStructures,
|
||||
VkQueryType queryType,
|
||||
size_t dataSize,
|
||||
void* pData,
|
||||
size_t stride);
|
||||
|
||||
VKAPI_ATTR void VKAPI_CALL vkCmdCopyAccelerationStructureKHR(
|
||||
VkCommandBuffer commandBuffer,
|
||||
const VkCopyAccelerationStructureInfoKHR* pInfo);
|
||||
|
||||
VKAPI_ATTR void VKAPI_CALL vkCmdCopyAccelerationStructureToMemoryKHR(
|
||||
VkCommandBuffer commandBuffer,
|
||||
const VkCopyAccelerationStructureToMemoryInfoKHR* pInfo);
|
||||
|
||||
VKAPI_ATTR void VKAPI_CALL vkCmdCopyMemoryToAccelerationStructureKHR(
|
||||
VkCommandBuffer commandBuffer,
|
||||
const VkCopyMemoryToAccelerationStructureInfoKHR* pInfo);
|
||||
|
||||
VKAPI_ATTR void VKAPI_CALL vkCmdTraceRaysKHR(
|
||||
VkCommandBuffer commandBuffer,
|
||||
const VkStridedBufferRegionKHR* pRaygenShaderBindingTable,
|
||||
const VkStridedBufferRegionKHR* pMissShaderBindingTable,
|
||||
const VkStridedBufferRegionKHR* pHitShaderBindingTable,
|
||||
const VkStridedBufferRegionKHR* pCallableShaderBindingTable,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t depth);
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkCreateRayTracingPipelinesKHR(
|
||||
VkDevice device,
|
||||
VkPipelineCache pipelineCache,
|
||||
uint32_t createInfoCount,
|
||||
const VkRayTracingPipelineCreateInfoKHR* pCreateInfos,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkPipeline* pPipelines);
|
||||
|
||||
VKAPI_ATTR VkDeviceAddress VKAPI_CALL vkGetAccelerationStructureDeviceAddressKHR(
|
||||
VkDevice device,
|
||||
const VkAccelerationStructureDeviceAddressInfoKHR* pInfo);
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkGetRayTracingCaptureReplayShaderGroupHandlesKHR(
|
||||
VkDevice device,
|
||||
VkPipeline pipeline,
|
||||
uint32_t firstGroup,
|
||||
uint32_t groupCount,
|
||||
size_t dataSize,
|
||||
void* pData);
|
||||
|
||||
VKAPI_ATTR void VKAPI_CALL vkCmdTraceRaysIndirectKHR(
|
||||
VkCommandBuffer commandBuffer,
|
||||
const VkStridedBufferRegionKHR* pRaygenShaderBindingTable,
|
||||
const VkStridedBufferRegionKHR* pMissShaderBindingTable,
|
||||
const VkStridedBufferRegionKHR* pHitShaderBindingTable,
|
||||
const VkStridedBufferRegionKHR* pCallableShaderBindingTable,
|
||||
VkBuffer buffer,
|
||||
VkDeviceSize offset);
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkGetDeviceAccelerationStructureCompatibilityKHR(
|
||||
VkDevice device,
|
||||
const VkAccelerationStructureVersionKHR* version);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
5872
externals/SDL/src/video/khronos/vulkan/vulkan_core.h
vendored
5872
externals/SDL/src/video/khronos/vulkan/vulkan_core.h
vendored
File diff suppressed because it is too large
Load Diff
54
externals/SDL/src/video/khronos/vulkan/vulkan_directfb.h
vendored
Executable file
54
externals/SDL/src/video/khronos/vulkan/vulkan_directfb.h
vendored
Executable file
@@ -0,0 +1,54 @@
|
||||
#ifndef VULKAN_DIRECTFB_H_
|
||||
#define VULKAN_DIRECTFB_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright (c) 2015-2020 The Khronos Group Inc.
|
||||
**
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
** This header is generated from the Khronos Vulkan XML API Registry.
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define VK_EXT_directfb_surface 1
|
||||
#define VK_EXT_DIRECTFB_SURFACE_SPEC_VERSION 1
|
||||
#define VK_EXT_DIRECTFB_SURFACE_EXTENSION_NAME "VK_EXT_directfb_surface"
|
||||
typedef VkFlags VkDirectFBSurfaceCreateFlagsEXT;
|
||||
typedef struct VkDirectFBSurfaceCreateInfoEXT {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkDirectFBSurfaceCreateFlagsEXT flags;
|
||||
IDirectFB* dfb;
|
||||
IDirectFBSurface* surface;
|
||||
} VkDirectFBSurfaceCreateInfoEXT;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkCreateDirectFBSurfaceEXT)(VkInstance instance, const VkDirectFBSurfaceCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
|
||||
typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceDirectFBPresentationSupportEXT)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, IDirectFB* dfb);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkCreateDirectFBSurfaceEXT(
|
||||
VkInstance instance,
|
||||
const VkDirectFBSurfaceCreateInfoEXT* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkSurfaceKHR* pSurface);
|
||||
|
||||
VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceDirectFBPresentationSupportEXT(
|
||||
VkPhysicalDevice physicalDevice,
|
||||
uint32_t queueFamilyIndex,
|
||||
IDirectFB* dfb);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@@ -1,24 +1,10 @@
|
||||
#ifndef VULKAN_FUCHSIA_H_
|
||||
#define VULKAN_FUCHSIA_H_ 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Copyright (c) 2015-2018 The Khronos Group Inc.
|
||||
** Copyright (c) 2015-2020 The Khronos Group Inc.
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -27,12 +13,16 @@ extern "C" {
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define VK_FUCHSIA_imagepipe_surface 1
|
||||
#define VK_FUCHSIA_IMAGEPIPE_SURFACE_SPEC_VERSION 1
|
||||
#define VK_FUCHSIA_IMAGEPIPE_SURFACE_EXTENSION_NAME "VK_FUCHSIA_imagepipe_surface"
|
||||
|
||||
typedef VkFlags VkImagePipeSurfaceCreateFlagsFUCHSIA;
|
||||
|
||||
typedef struct VkImagePipeSurfaceCreateInfoFUCHSIA {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
@@ -40,7 +30,6 @@ typedef struct VkImagePipeSurfaceCreateInfoFUCHSIA {
|
||||
zx_handle_t imagePipeHandle;
|
||||
} VkImagePipeSurfaceCreateInfoFUCHSIA;
|
||||
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkCreateImagePipeSurfaceFUCHSIA)(VkInstance instance, const VkImagePipeSurfaceCreateInfoFUCHSIA* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
|
58
externals/SDL/src/video/khronos/vulkan/vulkan_ggp.h
vendored
Executable file
58
externals/SDL/src/video/khronos/vulkan/vulkan_ggp.h
vendored
Executable file
@@ -0,0 +1,58 @@
|
||||
#ifndef VULKAN_GGP_H_
|
||||
#define VULKAN_GGP_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright (c) 2015-2020 The Khronos Group Inc.
|
||||
**
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
** This header is generated from the Khronos Vulkan XML API Registry.
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define VK_GGP_stream_descriptor_surface 1
|
||||
#define VK_GGP_STREAM_DESCRIPTOR_SURFACE_SPEC_VERSION 1
|
||||
#define VK_GGP_STREAM_DESCRIPTOR_SURFACE_EXTENSION_NAME "VK_GGP_stream_descriptor_surface"
|
||||
typedef VkFlags VkStreamDescriptorSurfaceCreateFlagsGGP;
|
||||
typedef struct VkStreamDescriptorSurfaceCreateInfoGGP {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkStreamDescriptorSurfaceCreateFlagsGGP flags;
|
||||
GgpStreamDescriptor streamDescriptor;
|
||||
} VkStreamDescriptorSurfaceCreateInfoGGP;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkCreateStreamDescriptorSurfaceGGP)(VkInstance instance, const VkStreamDescriptorSurfaceCreateInfoGGP* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkCreateStreamDescriptorSurfaceGGP(
|
||||
VkInstance instance,
|
||||
const VkStreamDescriptorSurfaceCreateInfoGGP* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkSurfaceKHR* pSurface);
|
||||
#endif
|
||||
|
||||
|
||||
#define VK_GGP_frame_token 1
|
||||
#define VK_GGP_FRAME_TOKEN_SPEC_VERSION 1
|
||||
#define VK_GGP_FRAME_TOKEN_EXTENSION_NAME "VK_GGP_frame_token"
|
||||
typedef struct VkPresentFrameTokenGGP {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
GgpFrameToken frameToken;
|
||||
} VkPresentFrameTokenGGP;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@@ -1,24 +1,10 @@
|
||||
#ifndef VULKAN_IOS_H_
|
||||
#define VULKAN_IOS_H_ 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Copyright (c) 2015-2018 The Khronos Group Inc.
|
||||
** Copyright (c) 2015-2020 The Khronos Group Inc.
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -27,12 +13,16 @@ extern "C" {
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define VK_MVK_ios_surface 1
|
||||
#define VK_MVK_IOS_SURFACE_SPEC_VERSION 2
|
||||
#define VK_MVK_IOS_SURFACE_SPEC_VERSION 3
|
||||
#define VK_MVK_IOS_SURFACE_EXTENSION_NAME "VK_MVK_ios_surface"
|
||||
|
||||
typedef VkFlags VkIOSSurfaceCreateFlagsMVK;
|
||||
|
||||
typedef struct VkIOSSurfaceCreateInfoMVK {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
@@ -40,7 +30,6 @@ typedef struct VkIOSSurfaceCreateInfoMVK {
|
||||
const void* pView;
|
||||
} VkIOSSurfaceCreateInfoMVK;
|
||||
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkCreateIOSSurfaceMVK)(VkInstance instance, const VkIOSSurfaceCreateInfoMVK* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
|
@@ -1,24 +1,10 @@
|
||||
#ifndef VULKAN_MACOS_H_
|
||||
#define VULKAN_MACOS_H_ 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Copyright (c) 2015-2018 The Khronos Group Inc.
|
||||
** Copyright (c) 2015-2020 The Khronos Group Inc.
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -27,12 +13,16 @@ extern "C" {
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define VK_MVK_macos_surface 1
|
||||
#define VK_MVK_MACOS_SURFACE_SPEC_VERSION 2
|
||||
#define VK_MVK_MACOS_SURFACE_SPEC_VERSION 3
|
||||
#define VK_MVK_MACOS_SURFACE_EXTENSION_NAME "VK_MVK_macos_surface"
|
||||
|
||||
typedef VkFlags VkMacOSSurfaceCreateFlagsMVK;
|
||||
|
||||
typedef struct VkMacOSSurfaceCreateInfoMVK {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
@@ -40,7 +30,6 @@ typedef struct VkMacOSSurfaceCreateInfoMVK {
|
||||
const void* pView;
|
||||
} VkMacOSSurfaceCreateInfoMVK;
|
||||
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkCreateMacOSSurfaceMVK)(VkInstance instance, const VkMacOSSurfaceCreateInfoMVK* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
|
54
externals/SDL/src/video/khronos/vulkan/vulkan_metal.h
vendored
Executable file
54
externals/SDL/src/video/khronos/vulkan/vulkan_metal.h
vendored
Executable file
@@ -0,0 +1,54 @@
|
||||
#ifndef VULKAN_METAL_H_
|
||||
#define VULKAN_METAL_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright (c) 2015-2020 The Khronos Group Inc.
|
||||
**
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
** This header is generated from the Khronos Vulkan XML API Registry.
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define VK_EXT_metal_surface 1
|
||||
|
||||
#ifdef __OBJC__
|
||||
@class CAMetalLayer;
|
||||
#else
|
||||
typedef void CAMetalLayer;
|
||||
#endif
|
||||
|
||||
#define VK_EXT_METAL_SURFACE_SPEC_VERSION 1
|
||||
#define VK_EXT_METAL_SURFACE_EXTENSION_NAME "VK_EXT_metal_surface"
|
||||
typedef VkFlags VkMetalSurfaceCreateFlagsEXT;
|
||||
typedef struct VkMetalSurfaceCreateInfoEXT {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkMetalSurfaceCreateFlagsEXT flags;
|
||||
const CAMetalLayer* pLayer;
|
||||
} VkMetalSurfaceCreateInfoEXT;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkCreateMetalSurfaceEXT)(VkInstance instance, const VkMetalSurfaceCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkCreateMetalSurfaceEXT(
|
||||
VkInstance instance,
|
||||
const VkMetalSurfaceCreateInfoEXT* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkSurfaceKHR* pSurface);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@@ -1,24 +1,10 @@
|
||||
#ifndef VULKAN_VI_H_
|
||||
#define VULKAN_VI_H_ 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Copyright (c) 2015-2018 The Khronos Group Inc.
|
||||
** Copyright (c) 2015-2020 The Khronos Group Inc.
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -27,12 +13,16 @@ extern "C" {
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define VK_NN_vi_surface 1
|
||||
#define VK_NN_VI_SURFACE_SPEC_VERSION 1
|
||||
#define VK_NN_VI_SURFACE_EXTENSION_NAME "VK_NN_vi_surface"
|
||||
|
||||
typedef VkFlags VkViSurfaceCreateFlagsNN;
|
||||
|
||||
typedef struct VkViSurfaceCreateInfoNN {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
@@ -40,7 +30,6 @@ typedef struct VkViSurfaceCreateInfoNN {
|
||||
void* window;
|
||||
} VkViSurfaceCreateInfoNN;
|
||||
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkCreateViSurfaceNN)(VkInstance instance, const VkViSurfaceCreateInfoNN* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
|
@@ -1,24 +1,10 @@
|
||||
#ifndef VULKAN_WAYLAND_H_
|
||||
#define VULKAN_WAYLAND_H_ 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Copyright (c) 2015-2018 The Khronos Group Inc.
|
||||
** Copyright (c) 2015-2020 The Khronos Group Inc.
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -27,12 +13,16 @@ extern "C" {
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define VK_KHR_wayland_surface 1
|
||||
#define VK_KHR_WAYLAND_SURFACE_SPEC_VERSION 6
|
||||
#define VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME "VK_KHR_wayland_surface"
|
||||
|
||||
typedef VkFlags VkWaylandSurfaceCreateFlagsKHR;
|
||||
|
||||
typedef struct VkWaylandSurfaceCreateInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
@@ -41,7 +31,6 @@ typedef struct VkWaylandSurfaceCreateInfoKHR {
|
||||
struct wl_surface* surface;
|
||||
} VkWaylandSurfaceCreateInfoKHR;
|
||||
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkCreateWaylandSurfaceKHR)(VkInstance instance, const VkWaylandSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
|
||||
typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, struct wl_display* display);
|
||||
|
||||
|
@@ -1,24 +1,10 @@
|
||||
#ifndef VULKAN_WIN32_H_
|
||||
#define VULKAN_WIN32_H_ 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Copyright (c) 2015-2018 The Khronos Group Inc.
|
||||
** Copyright (c) 2015-2020 The Khronos Group Inc.
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -27,12 +13,16 @@ extern "C" {
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define VK_KHR_win32_surface 1
|
||||
#define VK_KHR_WIN32_SURFACE_SPEC_VERSION 6
|
||||
#define VK_KHR_WIN32_SURFACE_EXTENSION_NAME "VK_KHR_win32_surface"
|
||||
|
||||
typedef VkFlags VkWin32SurfaceCreateFlagsKHR;
|
||||
|
||||
typedef struct VkWin32SurfaceCreateInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
@@ -41,7 +31,6 @@ typedef struct VkWin32SurfaceCreateInfoKHR {
|
||||
HWND hwnd;
|
||||
} VkWin32SurfaceCreateInfoKHR;
|
||||
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkCreateWin32SurfaceKHR)(VkInstance instance, const VkWin32SurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
|
||||
typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex);
|
||||
|
||||
@@ -57,10 +46,10 @@ VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWin32PresentationSupportKHR(
|
||||
uint32_t queueFamilyIndex);
|
||||
#endif
|
||||
|
||||
|
||||
#define VK_KHR_external_memory_win32 1
|
||||
#define VK_KHR_EXTERNAL_MEMORY_WIN32_SPEC_VERSION 1
|
||||
#define VK_KHR_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME "VK_KHR_external_memory_win32"
|
||||
|
||||
typedef struct VkImportMemoryWin32HandleInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
@@ -90,7 +79,6 @@ typedef struct VkMemoryGetWin32HandleInfoKHR {
|
||||
VkExternalMemoryHandleTypeFlagBits handleType;
|
||||
} VkMemoryGetWin32HandleInfoKHR;
|
||||
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryWin32HandleKHR)(VkDevice device, const VkMemoryGetWin32HandleInfoKHR* pGetWin32HandleInfo, HANDLE* pHandle);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryWin32HandlePropertiesKHR)(VkDevice device, VkExternalMemoryHandleTypeFlagBits handleType, HANDLE handle, VkMemoryWin32HandlePropertiesKHR* pMemoryWin32HandleProperties);
|
||||
|
||||
@@ -107,10 +95,10 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryWin32HandlePropertiesKHR(
|
||||
VkMemoryWin32HandlePropertiesKHR* pMemoryWin32HandleProperties);
|
||||
#endif
|
||||
|
||||
|
||||
#define VK_KHR_win32_keyed_mutex 1
|
||||
#define VK_KHR_WIN32_KEYED_MUTEX_SPEC_VERSION 1
|
||||
#define VK_KHR_WIN32_KEYED_MUTEX_EXTENSION_NAME "VK_KHR_win32_keyed_mutex"
|
||||
|
||||
typedef struct VkWin32KeyedMutexAcquireReleaseInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
@@ -128,7 +116,6 @@ typedef struct VkWin32KeyedMutexAcquireReleaseInfoKHR {
|
||||
#define VK_KHR_external_semaphore_win32 1
|
||||
#define VK_KHR_EXTERNAL_SEMAPHORE_WIN32_SPEC_VERSION 1
|
||||
#define VK_KHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME "VK_KHR_external_semaphore_win32"
|
||||
|
||||
typedef struct VkImportSemaphoreWin32HandleInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
@@ -163,7 +150,6 @@ typedef struct VkSemaphoreGetWin32HandleInfoKHR {
|
||||
VkExternalSemaphoreHandleTypeFlagBits handleType;
|
||||
} VkSemaphoreGetWin32HandleInfoKHR;
|
||||
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkImportSemaphoreWin32HandleKHR)(VkDevice device, const VkImportSemaphoreWin32HandleInfoKHR* pImportSemaphoreWin32HandleInfo);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkGetSemaphoreWin32HandleKHR)(VkDevice device, const VkSemaphoreGetWin32HandleInfoKHR* pGetWin32HandleInfo, HANDLE* pHandle);
|
||||
|
||||
@@ -178,10 +164,10 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetSemaphoreWin32HandleKHR(
|
||||
HANDLE* pHandle);
|
||||
#endif
|
||||
|
||||
|
||||
#define VK_KHR_external_fence_win32 1
|
||||
#define VK_KHR_EXTERNAL_FENCE_WIN32_SPEC_VERSION 1
|
||||
#define VK_KHR_EXTERNAL_FENCE_WIN32_EXTENSION_NAME "VK_KHR_external_fence_win32"
|
||||
|
||||
typedef struct VkImportFenceWin32HandleInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
@@ -207,7 +193,6 @@ typedef struct VkFenceGetWin32HandleInfoKHR {
|
||||
VkExternalFenceHandleTypeFlagBits handleType;
|
||||
} VkFenceGetWin32HandleInfoKHR;
|
||||
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkImportFenceWin32HandleKHR)(VkDevice device, const VkImportFenceWin32HandleInfoKHR* pImportFenceWin32HandleInfo);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkGetFenceWin32HandleKHR)(VkDevice device, const VkFenceGetWin32HandleInfoKHR* pGetWin32HandleInfo, HANDLE* pHandle);
|
||||
|
||||
@@ -222,10 +207,10 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetFenceWin32HandleKHR(
|
||||
HANDLE* pHandle);
|
||||
#endif
|
||||
|
||||
|
||||
#define VK_NV_external_memory_win32 1
|
||||
#define VK_NV_EXTERNAL_MEMORY_WIN32_SPEC_VERSION 1
|
||||
#define VK_NV_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME "VK_NV_external_memory_win32"
|
||||
|
||||
typedef struct VkImportMemoryWin32HandleInfoNV {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
@@ -240,7 +225,6 @@ typedef struct VkExportMemoryWin32HandleInfoNV {
|
||||
DWORD dwAccess;
|
||||
} VkExportMemoryWin32HandleInfoNV;
|
||||
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryWin32HandleNV)(VkDevice device, VkDeviceMemory memory, VkExternalMemoryHandleTypeFlagsNV handleType, HANDLE* pHandle);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
@@ -251,10 +235,10 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryWin32HandleNV(
|
||||
HANDLE* pHandle);
|
||||
#endif
|
||||
|
||||
#define VK_NV_win32_keyed_mutex 1
|
||||
#define VK_NV_WIN32_KEYED_MUTEX_SPEC_VERSION 1
|
||||
#define VK_NV_WIN32_KEYED_MUTEX_EXTENSION_NAME "VK_NV_win32_keyed_mutex"
|
||||
|
||||
#define VK_NV_win32_keyed_mutex 1
|
||||
#define VK_NV_WIN32_KEYED_MUTEX_SPEC_VERSION 2
|
||||
#define VK_NV_WIN32_KEYED_MUTEX_EXTENSION_NAME "VK_NV_win32_keyed_mutex"
|
||||
typedef struct VkWin32KeyedMutexAcquireReleaseInfoNV {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
@@ -269,6 +253,61 @@ typedef struct VkWin32KeyedMutexAcquireReleaseInfoNV {
|
||||
|
||||
|
||||
|
||||
#define VK_EXT_full_screen_exclusive 1
|
||||
#define VK_EXT_FULL_SCREEN_EXCLUSIVE_SPEC_VERSION 4
|
||||
#define VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME "VK_EXT_full_screen_exclusive"
|
||||
|
||||
typedef enum VkFullScreenExclusiveEXT {
|
||||
VK_FULL_SCREEN_EXCLUSIVE_DEFAULT_EXT = 0,
|
||||
VK_FULL_SCREEN_EXCLUSIVE_ALLOWED_EXT = 1,
|
||||
VK_FULL_SCREEN_EXCLUSIVE_DISALLOWED_EXT = 2,
|
||||
VK_FULL_SCREEN_EXCLUSIVE_APPLICATION_CONTROLLED_EXT = 3,
|
||||
VK_FULL_SCREEN_EXCLUSIVE_MAX_ENUM_EXT = 0x7FFFFFFF
|
||||
} VkFullScreenExclusiveEXT;
|
||||
typedef struct VkSurfaceFullScreenExclusiveInfoEXT {
|
||||
VkStructureType sType;
|
||||
void* pNext;
|
||||
VkFullScreenExclusiveEXT fullScreenExclusive;
|
||||
} VkSurfaceFullScreenExclusiveInfoEXT;
|
||||
|
||||
typedef struct VkSurfaceCapabilitiesFullScreenExclusiveEXT {
|
||||
VkStructureType sType;
|
||||
void* pNext;
|
||||
VkBool32 fullScreenExclusiveSupported;
|
||||
} VkSurfaceCapabilitiesFullScreenExclusiveEXT;
|
||||
|
||||
typedef struct VkSurfaceFullScreenExclusiveWin32InfoEXT {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
HMONITOR hmonitor;
|
||||
} VkSurfaceFullScreenExclusiveWin32InfoEXT;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceSurfacePresentModes2EXT)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo, uint32_t* pPresentModeCount, VkPresentModeKHR* pPresentModes);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkAcquireFullScreenExclusiveModeEXT)(VkDevice device, VkSwapchainKHR swapchain);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkReleaseFullScreenExclusiveModeEXT)(VkDevice device, VkSwapchainKHR swapchain);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkGetDeviceGroupSurfacePresentModes2EXT)(VkDevice device, const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo, VkDeviceGroupPresentModeFlagsKHR* pModes);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfacePresentModes2EXT(
|
||||
VkPhysicalDevice physicalDevice,
|
||||
const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo,
|
||||
uint32_t* pPresentModeCount,
|
||||
VkPresentModeKHR* pPresentModes);
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkAcquireFullScreenExclusiveModeEXT(
|
||||
VkDevice device,
|
||||
VkSwapchainKHR swapchain);
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkReleaseFullScreenExclusiveModeEXT(
|
||||
VkDevice device,
|
||||
VkSwapchainKHR swapchain);
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkGetDeviceGroupSurfacePresentModes2EXT(
|
||||
VkDevice device,
|
||||
const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo,
|
||||
VkDeviceGroupPresentModeFlagsKHR* pModes);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -1,24 +1,10 @@
|
||||
#ifndef VULKAN_XCB_H_
|
||||
#define VULKAN_XCB_H_ 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Copyright (c) 2015-2018 The Khronos Group Inc.
|
||||
** Copyright (c) 2015-2020 The Khronos Group Inc.
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -27,12 +13,16 @@ extern "C" {
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define VK_KHR_xcb_surface 1
|
||||
#define VK_KHR_XCB_SURFACE_SPEC_VERSION 6
|
||||
#define VK_KHR_XCB_SURFACE_EXTENSION_NAME "VK_KHR_xcb_surface"
|
||||
|
||||
typedef VkFlags VkXcbSurfaceCreateFlagsKHR;
|
||||
|
||||
typedef struct VkXcbSurfaceCreateInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
@@ -41,7 +31,6 @@ typedef struct VkXcbSurfaceCreateInfoKHR {
|
||||
xcb_window_t window;
|
||||
} VkXcbSurfaceCreateInfoKHR;
|
||||
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkCreateXcbSurfaceKHR)(VkInstance instance, const VkXcbSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
|
||||
typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, xcb_connection_t* connection, xcb_visualid_t visual_id);
|
||||
|
||||
|
@@ -1,24 +1,10 @@
|
||||
#ifndef VULKAN_XLIB_H_
|
||||
#define VULKAN_XLIB_H_ 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Copyright (c) 2015-2018 The Khronos Group Inc.
|
||||
** Copyright (c) 2015-2020 The Khronos Group Inc.
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -27,12 +13,16 @@ extern "C" {
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define VK_KHR_xlib_surface 1
|
||||
#define VK_KHR_XLIB_SURFACE_SPEC_VERSION 6
|
||||
#define VK_KHR_XLIB_SURFACE_EXTENSION_NAME "VK_KHR_xlib_surface"
|
||||
|
||||
typedef VkFlags VkXlibSurfaceCreateFlagsKHR;
|
||||
|
||||
typedef struct VkXlibSurfaceCreateInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
@@ -41,7 +31,6 @@ typedef struct VkXlibSurfaceCreateInfoKHR {
|
||||
Window window;
|
||||
} VkXlibSurfaceCreateInfoKHR;
|
||||
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkCreateXlibSurfaceKHR)(VkInstance instance, const VkXlibSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
|
||||
typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, Display* dpy, VisualID visualID);
|
||||
|
||||
|
@@ -1,24 +1,10 @@
|
||||
#ifndef VULKAN_XLIB_XRANDR_H_
|
||||
#define VULKAN_XLIB_XRANDR_H_ 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Copyright (c) 2015-2018 The Khronos Group Inc.
|
||||
** Copyright (c) 2015-2020 The Khronos Group Inc.
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -27,10 +13,15 @@ extern "C" {
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define VK_EXT_acquire_xlib_display 1
|
||||
#define VK_EXT_ACQUIRE_XLIB_DISPLAY_SPEC_VERSION 1
|
||||
#define VK_EXT_ACQUIRE_XLIB_DISPLAY_EXTENSION_NAME "VK_EXT_acquire_xlib_display"
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkAcquireXlibDisplayEXT)(VkPhysicalDevice physicalDevice, Display* dpy, VkDisplayKHR display);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkGetRandROutputDisplayEXT)(VkPhysicalDevice physicalDevice, Display* dpy, RROutput rrOutput, VkDisplayKHR* pDisplay);
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Atomic KMSDRM backend by Manuel Alfayate Corchete <redwindwanderer@gmail.com>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@@ -27,9 +28,6 @@
|
||||
|
||||
#include "SDL_kmsdrmdyn.h"
|
||||
|
||||
#if DEBUG_DYNAMIC_KMSDRM
|
||||
#include "SDL_log.h"
|
||||
#endif
|
||||
|
||||
#ifdef SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Atomic KMSDRM backend by Manuel Alfayate Corchete <redwindwanderer@gmail.com>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Atomic KMSDRM backend by Manuel Alfayate Corchete <redwindwanderer@gmail.com>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Atomic KMSDRM backend by Manuel Alfayate Corchete <redwindwanderer@gmail.com>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
622
externals/SDL/src/video/kmsdrm/SDL_kmsdrmmouse.c
vendored
622
externals/SDL/src/video/kmsdrm/SDL_kmsdrmmouse.c
vendored
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Atomic KMSDRM backend by Manuel Alfayate Corchete <redwindwanderer@gmail.com>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@@ -26,6 +27,7 @@
|
||||
#include "SDL_kmsdrmvideo.h"
|
||||
#include "SDL_kmsdrmmouse.h"
|
||||
#include "SDL_kmsdrmdyn.h"
|
||||
#include "SDL_assert.h"
|
||||
|
||||
#include "../../events/SDL_mouse_c.h"
|
||||
#include "../../events/default_cursor.h"
|
||||
@@ -38,276 +40,194 @@ static void KMSDRM_FreeCursor(SDL_Cursor * cursor);
|
||||
static void KMSDRM_WarpMouse(SDL_Window * window, int x, int y);
|
||||
static int KMSDRM_WarpMouseGlobal(int x, int y);
|
||||
|
||||
/**********************************/
|
||||
/* Atomic helper functions block. */
|
||||
/**********************************/
|
||||
|
||||
int
|
||||
drm_atomic_movecursor(KMSDRM_CursorData *curdata, uint16_t x, uint16_t y)
|
||||
{
|
||||
SDL_DisplayData *dispdata = (SDL_DisplayData *)SDL_GetDisplayDriverData(0);
|
||||
|
||||
if (!dispdata->cursor_plane) /* We can't move a non-existing cursor, but that's ok. */
|
||||
return 0;
|
||||
|
||||
/* Do we have a set of changes already in the making? If not, allocate a new one. */
|
||||
if (!dispdata->atomic_req)
|
||||
dispdata->atomic_req = KMSDRM_drmModeAtomicAlloc();
|
||||
|
||||
add_plane_property(dispdata->atomic_req,
|
||||
dispdata->cursor_plane, "CRTC_X", x - curdata->hot_x);
|
||||
add_plane_property(dispdata->atomic_req,
|
||||
dispdata->cursor_plane, "CRTC_Y", y - curdata->hot_y);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/***************************************/
|
||||
/* Atomic helper functions block ends. */
|
||||
/***************************************/
|
||||
|
||||
/* Converts a pixel from straight-alpha [AA, RR, GG, BB], which the SDL cursor surface has,
|
||||
to premultiplied-alpha [AA. AA*RR, AA*GG, AA*BB].
|
||||
These multiplications have to be done with floats instead of uint32_t's,
|
||||
and the resulting values have to be converted to be relative to the 0-255 interval,
|
||||
where 255 is 1.00 and anything between 0 and 255 is 0.xx. */
|
||||
void alpha_premultiply_ARGB8888 (uint32_t *pixel) {
|
||||
|
||||
uint32_t A, R, G, B;
|
||||
|
||||
/* Component bytes extraction. */
|
||||
A = (*pixel >> (3 << 3)) & 0xFF;
|
||||
R = (*pixel >> (2 << 3)) & 0xFF;
|
||||
G = (*pixel >> (1 << 3)) & 0xFF;
|
||||
B = (*pixel >> (0 << 3)) & 0xFF;
|
||||
|
||||
/* Alpha pre-multiplication of each component. */
|
||||
R = (float)A * ((float)R /255);
|
||||
G = (float)A * ((float)G /255);
|
||||
B = (float)A * ((float)B /255);
|
||||
|
||||
/* ARGB8888 pixel recomposition. */
|
||||
(*pixel) = (((uint32_t)A << 24) | ((uint32_t)R << 16) | ((uint32_t)G << 8)) | ((uint32_t)B << 0);
|
||||
}
|
||||
|
||||
static SDL_Cursor *
|
||||
KMSDRM_CreateDefaultCursor(void)
|
||||
{
|
||||
return SDL_CreateCursor(default_cdata, default_cmask, DEFAULT_CWIDTH, DEFAULT_CHEIGHT, DEFAULT_CHOTX, DEFAULT_CHOTY);
|
||||
}
|
||||
|
||||
/* Evaluate if a given cursor size is supported or not. Notably, current Intel gfx only support 64x64 and up. */
|
||||
static SDL_bool
|
||||
KMSDRM_IsCursorSizeSupported (int w, int h, uint32_t bo_format) {
|
||||
|
||||
SDL_VideoDevice *dev = SDL_GetVideoDevice();
|
||||
SDL_VideoData *viddata = ((SDL_VideoData *)dev->driverdata);
|
||||
SDL_DisplayData *dispdata = (SDL_DisplayData *)SDL_GetDisplayDriverData(0);
|
||||
|
||||
int ret;
|
||||
uint32_t bo_handle;
|
||||
struct gbm_bo *bo = KMSDRM_gbm_bo_create(viddata->gbm, w, h, bo_format,
|
||||
GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE);
|
||||
|
||||
if (!bo) {
|
||||
SDL_SetError("Could not create GBM cursor BO width size %dx%d for size testing", w, h);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
bo_handle = KMSDRM_gbm_bo_get_handle(bo).u32;
|
||||
ret = KMSDRM_drmModeSetCursor(viddata->drm_fd, dispdata->crtc_id, bo_handle, w, h);
|
||||
|
||||
if (ret) {
|
||||
goto cleanup;
|
||||
}
|
||||
else {
|
||||
KMSDRM_gbm_bo_destroy(bo);
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
if (bo) {
|
||||
KMSDRM_gbm_bo_destroy(bo);
|
||||
}
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
/* Create a cursor from a surface */
|
||||
/* This simply gets the cursor soft-buffer ready. We don't copy it to a GBO BO until ShowCursor()
|
||||
because the cusor GBM BO (living in dispata) is destroyed and recreated when we recreate windows, etc. */
|
||||
static SDL_Cursor *
|
||||
KMSDRM_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
|
||||
{
|
||||
SDL_VideoDevice *dev = SDL_GetVideoDevice();
|
||||
SDL_VideoData *viddata = ((SDL_VideoData *)dev->driverdata);
|
||||
SDL_PixelFormat *pixlfmt = surface->format;
|
||||
KMSDRM_CursorData *curdata;
|
||||
SDL_Cursor *cursor;
|
||||
SDL_bool cursor_supported = SDL_FALSE;
|
||||
int i, ret, usable_cursor_w, usable_cursor_h;
|
||||
uint32_t bo_format, bo_stride;
|
||||
char *buffer = NULL;
|
||||
size_t bufsize;
|
||||
SDL_Cursor *cursor, *ret;
|
||||
|
||||
switch(pixlfmt->format) {
|
||||
case SDL_PIXELFORMAT_RGB332:
|
||||
bo_format = GBM_FORMAT_RGB332;
|
||||
break;
|
||||
case SDL_PIXELFORMAT_ARGB4444:
|
||||
bo_format = GBM_FORMAT_ARGB4444;
|
||||
break;
|
||||
case SDL_PIXELFORMAT_RGBA4444:
|
||||
bo_format = GBM_FORMAT_RGBA4444;
|
||||
break;
|
||||
case SDL_PIXELFORMAT_ABGR4444:
|
||||
bo_format = GBM_FORMAT_ABGR4444;
|
||||
break;
|
||||
case SDL_PIXELFORMAT_BGRA4444:
|
||||
bo_format = GBM_FORMAT_BGRA4444;
|
||||
break;
|
||||
case SDL_PIXELFORMAT_ARGB1555:
|
||||
bo_format = GBM_FORMAT_ARGB1555;
|
||||
break;
|
||||
case SDL_PIXELFORMAT_RGBA5551:
|
||||
bo_format = GBM_FORMAT_RGBA5551;
|
||||
break;
|
||||
case SDL_PIXELFORMAT_ABGR1555:
|
||||
bo_format = GBM_FORMAT_ABGR1555;
|
||||
break;
|
||||
case SDL_PIXELFORMAT_BGRA5551:
|
||||
bo_format = GBM_FORMAT_BGRA5551;
|
||||
break;
|
||||
case SDL_PIXELFORMAT_RGB565:
|
||||
bo_format = GBM_FORMAT_RGB565;
|
||||
break;
|
||||
case SDL_PIXELFORMAT_BGR565:
|
||||
bo_format = GBM_FORMAT_BGR565;
|
||||
break;
|
||||
case SDL_PIXELFORMAT_RGB888:
|
||||
case SDL_PIXELFORMAT_RGB24:
|
||||
bo_format = GBM_FORMAT_RGB888;
|
||||
break;
|
||||
case SDL_PIXELFORMAT_BGR888:
|
||||
case SDL_PIXELFORMAT_BGR24:
|
||||
bo_format = GBM_FORMAT_BGR888;
|
||||
break;
|
||||
case SDL_PIXELFORMAT_RGBX8888:
|
||||
bo_format = GBM_FORMAT_RGBX8888;
|
||||
break;
|
||||
case SDL_PIXELFORMAT_BGRX8888:
|
||||
bo_format = GBM_FORMAT_BGRX8888;
|
||||
break;
|
||||
case SDL_PIXELFORMAT_ARGB8888:
|
||||
bo_format = GBM_FORMAT_ARGB8888;
|
||||
break;
|
||||
case SDL_PIXELFORMAT_RGBA8888:
|
||||
bo_format = GBM_FORMAT_RGBA8888;
|
||||
break;
|
||||
case SDL_PIXELFORMAT_ABGR8888:
|
||||
bo_format = GBM_FORMAT_ABGR8888;
|
||||
break;
|
||||
case SDL_PIXELFORMAT_BGRA8888:
|
||||
bo_format = GBM_FORMAT_BGRA8888;
|
||||
break;
|
||||
case SDL_PIXELFORMAT_ARGB2101010:
|
||||
bo_format = GBM_FORMAT_ARGB2101010;
|
||||
break;
|
||||
default:
|
||||
SDL_SetError("Unsupported pixel format for cursor");
|
||||
return NULL;
|
||||
}
|
||||
curdata = NULL;
|
||||
ret = NULL;
|
||||
|
||||
if (!KMSDRM_gbm_device_is_format_supported(viddata->gbm, bo_format, GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE)) {
|
||||
SDL_SetError("Unsupported pixel format for cursor");
|
||||
return NULL;
|
||||
}
|
||||
/* All code below assumes ARGB8888 format for the cursor surface,
|
||||
like other backends do. Also, the GBM BO pixels have to be
|
||||
alpha-premultiplied, but the SDL surface we receive has
|
||||
straight-alpha pixels, so we always have to convert. */
|
||||
SDL_assert(surface->format->format == SDL_PIXELFORMAT_ARGB8888);
|
||||
SDL_assert(surface->pitch == surface->w * 4);
|
||||
|
||||
cursor = (SDL_Cursor *) SDL_calloc(1, sizeof(*cursor));
|
||||
if (!cursor) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
goto cleanup;
|
||||
}
|
||||
curdata = (KMSDRM_CursorData *) SDL_calloc(1, sizeof(*curdata));
|
||||
if (!curdata) {
|
||||
SDL_OutOfMemory();
|
||||
SDL_free(cursor);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* We have to know beforehand if a cursor with the same size as the surface is supported.
|
||||
* If it's not, we have to find an usable cursor size and use an intermediate and clean buffer.
|
||||
* If we can't find a cursor size supported by the hardware, we won't go on trying to
|
||||
* call SDL_SetCursor() later. */
|
||||
|
||||
usable_cursor_w = surface->w;
|
||||
usable_cursor_h = surface->h;
|
||||
|
||||
while (usable_cursor_w <= MAX_CURSOR_W && usable_cursor_h <= MAX_CURSOR_H) {
|
||||
if (KMSDRM_IsCursorSizeSupported(usable_cursor_w, usable_cursor_h, bo_format)) {
|
||||
cursor_supported = SDL_TRUE;
|
||||
break;
|
||||
}
|
||||
usable_cursor_w += usable_cursor_w;
|
||||
usable_cursor_h += usable_cursor_h;
|
||||
}
|
||||
|
||||
if (!cursor_supported) {
|
||||
SDL_SetError("Could not find a cursor size supported by the kernel driver");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* hox_x and hot_y are the coordinates of the "tip of the cursor" from it's base. */
|
||||
curdata->hot_x = hot_x;
|
||||
curdata->hot_y = hot_y;
|
||||
curdata->w = usable_cursor_w;
|
||||
curdata->h = usable_cursor_h;
|
||||
curdata->w = surface->w;
|
||||
curdata->h = surface->h;
|
||||
curdata->buffer = NULL;
|
||||
|
||||
curdata->bo = KMSDRM_gbm_bo_create(viddata->gbm, usable_cursor_w, usable_cursor_h, bo_format,
|
||||
GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE);
|
||||
/* Configure the cursor buffer info.
|
||||
This buffer has the original size of the cursor surface we are given. */
|
||||
curdata->buffer_pitch = surface->pitch;
|
||||
curdata->buffer_size = surface->pitch * surface->h;
|
||||
curdata->buffer = (uint32_t*)SDL_malloc(curdata->buffer_size);
|
||||
|
||||
if (!curdata->bo) {
|
||||
SDL_SetError("Could not create GBM cursor BO");
|
||||
if (!curdata->buffer) {
|
||||
SDL_OutOfMemory();
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
bo_stride = KMSDRM_gbm_bo_get_stride(curdata->bo);
|
||||
bufsize = bo_stride * curdata->h;
|
||||
|
||||
if (surface->pitch != bo_stride) {
|
||||
/* pitch doesn't match stride, must be copied to temp buffer */
|
||||
buffer = SDL_malloc(bufsize);
|
||||
if (!buffer) {
|
||||
SDL_OutOfMemory();
|
||||
if (SDL_MUSTLOCK(surface)) {
|
||||
if (SDL_LockSurface(surface) < 0) {
|
||||
/* Could not lock surface */
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
if (SDL_MUSTLOCK(surface)) {
|
||||
if (SDL_LockSurface(surface) < 0) {
|
||||
/* Could not lock surface */
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
/* Copy the surface pixels to the cursor buffer, for future use in ShowCursor() */
|
||||
SDL_memcpy(curdata->buffer, surface->pixels, curdata->buffer_size);
|
||||
|
||||
/* Clean the whole temporary buffer */
|
||||
SDL_memset(buffer, 0x00, bo_stride * curdata->h);
|
||||
|
||||
/* Copy to temporary buffer */
|
||||
for (i = 0; i < surface->h; i++) {
|
||||
SDL_memcpy(buffer + (i * bo_stride),
|
||||
((char *)surface->pixels) + (i * surface->pitch),
|
||||
surface->w * pixlfmt->BytesPerPixel);
|
||||
}
|
||||
|
||||
if (SDL_MUSTLOCK(surface)) {
|
||||
SDL_UnlockSurface(surface);
|
||||
}
|
||||
|
||||
if (KMSDRM_gbm_bo_write(curdata->bo, buffer, bufsize)) {
|
||||
SDL_SetError("Could not write to GBM cursor BO");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* Free temporary buffer */
|
||||
SDL_free(buffer);
|
||||
buffer = NULL;
|
||||
} else {
|
||||
/* surface matches BO format */
|
||||
if (SDL_MUSTLOCK(surface)) {
|
||||
if (SDL_LockSurface(surface) < 0) {
|
||||
/* Could not lock surface */
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
ret = KMSDRM_gbm_bo_write(curdata->bo, surface->pixels, bufsize);
|
||||
|
||||
if (SDL_MUSTLOCK(surface)) {
|
||||
SDL_UnlockSurface(surface);
|
||||
}
|
||||
|
||||
if (ret) {
|
||||
SDL_SetError("Could not write to GBM cursor BO");
|
||||
goto cleanup;
|
||||
}
|
||||
if (SDL_MUSTLOCK(surface)) {
|
||||
SDL_UnlockSurface(surface);
|
||||
}
|
||||
|
||||
cursor->driverdata = curdata;
|
||||
|
||||
return cursor;
|
||||
ret = cursor;
|
||||
|
||||
cleanup:
|
||||
if (buffer) {
|
||||
SDL_free(buffer);
|
||||
if (ret == NULL) {
|
||||
if (curdata) {
|
||||
if (curdata->buffer) {
|
||||
SDL_free(curdata->buffer);
|
||||
}
|
||||
SDL_free(curdata);
|
||||
}
|
||||
if (cursor) {
|
||||
SDL_free(cursor);
|
||||
}
|
||||
}
|
||||
if (cursor) {
|
||||
SDL_free(cursor);
|
||||
}
|
||||
if (curdata) {
|
||||
if (curdata->bo) {
|
||||
KMSDRM_gbm_bo_destroy(curdata->bo);
|
||||
}
|
||||
SDL_free(curdata);
|
||||
}
|
||||
return NULL;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Show the specified cursor, or hide if cursor is NULL */
|
||||
/* When we create a window, we have to test if we have to show the cursor,
|
||||
and explicily do so if necessary.
|
||||
This is because when we destroy a window, we take the cursor away from the
|
||||
cursor plane, and destroy the cusror GBM BO. So we have to re-show it,
|
||||
so to say. */
|
||||
void
|
||||
KMSDRM_InitCursor()
|
||||
{
|
||||
SDL_Mouse *mouse = NULL;
|
||||
mouse = SDL_GetMouse();
|
||||
|
||||
if (!mouse) {
|
||||
return;
|
||||
}
|
||||
if (!(mouse->cur_cursor)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(mouse->cursor_shown)) {
|
||||
return;
|
||||
}
|
||||
|
||||
KMSDRM_ShowCursor(mouse->cur_cursor);
|
||||
}
|
||||
|
||||
/* Show the specified cursor, or hide if cursor is NULL.
|
||||
cur_cursor is the current cursor, and cursor is the new cursor.
|
||||
A cursor is displayed on a display, so we have to add a pointer to dispdata
|
||||
to the driverdata
|
||||
*/
|
||||
static int
|
||||
KMSDRM_ShowCursor(SDL_Cursor * cursor)
|
||||
{
|
||||
SDL_VideoDevice *dev = SDL_GetVideoDevice();
|
||||
SDL_VideoData *viddata = ((SDL_VideoData *)dev->driverdata);
|
||||
SDL_VideoDevice *video_device = SDL_GetVideoDevice();
|
||||
//SDL_VideoData *viddata = ((SDL_VideoData *)dev->driverdata);
|
||||
SDL_Mouse *mouse;
|
||||
KMSDRM_CursorData *curdata;
|
||||
SDL_VideoDisplay *display = NULL;
|
||||
SDL_DisplayData *dispdata = NULL;
|
||||
KMSDRM_FBInfo *fb;
|
||||
KMSDRM_PlaneInfo info = {0};
|
||||
|
||||
size_t bo_stride;
|
||||
size_t bufsize;
|
||||
uint32_t *ready_buffer = NULL;
|
||||
uint32_t pixel;
|
||||
|
||||
int i,j;
|
||||
int ret;
|
||||
uint32_t bo_handle;
|
||||
|
||||
mouse = SDL_GetMouse();
|
||||
if (!mouse) {
|
||||
@@ -321,87 +241,121 @@ KMSDRM_ShowCursor(SDL_Cursor * cursor)
|
||||
}
|
||||
}
|
||||
|
||||
/**********************************/
|
||||
/* if cursor == NULL, HIDE cursor */
|
||||
/**********************************/
|
||||
if (!cursor) {
|
||||
/* Hide current cursor */
|
||||
/* Hide CURRENT cursor, a cursor that is already on screen
|
||||
and SDL is stored in mouse->cur_cursor. */
|
||||
if (mouse->cur_cursor && mouse->cur_cursor->driverdata) {
|
||||
curdata = (KMSDRM_CursorData *) mouse->cur_cursor->driverdata;
|
||||
|
||||
if (curdata->crtc_id != 0) {
|
||||
ret = KMSDRM_drmModeSetCursor(viddata->drm_fd, curdata->crtc_id, 0, 0, 0);
|
||||
if (ret) {
|
||||
SDL_SetError("Could not hide current cursor with drmModeSetCursor().");
|
||||
return ret;
|
||||
if (dispdata && dispdata->cursor_plane) {
|
||||
info.plane = dispdata->cursor_plane;
|
||||
/* The rest of the members are zeroed. */
|
||||
drm_atomic_set_plane_props(&info);
|
||||
if (drm_atomic_commit(display->device, SDL_TRUE))
|
||||
return SDL_SetError("Failed atomic commit in KMSDRM_ShowCursor.");
|
||||
}
|
||||
/* Mark previous cursor as not-displayed */
|
||||
curdata->crtc_id = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/* otherwise if possible, hide global cursor */
|
||||
if (dispdata && dispdata->crtc_id != 0) {
|
||||
ret = KMSDRM_drmModeSetCursor(viddata->drm_fd, dispdata->crtc_id, 0, 0, 0);
|
||||
if (ret) {
|
||||
SDL_SetError("Could not hide display's cursor with drmModeSetCursor().");
|
||||
return ret;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
return SDL_SetError("Couldn't find cursor to hide.");
|
||||
}
|
||||
/* If cursor != NULL, show new cursor on display */
|
||||
|
||||
/************************************************/
|
||||
/* If cursor != NULL, DO show cursor on display */
|
||||
/************************************************/
|
||||
if (!display) {
|
||||
return SDL_SetError("Could not get display for mouse.");
|
||||
}
|
||||
if (!dispdata) {
|
||||
return SDL_SetError("Could not get display driverdata.");
|
||||
}
|
||||
|
||||
if (!dispdata->cursor_plane) {
|
||||
return SDL_SetError("Hardware cursor plane not initialized.");
|
||||
}
|
||||
|
||||
curdata = (KMSDRM_CursorData *) cursor->driverdata;
|
||||
if (!curdata || !curdata->bo) {
|
||||
|
||||
if (!curdata || !dispdata->cursor_bo) {
|
||||
return SDL_SetError("Cursor not initialized properly.");
|
||||
}
|
||||
|
||||
bo_handle = KMSDRM_gbm_bo_get_handle(curdata->bo).u32;
|
||||
if (curdata->hot_x == 0 && curdata->hot_y == 0) {
|
||||
ret = KMSDRM_drmModeSetCursor(viddata->drm_fd, dispdata->crtc_id, bo_handle,
|
||||
curdata->w, curdata->h);
|
||||
} else {
|
||||
ret = KMSDRM_drmModeSetCursor2(viddata->drm_fd, dispdata->crtc_id, bo_handle,
|
||||
curdata->w, curdata->h, curdata->hot_x, curdata->hot_y);
|
||||
}
|
||||
if (ret) {
|
||||
SDL_SetError("drmModeSetCursor failed.");
|
||||
return ret;
|
||||
/* Prepare a buffer we can dump to our GBM BO (different size, alpha premultiplication...) */
|
||||
bo_stride = KMSDRM_gbm_bo_get_stride(dispdata->cursor_bo);
|
||||
bufsize = bo_stride * curdata->h;
|
||||
|
||||
ready_buffer = (uint32_t*)SDL_malloc(bufsize);
|
||||
if (!ready_buffer) {
|
||||
ret = SDL_OutOfMemory();
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
curdata->crtc_id = dispdata->crtc_id;
|
||||
/* Clean the whole buffer we are preparing. */
|
||||
SDL_memset(ready_buffer, 0x00, bo_stride * curdata->h);
|
||||
|
||||
return 0;
|
||||
/* Copy from the cursor buffer to a buffer that we can dump to the GBM BO,
|
||||
pre-multiplying by alpha each pixel as we go. */
|
||||
for (i = 0; i < curdata->h; i++) {
|
||||
for (j = 0; j < curdata->w; j++) {
|
||||
pixel = ((uint32_t*)curdata->buffer)[i * curdata->w + j];
|
||||
alpha_premultiply_ARGB8888 (&pixel);
|
||||
SDL_memcpy(ready_buffer + (i * dispdata->cursor_w) + j, &pixel, 4);
|
||||
}
|
||||
}
|
||||
|
||||
/* Dump the cursor buffer to our GBM BO. */
|
||||
if (KMSDRM_gbm_bo_write(dispdata->cursor_bo, ready_buffer, bufsize)) {
|
||||
ret = SDL_SetError("Could not write to GBM cursor BO");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* Get the fb_id for the GBM BO so we can show it on the cursor plane. */
|
||||
fb = KMSDRM_FBFromBO(video_device, dispdata->cursor_bo);
|
||||
|
||||
/* Show the GBM BO buffer on the cursor plane. */
|
||||
info.plane = dispdata->cursor_plane;
|
||||
info.crtc_id = dispdata->crtc->crtc->crtc_id;
|
||||
info.fb_id = fb->fb_id;
|
||||
info.src_w = curdata->w;
|
||||
info.src_h = curdata->h;
|
||||
info.crtc_x = mouse->x - curdata->hot_x;
|
||||
info.crtc_y = mouse->y - curdata->hot_y;
|
||||
info.crtc_w = curdata->w;
|
||||
info.crtc_h = curdata->h;
|
||||
|
||||
drm_atomic_set_plane_props(&info);
|
||||
|
||||
if (drm_atomic_commit(display->device, SDL_TRUE)) {
|
||||
ret = SDL_SetError("Failed atomic commit in KMSDRM_ShowCursor.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
|
||||
if (ready_buffer) {
|
||||
SDL_free(ready_buffer);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Free a window manager cursor */
|
||||
/* We have destroyed the cursor by now, in KMSDRM_DestroyCursor.
|
||||
This is only for freeing the SDL_cursor.*/
|
||||
static void
|
||||
KMSDRM_FreeCursor(SDL_Cursor * cursor)
|
||||
{
|
||||
KMSDRM_CursorData *curdata;
|
||||
int drm_fd;
|
||||
|
||||
/* Even if the cursor is not ours, free it. */
|
||||
if (cursor) {
|
||||
curdata = (KMSDRM_CursorData *) cursor->driverdata;
|
||||
|
||||
if (curdata) {
|
||||
if (curdata->bo) {
|
||||
if (curdata->crtc_id != 0) {
|
||||
drm_fd = KMSDRM_gbm_device_get_fd(KMSDRM_gbm_bo_get_device(curdata->bo));
|
||||
/* Hide the cursor if previously shown on a CRTC */
|
||||
KMSDRM_drmModeSetCursor(drm_fd, curdata->crtc_id, 0, 0, 0);
|
||||
curdata->crtc_id = 0;
|
||||
}
|
||||
KMSDRM_gbm_bo_destroy(curdata->bo);
|
||||
curdata->bo = NULL;
|
||||
}
|
||||
/* Free cursor buffer */
|
||||
if (curdata->buffer) {
|
||||
SDL_free(curdata->buffer);
|
||||
curdata->buffer = NULL;
|
||||
}
|
||||
/* Free cursor itself */
|
||||
if (cursor->driverdata) {
|
||||
SDL_free(cursor->driverdata);
|
||||
}
|
||||
SDL_free(cursor);
|
||||
@@ -422,6 +376,7 @@ KMSDRM_WarpMouseGlobal(int x, int y)
|
||||
{
|
||||
KMSDRM_CursorData *curdata;
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
SDL_DisplayData *dispdata = (SDL_DisplayData *)SDL_GetDisplayDriverData(0);
|
||||
|
||||
if (mouse && mouse->cur_cursor && mouse->cur_cursor->driverdata) {
|
||||
/* Update internal mouse position. */
|
||||
@@ -429,20 +384,9 @@ KMSDRM_WarpMouseGlobal(int x, int y)
|
||||
|
||||
/* And now update the cursor graphic position on screen. */
|
||||
curdata = (KMSDRM_CursorData *) mouse->cur_cursor->driverdata;
|
||||
if (curdata->bo) {
|
||||
|
||||
if (curdata->crtc_id != 0) {
|
||||
int ret, drm_fd;
|
||||
drm_fd = KMSDRM_gbm_device_get_fd(KMSDRM_gbm_bo_get_device(curdata->bo));
|
||||
ret = KMSDRM_drmModeMoveCursor(drm_fd, curdata->crtc_id, x, y);
|
||||
|
||||
if (ret) {
|
||||
SDL_SetError("drmModeMoveCursor() failed.");
|
||||
}
|
||||
|
||||
return ret;
|
||||
} else {
|
||||
return SDL_SetError("Cursor is not currently shown.");
|
||||
if (dispdata->cursor_bo) {
|
||||
if (drm_atomic_movecursor(curdata, x, y)) {
|
||||
return SDL_SetError("drm_atomic_movecursor() failed.");
|
||||
}
|
||||
} else {
|
||||
return SDL_SetError("Cursor not initialized properly.");
|
||||
@@ -450,6 +394,8 @@ KMSDRM_WarpMouseGlobal(int x, int y)
|
||||
} else {
|
||||
return SDL_SetError("No mouse or current cursor.");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -458,7 +404,12 @@ KMSDRM_InitMouse(_THIS)
|
||||
/* FIXME: Using UDEV it should be possible to scan all mice
|
||||
* but there's no point in doing so as there's no multimice support...yet!
|
||||
*/
|
||||
|
||||
SDL_VideoDevice *dev = SDL_GetVideoDevice();
|
||||
SDL_VideoData *viddata = ((SDL_VideoData *)dev->driverdata);
|
||||
SDL_DisplayData *dispdata = (SDL_DisplayData *)SDL_GetDisplayDriverData(0);
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
uint64_t usable_cursor_w, usable_cursor_h;
|
||||
|
||||
mouse->CreateCursor = KMSDRM_CreateCursor;
|
||||
mouse->ShowCursor = KMSDRM_ShowCursor;
|
||||
@@ -467,13 +418,96 @@ KMSDRM_InitMouse(_THIS)
|
||||
mouse->WarpMouse = KMSDRM_WarpMouse;
|
||||
mouse->WarpMouseGlobal = KMSDRM_WarpMouseGlobal;
|
||||
|
||||
/***************************************************************************/
|
||||
/* REMEMBER TO BE SURE OF UNDOING ALL THESE STEPS PROPERLY BEFORE CALLING */
|
||||
/* gbm_device_destroy, OR YOU WON'T BE ABLE TO CREATE A NEW ONE (ERROR -13 */
|
||||
/* ON gbm_create_device). */
|
||||
/***************************************************************************/
|
||||
|
||||
/* 1- Init cursor plane, if we haven't yet. */
|
||||
if (!dispdata->cursor_plane) {
|
||||
setup_plane(_this, &(dispdata->cursor_plane), DRM_PLANE_TYPE_CURSOR);
|
||||
}
|
||||
|
||||
/* 2- Create the cursor GBM BO, if we haven't yet. */
|
||||
if (!dispdata->cursor_bo) {
|
||||
|
||||
if (!KMSDRM_gbm_device_is_format_supported(viddata->gbm_dev, GBM_FORMAT_ARGB8888,
|
||||
GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE))
|
||||
{
|
||||
SDL_SetError("Unsupported pixel format for cursor");
|
||||
return;
|
||||
}
|
||||
|
||||
if (KMSDRM_drmGetCap(viddata->drm_fd, DRM_CAP_CURSOR_WIDTH, &usable_cursor_w) ||
|
||||
KMSDRM_drmGetCap(viddata->drm_fd, DRM_CAP_CURSOR_HEIGHT, &usable_cursor_h))
|
||||
{
|
||||
SDL_SetError("Could not get the recommended GBM cursor size");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (usable_cursor_w == 0 || usable_cursor_h == 0) {
|
||||
SDL_SetError("Could not get an usable GBM cursor size");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
dispdata->cursor_w = usable_cursor_w;
|
||||
dispdata->cursor_h = usable_cursor_h;
|
||||
|
||||
dispdata->cursor_bo = KMSDRM_gbm_bo_create(viddata->gbm_dev,
|
||||
usable_cursor_w, usable_cursor_h,
|
||||
GBM_FORMAT_ARGB8888, GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE);
|
||||
|
||||
if (!dispdata->cursor_bo) {
|
||||
SDL_SetError("Could not create GBM cursor BO");
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
/* SDL expects to set the default cursor on screen when we init the mouse. */
|
||||
SDL_SetDefaultCursor(KMSDRM_CreateDefaultCursor());
|
||||
|
||||
return;
|
||||
|
||||
cleanup:
|
||||
if (dispdata->cursor_bo) {
|
||||
KMSDRM_gbm_bo_destroy(dispdata->cursor_bo);
|
||||
dispdata->cursor_bo = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
KMSDRM_QuitMouse(_THIS)
|
||||
KMSDRM_DeinitMouse(_THIS)
|
||||
{
|
||||
/* TODO: ? */
|
||||
SDL_VideoDevice *video_device = SDL_GetVideoDevice();
|
||||
SDL_DisplayData *dispdata = (SDL_DisplayData *)SDL_GetDisplayDriverData(0);
|
||||
KMSDRM_PlaneInfo info = {0};
|
||||
|
||||
/*******************************************/
|
||||
/* UNDO WHAT WE DID IN KMSDRM_InitMouse(). */
|
||||
/*******************************************/
|
||||
|
||||
/* 1- Destroy the curso GBM BO. */
|
||||
if (video_device && dispdata->cursor_bo) {
|
||||
/* Unsethe the cursor BO from the cursor plane.
|
||||
(The other members of the plane info are zeroed). */
|
||||
info.plane = dispdata->cursor_plane;
|
||||
drm_atomic_set_plane_props(&info);
|
||||
/* Wait until the cursor is unset from the cursor plane
|
||||
before destroying it's BO. */
|
||||
if (drm_atomic_commit(video_device, SDL_TRUE)) {
|
||||
SDL_SetError("Failed atomic commit in KMSDRM_DenitMouse.");
|
||||
}
|
||||
/* ..and finally destroy the cursor DRM BO! */
|
||||
KMSDRM_gbm_bo_destroy(dispdata->cursor_bo);
|
||||
dispdata->cursor_bo = NULL;
|
||||
}
|
||||
|
||||
/* 2- Free the cursor plane, on which the cursor was being shown. */
|
||||
if (dispdata->cursor_plane) {
|
||||
free_plane(&dispdata->cursor_plane);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* This is called when a mouse motion event occurs */
|
||||
@@ -482,17 +516,21 @@ KMSDRM_MoveCursor(SDL_Cursor * cursor)
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
KMSDRM_CursorData *curdata;
|
||||
int drm_fd, ret;
|
||||
|
||||
/* We must NOT call SDL_SendMouseMotion() here or we will enter recursivity!
|
||||
That's why we move the cursor graphic ONLY. */
|
||||
if (mouse && mouse->cur_cursor && mouse->cur_cursor->driverdata) {
|
||||
curdata = (KMSDRM_CursorData *) mouse->cur_cursor->driverdata;
|
||||
drm_fd = KMSDRM_gbm_device_get_fd(KMSDRM_gbm_bo_get_device(curdata->bo));
|
||||
ret = KMSDRM_drmModeMoveCursor(drm_fd, curdata->crtc_id, mouse->x, mouse->y);
|
||||
|
||||
if (ret) {
|
||||
SDL_SetError("drmModeMoveCursor() failed.");
|
||||
/* Some programs expect cursor movement even while they don't do SwapWindow() calls,
|
||||
and since we ride on the atomic_commit() in SwapWindow() for cursor movement,
|
||||
cursor won't move in these situations. We could do an atomic_commit() here
|
||||
for each cursor movement request, but it cripples the movement to 30FPS,
|
||||
so a future solution is needed. SDLPoP "QUIT?" menu is an example of this
|
||||
situation. */
|
||||
|
||||
if (drm_atomic_movecursor(curdata, mouse->x, mouse->y)) {
|
||||
SDL_SetError("drm_atomic_movecursor() failed.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
19
externals/SDL/src/video/kmsdrm/SDL_kmsdrmmouse.h
vendored
19
externals/SDL/src/video/kmsdrm/SDL_kmsdrmmouse.h
vendored
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Atomic KMSDRM backend by Manuel Alfayate Corchete <redwindwanderer@gmail.com>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@@ -29,16 +30,24 @@
|
||||
#define MAX_CURSOR_W 512
|
||||
#define MAX_CURSOR_H 512
|
||||
|
||||
/* Driverdata with driver-side info about the cursor. */
|
||||
typedef struct _KMSDRM_CursorData
|
||||
{
|
||||
struct gbm_bo *bo;
|
||||
uint32_t crtc_id;
|
||||
int hot_x, hot_y;
|
||||
int w, h;
|
||||
uint16_t hot_x, hot_y;
|
||||
uint16_t w, h;
|
||||
|
||||
/* The buffer where we store the mouse bitmap ready to be used.
|
||||
We get it ready and filled in CreateCursor(), and copy it to a GBM BO in ShowCursor().*/
|
||||
uint32_t *buffer;
|
||||
size_t buffer_size;
|
||||
size_t buffer_pitch;
|
||||
|
||||
} KMSDRM_CursorData;
|
||||
|
||||
extern void KMSDRM_InitMouse(_THIS);
|
||||
extern void KMSDRM_QuitMouse(_THIS);
|
||||
extern void KMSDRM_DeinitMouse(_THIS);
|
||||
|
||||
extern void KMSDRM_InitCursor();
|
||||
|
||||
#endif /* SDL_KMSDRM_mouse_h_ */
|
||||
|
||||
|
373
externals/SDL/src/video/kmsdrm/SDL_kmsdrmopengles.c
vendored
373
externals/SDL/src/video/kmsdrm/SDL_kmsdrmopengles.c
vendored
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Atomic KMSDRM backend by Manuel Alfayate Corchete <redwindwanderer@gmail.com>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@@ -23,22 +24,59 @@
|
||||
|
||||
#if SDL_VIDEO_DRIVER_KMSDRM && SDL_VIDEO_OPENGL_EGL
|
||||
|
||||
#include "SDL_log.h"
|
||||
|
||||
#include "SDL_kmsdrmvideo.h"
|
||||
#include "SDL_kmsdrmopengles.h"
|
||||
#include "SDL_kmsdrmdyn.h"
|
||||
#include "SDL_hints.h"
|
||||
|
||||
#ifndef EGL_PLATFORM_GBM_MESA
|
||||
#define EGL_PLATFORM_GBM_MESA 0x31D7
|
||||
#endif
|
||||
|
||||
#ifndef EGL_SYNC_NATIVE_FENCE_ANDROID
|
||||
#define EGL_SYNC_NATIVE_FENCE_ANDROID 0x3144
|
||||
#endif
|
||||
|
||||
#ifndef EGL_SYNC_NATIVE_FENCE_FD_ANDROID
|
||||
#define EGL_SYNC_NATIVE_FENCE_FD_ANDROID 0x3145
|
||||
#endif
|
||||
|
||||
#ifndef EGL_NO_NATIVE_FENCE_FD_ANDROID
|
||||
#define EGL_NO_NATIVE_FENCE_FD_ANDROID -1
|
||||
#endif
|
||||
|
||||
/* EGL implementation of SDL OpenGL support */
|
||||
|
||||
void
|
||||
KMSDRM_GLES_DefaultProfileConfig(_THIS, int *mask, int *major, int *minor)
|
||||
{
|
||||
/* if SDL was _also_ built with the Raspberry Pi driver (so we're
|
||||
definitely a Pi device), default to GLES2. */
|
||||
#if SDL_VIDEO_DRIVER_RPI
|
||||
*mask = SDL_GL_CONTEXT_PROFILE_ES;
|
||||
*major = 2;
|
||||
*minor = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
KMSDRM_GLES_LoadLibrary(_THIS, const char *path) {
|
||||
NativeDisplayType display = (NativeDisplayType)((SDL_VideoData *)_this->driverdata)->gbm;
|
||||
/* Just pretend you do this here, but don't do it until KMSDRM_CreateWindow(),
|
||||
where we do the same library load we would normally do here.
|
||||
because this gets called by SDL_CreateWindow() before KMSDR_CreateWindow(),
|
||||
so gbm dev isn't yet created when this is called, AND we can't alter the
|
||||
call order in SDL_CreateWindow(). */
|
||||
#if 0
|
||||
NativeDisplayType display = (NativeDisplayType)((SDL_VideoData *)_this->driverdata)->gbm_dev;
|
||||
return SDL_EGL_LoadLibrary(_this, path, display, EGL_PLATFORM_GBM_MESA);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
KMSDRM_GLES_UnloadLibrary(_THIS) {
|
||||
/* As with KMSDRM_GLES_LoadLibrary(), we define our own unloading function so
|
||||
we manually unload the library whenever we want. */
|
||||
}
|
||||
|
||||
SDL_EGL_CreateContext_impl(KMSDRM)
|
||||
@@ -57,94 +95,285 @@ int KMSDRM_GLES_SetSwapInterval(_THIS, int interval) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*********************************/
|
||||
/* Atomic functions block */
|
||||
/*********************************/
|
||||
|
||||
#define VOID2U64(x) ((uint64_t)(unsigned long)(x))
|
||||
|
||||
static EGLSyncKHR create_fence(int fd, _THIS)
|
||||
{
|
||||
EGLint attrib_list[] = {
|
||||
EGL_SYNC_NATIVE_FENCE_FD_ANDROID, fd,
|
||||
EGL_NONE,
|
||||
};
|
||||
|
||||
EGLSyncKHR fence = _this->egl_data->eglCreateSyncKHR
|
||||
(_this->egl_data->egl_display, EGL_SYNC_NATIVE_FENCE_ANDROID, attrib_list);
|
||||
|
||||
assert(fence);
|
||||
return fence;
|
||||
}
|
||||
|
||||
/***********************************************************************************/
|
||||
/* Comments about buffer access protection mechanism (=fences) are the ones boxed. */
|
||||
/* Also, DON'T remove the asserts: if a fence-related call fails, it's better that */
|
||||
/* program exits immediately, or we could leave KMS waiting for a failed/missing */
|
||||
/* fence forevever. */
|
||||
/***********************************************************************************/
|
||||
int
|
||||
KMSDRM_GLES_SwapWindow(_THIS, SDL_Window * window) {
|
||||
KMSDRM_GLES_SwapWindowFenced(_THIS, SDL_Window * window)
|
||||
{
|
||||
SDL_WindowData *windata = ((SDL_WindowData *) window->driverdata);
|
||||
SDL_DisplayData *dispdata = (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata;
|
||||
SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
|
||||
KMSDRM_FBInfo *fb_info;
|
||||
int ret, timeout;
|
||||
KMSDRM_FBInfo *fb;
|
||||
KMSDRM_PlaneInfo info = {0};
|
||||
|
||||
/* Recreate the GBM / EGL surfaces if the display mode has changed */
|
||||
if (windata->egl_surface_dirty) {
|
||||
KMSDRM_CreateSurfaces(_this, window);
|
||||
/******************************************************************/
|
||||
/* Create the GPU-side FENCE OBJECT. It will be inserted into the */
|
||||
/* GL CMDSTREAM exactly at the end of the gl commands that form a */
|
||||
/* frame.(KMS will have to wait on it before doing a pageflip.) */
|
||||
/******************************************************************/
|
||||
dispdata->gpu_fence = create_fence(EGL_NO_NATIVE_FENCE_FD_ANDROID, _this);
|
||||
assert(dispdata->gpu_fence);
|
||||
|
||||
/******************************************************************/
|
||||
/* eglSwapBuffers flushes the fence down the GL CMDSTREAM, so we */
|
||||
/* know for sure it's there now. */
|
||||
/* Also it marks, at EGL level, the buffer that we want to become */
|
||||
/* the new front buffer. (Remember that won't really happen until */
|
||||
/* we request a pageflip at the KMS level and it completes. */
|
||||
/******************************************************************/
|
||||
if (! _this->egl_data->eglSwapBuffers(_this->egl_data->egl_display, windata->egl_surface)) {
|
||||
return SDL_EGL_SetError("Failed to swap EGL buffers", "eglSwapBuffers");
|
||||
}
|
||||
|
||||
/* Wait for confirmation that the next front buffer has been flipped, at which
|
||||
point the previous front buffer can be released */
|
||||
timeout = 0;
|
||||
if (_this->egl_data->egl_swapinterval == 1) {
|
||||
timeout = -1;
|
||||
}
|
||||
if (!KMSDRM_WaitPageFlip(_this, windata, timeout)) {
|
||||
return 0;
|
||||
}
|
||||
/******************************************************************/
|
||||
/* EXPORT the GPU-side FENCE OBJECT to the fence INPUT FD, so we */
|
||||
/* can pass it into the kernel. Atomic ioctl will pass the */
|
||||
/* in-fence fd into the kernel, thus telling KMS that it has to */
|
||||
/* wait for GPU to finish rendering the frame (remember where we */
|
||||
/* put the fence in the GL CMDSTREAM) before doing the changes */
|
||||
/* requested in the atomic ioct (the pageflip in this case). */
|
||||
/* (We export the GPU-side FENCE OJECT to the fence INPUT FD now, */
|
||||
/* not sooner, because now we are sure that the GPU-side fence is */
|
||||
/* in the CMDSTREAM to be lifted when the CMDSTREAM to this point */
|
||||
/* is completed). */
|
||||
/******************************************************************/
|
||||
dispdata->kms_in_fence_fd = _this->egl_data->eglDupNativeFenceFDANDROID (_this->egl_data->egl_display,
|
||||
dispdata->gpu_fence);
|
||||
|
||||
_this->egl_data->eglDestroySyncKHR(_this->egl_data->egl_display, dispdata->gpu_fence);
|
||||
assert(dispdata->kms_in_fence_fd != -1);
|
||||
|
||||
/* Release the previous front buffer */
|
||||
if (windata->curr_bo) {
|
||||
KMSDRM_gbm_surface_release_buffer(windata->gs, windata->curr_bo);
|
||||
/* SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Released GBM surface %p", (void *)windata->curr_bo); */
|
||||
windata->curr_bo = NULL;
|
||||
}
|
||||
|
||||
windata->curr_bo = windata->next_bo;
|
||||
|
||||
/* Make the current back buffer the next front buffer */
|
||||
if (!(_this->egl_data->eglSwapBuffers(_this->egl_data->egl_display, windata->egl_surface))) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "eglSwapBuffers failed.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Lock the next front buffer so it can't be allocated as a back buffer */
|
||||
/* Lock the buffer that is marked by eglSwapBuffers() to become the
|
||||
next front buffer (so it can not be chosen by EGL as back buffer
|
||||
to draw on), and get a handle to it to request the pageflip on it.
|
||||
REMEMBER that gbm_surface_lock_front_buffer() ALWAYS has to be
|
||||
called after eglSwapBuffers(). */
|
||||
windata->next_bo = KMSDRM_gbm_surface_lock_front_buffer(windata->gs);
|
||||
if (!windata->next_bo) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not lock GBM surface front buffer");
|
||||
return 0;
|
||||
/* } else {
|
||||
SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Locked GBM surface %p", (void *)windata->next_bo); */
|
||||
return SDL_SetError("Failed to lock frontbuffer");
|
||||
}
|
||||
fb = KMSDRM_FBFromBO(_this, windata->next_bo);
|
||||
if (!fb) {
|
||||
return SDL_SetError("Failed to get a new framebuffer from BO");
|
||||
}
|
||||
|
||||
fb_info = KMSDRM_FBFromBO(_this, windata->next_bo);
|
||||
if (!fb_info) {
|
||||
return 0;
|
||||
/* Add the pageflip to the request list. */
|
||||
info.plane = dispdata->display_plane;
|
||||
info.crtc_id = dispdata->crtc->crtc->crtc_id;
|
||||
info.fb_id = fb->fb_id;
|
||||
|
||||
info.src_w = windata->src_w;
|
||||
info.src_h = windata->src_h;
|
||||
info.crtc_w = windata->output_w;
|
||||
info.crtc_h = windata->output_h;
|
||||
info.crtc_x = windata->output_x;
|
||||
|
||||
drm_atomic_set_plane_props(&info);
|
||||
|
||||
/*****************************************************************/
|
||||
/* Tell the display (KMS) that it will have to wait on the fence */
|
||||
/* for the GPU-side FENCE. */
|
||||
/* */
|
||||
/* Since KMS is a kernel thing, we have to pass an FD into */
|
||||
/* the kernel, and get another FD out of the kernel. */
|
||||
/* */
|
||||
/* 1) To pass the GPU-side fence into the kernel, we set the */
|
||||
/* INPUT FD as the IN_FENCE_FD prop of the PRIMARY PLANE. */
|
||||
/* This FD tells KMS (the kernel) to wait for the GPU-side fence.*/
|
||||
/* */
|
||||
/* 2) To get the KMS-side fence out of the kernel, we set the */
|
||||
/* OUTPUT FD as the OUT_FEWNCE_FD prop of the CRTC. */
|
||||
/* This FD will be later imported as a FENCE OBJECT which will be*/
|
||||
/* used to tell the GPU to wait for KMS to complete the changes */
|
||||
/* requested in atomic_commit (the pageflip in this case). */
|
||||
/*****************************************************************/
|
||||
if (dispdata->kms_in_fence_fd != -1)
|
||||
{
|
||||
add_plane_property(dispdata->atomic_req, dispdata->display_plane,
|
||||
"IN_FENCE_FD", dispdata->kms_in_fence_fd);
|
||||
add_crtc_property(dispdata->atomic_req, dispdata->crtc,
|
||||
"OUT_FENCE_PTR", VOID2U64(&dispdata->kms_out_fence_fd));
|
||||
}
|
||||
|
||||
if (!windata->curr_bo) {
|
||||
/* On the first swap, immediately present the new front buffer. Before
|
||||
drmModePageFlip can be used the CRTC has to be configured to use
|
||||
the current connector and mode with drmModeSetCrtc */
|
||||
ret = KMSDRM_drmModeSetCrtc(viddata->drm_fd, dispdata->crtc_id, fb_info->fb_id, 0,
|
||||
0, &dispdata->conn->connector_id, 1, &dispdata->mode);
|
||||
/* Do we have a pending modesetting? If so, set the necessary
|
||||
props so it's included in the incoming atomic commit. */
|
||||
if (dispdata->modeset_pending) {
|
||||
uint32_t blob_id;
|
||||
SDL_VideoData *viddata = (SDL_VideoData *)_this->driverdata;
|
||||
|
||||
if (ret) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not configure CRTC");
|
||||
}
|
||||
} else {
|
||||
/* On subsequent swaps, queue the new front buffer to be flipped during
|
||||
the next vertical blank */
|
||||
ret = KMSDRM_drmModePageFlip(viddata->drm_fd, dispdata->crtc_id, fb_info->fb_id,
|
||||
DRM_MODE_PAGE_FLIP_EVENT, &windata->waiting_for_flip);
|
||||
/* SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "drmModePageFlip(%d, %u, %u, DRM_MODE_PAGE_FLIP_EVENT, &windata->waiting_for_flip)",
|
||||
viddata->drm_fd, displaydata->crtc_id, fb_info->fb_id); */
|
||||
|
||||
if (_this->egl_data->egl_swapinterval == 1) {
|
||||
if (ret == 0) {
|
||||
windata->waiting_for_flip = SDL_TRUE;
|
||||
} else {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not queue pageflip: %d", ret);
|
||||
}
|
||||
}
|
||||
|
||||
/* Wait immediately for vsync (as if we only had two buffers), for low input-lag scenarios.
|
||||
Run your SDL2 program with "SDL_KMSDRM_DOUBLE_BUFFER=1 <program_name>" to enable this. */
|
||||
if (_this->egl_data->egl_swapinterval == 1 && windata->double_buffer) {
|
||||
KMSDRM_WaitPageFlip(_this, windata, -1);
|
||||
}
|
||||
dispdata->atomic_flags |= DRM_MODE_ATOMIC_ALLOW_MODESET;
|
||||
add_connector_property(dispdata->atomic_req, dispdata->connector, "CRTC_ID", dispdata->crtc->crtc->crtc_id);
|
||||
KMSDRM_drmModeCreatePropertyBlob(viddata->drm_fd, &dispdata->mode, sizeof(dispdata->mode), &blob_id);
|
||||
add_crtc_property(dispdata->atomic_req, dispdata->crtc, "MODE_ID", blob_id);
|
||||
add_crtc_property(dispdata->atomic_req, dispdata->crtc, "ACTIVE", 1);
|
||||
dispdata->modeset_pending = SDL_FALSE;
|
||||
}
|
||||
|
||||
/*****************************************************************/
|
||||
/* Issue a non-blocking atomic commit: for triple buffering, */
|
||||
/* this must not block so the game can start building another */
|
||||
/* frame, even if the just-requested pageflip hasnt't completed. */
|
||||
/*****************************************************************/
|
||||
if (drm_atomic_commit(_this, SDL_FALSE)) {
|
||||
return SDL_SetError("Failed to issue atomic commit on pageflip");
|
||||
}
|
||||
|
||||
/* Release the previous front buffer so EGL can chose it as back buffer
|
||||
and render on it again. */
|
||||
if (windata->bo) {
|
||||
KMSDRM_gbm_surface_release_buffer(windata->gs, windata->bo);
|
||||
}
|
||||
|
||||
/* Take note of the buffer about to become front buffer, so next
|
||||
time we come here we can free it like we just did with the previous
|
||||
front buffer. */
|
||||
windata->bo = windata->next_bo;
|
||||
|
||||
/****************************************************************/
|
||||
/* Import the KMS-side FENCE OUTPUT FD from the kernel to the */
|
||||
/* KMS-side FENCE OBJECT so we can use use it to fence the GPU. */
|
||||
/****************************************************************/
|
||||
dispdata->kms_fence = create_fence(dispdata->kms_out_fence_fd, _this);
|
||||
assert(dispdata->kms_fence);
|
||||
|
||||
/****************************************************************/
|
||||
/* "Delete" the fence OUTPUT FD, because we already have the */
|
||||
/* KMS FENCE OBJECT, the fence itself is away from us, on the */
|
||||
/* kernel side. */
|
||||
/****************************************************************/
|
||||
dispdata->kms_out_fence_fd = -1;
|
||||
|
||||
/*****************************************************************/
|
||||
/* Tell the GPU to wait on the fence for the KMS-side FENCE, */
|
||||
/* which means waiting until the requested pageflip is completed.*/
|
||||
/*****************************************************************/
|
||||
_this->egl_data->eglWaitSyncKHR(_this->egl_data->egl_display, dispdata->kms_fence, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
KMSDRM_GLES_SwapWindowDoubleBuffered(_THIS, SDL_Window * window)
|
||||
{
|
||||
SDL_WindowData *windata = ((SDL_WindowData *) window->driverdata);
|
||||
SDL_DisplayData *dispdata = (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata;
|
||||
KMSDRM_FBInfo *fb;
|
||||
KMSDRM_PlaneInfo info = {0};
|
||||
|
||||
/****************************************************************************************************/
|
||||
/* In double-buffer mode, atomic_commit will always be synchronous/blocking (ie: won't return until */
|
||||
/* the requested changes are really done). */
|
||||
/* Also, there's no need to fence KMS or the GPU, because we won't be entering game loop again */
|
||||
/* (hence not building or executing a new cmdstring) until pageflip is done, so we don't need to */
|
||||
/* protect the KMS/GPU access to the buffer. */
|
||||
/****************************************************************************************************/
|
||||
|
||||
/* Mark, at EGL level, the buffer that we want to become the new front buffer.
|
||||
However, it won't really happen until we request a pageflip at the KMS level and it completes. */
|
||||
if (! _this->egl_data->eglSwapBuffers(_this->egl_data->egl_display, windata->egl_surface)) {
|
||||
return SDL_EGL_SetError("Failed to swap EGL buffers", "eglSwapBuffers");
|
||||
}
|
||||
|
||||
/* Lock the buffer that is marked by eglSwapBuffers() to become the next front buffer (so it can not
|
||||
be chosen by EGL as back buffer to draw on), and get a handle to it to request the pageflip on it. */
|
||||
windata->next_bo = KMSDRM_gbm_surface_lock_front_buffer(windata->gs);
|
||||
if (!windata->next_bo) {
|
||||
return SDL_SetError("Failed to lock frontbuffer");
|
||||
}
|
||||
fb = KMSDRM_FBFromBO(_this, windata->next_bo);
|
||||
if (!fb) {
|
||||
return SDL_SetError("Failed to get a new framebuffer BO");
|
||||
}
|
||||
|
||||
/* Add the pageflip to the request list. */
|
||||
info.plane = dispdata->display_plane;
|
||||
info.crtc_id = dispdata->crtc->crtc->crtc_id;
|
||||
info.fb_id = fb->fb_id;
|
||||
|
||||
info.src_w = windata->src_w;
|
||||
info.src_h = windata->src_h;
|
||||
info.crtc_w = windata->output_w;
|
||||
info.crtc_h = windata->output_h;
|
||||
info.crtc_x = windata->output_x;
|
||||
|
||||
drm_atomic_set_plane_props(&info);
|
||||
|
||||
/* Do we have a pending modesetting? If so, set the necessary
|
||||
props so it's included in the incoming atomic commit. */
|
||||
if (dispdata->modeset_pending) {
|
||||
SDL_VideoData *viddata = (SDL_VideoData *)_this->driverdata;
|
||||
uint32_t blob_id;
|
||||
dispdata->atomic_flags |= DRM_MODE_ATOMIC_ALLOW_MODESET;
|
||||
add_connector_property(dispdata->atomic_req, dispdata->connector, "CRTC_ID", dispdata->crtc->crtc->crtc_id);
|
||||
KMSDRM_drmModeCreatePropertyBlob(viddata->drm_fd, &dispdata->mode, sizeof(dispdata->mode), &blob_id);
|
||||
add_crtc_property(dispdata->atomic_req, dispdata->crtc, "MODE_ID", blob_id);
|
||||
add_crtc_property(dispdata->atomic_req, dispdata->crtc, "ACTIVE", 1);
|
||||
dispdata->modeset_pending = SDL_FALSE;
|
||||
}
|
||||
|
||||
/* Issue the one and only atomic commit where all changes will be requested!.
|
||||
Blocking for double buffering: won't return until completed. */
|
||||
if (drm_atomic_commit(_this, SDL_TRUE)) {
|
||||
return SDL_SetError("Failed to issue atomic commit");
|
||||
}
|
||||
|
||||
/* Release last front buffer so EGL can chose it as back buffer and render on it again. */
|
||||
if (windata->bo) {
|
||||
KMSDRM_gbm_surface_release_buffer(windata->gs, windata->bo);
|
||||
}
|
||||
|
||||
/* Take note of current front buffer, so we can free it next time we come here. */
|
||||
windata->bo = windata->next_bo;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
KMSDRM_GLES_SwapWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
SDL_WindowData *windata = ((SDL_WindowData *) window->driverdata);
|
||||
|
||||
if (windata->swap_window == NULL) {
|
||||
/* We want the fenced version by default, but it needs extensions. */
|
||||
if ( (SDL_GetHintBoolean(SDL_HINT_VIDEO_DOUBLE_BUFFER, SDL_FALSE)) ||
|
||||
(!SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_ANDROID_native_fence_sync")) )
|
||||
{
|
||||
windata->swap_window = KMSDRM_GLES_SwapWindowDoubleBuffered;
|
||||
} else {
|
||||
windata->swap_window = KMSDRM_GLES_SwapWindowFenced;
|
||||
}
|
||||
}
|
||||
|
||||
return windata->swap_window(_this, window);
|
||||
}
|
||||
|
||||
/***************************************/
|
||||
/* End of Atomic functions block */
|
||||
/***************************************/
|
||||
|
||||
SDL_EGL_MakeCurrent_impl(KMSDRM)
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_KMSDRM && SDL_VIDEO_OPENGL_EGL */
|
||||
|
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Atomic KMSDRM backend by Manuel Alfayate Corchete <redwindwanderer@gmail.com>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@@ -31,10 +32,10 @@
|
||||
/* OpenGLES functions */
|
||||
#define KMSDRM_GLES_GetAttribute SDL_EGL_GetAttribute
|
||||
#define KMSDRM_GLES_GetProcAddress SDL_EGL_GetProcAddress
|
||||
#define KMSDRM_GLES_UnloadLibrary SDL_EGL_UnloadLibrary
|
||||
#define KMSDRM_GLES_DeleteContext SDL_EGL_DeleteContext
|
||||
#define KMSDRM_GLES_GetSwapInterval SDL_EGL_GetSwapInterval
|
||||
|
||||
extern void KMSDRM_GLES_DefaultProfileConfig(_THIS, int *mask, int *major, int *minor);
|
||||
extern int KMSDRM_GLES_SetSwapInterval(_THIS, int interval);
|
||||
extern int KMSDRM_GLES_LoadLibrary(_THIS, const char *path);
|
||||
extern SDL_GLContext KMSDRM_GLES_CreateContext(_THIS, SDL_Window * window);
|
||||
|
52
externals/SDL/src/video/kmsdrm/SDL_kmsdrmsym.h
vendored
52
externals/SDL/src/video/kmsdrm/SDL_kmsdrmsym.h
vendored
@@ -40,28 +40,51 @@ SDL_KMSDRM_SYM(void,drmModeFreeFB,(drmModeFBPtr ptr))
|
||||
SDL_KMSDRM_SYM(void,drmModeFreeCrtc,(drmModeCrtcPtr ptr))
|
||||
SDL_KMSDRM_SYM(void,drmModeFreeConnector,(drmModeConnectorPtr ptr))
|
||||
SDL_KMSDRM_SYM(void,drmModeFreeEncoder,(drmModeEncoderPtr ptr))
|
||||
SDL_KMSDRM_SYM(int,drmGetCap,(int fd, uint64_t capability, uint64_t *value))
|
||||
SDL_KMSDRM_SYM(int,drmIoctl,(int fd, unsigned long request, void *arg))
|
||||
SDL_KMSDRM_SYM(drmModeResPtr,drmModeGetResources,(int fd))
|
||||
|
||||
SDL_KMSDRM_SYM(int,drmModeAddFB,(int fd, uint32_t width, uint32_t height, uint8_t depth,
|
||||
uint8_t bpp, uint32_t pitch, uint32_t bo_handle,
|
||||
uint32_t *buf_id))
|
||||
|
||||
SDL_KMSDRM_SYM(int,drmModeAddFB2,(int fd, uint32_t width, uint32_t height,
|
||||
uint32_t pixel_format, const uint32_t bo_handles[4],
|
||||
const uint32_t pitches[4], const uint32_t offsets[4],
|
||||
uint32_t *buf_id, uint32_t flags))
|
||||
|
||||
SDL_KMSDRM_SYM(int,drmModeAddFB2WithModifiers,(int fd, uint32_t width, uint32_t height,
|
||||
uint32_t pixel_format, const uint32_t bo_handles[4],
|
||||
const uint32_t pitches[4], const uint32_t offsets[4],
|
||||
const uint64_t modifier[4], uint32_t *buf_id,
|
||||
uint32_t flags))
|
||||
|
||||
SDL_KMSDRM_SYM(int,drmModeRmFB,(int fd, uint32_t bufferId))
|
||||
SDL_KMSDRM_SYM(drmModeFBPtr,drmModeGetFB,(int fd, uint32_t buf))
|
||||
SDL_KMSDRM_SYM(drmModeCrtcPtr,drmModeGetCrtc,(int fd, uint32_t crtcId))
|
||||
SDL_KMSDRM_SYM(int,drmModeSetCrtc,(int fd, uint32_t crtcId, uint32_t bufferId,
|
||||
uint32_t x, uint32_t y, uint32_t *connectors, int count,
|
||||
drmModeModeInfoPtr mode))
|
||||
SDL_KMSDRM_SYM(int,drmModeSetCursor,(int fd, uint32_t crtcId, uint32_t bo_handle,
|
||||
uint32_t width, uint32_t height))
|
||||
SDL_KMSDRM_SYM(int,drmModeSetCursor2,(int fd, uint32_t crtcId, uint32_t bo_handle,
|
||||
uint32_t width, uint32_t height,
|
||||
int32_t hot_x, int32_t hot_y))
|
||||
SDL_KMSDRM_SYM(int,drmModeMoveCursor,(int fd, uint32_t crtcId, int x, int y))
|
||||
SDL_KMSDRM_SYM(drmModeEncoderPtr,drmModeGetEncoder,(int fd, uint32_t encoder_id))
|
||||
SDL_KMSDRM_SYM(drmModeConnectorPtr,drmModeGetConnector,(int fd, uint32_t connector_id))
|
||||
SDL_KMSDRM_SYM(int,drmHandleEvent,(int fd,drmEventContextPtr evctx))
|
||||
SDL_KMSDRM_SYM(int,drmModePageFlip,(int fd, uint32_t crtc_id, uint32_t fb_id,
|
||||
uint32_t flags, void *user_data))
|
||||
|
||||
/* Atomic functions */
|
||||
|
||||
SDL_KMSDRM_SYM(int,drmSetClientCap,(int fd, uint64_t capability, uint64_t value))
|
||||
SDL_KMSDRM_SYM(drmModePlaneResPtr,drmModeGetPlaneResources,(int fd))
|
||||
SDL_KMSDRM_SYM(drmModePlanePtr,drmModeGetPlane,(int fd, uint32_t plane_id))
|
||||
SDL_KMSDRM_SYM(drmModeObjectPropertiesPtr,drmModeObjectGetProperties,(int fd,uint32_t object_id,uint32_t object_type))
|
||||
SDL_KMSDRM_SYM(drmModePropertyPtr,drmModeGetProperty,(int fd, uint32_t propertyId))
|
||||
|
||||
SDL_KMSDRM_SYM(void,drmModeFreeProperty,(drmModePropertyPtr ptr))
|
||||
SDL_KMSDRM_SYM(void,drmModeFreeObjectProperties,(drmModeObjectPropertiesPtr ptr))
|
||||
SDL_KMSDRM_SYM(void,drmModeFreePlane,(drmModePlanePtr ptr))
|
||||
SDL_KMSDRM_SYM(void,drmModeFreePlaneResources,(drmModePlaneResPtr ptr))
|
||||
|
||||
SDL_KMSDRM_SYM(drmModeAtomicReqPtr,drmModeAtomicAlloc,(void))
|
||||
SDL_KMSDRM_SYM(void,drmModeAtomicFree,(drmModeAtomicReqPtr req))
|
||||
SDL_KMSDRM_SYM(int,drmModeAtomicCommit,(int fd,drmModeAtomicReqPtr req,uint32_t flags,void *user_data))
|
||||
SDL_KMSDRM_SYM(int,drmModeAtomicAddProperty,(drmModeAtomicReqPtr req,uint32_t object_id,uint32_t property_id,uint64_t value))
|
||||
SDL_KMSDRM_SYM(int,drmModeCreatePropertyBlob,(int fd,const void *data,size_t size,uint32_t *id))
|
||||
|
||||
/* End of atomic fns */
|
||||
|
||||
SDL_KMSDRM_MODULE(GBM)
|
||||
SDL_KMSDRM_SYM(int,gbm_device_get_fd,(struct gbm_device *gbm))
|
||||
@@ -72,6 +95,11 @@ SDL_KMSDRM_SYM(struct gbm_device *,gbm_create_device,(int fd))
|
||||
SDL_KMSDRM_SYM(unsigned int,gbm_bo_get_width,(struct gbm_bo *bo))
|
||||
SDL_KMSDRM_SYM(unsigned int,gbm_bo_get_height,(struct gbm_bo *bo))
|
||||
SDL_KMSDRM_SYM(uint32_t,gbm_bo_get_stride,(struct gbm_bo *bo))
|
||||
SDL_KMSDRM_SYM(uint32_t,gbm_bo_get_stride_for_plane,(struct gbm_bo *bo,int plane))
|
||||
SDL_KMSDRM_SYM(uint32_t,gbm_bo_get_format,(struct gbm_bo *bo))
|
||||
SDL_KMSDRM_SYM(uint32_t,gbm_bo_get_offset,(struct gbm_bo *bo, int plane))
|
||||
SDL_KMSDRM_SYM(int,gbm_bo_get_plane_count,(struct gbm_bo *bo))
|
||||
|
||||
SDL_KMSDRM_SYM(union gbm_bo_handle,gbm_bo_get_handle,(struct gbm_bo *bo))
|
||||
SDL_KMSDRM_SYM(int,gbm_bo_write,(struct gbm_bo *bo, const void *buf, size_t count))
|
||||
SDL_KMSDRM_SYM(struct gbm_device *,gbm_bo_get_device,(struct gbm_bo *bo))
|
||||
|
1715
externals/SDL/src/video/kmsdrm/SDL_kmsdrmvideo.c
vendored
1715
externals/SDL/src/video/kmsdrm/SDL_kmsdrmvideo.c
vendored
File diff suppressed because it is too large
Load Diff
162
externals/SDL/src/video/kmsdrm/SDL_kmsdrmvideo.h
vendored
162
externals/SDL/src/video/kmsdrm/SDL_kmsdrmvideo.h
vendored
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Atomic KMSDRM backend by Manuel Alfayate Corchete <redwindwanderer@gmail.com>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@@ -30,63 +31,163 @@
|
||||
#include <unistd.h>
|
||||
#include <xf86drm.h>
|
||||
#include <xf86drmMode.h>
|
||||
|
||||
#include <gbm.h>
|
||||
#include <assert.h>
|
||||
#if SDL_VIDEO_OPENGL_EGL
|
||||
#include <EGL/egl.h>
|
||||
#include <EGL/eglext.h>
|
||||
#endif
|
||||
|
||||
/****************************************************************************************/
|
||||
/* Driverdata pointers are void struct* used to store backend-specific variables */
|
||||
/* and info that supports the SDL-side structs like SDL Display Devices, SDL_Windows... */
|
||||
/* which need to be "supported" with backend-side info and mechanisms to work. */
|
||||
/****************************************************************************************/
|
||||
|
||||
typedef struct SDL_VideoData
|
||||
{
|
||||
int devindex; /* device index that was passed on creation */
|
||||
int drm_fd; /* DRM file desc */
|
||||
struct gbm_device *gbm;
|
||||
char devpath[32]; /* DRM dev path. */
|
||||
|
||||
struct gbm_device *gbm_dev;
|
||||
|
||||
SDL_Window **windows;
|
||||
int max_windows;
|
||||
int num_windows;
|
||||
unsigned int max_windows;
|
||||
unsigned int num_windows;
|
||||
|
||||
SDL_bool video_init; /* Has VideoInit succeeded? */
|
||||
|
||||
} SDL_VideoData;
|
||||
|
||||
typedef struct plane {
|
||||
drmModePlane *plane;
|
||||
drmModeObjectProperties *props;
|
||||
drmModePropertyRes **props_info;
|
||||
} plane;
|
||||
|
||||
typedef struct crtc {
|
||||
drmModeCrtc *crtc;
|
||||
drmModeObjectProperties *props;
|
||||
drmModePropertyRes **props_info;
|
||||
} crtc;
|
||||
|
||||
typedef struct connector {
|
||||
drmModeConnector *connector;
|
||||
drmModeObjectProperties *props;
|
||||
drmModePropertyRes **props_info;
|
||||
} connector;
|
||||
|
||||
/* More general driverdata info that gives support and substance to the SDL_Display. */
|
||||
typedef struct SDL_DisplayData
|
||||
{
|
||||
drmModeModeInfo mode;
|
||||
drmModeModeInfo preferred_mode;
|
||||
uint32_t atomic_flags;
|
||||
|
||||
plane *display_plane;
|
||||
plane *cursor_plane;
|
||||
crtc *crtc;
|
||||
connector *connector;
|
||||
|
||||
/* Central atomic request list, used for the prop
|
||||
changeset related to pageflip in SwapWindow. */
|
||||
drmModeAtomicReq *atomic_req;
|
||||
|
||||
int kms_in_fence_fd;
|
||||
int kms_out_fence_fd;
|
||||
|
||||
EGLSyncKHR kms_fence;
|
||||
EGLSyncKHR gpu_fence;
|
||||
|
||||
#if SDL_VIDEO_OPENGL_EGL
|
||||
EGLSurface old_egl_surface;
|
||||
#endif
|
||||
|
||||
SDL_bool modeset_pending;
|
||||
SDL_bool gbm_init;
|
||||
|
||||
/* DRM & GBM cursor stuff lives here, not in an SDL_Cursor's driverdata struct,
|
||||
because setting/unsetting up these is done on window creation/destruction,
|
||||
where we may not have an SDL_Cursor at all (so no SDL_Cursor driverdata).
|
||||
There's only one cursor GBM BO because we only support one cursor. */
|
||||
struct gbm_bo *cursor_bo;
|
||||
uint64_t cursor_w, cursor_h;
|
||||
|
||||
} SDL_DisplayData;
|
||||
|
||||
/* Driverdata info that gives KMSDRM-side support and substance to the SDL_Window. */
|
||||
typedef struct SDL_WindowData
|
||||
{
|
||||
SDL_VideoData *viddata;
|
||||
/* SDL internals expect EGL surface to be here, and in KMSDRM the GBM surface is
|
||||
what supports the EGL surface on the driver side, so all these surfaces and buffers
|
||||
are expected to be here, in the struct pointed by SDL_Window driverdata pointer:
|
||||
this one. So don't try to move these to dispdata! */
|
||||
struct gbm_surface *gs;
|
||||
struct gbm_bo *bo;
|
||||
struct gbm_bo *next_bo;
|
||||
|
||||
#if SDL_VIDEO_OPENGL_EGL
|
||||
EGLSurface egl_surface;
|
||||
#endif
|
||||
|
||||
/* For scaling and AR correction. */
|
||||
int32_t src_w;
|
||||
int32_t src_h;
|
||||
int32_t output_w;
|
||||
int32_t output_h;
|
||||
int32_t output_x;
|
||||
|
||||
/* This dictates what approach we'll use for SwapBuffers. */
|
||||
int (*swap_window)(_THIS, SDL_Window * window);
|
||||
|
||||
} SDL_WindowData;
|
||||
|
||||
typedef struct SDL_DisplayModeData
|
||||
{
|
||||
int mode_index;
|
||||
} SDL_DisplayModeData;
|
||||
|
||||
|
||||
typedef struct SDL_DisplayData
|
||||
{
|
||||
uint32_t crtc_id;
|
||||
drmModeConnector *conn;
|
||||
drmModeModeInfo mode;
|
||||
drmModeCrtc *saved_crtc; /* CRTC to restore on quit */
|
||||
} SDL_DisplayData;
|
||||
|
||||
|
||||
typedef struct SDL_WindowData
|
||||
{
|
||||
SDL_VideoData *viddata;
|
||||
struct gbm_surface *gs;
|
||||
struct gbm_bo *curr_bo;
|
||||
struct gbm_bo *next_bo;
|
||||
struct gbm_bo *crtc_bo;
|
||||
SDL_bool waiting_for_flip;
|
||||
SDL_bool double_buffer;
|
||||
#if SDL_VIDEO_OPENGL_EGL
|
||||
int egl_surface_dirty;
|
||||
EGLSurface egl_surface;
|
||||
#endif
|
||||
} SDL_WindowData;
|
||||
|
||||
typedef struct KMSDRM_FBInfo
|
||||
{
|
||||
int drm_fd; /* DRM file desc */
|
||||
uint32_t fb_id; /* DRM framebuffer ID */
|
||||
} KMSDRM_FBInfo;
|
||||
|
||||
typedef struct KMSDRM_PlaneInfo
|
||||
{
|
||||
struct plane *plane;
|
||||
uint32_t fb_id;
|
||||
uint32_t crtc_id;
|
||||
int32_t src_x;
|
||||
int32_t src_y;
|
||||
int32_t src_w;
|
||||
int32_t src_h;
|
||||
int32_t crtc_x;
|
||||
int32_t crtc_y;
|
||||
int32_t crtc_w;
|
||||
int32_t crtc_h;
|
||||
} KMSDRM_PlaneInfo;
|
||||
|
||||
/* Helper functions */
|
||||
int KMSDRM_CreateSurfaces(_THIS, SDL_Window * window);
|
||||
int KMSDRM_CreateEGLSurface(_THIS, SDL_Window * window);
|
||||
KMSDRM_FBInfo *KMSDRM_FBFromBO(_THIS, struct gbm_bo *bo);
|
||||
SDL_bool KMSDRM_WaitPageFlip(_THIS, SDL_WindowData *windata, int timeout);
|
||||
|
||||
/* Atomic functions that are used from SDL_kmsdrmopengles.c and SDL_kmsdrmmouse.c */
|
||||
void drm_atomic_set_plane_props(struct KMSDRM_PlaneInfo *info);
|
||||
|
||||
void drm_atomic_waitpending(_THIS);
|
||||
int drm_atomic_commit(_THIS, SDL_bool blocking);
|
||||
int add_plane_property(drmModeAtomicReq *req, struct plane *plane,
|
||||
const char *name, uint64_t value);
|
||||
int add_crtc_property(drmModeAtomicReq *req, struct crtc *crtc,
|
||||
const char *name, uint64_t value);
|
||||
int add_connector_property(drmModeAtomicReq *req, struct connector *connector,
|
||||
const char *name, uint64_t value);
|
||||
int setup_plane(_THIS, struct plane **plane, uint32_t plane_type);
|
||||
void free_plane(struct plane **plane);
|
||||
|
||||
/****************************************************************************/
|
||||
/* SDL_VideoDevice functions declaration */
|
||||
@@ -103,6 +204,7 @@ void KMSDRM_SetWindowTitle(_THIS, SDL_Window * window);
|
||||
void KMSDRM_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon);
|
||||
void KMSDRM_SetWindowPosition(_THIS, SDL_Window * window);
|
||||
void KMSDRM_SetWindowSize(_THIS, SDL_Window * window);
|
||||
void KMSDRM_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * _display, SDL_bool fullscreen);
|
||||
void KMSDRM_ShowWindow(_THIS, SDL_Window * window);
|
||||
void KMSDRM_HideWindow(_THIS, SDL_Window * window);
|
||||
void KMSDRM_RaiseWindow(_THIS, SDL_Window * window);
|
||||
|
408
externals/SDL/src/video/kmsdrm/SDL_kmsdrmvulkan.c
vendored
Executable file
408
externals/SDL/src/video/kmsdrm/SDL_kmsdrmvulkan.c
vendored
Executable file
@@ -0,0 +1,408 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @author Manuel Alfayate Corchere <redwindwanderer@gmail.com>.
|
||||
* Based on Jacob Lifshay's SDL_x11vulkan.c.
|
||||
*/
|
||||
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if SDL_VIDEO_VULKAN && SDL_VIDEO_DRIVER_KMSDRM
|
||||
|
||||
#include "SDL_kmsdrmvideo.h"
|
||||
#include "SDL_kmsdrmdyn.h"
|
||||
#include "SDL_assert.h"
|
||||
|
||||
#include "SDL_loadso.h"
|
||||
#include "SDL_kmsdrmvulkan.h"
|
||||
#include "SDL_syswm.h"
|
||||
#include "sys/ioctl.h"
|
||||
|
||||
#if defined(__OpenBSD__)
|
||||
#define DEFAULT_VULKAN "libvulkan.so"
|
||||
#else
|
||||
#define DEFAULT_VULKAN "libvulkan.so.1"
|
||||
#endif
|
||||
|
||||
int KMSDRM_Vulkan_LoadLibrary(_THIS, const char *path)
|
||||
{
|
||||
VkExtensionProperties *extensions = NULL;
|
||||
Uint32 i, extensionCount = 0;
|
||||
SDL_bool hasSurfaceExtension = SDL_FALSE;
|
||||
SDL_bool hasDisplayExtension = SDL_FALSE;
|
||||
PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = NULL;
|
||||
|
||||
if(_this->vulkan_config.loader_handle)
|
||||
return SDL_SetError("Vulkan already loaded");
|
||||
|
||||
/* Load the Vulkan library */
|
||||
if(!path)
|
||||
path = SDL_getenv("SDL_VULKAN_LIBRARY");
|
||||
if(!path)
|
||||
path = DEFAULT_VULKAN;
|
||||
|
||||
_this->vulkan_config.loader_handle = SDL_LoadObject(path);
|
||||
|
||||
if(!_this->vulkan_config.loader_handle)
|
||||
return -1;
|
||||
|
||||
SDL_strlcpy(_this->vulkan_config.loader_path, path,
|
||||
SDL_arraysize(_this->vulkan_config.loader_path));
|
||||
|
||||
vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)SDL_LoadFunction(
|
||||
_this->vulkan_config.loader_handle, "vkGetInstanceProcAddr");
|
||||
|
||||
if(!vkGetInstanceProcAddr)
|
||||
goto fail;
|
||||
|
||||
_this->vulkan_config.vkGetInstanceProcAddr = (void *)vkGetInstanceProcAddr;
|
||||
_this->vulkan_config.vkEnumerateInstanceExtensionProperties =
|
||||
(void *)((PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr)(
|
||||
VK_NULL_HANDLE, "vkEnumerateInstanceExtensionProperties");
|
||||
|
||||
if(!_this->vulkan_config.vkEnumerateInstanceExtensionProperties)
|
||||
goto fail;
|
||||
|
||||
extensions = SDL_Vulkan_CreateInstanceExtensionsList(
|
||||
(PFN_vkEnumerateInstanceExtensionProperties)
|
||||
_this->vulkan_config.vkEnumerateInstanceExtensionProperties,
|
||||
&extensionCount);
|
||||
|
||||
if(!extensions)
|
||||
goto fail;
|
||||
|
||||
for(i = 0; i < extensionCount; i++)
|
||||
{
|
||||
if(SDL_strcmp(VK_KHR_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0)
|
||||
hasSurfaceExtension = SDL_TRUE;
|
||||
else if(SDL_strcmp(VK_KHR_DISPLAY_EXTENSION_NAME, extensions[i].extensionName) == 0)
|
||||
hasDisplayExtension = SDL_TRUE;
|
||||
}
|
||||
|
||||
SDL_free(extensions);
|
||||
|
||||
if(!hasSurfaceExtension)
|
||||
{
|
||||
SDL_SetError("Installed Vulkan doesn't implement the "
|
||||
VK_KHR_SURFACE_EXTENSION_NAME " extension");
|
||||
goto fail;
|
||||
}
|
||||
else if(!hasDisplayExtension)
|
||||
{
|
||||
SDL_SetError("Installed Vulkan doesn't implement the "
|
||||
VK_KHR_DISPLAY_EXTENSION_NAME "extension");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
SDL_UnloadObject(_this->vulkan_config.loader_handle);
|
||||
_this->vulkan_config.loader_handle = NULL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
void KMSDRM_Vulkan_UnloadLibrary(_THIS)
|
||||
{
|
||||
if(_this->vulkan_config.loader_handle)
|
||||
{
|
||||
SDL_UnloadObject(_this->vulkan_config.loader_handle);
|
||||
_this->vulkan_config.loader_handle = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************/
|
||||
/* Here we can put whatever Vulkan extensions we want to be enabled */
|
||||
/* at instance creation, which is done in the programs, not in SDL. */
|
||||
/* So: programs call SDL_Vulkan_GetInstanceExtensions() and here */
|
||||
/* we put the extensions specific to this backend so the programs */
|
||||
/* get a list with the extension we want, so they can include that */
|
||||
/* list in the ppEnabledExtensionNames and EnabledExtensionCount */
|
||||
/* members of the VkInstanceCreateInfo struct passed to */
|
||||
/* vkCreateInstance(). */
|
||||
/*********************************************************************/
|
||||
SDL_bool KMSDRM_Vulkan_GetInstanceExtensions(_THIS,
|
||||
SDL_Window *window,
|
||||
unsigned *count,
|
||||
const char **names)
|
||||
{
|
||||
static const char *const extensionsForKMSDRM[] = {
|
||||
VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_DISPLAY_EXTENSION_NAME
|
||||
};
|
||||
if(!_this->vulkan_config.loader_handle)
|
||||
{
|
||||
SDL_SetError("Vulkan is not loaded");
|
||||
return SDL_FALSE;
|
||||
}
|
||||
return SDL_Vulkan_GetInstanceExtensions_Helper(
|
||||
count, names, SDL_arraysize(extensionsForKMSDRM),
|
||||
extensionsForKMSDRM);
|
||||
}
|
||||
|
||||
void KMSDRM_Vulkan_GetDrawableSize(_THIS, SDL_Window *window, int *w, int *h)
|
||||
{
|
||||
if (w) {
|
||||
*w = window->w;
|
||||
}
|
||||
|
||||
if (h) {
|
||||
*h = window->h;
|
||||
}
|
||||
}
|
||||
|
||||
/***********************************************************************/
|
||||
/* First thing to know is that we don't call vkCreateInstance() here. */
|
||||
/* Instead, programs using SDL and Vulkan create their Vulkan instance */
|
||||
/* and we get it here, ready to use. */
|
||||
/* Extensions specific for this platform are activated in */
|
||||
/* KMSDRM_Vulkan_GetInstanceExtensions(), like we do with */
|
||||
/* VK_KHR_DISPLAY_EXTENSION_NAME, which is what we need for x-less VK. */
|
||||
/***********************************************************************/
|
||||
SDL_bool KMSDRM_Vulkan_CreateSurface(_THIS,
|
||||
SDL_Window *window,
|
||||
VkInstance instance,
|
||||
VkSurfaceKHR *surface)
|
||||
{
|
||||
VkPhysicalDevice gpu;
|
||||
uint32_t gpu_count;
|
||||
uint32_t display_count;
|
||||
uint32_t mode_count;
|
||||
uint32_t plane_count;
|
||||
|
||||
VkPhysicalDevice *physical_devices = NULL;
|
||||
VkDisplayPropertiesKHR *displays_props = NULL;
|
||||
VkDisplayModePropertiesKHR *modes_props = NULL;
|
||||
VkDisplayPlanePropertiesKHR *planes_props = NULL;
|
||||
|
||||
VkDisplayModeCreateInfoKHR display_mode_create_info;
|
||||
VkDisplaySurfaceCreateInfoKHR display_plane_surface_create_info;
|
||||
|
||||
VkExtent2D image_size;
|
||||
VkDisplayModeKHR display_mode;
|
||||
VkDisplayModePropertiesKHR display_mode_props = {0};
|
||||
|
||||
VkResult result;
|
||||
SDL_bool ret = SDL_FALSE;
|
||||
|
||||
/* We don't receive a display index in KMSDRM_CreateDevice(), only
|
||||
a device index, which determines the GPU to use, but not the output.
|
||||
So we simply use the first connected output (ie, the first connected
|
||||
video output) for now.
|
||||
In other words, change this index to select a different output. Easy! */
|
||||
int display_index = 0;
|
||||
|
||||
int i;
|
||||
|
||||
SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
|
||||
|
||||
/* Get the function pointers for the functions we will use. */
|
||||
PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr =
|
||||
(PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr;
|
||||
|
||||
PFN_vkCreateDisplayPlaneSurfaceKHR vkCreateDisplayPlaneSurfaceKHR =
|
||||
(PFN_vkCreateDisplayPlaneSurfaceKHR)vkGetInstanceProcAddr(
|
||||
instance, "vkCreateDisplayPlaneSurfaceKHR");
|
||||
|
||||
PFN_vkEnumeratePhysicalDevices vkEnumeratePhysicalDevices =
|
||||
(PFN_vkEnumeratePhysicalDevices)vkGetInstanceProcAddr(
|
||||
instance, "vkEnumeratePhysicalDevices");
|
||||
|
||||
PFN_vkGetPhysicalDeviceDisplayPropertiesKHR vkGetPhysicalDeviceDisplayPropertiesKHR =
|
||||
(PFN_vkGetPhysicalDeviceDisplayPropertiesKHR)vkGetInstanceProcAddr(
|
||||
instance, "vkGetPhysicalDeviceDisplayPropertiesKHR");
|
||||
|
||||
PFN_vkGetDisplayModePropertiesKHR vkGetDisplayModePropertiesKHR =
|
||||
(PFN_vkGetDisplayModePropertiesKHR)vkGetInstanceProcAddr(
|
||||
instance, "vkGetDisplayModePropertiesKHR");
|
||||
|
||||
PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR vkGetPhysicalDeviceDisplayPlanePropertiesKHR =
|
||||
(PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR)vkGetInstanceProcAddr(
|
||||
instance, "vkGetPhysicalDeviceDisplayPlanePropertiesKHR");
|
||||
|
||||
/*PFN_vkGetDisplayPlaneSupportedDisplaysKHR vkGetDisplayPlaneSupportedDisplaysKHR =
|
||||
(PFN_vkGetDisplayPlaneSupportedDisplaysKHR)vkGetInstanceProcAddr(
|
||||
instance, "vkGetDisplayPlaneSupportedDisplaysKHR");
|
||||
|
||||
PFN_vkGetDisplayPlaneCapabilitiesKHR vkGetDisplayPlaneCapabilitiesKHR =
|
||||
(PFN_vkGetDisplayPlaneCapabilitiesKHR)vkGetInstanceProcAddr(
|
||||
instance, "vkGetDisplayPlaneCapabilitiesKHR");
|
||||
*/
|
||||
|
||||
PFN_vkCreateDisplayModeKHR vkCreateDisplayModeKHR =
|
||||
(PFN_vkCreateDisplayModeKHR)vkGetInstanceProcAddr(
|
||||
instance, "vkCreateDisplayModeKHR");
|
||||
|
||||
if(!_this->vulkan_config.loader_handle)
|
||||
{
|
||||
SDL_SetError("Vulkan is not loaded");
|
||||
goto clean;
|
||||
}
|
||||
|
||||
/*************************************/
|
||||
/* Block for vulkan surface creation */
|
||||
/*************************************/
|
||||
|
||||
/****************************************************************/
|
||||
/* If we got vkCreateDisplayPlaneSurfaceKHR() pointer, it means */
|
||||
/* that the VK_KHR_Display extension is active on the instance. */
|
||||
/* That's the central extension we need for x-less VK! */
|
||||
/****************************************************************/
|
||||
if(!vkCreateDisplayPlaneSurfaceKHR)
|
||||
{
|
||||
SDL_SetError(VK_KHR_DISPLAY_EXTENSION_NAME
|
||||
" extension is not enabled in the Vulkan instance.");
|
||||
goto clean;
|
||||
}
|
||||
|
||||
/* Get the physical device count. */
|
||||
vkEnumeratePhysicalDevices(instance, &gpu_count, NULL);
|
||||
|
||||
if (gpu_count == 0) {
|
||||
SDL_SetError("Vulkan can't find physical devices (gpus).");
|
||||
goto clean;
|
||||
}
|
||||
|
||||
/* Get the physical devices. */
|
||||
physical_devices = malloc(sizeof(VkPhysicalDevice) * gpu_count);
|
||||
vkEnumeratePhysicalDevices(instance, &gpu_count, physical_devices);
|
||||
|
||||
/* A GPU (or physical_device, in vkcube terms) is a GPU. A machine with more
|
||||
than one video output doen't need to have more than one GPU, like the Pi4
|
||||
which has 1 GPU and 2 video outputs.
|
||||
We grab the GPU/physical_device with the index we got in KMSDR_CreateDevice(). */
|
||||
gpu = physical_devices[viddata->devindex];
|
||||
|
||||
/* A display is a video output. 1 GPU can have N displays.
|
||||
Vulkan only counts the connected displays.
|
||||
Get the display count of the GPU. */
|
||||
vkGetPhysicalDeviceDisplayPropertiesKHR(gpu, &display_count, NULL);
|
||||
if (display_count == 0) {
|
||||
SDL_SetError("Vulkan can't find any displays.");
|
||||
goto clean;
|
||||
}
|
||||
|
||||
/* Get the props of the displays of the physical device. */
|
||||
displays_props = (VkDisplayPropertiesKHR *) malloc(display_count * sizeof(*displays_props));
|
||||
vkGetPhysicalDeviceDisplayPropertiesKHR(gpu,
|
||||
&display_count,
|
||||
displays_props);
|
||||
|
||||
/* Get the videomode count for the first display. */
|
||||
vkGetDisplayModePropertiesKHR(gpu,
|
||||
displays_props[display_index].display,
|
||||
&mode_count, NULL);
|
||||
|
||||
if (mode_count == 0) {
|
||||
SDL_SetError("Vulkan can't find any video modes for display %i (%s)\n", 0,
|
||||
displays_props[display_index].displayName);
|
||||
goto clean;
|
||||
}
|
||||
|
||||
/* Get the props of the videomodes for the first display. */
|
||||
modes_props = (VkDisplayModePropertiesKHR *) malloc(mode_count * sizeof(*modes_props));
|
||||
vkGetDisplayModePropertiesKHR(gpu,
|
||||
displays_props[display_index].display,
|
||||
&mode_count, modes_props);
|
||||
|
||||
/* Get the planes count of the physical device. */
|
||||
vkGetPhysicalDeviceDisplayPlanePropertiesKHR(gpu, &plane_count, NULL);
|
||||
if (plane_count == 0) {
|
||||
SDL_SetError("Vulkan can't find any planes.");
|
||||
goto clean;
|
||||
}
|
||||
|
||||
/* Get the props of the planes for the physical device. */
|
||||
planes_props = malloc(sizeof(VkDisplayPlanePropertiesKHR) * plane_count);
|
||||
vkGetPhysicalDeviceDisplayPlanePropertiesKHR(gpu, &plane_count, planes_props);
|
||||
|
||||
/* Get a video mode equal or smaller than the window size. REMEMBER:
|
||||
We have to get a small enough videomode for the window size,
|
||||
because videomode determines how big the scanout region is and we can't
|
||||
scanout a region bigger than the window (we would be reading past the
|
||||
buffer, and Vulkan would give us a confusing VK_ERROR_SURFACE_LOST_KHR). */
|
||||
for (i = 0; i < mode_count; i++) {
|
||||
if (modes_props[i].parameters.visibleRegion.width <= window->w &&
|
||||
modes_props[i].parameters.visibleRegion.height <= window->h)
|
||||
{
|
||||
display_mode_props = modes_props[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (display_mode_props.parameters.visibleRegion.width == 0
|
||||
|| display_mode_props.parameters.visibleRegion.height == 0)
|
||||
{
|
||||
SDL_SetError("Vulkan can't find a proper display mode for the window size.");
|
||||
goto clean;
|
||||
}
|
||||
|
||||
/* We have the props of the display mode, but we need an actual display mode. */
|
||||
display_mode_create_info.sType = VK_STRUCTURE_TYPE_DISPLAY_MODE_CREATE_INFO_KHR;
|
||||
display_mode_create_info.parameters = display_mode_props.parameters;
|
||||
result = vkCreateDisplayModeKHR(gpu,
|
||||
displays_props[display_index].display,
|
||||
&display_mode_create_info,
|
||||
NULL, &display_mode);
|
||||
if (result != VK_SUCCESS) {
|
||||
SDL_SetError("Vulkan can't create the display mode.");
|
||||
goto clean;
|
||||
}
|
||||
|
||||
/* Let's finally create the Vulkan surface! */
|
||||
|
||||
image_size.width = window->w;
|
||||
image_size.height = window->h;
|
||||
|
||||
display_plane_surface_create_info.sType = VK_STRUCTURE_TYPE_DISPLAY_SURFACE_CREATE_INFO_KHR;
|
||||
display_plane_surface_create_info.displayMode = display_mode;
|
||||
/* For now, simply use the first plane. */
|
||||
display_plane_surface_create_info.planeIndex = 0;
|
||||
display_plane_surface_create_info.imageExtent = image_size;
|
||||
result = vkCreateDisplayPlaneSurfaceKHR(instance,
|
||||
&display_plane_surface_create_info,
|
||||
NULL,
|
||||
surface);
|
||||
if(result != VK_SUCCESS)
|
||||
{
|
||||
SDL_SetError("vkCreateKMSDRMSurfaceKHR failed: %s",
|
||||
SDL_Vulkan_GetResultString(result));
|
||||
goto clean;
|
||||
}
|
||||
|
||||
ret = SDL_TRUE;
|
||||
|
||||
clean:
|
||||
if (physical_devices)
|
||||
free (physical_devices);
|
||||
if (displays_props)
|
||||
free (displays_props);
|
||||
if (planes_props)
|
||||
free (planes_props);
|
||||
if (modes_props)
|
||||
free (modes_props);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* vim: set ts=4 sw=4 expandtab: */
|
53
externals/SDL/src/video/kmsdrm/SDL_kmsdrmvulkan.h
vendored
Executable file
53
externals/SDL/src/video/kmsdrm/SDL_kmsdrmvulkan.h
vendored
Executable file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @author Manuel Alfayate Corchere <redwindwanderer@gmail.com>.
|
||||
* Based on Jacob Lifshay's SDL_x11vulkan.c.
|
||||
*/
|
||||
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#ifndef SDL_kmsdrmvulkan_h_
|
||||
#define SDL_kmsdrmvulkan_h_
|
||||
|
||||
#include "../SDL_vulkan_internal.h"
|
||||
#include "../SDL_sysvideo.h"
|
||||
|
||||
#if SDL_VIDEO_VULKAN && SDL_VIDEO_DRIVER_KMSDRM
|
||||
|
||||
int KMSDRM_Vulkan_LoadLibrary(_THIS, const char *path);
|
||||
void KMSDRM_Vulkan_UnloadLibrary(_THIS);
|
||||
SDL_bool KMSDRM_Vulkan_GetInstanceExtensions(_THIS,
|
||||
SDL_Window *window,
|
||||
unsigned *count,
|
||||
const char **names);
|
||||
void KMSDRM_Vulkan_GetDrawableSize(_THIS, SDL_Window *window, int *w, int *h);
|
||||
SDL_bool KMSDRM_Vulkan_CreateSurface(_THIS,
|
||||
SDL_Window *window,
|
||||
VkInstance instance,
|
||||
VkSurfaceKHR *surface);
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* SDL_kmsdrmvulkan_h_ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
167
externals/SDL/src/video/kmsdrm_legacy/SDL_kmsdrm_legacy_dyn.c
vendored
Executable file
167
externals/SDL/src/video/kmsdrm_legacy/SDL_kmsdrm_legacy_dyn.c
vendored
Executable file
@@ -0,0 +1,167 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 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_KMSDRM
|
||||
|
||||
#define DEBUG_DYNAMIC_KMSDRM_LEGACY 0
|
||||
|
||||
#include "SDL_kmsdrm_legacy_dyn.h"
|
||||
|
||||
#ifdef SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC
|
||||
|
||||
#include "SDL_name.h"
|
||||
#include "SDL_loadso.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void *lib;
|
||||
const char *libname;
|
||||
} kmsdrmdynlib;
|
||||
|
||||
#ifndef SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC
|
||||
#define SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC NULL
|
||||
#endif
|
||||
#ifndef SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC_GBM
|
||||
#define SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC_GBM NULL
|
||||
#endif
|
||||
|
||||
static kmsdrmdynlib kmsdrmlibs[] = {
|
||||
{NULL, SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC_GBM},
|
||||
{NULL, SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC}
|
||||
};
|
||||
|
||||
static void *
|
||||
KMSDRM_LEGACY_GetSym(const char *fnname, int *pHasModule)
|
||||
{
|
||||
int i;
|
||||
void *fn = NULL;
|
||||
for (i = 0; i < SDL_TABLESIZE(kmsdrmlibs); i++) {
|
||||
if (kmsdrmlibs[i].lib != NULL) {
|
||||
fn = SDL_LoadFunction(kmsdrmlibs[i].lib, fnname);
|
||||
if (fn != NULL)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG_DYNAMIC_KMSDRM_LEGACY
|
||||
if (fn != NULL)
|
||||
SDL_Log("KMSDRM_LEGACY: Found '%s' in %s (%p)\n", fnname, kmsdrmlibs[i].libname, fn);
|
||||
else
|
||||
SDL_Log("KMSDRM_LEGACY: Symbol '%s' NOT FOUND!\n", fnname);
|
||||
#endif
|
||||
|
||||
if (fn == NULL)
|
||||
*pHasModule = 0; /* kill this module. */
|
||||
|
||||
return fn;
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC */
|
||||
|
||||
/* Define all the function pointers and wrappers... */
|
||||
#define SDL_KMSDRM_LEGACY_MODULE(modname) int SDL_KMSDRM_LEGACY_HAVE_##modname = 0;
|
||||
#define SDL_KMSDRM_LEGACY_SYM(rc,fn,params) SDL_DYNKMSDRM_LEGACYFN_##fn KMSDRM_LEGACY_##fn = NULL;
|
||||
#define SDL_KMSDRM_LEGACY_SYM_CONST(type,name) SDL_DYNKMSDRM_LEGACYCONST_##name KMSDRM_LEGACY_##name = NULL;
|
||||
#include "SDL_kmsdrm_legacy_sym.h"
|
||||
|
||||
static int kmsdrm_load_refcount = 0;
|
||||
|
||||
void
|
||||
SDL_KMSDRM_LEGACY_UnloadSymbols(void)
|
||||
{
|
||||
/* Don't actually unload if more than one module is using the libs... */
|
||||
if (kmsdrm_load_refcount > 0) {
|
||||
if (--kmsdrm_load_refcount == 0) {
|
||||
#ifdef SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC
|
||||
int i;
|
||||
#endif
|
||||
|
||||
/* set all the function pointers to NULL. */
|
||||
#define SDL_KMSDRM_LEGACY_MODULE(modname) SDL_KMSDRM_LEGACY_HAVE_##modname = 0;
|
||||
#define SDL_KMSDRM_LEGACY_SYM(rc,fn,params) KMSDRM_LEGACY_##fn = NULL;
|
||||
#define SDL_KMSDRM_LEGACY_SYM_CONST(type,name) KMSDRM_LEGACY_##name = NULL;
|
||||
#include "SDL_kmsdrm_legacy_sym.h"
|
||||
|
||||
|
||||
#ifdef SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC
|
||||
for (i = 0; i < SDL_TABLESIZE(kmsdrmlibs); i++) {
|
||||
if (kmsdrmlibs[i].lib != NULL) {
|
||||
SDL_UnloadObject(kmsdrmlibs[i].lib);
|
||||
kmsdrmlibs[i].lib = NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* returns non-zero if all needed symbols were loaded. */
|
||||
int
|
||||
SDL_KMSDRM_LEGACY_LoadSymbols(void)
|
||||
{
|
||||
int rc = 1; /* always succeed if not using Dynamic KMSDRM_LEGACY stuff. */
|
||||
|
||||
/* deal with multiple modules needing these symbols... */
|
||||
if (kmsdrm_load_refcount++ == 0) {
|
||||
#ifdef SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC
|
||||
int i;
|
||||
int *thismod = NULL;
|
||||
for (i = 0; i < SDL_TABLESIZE(kmsdrmlibs); i++) {
|
||||
if (kmsdrmlibs[i].libname != NULL) {
|
||||
kmsdrmlibs[i].lib = SDL_LoadObject(kmsdrmlibs[i].libname);
|
||||
}
|
||||
}
|
||||
|
||||
#define SDL_KMSDRM_LEGACY_MODULE(modname) SDL_KMSDRM_LEGACY_HAVE_##modname = 1; /* default yes */
|
||||
#include "SDL_kmsdrm_legacy_sym.h"
|
||||
|
||||
#define SDL_KMSDRM_LEGACY_MODULE(modname) thismod = &SDL_KMSDRM_LEGACY_HAVE_##modname;
|
||||
#define SDL_KMSDRM_LEGACY_SYM(rc,fn,params) KMSDRM_LEGACY_##fn = (SDL_DYNKMSDRM_LEGACYFN_##fn) KMSDRM_LEGACY_GetSym(#fn,thismod);
|
||||
#define SDL_KMSDRM_LEGACY_SYM_CONST(type,name) KMSDRM_LEGACY_##name = *(SDL_DYNKMSDRM_LEGACYCONST_##name*) KMSDRM_LEGACY_GetSym(#name,thismod);
|
||||
#include "SDL_kmsdrm_legacy_sym.h"
|
||||
|
||||
if ((SDL_KMSDRM_LEGACY_HAVE_LIBDRM) && (SDL_KMSDRM_LEGACY_HAVE_GBM)) {
|
||||
/* all required symbols loaded. */
|
||||
SDL_ClearError();
|
||||
} else {
|
||||
/* in case something got loaded... */
|
||||
SDL_KMSDRM_LEGACY_UnloadSymbols();
|
||||
rc = 0;
|
||||
}
|
||||
|
||||
#else /* no dynamic KMSDRM_LEGACY */
|
||||
|
||||
#define SDL_KMSDRM_LEGACY_MODULE(modname) SDL_KMSDRM_LEGACY_HAVE_##modname = 1; /* default yes */
|
||||
#define SDL_KMSDRM_LEGACY_SYM(rc,fn,params) KMSDRM_LEGACY_##fn = fn;
|
||||
#define SDL_KMSDRM_LEGACY_SYM_CONST(type,name) KMSDRM_LEGACY_##name = name;
|
||||
#include "SDL_kmsdrm_legacy_sym.h"
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_KMSDRM */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
53
externals/SDL/src/video/kmsdrm_legacy/SDL_kmsdrm_legacy_dyn.h
vendored
Executable file
53
externals/SDL/src/video/kmsdrm_legacy/SDL_kmsdrm_legacy_dyn.h
vendored
Executable file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 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.
|
||||
*/
|
||||
|
||||
#ifndef SDL_kmsdrmdyn_h_
|
||||
#define SDL_kmsdrmdyn_h_
|
||||
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#include <xf86drm.h>
|
||||
#include <xf86drmMode.h>
|
||||
#include <gbm.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int SDL_KMSDRM_LEGACY_LoadSymbols(void);
|
||||
void SDL_KMSDRM_LEGACY_UnloadSymbols(void);
|
||||
|
||||
/* Declare all the function pointers and wrappers... */
|
||||
#define SDL_KMSDRM_LEGACY_SYM(rc,fn,params) \
|
||||
typedef rc (*SDL_DYNKMSDRM_LEGACYFN_##fn) params; \
|
||||
extern SDL_DYNKMSDRM_LEGACYFN_##fn KMSDRM_LEGACY_##fn;
|
||||
#define SDL_KMSDRM_LEGACY_SYM_CONST(type, name) \
|
||||
typedef type SDL_DYNKMSDRM_LEGACYCONST_##name; \
|
||||
extern SDL_DYNKMSDRM_LEGACYCONST_##name KMSDRM_LEGACY_##name;
|
||||
#include "SDL_kmsdrm_legacy_sym.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* SDL_kmsdrmdyn_h_ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
42
externals/SDL/src/video/kmsdrm_legacy/SDL_kmsdrm_legacy_events.c
vendored
Executable file
42
externals/SDL/src/video/kmsdrm_legacy/SDL_kmsdrm_legacy_events.c
vendored
Executable file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 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_KMSDRM
|
||||
|
||||
#include "SDL_kmsdrm_legacy_video.h"
|
||||
#include "SDL_kmsdrm_legacy_events.h"
|
||||
|
||||
#ifdef SDL_INPUT_LINUXEV
|
||||
#include "../../core/linux/SDL_evdev.h"
|
||||
#endif
|
||||
|
||||
void KMSDRM_LEGACY_PumpEvents(_THIS)
|
||||
{
|
||||
#ifdef SDL_INPUT_LINUXEV
|
||||
SDL_EVDEV_Poll();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_KMSDRM */
|
||||
|
31
externals/SDL/src/video/kmsdrm_legacy/SDL_kmsdrm_legacy_events.h
vendored
Executable file
31
externals/SDL/src/video/kmsdrm_legacy/SDL_kmsdrm_legacy_events.h
vendored
Executable file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 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_kmsdrmevents_h_
|
||||
#define SDL_kmsdrmevents_h_
|
||||
|
||||
extern void KMSDRM_LEGACY_PumpEvents(_THIS);
|
||||
extern void KMSDRM_LEGACY_EventInit(_THIS);
|
||||
extern void KMSDRM_LEGACY_EventQuit(_THIS);
|
||||
|
||||
#endif /* SDL_kmsdrmevents_h_ */
|
502
externals/SDL/src/video/kmsdrm_legacy/SDL_kmsdrm_legacy_mouse.c
vendored
Executable file
502
externals/SDL/src/video/kmsdrm_legacy/SDL_kmsdrm_legacy_mouse.c
vendored
Executable file
@@ -0,0 +1,502 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 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_KMSDRM
|
||||
|
||||
#include "SDL_kmsdrm_legacy_video.h"
|
||||
#include "SDL_kmsdrm_legacy_mouse.h"
|
||||
#include "SDL_kmsdrm_legacy_dyn.h"
|
||||
|
||||
#include "../../events/SDL_mouse_c.h"
|
||||
#include "../../events/default_cursor.h"
|
||||
|
||||
static SDL_Cursor *KMSDRM_LEGACY_CreateDefaultCursor(void);
|
||||
static SDL_Cursor *KMSDRM_LEGACY_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y);
|
||||
static int KMSDRM_LEGACY_ShowCursor(SDL_Cursor * cursor);
|
||||
static void KMSDRM_LEGACY_MoveCursor(SDL_Cursor * cursor);
|
||||
static void KMSDRM_LEGACY_FreeCursor(SDL_Cursor * cursor);
|
||||
static void KMSDRM_LEGACY_WarpMouse(SDL_Window * window, int x, int y);
|
||||
static int KMSDRM_LEGACY_WarpMouseGlobal(int x, int y);
|
||||
|
||||
static SDL_Cursor *
|
||||
KMSDRM_LEGACY_CreateDefaultCursor(void)
|
||||
{
|
||||
return SDL_CreateCursor(default_cdata, default_cmask, DEFAULT_CWIDTH, DEFAULT_CHEIGHT, DEFAULT_CHOTX, DEFAULT_CHOTY);
|
||||
}
|
||||
|
||||
/* Evaluate if a given cursor size is supported or not. Notably, current Intel gfx only support 64x64 and up. */
|
||||
static SDL_bool
|
||||
KMSDRM_LEGACY_IsCursorSizeSupported (int w, int h, uint32_t bo_format) {
|
||||
|
||||
SDL_VideoDevice *dev = SDL_GetVideoDevice();
|
||||
SDL_VideoData *viddata = ((SDL_VideoData *)dev->driverdata);
|
||||
SDL_DisplayData *dispdata = (SDL_DisplayData *)SDL_GetDisplayDriverData(0);
|
||||
|
||||
int ret;
|
||||
uint32_t bo_handle;
|
||||
struct gbm_bo *bo = KMSDRM_LEGACY_gbm_bo_create(viddata->gbm, w, h, bo_format,
|
||||
GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE);
|
||||
|
||||
if (!bo) {
|
||||
SDL_SetError("Could not create GBM cursor BO width size %dx%d for size testing", w, h);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
bo_handle = KMSDRM_LEGACY_gbm_bo_get_handle(bo).u32;
|
||||
ret = KMSDRM_LEGACY_drmModeSetCursor(viddata->drm_fd, dispdata->crtc_id, bo_handle, w, h);
|
||||
|
||||
if (ret) {
|
||||
goto cleanup;
|
||||
}
|
||||
else {
|
||||
KMSDRM_LEGACY_gbm_bo_destroy(bo);
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
if (bo) {
|
||||
KMSDRM_LEGACY_gbm_bo_destroy(bo);
|
||||
}
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
/* Create a cursor from a surface */
|
||||
static SDL_Cursor *
|
||||
KMSDRM_LEGACY_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
|
||||
{
|
||||
SDL_VideoDevice *dev = SDL_GetVideoDevice();
|
||||
SDL_VideoData *viddata = ((SDL_VideoData *)dev->driverdata);
|
||||
SDL_PixelFormat *pixlfmt = surface->format;
|
||||
KMSDRM_LEGACY_CursorData *curdata;
|
||||
SDL_Cursor *cursor;
|
||||
SDL_bool cursor_supported = SDL_FALSE;
|
||||
int i, ret, usable_cursor_w, usable_cursor_h;
|
||||
uint32_t bo_format, bo_stride;
|
||||
char *buffer = NULL;
|
||||
size_t bufsize;
|
||||
|
||||
switch(pixlfmt->format) {
|
||||
case SDL_PIXELFORMAT_RGB332:
|
||||
bo_format = GBM_FORMAT_RGB332;
|
||||
break;
|
||||
case SDL_PIXELFORMAT_ARGB4444:
|
||||
bo_format = GBM_FORMAT_ARGB4444;
|
||||
break;
|
||||
case SDL_PIXELFORMAT_RGBA4444:
|
||||
bo_format = GBM_FORMAT_RGBA4444;
|
||||
break;
|
||||
case SDL_PIXELFORMAT_ABGR4444:
|
||||
bo_format = GBM_FORMAT_ABGR4444;
|
||||
break;
|
||||
case SDL_PIXELFORMAT_BGRA4444:
|
||||
bo_format = GBM_FORMAT_BGRA4444;
|
||||
break;
|
||||
case SDL_PIXELFORMAT_ARGB1555:
|
||||
bo_format = GBM_FORMAT_ARGB1555;
|
||||
break;
|
||||
case SDL_PIXELFORMAT_RGBA5551:
|
||||
bo_format = GBM_FORMAT_RGBA5551;
|
||||
break;
|
||||
case SDL_PIXELFORMAT_ABGR1555:
|
||||
bo_format = GBM_FORMAT_ABGR1555;
|
||||
break;
|
||||
case SDL_PIXELFORMAT_BGRA5551:
|
||||
bo_format = GBM_FORMAT_BGRA5551;
|
||||
break;
|
||||
case SDL_PIXELFORMAT_RGB565:
|
||||
bo_format = GBM_FORMAT_RGB565;
|
||||
break;
|
||||
case SDL_PIXELFORMAT_BGR565:
|
||||
bo_format = GBM_FORMAT_BGR565;
|
||||
break;
|
||||
case SDL_PIXELFORMAT_RGB888:
|
||||
case SDL_PIXELFORMAT_RGB24:
|
||||
bo_format = GBM_FORMAT_RGB888;
|
||||
break;
|
||||
case SDL_PIXELFORMAT_BGR888:
|
||||
case SDL_PIXELFORMAT_BGR24:
|
||||
bo_format = GBM_FORMAT_BGR888;
|
||||
break;
|
||||
case SDL_PIXELFORMAT_RGBX8888:
|
||||
bo_format = GBM_FORMAT_RGBX8888;
|
||||
break;
|
||||
case SDL_PIXELFORMAT_BGRX8888:
|
||||
bo_format = GBM_FORMAT_BGRX8888;
|
||||
break;
|
||||
case SDL_PIXELFORMAT_ARGB8888:
|
||||
bo_format = GBM_FORMAT_ARGB8888;
|
||||
break;
|
||||
case SDL_PIXELFORMAT_RGBA8888:
|
||||
bo_format = GBM_FORMAT_RGBA8888;
|
||||
break;
|
||||
case SDL_PIXELFORMAT_ABGR8888:
|
||||
bo_format = GBM_FORMAT_ABGR8888;
|
||||
break;
|
||||
case SDL_PIXELFORMAT_BGRA8888:
|
||||
bo_format = GBM_FORMAT_BGRA8888;
|
||||
break;
|
||||
case SDL_PIXELFORMAT_ARGB2101010:
|
||||
bo_format = GBM_FORMAT_ARGB2101010;
|
||||
break;
|
||||
default:
|
||||
SDL_SetError("Unsupported pixel format for cursor");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!KMSDRM_LEGACY_gbm_device_is_format_supported(viddata->gbm, bo_format, GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE)) {
|
||||
SDL_SetError("Unsupported pixel format for cursor");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cursor = (SDL_Cursor *) SDL_calloc(1, sizeof(*cursor));
|
||||
if (!cursor) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
curdata = (KMSDRM_LEGACY_CursorData *) SDL_calloc(1, sizeof(*curdata));
|
||||
if (!curdata) {
|
||||
SDL_OutOfMemory();
|
||||
SDL_free(cursor);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* We have to know beforehand if a cursor with the same size as the surface is supported.
|
||||
* If it's not, we have to find an usable cursor size and use an intermediate and clean buffer.
|
||||
* If we can't find a cursor size supported by the hardware, we won't go on trying to
|
||||
* call SDL_SetCursor() later. */
|
||||
|
||||
usable_cursor_w = surface->w;
|
||||
usable_cursor_h = surface->h;
|
||||
|
||||
while (usable_cursor_w <= MAX_CURSOR_W && usable_cursor_h <= MAX_CURSOR_H) {
|
||||
if (KMSDRM_LEGACY_IsCursorSizeSupported(usable_cursor_w, usable_cursor_h, bo_format)) {
|
||||
cursor_supported = SDL_TRUE;
|
||||
break;
|
||||
}
|
||||
usable_cursor_w += usable_cursor_w;
|
||||
usable_cursor_h += usable_cursor_h;
|
||||
}
|
||||
|
||||
if (!cursor_supported) {
|
||||
SDL_SetError("Could not find a cursor size supported by the kernel driver");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
curdata->hot_x = hot_x;
|
||||
curdata->hot_y = hot_y;
|
||||
curdata->w = usable_cursor_w;
|
||||
curdata->h = usable_cursor_h;
|
||||
|
||||
curdata->bo = KMSDRM_LEGACY_gbm_bo_create(viddata->gbm, usable_cursor_w, usable_cursor_h, bo_format,
|
||||
GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE);
|
||||
|
||||
if (!curdata->bo) {
|
||||
SDL_SetError("Could not create GBM cursor BO");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
bo_stride = KMSDRM_LEGACY_gbm_bo_get_stride(curdata->bo);
|
||||
bufsize = bo_stride * curdata->h;
|
||||
|
||||
if (surface->pitch != bo_stride) {
|
||||
/* pitch doesn't match stride, must be copied to temp buffer */
|
||||
buffer = SDL_malloc(bufsize);
|
||||
if (!buffer) {
|
||||
SDL_OutOfMemory();
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (SDL_MUSTLOCK(surface)) {
|
||||
if (SDL_LockSurface(surface) < 0) {
|
||||
/* Could not lock surface */
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
/* Clean the whole temporary buffer */
|
||||
SDL_memset(buffer, 0x00, bo_stride * curdata->h);
|
||||
|
||||
/* Copy to temporary buffer */
|
||||
for (i = 0; i < surface->h; i++) {
|
||||
SDL_memcpy(buffer + (i * bo_stride),
|
||||
((char *)surface->pixels) + (i * surface->pitch),
|
||||
surface->w * pixlfmt->BytesPerPixel);
|
||||
}
|
||||
|
||||
if (SDL_MUSTLOCK(surface)) {
|
||||
SDL_UnlockSurface(surface);
|
||||
}
|
||||
|
||||
if (KMSDRM_LEGACY_gbm_bo_write(curdata->bo, buffer, bufsize)) {
|
||||
SDL_SetError("Could not write to GBM cursor BO");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* Free temporary buffer */
|
||||
SDL_free(buffer);
|
||||
buffer = NULL;
|
||||
} else {
|
||||
/* surface matches BO format */
|
||||
if (SDL_MUSTLOCK(surface)) {
|
||||
if (SDL_LockSurface(surface) < 0) {
|
||||
/* Could not lock surface */
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
ret = KMSDRM_LEGACY_gbm_bo_write(curdata->bo, surface->pixels, bufsize);
|
||||
|
||||
if (SDL_MUSTLOCK(surface)) {
|
||||
SDL_UnlockSurface(surface);
|
||||
}
|
||||
|
||||
if (ret) {
|
||||
SDL_SetError("Could not write to GBM cursor BO");
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
cursor->driverdata = curdata;
|
||||
|
||||
return cursor;
|
||||
|
||||
cleanup:
|
||||
if (buffer) {
|
||||
SDL_free(buffer);
|
||||
}
|
||||
if (cursor) {
|
||||
SDL_free(cursor);
|
||||
}
|
||||
if (curdata) {
|
||||
if (curdata->bo) {
|
||||
KMSDRM_LEGACY_gbm_bo_destroy(curdata->bo);
|
||||
}
|
||||
SDL_free(curdata);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Show the specified cursor, or hide if cursor is NULL */
|
||||
static int
|
||||
KMSDRM_LEGACY_ShowCursor(SDL_Cursor * cursor)
|
||||
{
|
||||
SDL_VideoDevice *dev = SDL_GetVideoDevice();
|
||||
SDL_VideoData *viddata = ((SDL_VideoData *)dev->driverdata);
|
||||
SDL_Mouse *mouse;
|
||||
KMSDRM_LEGACY_CursorData *curdata;
|
||||
SDL_VideoDisplay *display = NULL;
|
||||
SDL_DisplayData *dispdata = NULL;
|
||||
int ret;
|
||||
uint32_t bo_handle;
|
||||
|
||||
mouse = SDL_GetMouse();
|
||||
if (!mouse) {
|
||||
return SDL_SetError("No mouse.");
|
||||
}
|
||||
|
||||
if (mouse->focus) {
|
||||
display = SDL_GetDisplayForWindow(mouse->focus);
|
||||
if (display) {
|
||||
dispdata = (SDL_DisplayData*) display->driverdata;
|
||||
}
|
||||
}
|
||||
|
||||
if (!cursor) {
|
||||
/* Hide current cursor */
|
||||
if (mouse->cur_cursor && mouse->cur_cursor->driverdata) {
|
||||
curdata = (KMSDRM_LEGACY_CursorData *) mouse->cur_cursor->driverdata;
|
||||
|
||||
if (curdata->crtc_id != 0) {
|
||||
ret = KMSDRM_LEGACY_drmModeSetCursor(viddata->drm_fd, curdata->crtc_id, 0, 0, 0);
|
||||
if (ret) {
|
||||
SDL_SetError("Could not hide current cursor with drmModeSetCursor().");
|
||||
return ret;
|
||||
}
|
||||
/* Mark previous cursor as not-displayed */
|
||||
curdata->crtc_id = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/* otherwise if possible, hide global cursor */
|
||||
if (dispdata && dispdata->crtc_id != 0) {
|
||||
ret = KMSDRM_LEGACY_drmModeSetCursor(viddata->drm_fd, dispdata->crtc_id, 0, 0, 0);
|
||||
if (ret) {
|
||||
SDL_SetError("Could not hide display's cursor with drmModeSetCursor().");
|
||||
return ret;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
return SDL_SetError("Couldn't find cursor to hide.");
|
||||
}
|
||||
/* If cursor != NULL, show new cursor on display */
|
||||
if (!display) {
|
||||
return SDL_SetError("Could not get display for mouse.");
|
||||
}
|
||||
if (!dispdata) {
|
||||
return SDL_SetError("Could not get display driverdata.");
|
||||
}
|
||||
|
||||
curdata = (KMSDRM_LEGACY_CursorData *) cursor->driverdata;
|
||||
if (!curdata || !curdata->bo) {
|
||||
return SDL_SetError("Cursor not initialized properly.");
|
||||
}
|
||||
|
||||
bo_handle = KMSDRM_LEGACY_gbm_bo_get_handle(curdata->bo).u32;
|
||||
if (curdata->hot_x == 0 && curdata->hot_y == 0) {
|
||||
ret = KMSDRM_LEGACY_drmModeSetCursor(viddata->drm_fd, dispdata->crtc_id, bo_handle,
|
||||
curdata->w, curdata->h);
|
||||
} else {
|
||||
ret = KMSDRM_LEGACY_drmModeSetCursor2(viddata->drm_fd, dispdata->crtc_id, bo_handle,
|
||||
curdata->w, curdata->h, curdata->hot_x, curdata->hot_y);
|
||||
}
|
||||
if (ret) {
|
||||
SDL_SetError("drmModeSetCursor failed.");
|
||||
return ret;
|
||||
}
|
||||
|
||||
curdata->crtc_id = dispdata->crtc_id;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Free a window manager cursor */
|
||||
static void
|
||||
KMSDRM_LEGACY_FreeCursor(SDL_Cursor * cursor)
|
||||
{
|
||||
KMSDRM_LEGACY_CursorData *curdata;
|
||||
int drm_fd;
|
||||
|
||||
if (cursor) {
|
||||
curdata = (KMSDRM_LEGACY_CursorData *) cursor->driverdata;
|
||||
|
||||
if (curdata) {
|
||||
if (curdata->bo) {
|
||||
if (curdata->crtc_id != 0) {
|
||||
drm_fd = KMSDRM_LEGACY_gbm_device_get_fd(KMSDRM_LEGACY_gbm_bo_get_device(curdata->bo));
|
||||
/* Hide the cursor if previously shown on a CRTC */
|
||||
KMSDRM_LEGACY_drmModeSetCursor(drm_fd, curdata->crtc_id, 0, 0, 0);
|
||||
curdata->crtc_id = 0;
|
||||
}
|
||||
KMSDRM_LEGACY_gbm_bo_destroy(curdata->bo);
|
||||
curdata->bo = NULL;
|
||||
}
|
||||
SDL_free(cursor->driverdata);
|
||||
}
|
||||
SDL_free(cursor);
|
||||
}
|
||||
}
|
||||
|
||||
/* Warp the mouse to (x,y) */
|
||||
static void
|
||||
KMSDRM_LEGACY_WarpMouse(SDL_Window * window, int x, int y)
|
||||
{
|
||||
/* Only one global/fullscreen window is supported */
|
||||
KMSDRM_LEGACY_WarpMouseGlobal(x, y);
|
||||
}
|
||||
|
||||
/* Warp the mouse to (x,y) */
|
||||
static int
|
||||
KMSDRM_LEGACY_WarpMouseGlobal(int x, int y)
|
||||
{
|
||||
KMSDRM_LEGACY_CursorData *curdata;
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
|
||||
if (mouse && mouse->cur_cursor && mouse->cur_cursor->driverdata) {
|
||||
/* Update internal mouse position. */
|
||||
SDL_SendMouseMotion(mouse->focus, mouse->mouseID, 0, x, y);
|
||||
|
||||
/* And now update the cursor graphic position on screen. */
|
||||
curdata = (KMSDRM_LEGACY_CursorData *) mouse->cur_cursor->driverdata;
|
||||
if (curdata->bo) {
|
||||
|
||||
if (curdata->crtc_id != 0) {
|
||||
int ret, drm_fd;
|
||||
drm_fd = KMSDRM_LEGACY_gbm_device_get_fd(KMSDRM_LEGACY_gbm_bo_get_device(curdata->bo));
|
||||
ret = KMSDRM_LEGACY_drmModeMoveCursor(drm_fd, curdata->crtc_id, x, y);
|
||||
|
||||
if (ret) {
|
||||
SDL_SetError("drmModeMoveCursor() failed.");
|
||||
}
|
||||
|
||||
return ret;
|
||||
} else {
|
||||
return SDL_SetError("Cursor is not currently shown.");
|
||||
}
|
||||
} else {
|
||||
return SDL_SetError("Cursor not initialized properly.");
|
||||
}
|
||||
} else {
|
||||
return SDL_SetError("No mouse or current cursor.");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
KMSDRM_LEGACY_InitMouse(_THIS)
|
||||
{
|
||||
/* FIXME: Using UDEV it should be possible to scan all mice
|
||||
* but there's no point in doing so as there's no multimice support...yet!
|
||||
*/
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
|
||||
mouse->CreateCursor = KMSDRM_LEGACY_CreateCursor;
|
||||
mouse->ShowCursor = KMSDRM_LEGACY_ShowCursor;
|
||||
mouse->MoveCursor = KMSDRM_LEGACY_MoveCursor;
|
||||
mouse->FreeCursor = KMSDRM_LEGACY_FreeCursor;
|
||||
mouse->WarpMouse = KMSDRM_LEGACY_WarpMouse;
|
||||
mouse->WarpMouseGlobal = KMSDRM_LEGACY_WarpMouseGlobal;
|
||||
|
||||
SDL_SetDefaultCursor(KMSDRM_LEGACY_CreateDefaultCursor());
|
||||
}
|
||||
|
||||
void
|
||||
KMSDRM_LEGACY_QuitMouse(_THIS)
|
||||
{
|
||||
/* TODO: ? */
|
||||
}
|
||||
|
||||
/* This is called when a mouse motion event occurs */
|
||||
static void
|
||||
KMSDRM_LEGACY_MoveCursor(SDL_Cursor * cursor)
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
KMSDRM_LEGACY_CursorData *curdata;
|
||||
int drm_fd, ret;
|
||||
|
||||
/* We must NOT call SDL_SendMouseMotion() here or we will enter recursivity!
|
||||
That's why we move the cursor graphic ONLY. */
|
||||
if (mouse && mouse->cur_cursor && mouse->cur_cursor->driverdata) {
|
||||
curdata = (KMSDRM_LEGACY_CursorData *) mouse->cur_cursor->driverdata;
|
||||
drm_fd = KMSDRM_LEGACY_gbm_device_get_fd(KMSDRM_LEGACY_gbm_bo_get_device(curdata->bo));
|
||||
ret = KMSDRM_LEGACY_drmModeMoveCursor(drm_fd, curdata->crtc_id, mouse->x, mouse->y);
|
||||
|
||||
if (ret) {
|
||||
SDL_SetError("drmModeMoveCursor() failed.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_KMSDRM */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
45
externals/SDL/src/video/kmsdrm_legacy/SDL_kmsdrm_legacy_mouse.h
vendored
Executable file
45
externals/SDL/src/video/kmsdrm_legacy/SDL_kmsdrm_legacy_mouse.h
vendored
Executable file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 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_KMSDRM_LEGACY_mouse_h_
|
||||
#define SDL_KMSDRM_LEGACY_mouse_h_
|
||||
|
||||
#include <gbm.h>
|
||||
|
||||
#define MAX_CURSOR_W 512
|
||||
#define MAX_CURSOR_H 512
|
||||
|
||||
typedef struct _KMSDRM_LEGACY_CursorData
|
||||
{
|
||||
struct gbm_bo *bo;
|
||||
uint32_t crtc_id;
|
||||
int hot_x, hot_y;
|
||||
int w, h;
|
||||
} KMSDRM_LEGACY_CursorData;
|
||||
|
||||
extern void KMSDRM_LEGACY_InitMouse(_THIS);
|
||||
extern void KMSDRM_LEGACY_QuitMouse(_THIS);
|
||||
|
||||
#endif /* SDL_KMSDRM_LEGACY_mouse_h_ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
152
externals/SDL/src/video/kmsdrm_legacy/SDL_kmsdrm_legacy_opengles.c
vendored
Executable file
152
externals/SDL/src/video/kmsdrm_legacy/SDL_kmsdrm_legacy_opengles.c
vendored
Executable file
@@ -0,0 +1,152 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 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_KMSDRM && SDL_VIDEO_OPENGL_EGL
|
||||
|
||||
#include "SDL_log.h"
|
||||
|
||||
#include "SDL_kmsdrm_legacy_video.h"
|
||||
#include "SDL_kmsdrm_legacy_opengles.h"
|
||||
#include "SDL_kmsdrm_legacy_dyn.h"
|
||||
|
||||
#ifndef EGL_PLATFORM_GBM_MESA
|
||||
#define EGL_PLATFORM_GBM_MESA 0x31D7
|
||||
#endif
|
||||
|
||||
/* EGL implementation of SDL OpenGL support */
|
||||
|
||||
int
|
||||
KMSDRM_LEGACY_GLES_LoadLibrary(_THIS, const char *path) {
|
||||
NativeDisplayType display = (NativeDisplayType)((SDL_VideoData *)_this->driverdata)->gbm;
|
||||
return SDL_EGL_LoadLibrary(_this, path, display, EGL_PLATFORM_GBM_MESA);
|
||||
}
|
||||
|
||||
SDL_EGL_CreateContext_impl(KMSDRM_LEGACY)
|
||||
|
||||
int KMSDRM_LEGACY_GLES_SetSwapInterval(_THIS, int interval) {
|
||||
if (!_this->egl_data) {
|
||||
return SDL_SetError("EGL not initialized");
|
||||
}
|
||||
|
||||
if (interval == 0 || interval == 1) {
|
||||
_this->egl_data->egl_swapinterval = interval;
|
||||
} else {
|
||||
return SDL_SetError("Only swap intervals of 0 or 1 are supported");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
KMSDRM_LEGACY_GLES_SwapWindow(_THIS, SDL_Window * window) {
|
||||
SDL_WindowData *windata = ((SDL_WindowData *) window->driverdata);
|
||||
SDL_DisplayData *dispdata = (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata;
|
||||
SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
|
||||
KMSDRM_LEGACY_FBInfo *fb_info;
|
||||
int ret, timeout;
|
||||
|
||||
/* Recreate the GBM / EGL surfaces if the display mode has changed */
|
||||
if (windata->egl_surface_dirty) {
|
||||
KMSDRM_LEGACY_CreateSurfaces(_this, window);
|
||||
}
|
||||
|
||||
/* Wait for confirmation that the next front buffer has been flipped, at which
|
||||
point the previous front buffer can be released */
|
||||
timeout = 0;
|
||||
if (_this->egl_data->egl_swapinterval == 1) {
|
||||
timeout = -1;
|
||||
}
|
||||
if (!KMSDRM_LEGACY_WaitPageFlip(_this, windata, timeout)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Release the previous front buffer */
|
||||
if (windata->curr_bo) {
|
||||
KMSDRM_LEGACY_gbm_surface_release_buffer(windata->gs, windata->curr_bo);
|
||||
/* SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Released GBM surface %p", (void *)windata->curr_bo); */
|
||||
windata->curr_bo = NULL;
|
||||
}
|
||||
|
||||
windata->curr_bo = windata->next_bo;
|
||||
|
||||
/* Make the current back buffer the next front buffer */
|
||||
if (!(_this->egl_data->eglSwapBuffers(_this->egl_data->egl_display, windata->egl_surface))) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "eglSwapBuffers failed.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Lock the next front buffer so it can't be allocated as a back buffer */
|
||||
windata->next_bo = KMSDRM_LEGACY_gbm_surface_lock_front_buffer(windata->gs);
|
||||
if (!windata->next_bo) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not lock GBM surface front buffer");
|
||||
return 0;
|
||||
/* } else {
|
||||
SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Locked GBM surface %p", (void *)windata->next_bo); */
|
||||
}
|
||||
|
||||
fb_info = KMSDRM_LEGACY_FBFromBO(_this, windata->next_bo);
|
||||
if (!fb_info) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!windata->curr_bo) {
|
||||
/* On the first swap, immediately present the new front buffer. Before
|
||||
drmModePageFlip can be used the CRTC has to be configured to use
|
||||
the current connector and mode with drmModeSetCrtc */
|
||||
ret = KMSDRM_LEGACY_drmModeSetCrtc(viddata->drm_fd, dispdata->crtc_id, fb_info->fb_id, 0,
|
||||
0, &dispdata->conn->connector_id, 1, &dispdata->mode);
|
||||
|
||||
if (ret) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not configure CRTC");
|
||||
}
|
||||
} else {
|
||||
/* On subsequent swaps, queue the new front buffer to be flipped during
|
||||
the next vertical blank */
|
||||
ret = KMSDRM_LEGACY_drmModePageFlip(viddata->drm_fd, dispdata->crtc_id, fb_info->fb_id,
|
||||
DRM_MODE_PAGE_FLIP_EVENT, &windata->waiting_for_flip);
|
||||
/* SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "drmModePageFlip(%d, %u, %u, DRM_MODE_PAGE_FLIP_EVENT, &windata->waiting_for_flip)",
|
||||
viddata->drm_fd, displaydata->crtc_id, fb_info->fb_id); */
|
||||
|
||||
if (_this->egl_data->egl_swapinterval == 1) {
|
||||
if (ret == 0) {
|
||||
windata->waiting_for_flip = SDL_TRUE;
|
||||
} else {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not queue pageflip: %d", ret);
|
||||
}
|
||||
}
|
||||
|
||||
/* Wait immediately for vsync (as if we only had two buffers), for low input-lag scenarios.
|
||||
Run your SDL2 program with "SDL_KMSDRM_LEGACY_DOUBLE_BUFFER=1 <program_name>" to enable this. */
|
||||
if (_this->egl_data->egl_swapinterval == 1 && windata->double_buffer) {
|
||||
KMSDRM_LEGACY_WaitPageFlip(_this, windata, -1);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SDL_EGL_MakeCurrent_impl(KMSDRM_LEGACY)
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_KMSDRM && SDL_VIDEO_OPENGL_EGL */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
48
externals/SDL/src/video/kmsdrm_legacy/SDL_kmsdrm_legacy_opengles.h
vendored
Executable file
48
externals/SDL/src/video/kmsdrm_legacy/SDL_kmsdrm_legacy_opengles.h
vendored
Executable file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 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_kmsdrmopengles_h_
|
||||
#define SDL_kmsdrmopengles_h_
|
||||
|
||||
#if SDL_VIDEO_DRIVER_KMSDRM && SDL_VIDEO_OPENGL_EGL
|
||||
|
||||
#include "../SDL_sysvideo.h"
|
||||
#include "../SDL_egl_c.h"
|
||||
|
||||
/* OpenGLES functions */
|
||||
#define KMSDRM_LEGACY_GLES_GetAttribute SDL_EGL_GetAttribute
|
||||
#define KMSDRM_LEGACY_GLES_GetProcAddress SDL_EGL_GetProcAddress
|
||||
#define KMSDRM_LEGACY_GLES_UnloadLibrary SDL_EGL_UnloadLibrary
|
||||
#define KMSDRM_LEGACY_GLES_DeleteContext SDL_EGL_DeleteContext
|
||||
#define KMSDRM_LEGACY_GLES_GetSwapInterval SDL_EGL_GetSwapInterval
|
||||
|
||||
extern int KMSDRM_LEGACY_GLES_SetSwapInterval(_THIS, int interval);
|
||||
extern int KMSDRM_LEGACY_GLES_LoadLibrary(_THIS, const char *path);
|
||||
extern SDL_GLContext KMSDRM_LEGACY_GLES_CreateContext(_THIS, SDL_Window * window);
|
||||
extern int KMSDRM_LEGACY_GLES_SwapWindow(_THIS, SDL_Window * window);
|
||||
extern int KMSDRM_LEGACY_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context);
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_KMSDRM && SDL_VIDEO_OPENGL_EGL */
|
||||
|
||||
#endif /* SDL_kmsdrmopengles_h_ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
99
externals/SDL/src/video/kmsdrm_legacy/SDL_kmsdrm_legacy_sym.h
vendored
Executable file
99
externals/SDL/src/video/kmsdrm_legacy/SDL_kmsdrm_legacy_sym.h
vendored
Executable file
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 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.
|
||||
*/
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
|
||||
#ifndef SDL_KMSDRM_LEGACY_MODULE
|
||||
#define SDL_KMSDRM_LEGACY_MODULE(modname)
|
||||
#endif
|
||||
|
||||
#ifndef SDL_KMSDRM_LEGACY_SYM
|
||||
#define SDL_KMSDRM_LEGACY_SYM(rc,fn,params)
|
||||
#endif
|
||||
|
||||
#ifndef SDL_KMSDRM_LEGACY_SYM_CONST
|
||||
#define SDL_KMSDRM_LEGACY_SYM_CONST(type, name)
|
||||
#endif
|
||||
|
||||
|
||||
SDL_KMSDRM_LEGACY_MODULE(LIBDRM)
|
||||
SDL_KMSDRM_LEGACY_SYM(void,drmModeFreeResources,(drmModeResPtr ptr))
|
||||
SDL_KMSDRM_LEGACY_SYM(void,drmModeFreeFB,(drmModeFBPtr ptr))
|
||||
SDL_KMSDRM_LEGACY_SYM(void,drmModeFreeCrtc,(drmModeCrtcPtr ptr))
|
||||
SDL_KMSDRM_LEGACY_SYM(void,drmModeFreeConnector,(drmModeConnectorPtr ptr))
|
||||
SDL_KMSDRM_LEGACY_SYM(void,drmModeFreeEncoder,(drmModeEncoderPtr ptr))
|
||||
SDL_KMSDRM_LEGACY_SYM(drmModeResPtr,drmModeGetResources,(int fd))
|
||||
SDL_KMSDRM_LEGACY_SYM(int,drmModeAddFB,(int fd, uint32_t width, uint32_t height, uint8_t depth,
|
||||
uint8_t bpp, uint32_t pitch, uint32_t bo_handle,
|
||||
uint32_t *buf_id))
|
||||
SDL_KMSDRM_LEGACY_SYM(int,drmModeRmFB,(int fd, uint32_t bufferId))
|
||||
SDL_KMSDRM_LEGACY_SYM(drmModeFBPtr,drmModeGetFB,(int fd, uint32_t buf))
|
||||
SDL_KMSDRM_LEGACY_SYM(drmModeCrtcPtr,drmModeGetCrtc,(int fd, uint32_t crtcId))
|
||||
SDL_KMSDRM_LEGACY_SYM(int,drmModeSetCrtc,(int fd, uint32_t crtcId, uint32_t bufferId,
|
||||
uint32_t x, uint32_t y, uint32_t *connectors, int count,
|
||||
drmModeModeInfoPtr mode))
|
||||
SDL_KMSDRM_LEGACY_SYM(int,drmModeSetCursor,(int fd, uint32_t crtcId, uint32_t bo_handle,
|
||||
uint32_t width, uint32_t height))
|
||||
SDL_KMSDRM_LEGACY_SYM(int,drmModeSetCursor2,(int fd, uint32_t crtcId, uint32_t bo_handle,
|
||||
uint32_t width, uint32_t height,
|
||||
int32_t hot_x, int32_t hot_y))
|
||||
SDL_KMSDRM_LEGACY_SYM(int,drmModeMoveCursor,(int fd, uint32_t crtcId, int x, int y))
|
||||
SDL_KMSDRM_LEGACY_SYM(drmModeEncoderPtr,drmModeGetEncoder,(int fd, uint32_t encoder_id))
|
||||
SDL_KMSDRM_LEGACY_SYM(drmModeConnectorPtr,drmModeGetConnector,(int fd, uint32_t connector_id))
|
||||
SDL_KMSDRM_LEGACY_SYM(int,drmHandleEvent,(int fd,drmEventContextPtr evctx))
|
||||
SDL_KMSDRM_LEGACY_SYM(int,drmModePageFlip,(int fd, uint32_t crtc_id, uint32_t fb_id,
|
||||
uint32_t flags, void *user_data))
|
||||
|
||||
|
||||
SDL_KMSDRM_LEGACY_MODULE(GBM)
|
||||
SDL_KMSDRM_LEGACY_SYM(int,gbm_device_get_fd,(struct gbm_device *gbm))
|
||||
SDL_KMSDRM_LEGACY_SYM(int,gbm_device_is_format_supported,(struct gbm_device *gbm,
|
||||
uint32_t format, uint32_t usage))
|
||||
SDL_KMSDRM_LEGACY_SYM(void,gbm_device_destroy,(struct gbm_device *gbm))
|
||||
SDL_KMSDRM_LEGACY_SYM(struct gbm_device *,gbm_create_device,(int fd))
|
||||
SDL_KMSDRM_LEGACY_SYM(unsigned int,gbm_bo_get_width,(struct gbm_bo *bo))
|
||||
SDL_KMSDRM_LEGACY_SYM(unsigned int,gbm_bo_get_height,(struct gbm_bo *bo))
|
||||
SDL_KMSDRM_LEGACY_SYM(uint32_t,gbm_bo_get_stride,(struct gbm_bo *bo))
|
||||
SDL_KMSDRM_LEGACY_SYM(union gbm_bo_handle,gbm_bo_get_handle,(struct gbm_bo *bo))
|
||||
SDL_KMSDRM_LEGACY_SYM(int,gbm_bo_write,(struct gbm_bo *bo, const void *buf, size_t count))
|
||||
SDL_KMSDRM_LEGACY_SYM(struct gbm_device *,gbm_bo_get_device,(struct gbm_bo *bo))
|
||||
SDL_KMSDRM_LEGACY_SYM(void,gbm_bo_set_user_data,(struct gbm_bo *bo, void *data,
|
||||
void (*destroy_user_data)(struct gbm_bo *, void *)))
|
||||
SDL_KMSDRM_LEGACY_SYM(void *,gbm_bo_get_user_data,(struct gbm_bo *bo))
|
||||
SDL_KMSDRM_LEGACY_SYM(void,gbm_bo_destroy,(struct gbm_bo *bo))
|
||||
SDL_KMSDRM_LEGACY_SYM(struct gbm_bo *,gbm_bo_create,(struct gbm_device *gbm,
|
||||
uint32_t width, uint32_t height,
|
||||
uint32_t format, uint32_t usage))
|
||||
SDL_KMSDRM_LEGACY_SYM(struct gbm_surface *,gbm_surface_create,(struct gbm_device *gbm,
|
||||
uint32_t width, uint32_t height,
|
||||
uint32_t format, uint32_t flags))
|
||||
SDL_KMSDRM_LEGACY_SYM(void,gbm_surface_destroy,(struct gbm_surface *surf))
|
||||
SDL_KMSDRM_LEGACY_SYM(struct gbm_bo *,gbm_surface_lock_front_buffer,(struct gbm_surface *surf))
|
||||
SDL_KMSDRM_LEGACY_SYM(void,gbm_surface_release_buffer,(struct gbm_surface *surf, struct gbm_bo *bo))
|
||||
|
||||
|
||||
#undef SDL_KMSDRM_LEGACY_MODULE
|
||||
#undef SDL_KMSDRM_LEGACY_SYM
|
||||
#undef SDL_KMSDRM_LEGACY_SYM_CONST
|
||||
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
934
externals/SDL/src/video/kmsdrm_legacy/SDL_kmsdrm_legacy_video.c
vendored
Executable file
934
externals/SDL/src/video/kmsdrm_legacy/SDL_kmsdrm_legacy_video.c
vendored
Executable file
@@ -0,0 +1,934 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 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_KMSDRM
|
||||
|
||||
/* SDL internals */
|
||||
#include "../SDL_sysvideo.h"
|
||||
#include "SDL_syswm.h"
|
||||
#include "SDL_log.h"
|
||||
#include "SDL_hints.h"
|
||||
#include "../../events/SDL_events_c.h"
|
||||
#include "../../events/SDL_mouse_c.h"
|
||||
#include "../../events/SDL_keyboard_c.h"
|
||||
|
||||
#ifdef SDL_INPUT_LINUXEV
|
||||
#include "../../core/linux/SDL_evdev.h"
|
||||
#endif
|
||||
|
||||
/* KMS/DRM declarations */
|
||||
#include "SDL_kmsdrm_legacy_video.h"
|
||||
#include "SDL_kmsdrm_legacy_events.h"
|
||||
#include "SDL_kmsdrm_legacy_opengles.h"
|
||||
#include "SDL_kmsdrm_legacy_mouse.h"
|
||||
#include "SDL_kmsdrm_legacy_dyn.h"
|
||||
#include <sys/stat.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <poll.h>
|
||||
|
||||
#define KMSDRM_LEGACY_DRI_PATH "/dev/dri/"
|
||||
|
||||
static int
|
||||
check_modestting(int devindex)
|
||||
{
|
||||
SDL_bool available = SDL_FALSE;
|
||||
char device[512];
|
||||
int drm_fd;
|
||||
|
||||
SDL_snprintf(device, sizeof (device), "%scard%d", KMSDRM_LEGACY_DRI_PATH, devindex);
|
||||
|
||||
drm_fd = open(device, O_RDWR | O_CLOEXEC);
|
||||
if (drm_fd >= 0) {
|
||||
if (SDL_KMSDRM_LEGACY_LoadSymbols()) {
|
||||
drmModeRes *resources = KMSDRM_LEGACY_drmModeGetResources(drm_fd);
|
||||
if (resources) {
|
||||
SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "%scard%d connector, encoder and CRTC counts are: %d %d %d",
|
||||
KMSDRM_LEGACY_DRI_PATH, devindex,
|
||||
resources->count_connectors, resources->count_encoders, resources->count_crtcs);
|
||||
|
||||
if (resources->count_connectors > 0 && resources->count_encoders > 0 && resources->count_crtcs > 0) {
|
||||
available = SDL_TRUE;
|
||||
}
|
||||
KMSDRM_LEGACY_drmModeFreeResources(resources);
|
||||
}
|
||||
SDL_KMSDRM_LEGACY_UnloadSymbols();
|
||||
}
|
||||
close(drm_fd);
|
||||
}
|
||||
|
||||
return available;
|
||||
}
|
||||
|
||||
static int get_dricount(void)
|
||||
{
|
||||
int devcount = 0;
|
||||
struct dirent *res;
|
||||
struct stat sb;
|
||||
DIR *folder;
|
||||
|
||||
if (!(stat(KMSDRM_LEGACY_DRI_PATH, &sb) == 0
|
||||
&& S_ISDIR(sb.st_mode))) {
|
||||
printf("The path %s cannot be opened or is not available\n",
|
||||
KMSDRM_LEGACY_DRI_PATH);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (access(KMSDRM_LEGACY_DRI_PATH, F_OK) == -1) {
|
||||
printf("The path %s cannot be opened\n",
|
||||
KMSDRM_LEGACY_DRI_PATH);
|
||||
return 0;
|
||||
}
|
||||
|
||||
folder = opendir(KMSDRM_LEGACY_DRI_PATH);
|
||||
if (folder) {
|
||||
while ((res = readdir(folder))) {
|
||||
int len = SDL_strlen(res->d_name);
|
||||
if (len > 4 && SDL_strncmp(res->d_name, "card", 4) == 0) {
|
||||
devcount++;
|
||||
}
|
||||
}
|
||||
closedir(folder);
|
||||
}
|
||||
|
||||
return devcount;
|
||||
}
|
||||
|
||||
static int
|
||||
get_driindex(void)
|
||||
{
|
||||
const int devcount = get_dricount();
|
||||
int i;
|
||||
|
||||
for (i = 0; i < devcount; i++) {
|
||||
if (check_modestting(i)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
static int
|
||||
KMSDRM_LEGACY_Available(void)
|
||||
{
|
||||
int ret = -ENOENT;
|
||||
|
||||
ret = get_driindex();
|
||||
if (ret >= 0)
|
||||
return 1;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
KMSDRM_LEGACY_DeleteDevice(SDL_VideoDevice * device)
|
||||
{
|
||||
if (device->driverdata) {
|
||||
SDL_free(device->driverdata);
|
||||
device->driverdata = NULL;
|
||||
}
|
||||
|
||||
SDL_free(device);
|
||||
|
||||
SDL_KMSDRM_LEGACY_UnloadSymbols();
|
||||
}
|
||||
|
||||
static SDL_VideoDevice *
|
||||
KMSDRM_LEGACY_CreateDevice(int devindex)
|
||||
{
|
||||
SDL_VideoDevice *device;
|
||||
SDL_VideoData *viddata;
|
||||
|
||||
if (!KMSDRM_LEGACY_Available()) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!devindex || (devindex > 99)) {
|
||||
devindex = get_driindex();
|
||||
}
|
||||
|
||||
if (devindex < 0) {
|
||||
SDL_SetError("devindex (%d) must be between 0 and 99.\n", devindex);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!SDL_KMSDRM_LEGACY_LoadSymbols()) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
|
||||
if (!device) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
viddata = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
|
||||
if (!viddata) {
|
||||
SDL_OutOfMemory();
|
||||
goto cleanup;
|
||||
}
|
||||
viddata->devindex = devindex;
|
||||
viddata->drm_fd = -1;
|
||||
|
||||
device->driverdata = viddata;
|
||||
|
||||
/* Setup all functions which we can handle */
|
||||
device->VideoInit = KMSDRM_LEGACY_VideoInit;
|
||||
device->VideoQuit = KMSDRM_LEGACY_VideoQuit;
|
||||
device->GetDisplayModes = KMSDRM_LEGACY_GetDisplayModes;
|
||||
device->SetDisplayMode = KMSDRM_LEGACY_SetDisplayMode;
|
||||
device->CreateSDLWindow = KMSDRM_LEGACY_CreateWindow;
|
||||
device->CreateSDLWindowFrom = KMSDRM_LEGACY_CreateWindowFrom;
|
||||
device->SetWindowTitle = KMSDRM_LEGACY_SetWindowTitle;
|
||||
device->SetWindowIcon = KMSDRM_LEGACY_SetWindowIcon;
|
||||
device->SetWindowPosition = KMSDRM_LEGACY_SetWindowPosition;
|
||||
device->SetWindowSize = KMSDRM_LEGACY_SetWindowSize;
|
||||
device->ShowWindow = KMSDRM_LEGACY_ShowWindow;
|
||||
device->HideWindow = KMSDRM_LEGACY_HideWindow;
|
||||
device->RaiseWindow = KMSDRM_LEGACY_RaiseWindow;
|
||||
device->MaximizeWindow = KMSDRM_LEGACY_MaximizeWindow;
|
||||
device->MinimizeWindow = KMSDRM_LEGACY_MinimizeWindow;
|
||||
device->RestoreWindow = KMSDRM_LEGACY_RestoreWindow;
|
||||
device->SetWindowGrab = KMSDRM_LEGACY_SetWindowGrab;
|
||||
device->DestroyWindow = KMSDRM_LEGACY_DestroyWindow;
|
||||
device->GetWindowWMInfo = KMSDRM_LEGACY_GetWindowWMInfo;
|
||||
#if SDL_VIDEO_OPENGL_EGL
|
||||
device->GL_LoadLibrary = KMSDRM_LEGACY_GLES_LoadLibrary;
|
||||
device->GL_GetProcAddress = KMSDRM_LEGACY_GLES_GetProcAddress;
|
||||
device->GL_UnloadLibrary = KMSDRM_LEGACY_GLES_UnloadLibrary;
|
||||
device->GL_CreateContext = KMSDRM_LEGACY_GLES_CreateContext;
|
||||
device->GL_MakeCurrent = KMSDRM_LEGACY_GLES_MakeCurrent;
|
||||
device->GL_SetSwapInterval = KMSDRM_LEGACY_GLES_SetSwapInterval;
|
||||
device->GL_GetSwapInterval = KMSDRM_LEGACY_GLES_GetSwapInterval;
|
||||
device->GL_SwapWindow = KMSDRM_LEGACY_GLES_SwapWindow;
|
||||
device->GL_DeleteContext = KMSDRM_LEGACY_GLES_DeleteContext;
|
||||
#endif
|
||||
device->PumpEvents = KMSDRM_LEGACY_PumpEvents;
|
||||
device->free = KMSDRM_LEGACY_DeleteDevice;
|
||||
|
||||
return device;
|
||||
|
||||
cleanup:
|
||||
if (device)
|
||||
SDL_free(device);
|
||||
if (viddata)
|
||||
SDL_free(viddata);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
VideoBootStrap KMSDRM_LEGACY_bootstrap = {
|
||||
"KMSDRM_LEGACY",
|
||||
"KMS/DRM Video Driver",
|
||||
KMSDRM_LEGACY_CreateDevice
|
||||
};
|
||||
|
||||
|
||||
static void
|
||||
KMSDRM_LEGACY_FBDestroyCallback(struct gbm_bo *bo, void *data)
|
||||
{
|
||||
KMSDRM_LEGACY_FBInfo *fb_info = (KMSDRM_LEGACY_FBInfo *)data;
|
||||
|
||||
if (fb_info && fb_info->drm_fd >= 0 && fb_info->fb_id != 0) {
|
||||
KMSDRM_LEGACY_drmModeRmFB(fb_info->drm_fd, fb_info->fb_id);
|
||||
SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Delete DRM FB %u", fb_info->fb_id);
|
||||
}
|
||||
|
||||
SDL_free(fb_info);
|
||||
}
|
||||
|
||||
KMSDRM_LEGACY_FBInfo *
|
||||
KMSDRM_LEGACY_FBFromBO(_THIS, struct gbm_bo *bo)
|
||||
{
|
||||
SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
|
||||
unsigned w,h;
|
||||
int ret;
|
||||
Uint32 stride, handle;
|
||||
|
||||
/* Check for an existing framebuffer */
|
||||
KMSDRM_LEGACY_FBInfo *fb_info = (KMSDRM_LEGACY_FBInfo *)KMSDRM_LEGACY_gbm_bo_get_user_data(bo);
|
||||
|
||||
if (fb_info) {
|
||||
return fb_info;
|
||||
}
|
||||
|
||||
/* Create a structure that contains enough info to remove the framebuffer
|
||||
when the backing buffer is destroyed */
|
||||
fb_info = (KMSDRM_LEGACY_FBInfo *)SDL_calloc(1, sizeof(KMSDRM_LEGACY_FBInfo));
|
||||
|
||||
if (!fb_info) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
fb_info->drm_fd = viddata->drm_fd;
|
||||
|
||||
/* Create framebuffer object for the buffer */
|
||||
w = KMSDRM_LEGACY_gbm_bo_get_width(bo);
|
||||
h = KMSDRM_LEGACY_gbm_bo_get_height(bo);
|
||||
stride = KMSDRM_LEGACY_gbm_bo_get_stride(bo);
|
||||
handle = KMSDRM_LEGACY_gbm_bo_get_handle(bo).u32;
|
||||
ret = KMSDRM_LEGACY_drmModeAddFB(viddata->drm_fd, w, h, 24, 32, stride, handle,
|
||||
&fb_info->fb_id);
|
||||
if (ret) {
|
||||
SDL_free(fb_info);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "New DRM FB (%u): %ux%u, stride %u from BO %p",
|
||||
fb_info->fb_id, w, h, stride, (void *)bo);
|
||||
|
||||
/* Associate our DRM framebuffer with this buffer object */
|
||||
KMSDRM_LEGACY_gbm_bo_set_user_data(bo, fb_info, KMSDRM_LEGACY_FBDestroyCallback);
|
||||
|
||||
return fb_info;
|
||||
}
|
||||
|
||||
static void
|
||||
KMSDRM_LEGACY_FlipHandler(int fd, unsigned int frame, unsigned int sec, unsigned int usec, void *data)
|
||||
{
|
||||
*((SDL_bool *) data) = SDL_FALSE;
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
KMSDRM_LEGACY_WaitPageFlip(_THIS, SDL_WindowData *windata, int timeout) {
|
||||
SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
|
||||
drmEventContext ev = {0};
|
||||
struct pollfd pfd = {0};
|
||||
|
||||
ev.version = DRM_EVENT_CONTEXT_VERSION;
|
||||
ev.page_flip_handler = KMSDRM_LEGACY_FlipHandler;
|
||||
|
||||
pfd.fd = viddata->drm_fd;
|
||||
pfd.events = POLLIN;
|
||||
|
||||
while (windata->waiting_for_flip) {
|
||||
pfd.revents = 0;
|
||||
|
||||
if (poll(&pfd, 1, timeout) < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "DRM poll error");
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
if (pfd.revents & (POLLHUP | POLLERR)) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "DRM poll hup or error");
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
if (pfd.revents & POLLIN) {
|
||||
/* Page flip? If so, drmHandleEvent will unset windata->waiting_for_flip */
|
||||
KMSDRM_LEGACY_drmHandleEvent(viddata->drm_fd, &ev);
|
||||
} else {
|
||||
/* Timed out and page flip didn't happen */
|
||||
SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Dropping frame while waiting_for_flip");
|
||||
return SDL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* SDL Video and Display initialization/handling functions */
|
||||
/* _this is a SDL_VideoDevice * */
|
||||
/*****************************************************************************/
|
||||
static void
|
||||
KMSDRM_LEGACY_DestroySurfaces(_THIS, SDL_Window * window)
|
||||
{
|
||||
SDL_WindowData *windata = (SDL_WindowData *)window->driverdata;
|
||||
|
||||
KMSDRM_LEGACY_WaitPageFlip(_this, windata, -1);
|
||||
|
||||
if (windata->curr_bo) {
|
||||
KMSDRM_LEGACY_gbm_surface_release_buffer(windata->gs, windata->curr_bo);
|
||||
windata->curr_bo = NULL;
|
||||
}
|
||||
|
||||
if (windata->next_bo) {
|
||||
KMSDRM_LEGACY_gbm_surface_release_buffer(windata->gs, windata->next_bo);
|
||||
windata->next_bo = NULL;
|
||||
}
|
||||
|
||||
#if SDL_VIDEO_OPENGL_EGL
|
||||
SDL_EGL_MakeCurrent(_this, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
|
||||
if (windata->egl_surface != EGL_NO_SURFACE) {
|
||||
SDL_EGL_DestroySurface(_this, windata->egl_surface);
|
||||
windata->egl_surface = EGL_NO_SURFACE;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (windata->gs) {
|
||||
KMSDRM_LEGACY_gbm_surface_destroy(windata->gs);
|
||||
windata->gs = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
KMSDRM_LEGACY_CreateSurfaces(_THIS, SDL_Window * window)
|
||||
{
|
||||
SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
|
||||
SDL_WindowData *windata = (SDL_WindowData *)window->driverdata;
|
||||
SDL_DisplayData *dispdata = (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata;
|
||||
Uint32 width = dispdata->mode.hdisplay;
|
||||
Uint32 height = dispdata->mode.vdisplay;
|
||||
Uint32 surface_fmt = GBM_FORMAT_XRGB8888;
|
||||
Uint32 surface_flags = GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING;
|
||||
#if SDL_VIDEO_OPENGL_EGL
|
||||
EGLContext egl_context;
|
||||
#endif
|
||||
|
||||
if (!KMSDRM_LEGACY_gbm_device_is_format_supported(viddata->gbm, surface_fmt, surface_flags)) {
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_VIDEO, "GBM surface format not supported. Trying anyway.");
|
||||
}
|
||||
|
||||
#if SDL_VIDEO_OPENGL_EGL
|
||||
SDL_EGL_SetRequiredVisualId(_this, surface_fmt);
|
||||
egl_context = (EGLContext)SDL_GL_GetCurrentContext();
|
||||
#endif
|
||||
|
||||
KMSDRM_LEGACY_DestroySurfaces(_this, window);
|
||||
|
||||
windata->gs = KMSDRM_LEGACY_gbm_surface_create(viddata->gbm, width, height, surface_fmt, surface_flags);
|
||||
|
||||
if (!windata->gs) {
|
||||
return SDL_SetError("Could not create GBM surface");
|
||||
}
|
||||
|
||||
#if SDL_VIDEO_OPENGL_EGL
|
||||
windata->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType)windata->gs);
|
||||
|
||||
if (windata->egl_surface == EGL_NO_SURFACE) {
|
||||
return SDL_SetError("Could not create EGL window surface");
|
||||
}
|
||||
|
||||
SDL_EGL_MakeCurrent(_this, windata->egl_surface, egl_context);
|
||||
|
||||
windata->egl_surface_dirty = 0;
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
KMSDRM_LEGACY_VideoInit(_THIS)
|
||||
{
|
||||
int i, j, ret = 0;
|
||||
SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
|
||||
SDL_DisplayData *dispdata = NULL;
|
||||
drmModeRes *resources = NULL;
|
||||
drmModeEncoder *encoder = NULL;
|
||||
char devname[32];
|
||||
SDL_VideoDisplay display = {0};
|
||||
|
||||
dispdata = (SDL_DisplayData *) SDL_calloc(1, sizeof(SDL_DisplayData));
|
||||
|
||||
if (!dispdata) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "KMSDRM_LEGACY_VideoInit()");
|
||||
|
||||
/* Open /dev/dri/cardNN */
|
||||
SDL_snprintf(devname, sizeof(devname), "/dev/dri/card%d", viddata->devindex);
|
||||
|
||||
SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Opening device %s", devname);
|
||||
viddata->drm_fd = open(devname, O_RDWR | O_CLOEXEC);
|
||||
|
||||
if (viddata->drm_fd < 0) {
|
||||
ret = SDL_SetError("Could not open %s", devname);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Opened DRM FD (%d)", viddata->drm_fd);
|
||||
|
||||
viddata->gbm = KMSDRM_LEGACY_gbm_create_device(viddata->drm_fd);
|
||||
if (!viddata->gbm) {
|
||||
ret = SDL_SetError("Couldn't create gbm device.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* Get all of the available connectors / devices / crtcs */
|
||||
resources = KMSDRM_LEGACY_drmModeGetResources(viddata->drm_fd);
|
||||
if (!resources) {
|
||||
ret = SDL_SetError("drmModeGetResources(%d) failed", viddata->drm_fd);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
for (i = 0; i < resources->count_connectors; i++) {
|
||||
drmModeConnector *conn = KMSDRM_LEGACY_drmModeGetConnector(viddata->drm_fd, resources->connectors[i]);
|
||||
|
||||
if (!conn) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (conn->connection == DRM_MODE_CONNECTED && conn->count_modes) {
|
||||
SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Found connector %d with %d modes.",
|
||||
conn->connector_id, conn->count_modes);
|
||||
dispdata->conn = conn;
|
||||
break;
|
||||
}
|
||||
|
||||
KMSDRM_LEGACY_drmModeFreeConnector(conn);
|
||||
}
|
||||
|
||||
if (!dispdata->conn) {
|
||||
ret = SDL_SetError("No currently active connector found.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* Try to find the connector's current encoder */
|
||||
for (i = 0; i < resources->count_encoders; i++) {
|
||||
encoder = KMSDRM_LEGACY_drmModeGetEncoder(viddata->drm_fd, resources->encoders[i]);
|
||||
|
||||
if (!encoder) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (encoder->encoder_id == dispdata->conn->encoder_id) {
|
||||
SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Found encoder %d.", encoder->encoder_id);
|
||||
break;
|
||||
}
|
||||
|
||||
KMSDRM_LEGACY_drmModeFreeEncoder(encoder);
|
||||
encoder = NULL;
|
||||
}
|
||||
|
||||
if (!encoder) {
|
||||
/* No encoder was connected, find the first supported one */
|
||||
for (i = 0; i < resources->count_encoders; i++) {
|
||||
encoder = KMSDRM_LEGACY_drmModeGetEncoder(viddata->drm_fd, resources->encoders[i]);
|
||||
|
||||
if (!encoder) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (j = 0; j < dispdata->conn->count_encoders; j++) {
|
||||
if (dispdata->conn->encoders[j] == encoder->encoder_id) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (j != dispdata->conn->count_encoders) {
|
||||
break;
|
||||
}
|
||||
|
||||
KMSDRM_LEGACY_drmModeFreeEncoder(encoder);
|
||||
encoder = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (!encoder) {
|
||||
ret = SDL_SetError("No connected encoder found.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Found encoder %d.", encoder->encoder_id);
|
||||
|
||||
/* Try to find a CRTC connected to this encoder */
|
||||
dispdata->saved_crtc = KMSDRM_LEGACY_drmModeGetCrtc(viddata->drm_fd, encoder->crtc_id);
|
||||
|
||||
if (!dispdata->saved_crtc) {
|
||||
/* No CRTC was connected, find the first CRTC that can be connected */
|
||||
for (i = 0; i < resources->count_crtcs; i++) {
|
||||
if (encoder->possible_crtcs & (1 << i)) {
|
||||
encoder->crtc_id = resources->crtcs[i];
|
||||
dispdata->saved_crtc = KMSDRM_LEGACY_drmModeGetCrtc(viddata->drm_fd, encoder->crtc_id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!dispdata->saved_crtc) {
|
||||
ret = SDL_SetError("No CRTC found.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Saved crtc_id %u, fb_id %u, (%u,%u), %ux%u",
|
||||
dispdata->saved_crtc->crtc_id, dispdata->saved_crtc->buffer_id, dispdata->saved_crtc->x,
|
||||
dispdata->saved_crtc->y, dispdata->saved_crtc->width, dispdata->saved_crtc->height);
|
||||
|
||||
dispdata->crtc_id = encoder->crtc_id;
|
||||
|
||||
/* Figure out the default mode to be set. If the current CRTC's mode isn't
|
||||
valid, select the first mode supported by the connector
|
||||
|
||||
FIXME find first mode that specifies DRM_MODE_TYPE_PREFERRED */
|
||||
dispdata->mode = dispdata->saved_crtc->mode;
|
||||
|
||||
if (dispdata->saved_crtc->mode_valid == 0) {
|
||||
SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO,
|
||||
"Current mode is invalid, selecting connector's mode #0.");
|
||||
dispdata->mode = dispdata->conn->modes[0];
|
||||
}
|
||||
|
||||
/* Setup the single display that's available */
|
||||
|
||||
display.desktop_mode.w = dispdata->mode.hdisplay;
|
||||
display.desktop_mode.h = dispdata->mode.vdisplay;
|
||||
display.desktop_mode.refresh_rate = dispdata->mode.vrefresh;
|
||||
#if 1
|
||||
display.desktop_mode.format = SDL_PIXELFORMAT_ARGB8888;
|
||||
#else
|
||||
/* FIXME */
|
||||
drmModeFB *fb = drmModeGetFB(viddata->drm_fd, dispdata->saved_crtc->buffer_id);
|
||||
display.desktop_mode.format = drmToSDLPixelFormat(fb->bpp, fb->depth);
|
||||
drmModeFreeFB(fb);
|
||||
#endif
|
||||
display.current_mode = display.desktop_mode;
|
||||
display.driverdata = dispdata;
|
||||
SDL_AddVideoDisplay(&display, SDL_FALSE);
|
||||
|
||||
#ifdef SDL_INPUT_LINUXEV
|
||||
SDL_EVDEV_Init();
|
||||
#endif
|
||||
|
||||
KMSDRM_LEGACY_InitMouse(_this);
|
||||
|
||||
return ret;
|
||||
|
||||
cleanup:
|
||||
if (encoder)
|
||||
KMSDRM_LEGACY_drmModeFreeEncoder(encoder);
|
||||
if (resources)
|
||||
KMSDRM_LEGACY_drmModeFreeResources(resources);
|
||||
|
||||
if (ret != 0) {
|
||||
/* Error (complete) cleanup */
|
||||
if (dispdata->conn) {
|
||||
KMSDRM_LEGACY_drmModeFreeConnector(dispdata->conn);
|
||||
dispdata->conn = NULL;
|
||||
}
|
||||
if (dispdata->saved_crtc) {
|
||||
KMSDRM_LEGACY_drmModeFreeCrtc(dispdata->saved_crtc);
|
||||
dispdata->saved_crtc = NULL;
|
||||
}
|
||||
if (viddata->gbm) {
|
||||
KMSDRM_LEGACY_gbm_device_destroy(viddata->gbm);
|
||||
viddata->gbm = NULL;
|
||||
}
|
||||
if (viddata->drm_fd >= 0) {
|
||||
close(viddata->drm_fd);
|
||||
viddata->drm_fd = -1;
|
||||
}
|
||||
SDL_free(dispdata);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
KMSDRM_LEGACY_VideoQuit(_THIS)
|
||||
{
|
||||
SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
|
||||
SDL_DisplayData *dispdata = (SDL_DisplayData *)SDL_GetDisplayDriverData(0);
|
||||
|
||||
SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "KMSDRM_LEGACY_VideoQuit()");
|
||||
|
||||
if (_this->gl_config.driver_loaded) {
|
||||
SDL_GL_UnloadLibrary();
|
||||
}
|
||||
|
||||
/* Clear out the window list */
|
||||
SDL_free(viddata->windows);
|
||||
viddata->windows = NULL;
|
||||
viddata->max_windows = 0;
|
||||
viddata->num_windows = 0;
|
||||
|
||||
/* Restore saved CRTC settings */
|
||||
if (viddata->drm_fd >= 0 && dispdata && dispdata->conn && dispdata->saved_crtc) {
|
||||
drmModeConnector *conn = dispdata->conn;
|
||||
drmModeCrtc *crtc = dispdata->saved_crtc;
|
||||
|
||||
int ret = KMSDRM_LEGACY_drmModeSetCrtc(viddata->drm_fd, crtc->crtc_id, crtc->buffer_id,
|
||||
crtc->x, crtc->y, &conn->connector_id, 1, &crtc->mode);
|
||||
|
||||
if (ret != 0) {
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_VIDEO, "Could not restore original CRTC mode");
|
||||
}
|
||||
}
|
||||
if (dispdata && dispdata->conn) {
|
||||
KMSDRM_LEGACY_drmModeFreeConnector(dispdata->conn);
|
||||
dispdata->conn = NULL;
|
||||
}
|
||||
if (dispdata && dispdata->saved_crtc) {
|
||||
KMSDRM_LEGACY_drmModeFreeCrtc(dispdata->saved_crtc);
|
||||
dispdata->saved_crtc = NULL;
|
||||
}
|
||||
if (viddata->gbm) {
|
||||
KMSDRM_LEGACY_gbm_device_destroy(viddata->gbm);
|
||||
viddata->gbm = NULL;
|
||||
}
|
||||
if (viddata->drm_fd >= 0) {
|
||||
close(viddata->drm_fd);
|
||||
SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Closed DRM FD %d", viddata->drm_fd);
|
||||
viddata->drm_fd = -1;
|
||||
}
|
||||
#ifdef SDL_INPUT_LINUXEV
|
||||
SDL_EVDEV_Quit();
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
KMSDRM_LEGACY_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
|
||||
{
|
||||
SDL_DisplayData *dispdata = display->driverdata;
|
||||
drmModeConnector *conn = dispdata->conn;
|
||||
SDL_DisplayMode mode;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < conn->count_modes; i++) {
|
||||
SDL_DisplayModeData *modedata = SDL_calloc(1, sizeof(SDL_DisplayModeData));
|
||||
|
||||
if (modedata) {
|
||||
modedata->mode_index = i;
|
||||
}
|
||||
|
||||
mode.w = conn->modes[i].hdisplay;
|
||||
mode.h = conn->modes[i].vdisplay;
|
||||
mode.refresh_rate = conn->modes[i].vrefresh;
|
||||
mode.format = SDL_PIXELFORMAT_ARGB8888;
|
||||
mode.driverdata = modedata;
|
||||
|
||||
if (!SDL_AddDisplayMode(display, &mode)) {
|
||||
SDL_free(modedata);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
KMSDRM_LEGACY_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
|
||||
{
|
||||
SDL_VideoData *viddata = (SDL_VideoData *)_this->driverdata;
|
||||
SDL_DisplayData *dispdata = (SDL_DisplayData *)display->driverdata;
|
||||
SDL_DisplayModeData *modedata = (SDL_DisplayModeData *)mode->driverdata;
|
||||
drmModeConnector *conn = dispdata->conn;
|
||||
int i;
|
||||
|
||||
if (!modedata) {
|
||||
return SDL_SetError("Mode doesn't have an associated index");
|
||||
}
|
||||
|
||||
dispdata->mode = conn->modes[modedata->mode_index];
|
||||
|
||||
for (i = 0; i < viddata->num_windows; i++) {
|
||||
SDL_Window *window = viddata->windows[i];
|
||||
SDL_WindowData *windata = (SDL_WindowData *)window->driverdata;
|
||||
|
||||
#if SDL_VIDEO_OPENGL_EGL
|
||||
/* Can't recreate EGL surfaces right now, need to wait until SwapWindow
|
||||
so the correct thread-local surface and context state are available */
|
||||
windata->egl_surface_dirty = 1;
|
||||
#else
|
||||
if (KMSDRM_LEGACY_CreateSurfaces(_this, window)) {
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Tell app about the resize */
|
||||
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, mode->w, mode->h);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
KMSDRM_LEGACY_CreateWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
SDL_VideoData *viddata = (SDL_VideoData *)_this->driverdata;
|
||||
SDL_WindowData *windata;
|
||||
SDL_VideoDisplay *display;
|
||||
|
||||
#if SDL_VIDEO_OPENGL_EGL
|
||||
if (!_this->egl_data) {
|
||||
if (SDL_GL_LoadLibrary(NULL) < 0) {
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Allocate window internal data */
|
||||
windata = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData));
|
||||
|
||||
if (!windata) {
|
||||
SDL_OutOfMemory();
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* Windows have one size for now */
|
||||
display = SDL_GetDisplayForWindow(window);
|
||||
window->w = display->desktop_mode.w;
|
||||
window->h = display->desktop_mode.h;
|
||||
|
||||
/* Maybe you didn't ask for a fullscreen OpenGL window, but that's what you get */
|
||||
window->flags |= (SDL_WINDOW_FULLSCREEN | SDL_WINDOW_OPENGL);
|
||||
|
||||
/* In case we want low-latency, double-buffer video, we take note here */
|
||||
windata->double_buffer = SDL_FALSE;
|
||||
|
||||
if (SDL_GetHintBoolean(SDL_HINT_VIDEO_DOUBLE_BUFFER, SDL_FALSE)) {
|
||||
windata->double_buffer = SDL_TRUE;
|
||||
}
|
||||
|
||||
/* Setup driver data for this window */
|
||||
windata->viddata = viddata;
|
||||
window->driverdata = windata;
|
||||
|
||||
if (KMSDRM_LEGACY_CreateSurfaces(_this, window)) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* Add window to the internal list of tracked windows. Note, while it may
|
||||
seem odd to support multiple fullscreen windows, some apps create an
|
||||
extra window as a dummy surface when working with multiple contexts */
|
||||
if (viddata->num_windows >= viddata->max_windows) {
|
||||
int new_max_windows = viddata->max_windows + 1;
|
||||
viddata->windows = (SDL_Window **)SDL_realloc(viddata->windows,
|
||||
new_max_windows * sizeof(SDL_Window *));
|
||||
viddata->max_windows = new_max_windows;
|
||||
|
||||
if (!viddata->windows) {
|
||||
SDL_OutOfMemory();
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
viddata->windows[viddata->num_windows++] = window;
|
||||
|
||||
/* Focus on the newly created window */
|
||||
SDL_SetMouseFocus(window);
|
||||
SDL_SetKeyboardFocus(window);
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
KMSDRM_LEGACY_DestroyWindow(_this, window);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void
|
||||
KMSDRM_LEGACY_DestroyWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
|
||||
SDL_VideoData *viddata;
|
||||
int i, j;
|
||||
|
||||
if (!windata) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Remove from the internal window list */
|
||||
viddata = windata->viddata;
|
||||
|
||||
for (i = 0; i < viddata->num_windows; i++) {
|
||||
if (viddata->windows[i] == window) {
|
||||
viddata->num_windows--;
|
||||
|
||||
for (j = i; j < viddata->num_windows; j++) {
|
||||
viddata->windows[j] = viddata->windows[j + 1];
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
KMSDRM_LEGACY_DestroySurfaces(_this, window);
|
||||
|
||||
window->driverdata = NULL;
|
||||
|
||||
SDL_free(windata);
|
||||
}
|
||||
|
||||
int
|
||||
KMSDRM_LEGACY_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
void
|
||||
KMSDRM_LEGACY_SetWindowTitle(_THIS, SDL_Window * window)
|
||||
{
|
||||
}
|
||||
void
|
||||
KMSDRM_LEGACY_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon)
|
||||
{
|
||||
}
|
||||
void
|
||||
KMSDRM_LEGACY_SetWindowPosition(_THIS, SDL_Window * window)
|
||||
{
|
||||
}
|
||||
void
|
||||
KMSDRM_LEGACY_SetWindowSize(_THIS, SDL_Window * window)
|
||||
{
|
||||
}
|
||||
void
|
||||
KMSDRM_LEGACY_ShowWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
}
|
||||
void
|
||||
KMSDRM_LEGACY_HideWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
}
|
||||
void
|
||||
KMSDRM_LEGACY_RaiseWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
}
|
||||
void
|
||||
KMSDRM_LEGACY_MaximizeWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
}
|
||||
void
|
||||
KMSDRM_LEGACY_MinimizeWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
}
|
||||
void
|
||||
KMSDRM_LEGACY_RestoreWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
}
|
||||
void
|
||||
KMSDRM_LEGACY_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* SDL Window Manager function */
|
||||
/*****************************************************************************/
|
||||
SDL_bool
|
||||
KMSDRM_LEGACY_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info)
|
||||
{
|
||||
if (info->version.major <= SDL_MAJOR_VERSION) {
|
||||
return SDL_TRUE;
|
||||
} else {
|
||||
SDL_SetError("application not compiled with SDL %d.%d\n",
|
||||
SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
/* Failed to get window manager information */
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_KMSDRM */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
132
externals/SDL/src/video/kmsdrm_legacy/SDL_kmsdrm_legacy_video.h
vendored
Executable file
132
externals/SDL/src/video/kmsdrm_legacy/SDL_kmsdrm_legacy_video.h
vendored
Executable file
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 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_KMSDRM_LEGACYVIDEO_H__
|
||||
#define __SDL_KMSDRM_LEGACYVIDEO_H__
|
||||
|
||||
#include "../SDL_sysvideo.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <xf86drm.h>
|
||||
#include <xf86drmMode.h>
|
||||
#include <gbm.h>
|
||||
#if SDL_VIDEO_OPENGL_EGL
|
||||
#include <EGL/egl.h>
|
||||
#endif
|
||||
|
||||
typedef struct SDL_VideoData
|
||||
{
|
||||
int devindex; /* device index that was passed on creation */
|
||||
int drm_fd; /* DRM file desc */
|
||||
struct gbm_device *gbm;
|
||||
|
||||
SDL_Window **windows;
|
||||
int max_windows;
|
||||
int num_windows;
|
||||
} SDL_VideoData;
|
||||
|
||||
|
||||
typedef struct SDL_DisplayModeData
|
||||
{
|
||||
int mode_index;
|
||||
} SDL_DisplayModeData;
|
||||
|
||||
|
||||
typedef struct SDL_DisplayData
|
||||
{
|
||||
uint32_t crtc_id;
|
||||
drmModeConnector *conn;
|
||||
drmModeModeInfo mode;
|
||||
drmModeCrtc *saved_crtc; /* CRTC to restore on quit */
|
||||
} SDL_DisplayData;
|
||||
|
||||
|
||||
typedef struct SDL_WindowData
|
||||
{
|
||||
SDL_VideoData *viddata;
|
||||
struct gbm_surface *gs;
|
||||
struct gbm_bo *curr_bo;
|
||||
struct gbm_bo *next_bo;
|
||||
struct gbm_bo *crtc_bo;
|
||||
SDL_bool waiting_for_flip;
|
||||
SDL_bool double_buffer;
|
||||
#if SDL_VIDEO_OPENGL_EGL
|
||||
int egl_surface_dirty;
|
||||
EGLSurface egl_surface;
|
||||
#endif
|
||||
} SDL_WindowData;
|
||||
|
||||
typedef struct KMSDRM_LEGACY_FBInfo
|
||||
{
|
||||
int drm_fd; /* DRM file desc */
|
||||
uint32_t fb_id; /* DRM framebuffer ID */
|
||||
} KMSDRM_LEGACY_FBInfo;
|
||||
|
||||
/* Helper functions */
|
||||
int KMSDRM_LEGACY_CreateSurfaces(_THIS, SDL_Window * window);
|
||||
KMSDRM_LEGACY_FBInfo *KMSDRM_LEGACY_FBFromBO(_THIS, struct gbm_bo *bo);
|
||||
SDL_bool KMSDRM_LEGACY_WaitPageFlip(_THIS, SDL_WindowData *windata, int timeout);
|
||||
|
||||
/****************************************************************************/
|
||||
/* SDL_VideoDevice functions declaration */
|
||||
/****************************************************************************/
|
||||
|
||||
/* Display and window functions */
|
||||
int KMSDRM_LEGACY_VideoInit(_THIS);
|
||||
void KMSDRM_LEGACY_VideoQuit(_THIS);
|
||||
void KMSDRM_LEGACY_GetDisplayModes(_THIS, SDL_VideoDisplay * display);
|
||||
int KMSDRM_LEGACY_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
|
||||
int KMSDRM_LEGACY_CreateWindow(_THIS, SDL_Window * window);
|
||||
int KMSDRM_LEGACY_CreateWindowFrom(_THIS, SDL_Window * window, const void *data);
|
||||
void KMSDRM_LEGACY_SetWindowTitle(_THIS, SDL_Window * window);
|
||||
void KMSDRM_LEGACY_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon);
|
||||
void KMSDRM_LEGACY_SetWindowPosition(_THIS, SDL_Window * window);
|
||||
void KMSDRM_LEGACY_SetWindowSize(_THIS, SDL_Window * window);
|
||||
void KMSDRM_LEGACY_ShowWindow(_THIS, SDL_Window * window);
|
||||
void KMSDRM_LEGACY_HideWindow(_THIS, SDL_Window * window);
|
||||
void KMSDRM_LEGACY_RaiseWindow(_THIS, SDL_Window * window);
|
||||
void KMSDRM_LEGACY_MaximizeWindow(_THIS, SDL_Window * window);
|
||||
void KMSDRM_LEGACY_MinimizeWindow(_THIS, SDL_Window * window);
|
||||
void KMSDRM_LEGACY_RestoreWindow(_THIS, SDL_Window * window);
|
||||
void KMSDRM_LEGACY_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed);
|
||||
void KMSDRM_LEGACY_DestroyWindow(_THIS, SDL_Window * window);
|
||||
|
||||
/* Window manager function */
|
||||
SDL_bool KMSDRM_LEGACY_GetWindowWMInfo(_THIS, SDL_Window * window,
|
||||
struct SDL_SysWMinfo *info);
|
||||
|
||||
/* OpenGL/OpenGL ES functions */
|
||||
int KMSDRM_LEGACY_GLES_LoadLibrary(_THIS, const char *path);
|
||||
void *KMSDRM_LEGACY_GLES_GetProcAddress(_THIS, const char *proc);
|
||||
void KMSDRM_LEGACY_GLES_UnloadLibrary(_THIS);
|
||||
SDL_GLContext KMSDRM_LEGACY_GLES_CreateContext(_THIS, SDL_Window * window);
|
||||
int KMSDRM_LEGACY_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context);
|
||||
int KMSDRM_LEGACY_GLES_SetSwapInterval(_THIS, int interval);
|
||||
int KMSDRM_LEGACY_GLES_GetSwapInterval(_THIS);
|
||||
int KMSDRM_LEGACY_GLES_SwapWindow(_THIS, SDL_Window * window);
|
||||
void KMSDRM_LEGACY_GLES_DeleteContext(_THIS, SDL_GLContext context);
|
||||
|
||||
#endif /* __SDL_KMSDRM_LEGACYVIDEO_H__ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
6
externals/SDL/src/video/nacl/SDL_naclvideo.c
vendored
6
externals/SDL/src/video/nacl/SDL_naclvideo.c
vendored
@@ -94,6 +94,10 @@ NACL_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
|
||||
static SDL_VideoDevice *NACL_CreateDevice(int devindex) {
|
||||
SDL_VideoDevice *device;
|
||||
|
||||
if (!NACL_Available()) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Initialize all variables that we clean on shutdown */
|
||||
device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
|
||||
if (!device) {
|
||||
@@ -132,7 +136,7 @@ static SDL_VideoDevice *NACL_CreateDevice(int devindex) {
|
||||
|
||||
VideoBootStrap NACL_bootstrap = {
|
||||
NACLVID_DRIVER_NAME, "SDL Native Client Video Driver",
|
||||
NACL_Available, NACL_CreateDevice
|
||||
NACL_CreateDevice
|
||||
};
|
||||
|
||||
int NACL_VideoInit(_THIS) {
|
||||
|
@@ -51,13 +51,6 @@ static void OFFSCREEN_VideoQuit(_THIS);
|
||||
|
||||
/* OFFSCREEN driver bootstrap functions */
|
||||
|
||||
static int
|
||||
OFFSCREEN_Available(void)
|
||||
{
|
||||
/* Consider it always available */
|
||||
return (1);
|
||||
}
|
||||
|
||||
static void
|
||||
OFFSCREEN_DeleteDevice(SDL_VideoDevice * device)
|
||||
{
|
||||
@@ -106,22 +99,9 @@ OFFSCREEN_CreateDevice(int devindex)
|
||||
|
||||
VideoBootStrap OFFSCREEN_bootstrap = {
|
||||
OFFSCREENVID_DRIVER_NAME, "SDL offscreen video driver",
|
||||
OFFSCREEN_Available, OFFSCREEN_CreateDevice
|
||||
OFFSCREEN_CreateDevice
|
||||
};
|
||||
|
||||
static Uint32
|
||||
OFFSCREEN_GetGlobalMouseState(int *x, int *y)
|
||||
{
|
||||
if (x) {
|
||||
*x = 0;
|
||||
}
|
||||
|
||||
if (y) {
|
||||
*y = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
OFFSCREEN_VideoInit(_THIS)
|
||||
{
|
||||
@@ -141,11 +121,6 @@ OFFSCREEN_VideoInit(_THIS)
|
||||
SDL_zero(mode);
|
||||
SDL_AddDisplayMode(&_this->displays[0], &mode);
|
||||
|
||||
/* Init mouse */
|
||||
mouse = SDL_GetMouse();
|
||||
/* This function needs to be implemented by every driver */
|
||||
mouse->GetGlobalMouseState = OFFSCREEN_GetGlobalMouseState;
|
||||
|
||||
/* We're done! */
|
||||
return 0;
|
||||
}
|
||||
|
329
externals/SDL/src/video/os2/SDL_os2dive.c
vendored
Executable file
329
externals/SDL/src/video/os2/SDL_os2dive.c
vendored
Executable file
@@ -0,0 +1,329 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 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"
|
||||
#include "../SDL_sysvideo.h"
|
||||
#define INCL_WIN
|
||||
#define INCL_GPI
|
||||
#include <os2.h>
|
||||
#define _MEERROR_H_
|
||||
#include <mmioos2.h>
|
||||
#include <os2me.h>
|
||||
#define INCL_MM_OS2
|
||||
#include <dive.h>
|
||||
#include <fourcc.h>
|
||||
#include "SDL_os2output.h"
|
||||
|
||||
typedef struct _VODATA {
|
||||
HDIVE hDive;
|
||||
PVOID pBuffer;
|
||||
ULONG ulDIVEBufNum;
|
||||
FOURCC fccColorEncoding;
|
||||
ULONG ulWidth;
|
||||
ULONG ulHeight;
|
||||
BOOL fBlitterReady;
|
||||
} VODATA;
|
||||
|
||||
static BOOL voQueryInfo(VIDEOOUTPUTINFO *pInfo);
|
||||
static PVODATA voOpen(void);
|
||||
static VOID voClose(PVODATA pVOData);
|
||||
static BOOL voSetVisibleRegion(PVODATA pVOData, HWND hwnd,
|
||||
SDL_DisplayMode *pSDLDisplayMode,
|
||||
HRGN hrgnShape, BOOL fVisible);
|
||||
static PVOID voVideoBufAlloc(PVODATA pVOData, ULONG ulWidth, ULONG ulHeight,
|
||||
ULONG ulBPP, ULONG fccColorEncoding,
|
||||
PULONG pulScanLineSize);
|
||||
static VOID voVideoBufFree(PVODATA pVOData);
|
||||
static BOOL voUpdate(PVODATA pVOData, HWND hwnd, SDL_Rect *pSDLRects,
|
||||
ULONG cSDLRects);
|
||||
|
||||
OS2VIDEOOUTPUT voDive = {
|
||||
voQueryInfo,
|
||||
voOpen,
|
||||
voClose,
|
||||
voSetVisibleRegion,
|
||||
voVideoBufAlloc,
|
||||
voVideoBufFree,
|
||||
voUpdate
|
||||
};
|
||||
|
||||
|
||||
static BOOL voQueryInfo(VIDEOOUTPUTINFO *pInfo)
|
||||
{
|
||||
DIVE_CAPS sDiveCaps = { 0 };
|
||||
FOURCC fccFormats[100] = { 0 };
|
||||
|
||||
/* Query information about display hardware from DIVE. */
|
||||
sDiveCaps.pFormatData = fccFormats;
|
||||
sDiveCaps.ulFormatLength = 100;
|
||||
sDiveCaps.ulStructLen = sizeof(DIVE_CAPS);
|
||||
|
||||
if (DiveQueryCaps(&sDiveCaps, DIVE_BUFFER_SCREEN)) {
|
||||
debug_os2("DiveQueryCaps() failed.");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (sDiveCaps.ulDepth < 8) {
|
||||
debug_os2("Not enough screen colors to run DIVE. "
|
||||
"Must be at least 256 colors.");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
pInfo->ulBPP = sDiveCaps.ulDepth;
|
||||
pInfo->fccColorEncoding = sDiveCaps.fccColorEncoding;
|
||||
pInfo->ulScanLineSize = sDiveCaps.ulScanLineBytes;
|
||||
pInfo->ulHorizResolution = sDiveCaps.ulHorizontalResolution;
|
||||
pInfo->ulVertResolution = sDiveCaps.ulVerticalResolution;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
PVODATA voOpen(void)
|
||||
{
|
||||
PVODATA pVOData = SDL_calloc(1, sizeof(VODATA));
|
||||
|
||||
if (pVOData == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (DiveOpen(&pVOData->hDive, FALSE, NULL) != DIVE_SUCCESS) {
|
||||
SDL_free(pVOData);
|
||||
SDL_SetError("DIVE: A display engine instance open failed");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return pVOData;
|
||||
}
|
||||
|
||||
static VOID voClose(PVODATA pVOData)
|
||||
{
|
||||
voVideoBufFree(pVOData);
|
||||
DiveClose(pVOData->hDive);
|
||||
SDL_free(pVOData);
|
||||
}
|
||||
|
||||
static BOOL voSetVisibleRegion(PVODATA pVOData, HWND hwnd,
|
||||
SDL_DisplayMode *pSDLDisplayMode,
|
||||
HRGN hrgnShape, BOOL fVisible)
|
||||
{
|
||||
HPS hps;
|
||||
HRGN hrgn;
|
||||
RGNRECT rgnCtl;
|
||||
PRECTL prectl = NULL;
|
||||
ULONG ulRC;
|
||||
|
||||
if (!fVisible) {
|
||||
if (pVOData->fBlitterReady) {
|
||||
pVOData->fBlitterReady = FALSE;
|
||||
DiveSetupBlitter(pVOData->hDive, 0);
|
||||
debug_os2("DIVE blitter is tuned off");
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Query visible rectangles */
|
||||
hps = WinGetPS(hwnd);
|
||||
hrgn = GpiCreateRegion(hps, 0, NULL);
|
||||
if (hrgn == NULLHANDLE) {
|
||||
WinReleasePS(hps);
|
||||
SDL_SetError("GpiCreateRegion() failed");
|
||||
} else {
|
||||
WinQueryVisibleRegion(hwnd, hrgn);
|
||||
if (hrgnShape != NULLHANDLE)
|
||||
GpiCombineRegion(hps, hrgn, hrgn, hrgnShape, CRGN_AND);
|
||||
|
||||
rgnCtl.ircStart = 1;
|
||||
rgnCtl.crc = 0;
|
||||
rgnCtl.ulDirection = 1;
|
||||
GpiQueryRegionRects(hps, hrgn, NULL, &rgnCtl, NULL);
|
||||
if (rgnCtl.crcReturned != 0) {
|
||||
prectl = SDL_malloc(rgnCtl.crcReturned * sizeof(RECTL));
|
||||
if (prectl != NULL) {
|
||||
rgnCtl.ircStart = 1;
|
||||
rgnCtl.crc = rgnCtl.crcReturned;
|
||||
rgnCtl.ulDirection = 1;
|
||||
GpiQueryRegionRects(hps, hrgn, NULL, &rgnCtl, prectl);
|
||||
} else {
|
||||
SDL_OutOfMemory();
|
||||
}
|
||||
}
|
||||
GpiDestroyRegion(hps, hrgn);
|
||||
WinReleasePS(hps);
|
||||
|
||||
if (prectl != NULL) {
|
||||
/* Setup DIVE blitter. */
|
||||
SETUP_BLITTER sSetupBlitter;
|
||||
SWP swp;
|
||||
POINTL pointl = { 0 };
|
||||
|
||||
WinQueryWindowPos(hwnd, &swp);
|
||||
WinMapWindowPoints(hwnd, HWND_DESKTOP, &pointl, 1);
|
||||
|
||||
sSetupBlitter.ulStructLen = sizeof(SETUP_BLITTER);
|
||||
sSetupBlitter.fccSrcColorFormat = pVOData->fccColorEncoding;
|
||||
sSetupBlitter.fInvert = FALSE;
|
||||
sSetupBlitter.ulSrcWidth = pVOData->ulWidth;
|
||||
sSetupBlitter.ulSrcHeight = pVOData->ulHeight;
|
||||
sSetupBlitter.ulSrcPosX = 0;
|
||||
sSetupBlitter.ulSrcPosY = 0;
|
||||
sSetupBlitter.ulDitherType = 0;
|
||||
sSetupBlitter.fccDstColorFormat = FOURCC_SCRN;
|
||||
sSetupBlitter.ulDstWidth = swp.cx;
|
||||
sSetupBlitter.ulDstHeight = swp.cy;
|
||||
sSetupBlitter.lDstPosX = 0;
|
||||
sSetupBlitter.lDstPosY = 0;
|
||||
sSetupBlitter.lScreenPosX = pointl.x;
|
||||
sSetupBlitter.lScreenPosY = pointl.y;
|
||||
|
||||
sSetupBlitter.ulNumDstRects = rgnCtl.crcReturned;
|
||||
sSetupBlitter.pVisDstRects = prectl;
|
||||
|
||||
ulRC = DiveSetupBlitter(pVOData->hDive, &sSetupBlitter);
|
||||
SDL_free(prectl);
|
||||
|
||||
if (ulRC == DIVE_SUCCESS) {
|
||||
pVOData->fBlitterReady = TRUE;
|
||||
WinInvalidateRect(hwnd, NULL, TRUE);
|
||||
debug_os2("DIVE blitter is ready now.");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
SDL_SetError("DiveSetupBlitter(), rc = 0x%X", ulRC);
|
||||
} /* if (prectl != NULL) */
|
||||
} /* if (hrgn == NULLHANDLE) else */
|
||||
|
||||
pVOData->fBlitterReady = FALSE;
|
||||
DiveSetupBlitter(pVOData->hDive, 0);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static PVOID voVideoBufAlloc(PVODATA pVOData, ULONG ulWidth, ULONG ulHeight,
|
||||
ULONG ulBPP, FOURCC fccColorEncoding,
|
||||
PULONG pulScanLineSize)
|
||||
{
|
||||
ULONG ulRC;
|
||||
ULONG ulScanLineSize = ulWidth * (ulBPP >> 3);
|
||||
|
||||
/* Destroy previous buffer. */
|
||||
voVideoBufFree(pVOData);
|
||||
|
||||
if (ulWidth == 0 || ulHeight == 0 || ulBPP == 0)
|
||||
return NULL;
|
||||
|
||||
/* Bytes per line. */
|
||||
ulScanLineSize = (ulScanLineSize + 3) & ~3; /* 4-byte aligning */
|
||||
*pulScanLineSize = ulScanLineSize;
|
||||
|
||||
ulRC = DosAllocMem(&pVOData->pBuffer,
|
||||
(ulHeight * ulScanLineSize) + sizeof(ULONG),
|
||||
PAG_COMMIT | PAG_EXECUTE | PAG_READ | PAG_WRITE);
|
||||
if (ulRC != NO_ERROR) {
|
||||
debug_os2("DosAllocMem(), rc = %u", ulRC);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ulRC = DiveAllocImageBuffer(pVOData->hDive, &pVOData->ulDIVEBufNum,
|
||||
fccColorEncoding, ulWidth, ulHeight,
|
||||
ulScanLineSize, pVOData->pBuffer);
|
||||
if (ulRC != DIVE_SUCCESS) {
|
||||
debug_os2("DiveAllocImageBuffer(), rc = 0x%X", ulRC);
|
||||
DosFreeMem(pVOData->pBuffer);
|
||||
pVOData->pBuffer = NULL;
|
||||
pVOData->ulDIVEBufNum = 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pVOData->fccColorEncoding = fccColorEncoding;
|
||||
pVOData->ulWidth = ulWidth;
|
||||
pVOData->ulHeight = ulHeight;
|
||||
|
||||
debug_os2("buffer: 0x%P, DIVE buffer number: %u",
|
||||
pVOData->pBuffer, pVOData->ulDIVEBufNum);
|
||||
|
||||
return pVOData->pBuffer;
|
||||
}
|
||||
|
||||
static VOID voVideoBufFree(PVODATA pVOData)
|
||||
{
|
||||
ULONG ulRC;
|
||||
|
||||
if (pVOData->ulDIVEBufNum != 0) {
|
||||
ulRC = DiveFreeImageBuffer(pVOData->hDive, pVOData->ulDIVEBufNum);
|
||||
if (ulRC != DIVE_SUCCESS) {
|
||||
debug_os2("DiveFreeImageBuffer(,%u), rc = %u", pVOData->ulDIVEBufNum, ulRC);
|
||||
} else {
|
||||
debug_os2("DIVE buffer %u destroyed", pVOData->ulDIVEBufNum);
|
||||
}
|
||||
pVOData->ulDIVEBufNum = 0;
|
||||
}
|
||||
|
||||
if (pVOData->pBuffer != NULL) {
|
||||
ulRC = DosFreeMem(pVOData->pBuffer);
|
||||
if (ulRC != NO_ERROR) {
|
||||
debug_os2("DosFreeMem(), rc = %u", ulRC);
|
||||
}
|
||||
pVOData->pBuffer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static BOOL voUpdate(PVODATA pVOData, HWND hwnd, SDL_Rect *pSDLRects,
|
||||
ULONG cSDLRects)
|
||||
{
|
||||
ULONG ulRC;
|
||||
|
||||
if (!pVOData->fBlitterReady || (pVOData->ulDIVEBufNum == 0)) {
|
||||
debug_os2("DIVE blitter is not ready");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (pSDLRects != 0) {
|
||||
PBYTE pbLineMask;
|
||||
|
||||
pbLineMask = SDL_stack_alloc(BYTE, pVOData->ulHeight);
|
||||
if (pbLineMask == NULL) {
|
||||
debug_os2("Not enough stack size");
|
||||
return FALSE;
|
||||
}
|
||||
memset(pbLineMask, 0, pVOData->ulHeight);
|
||||
|
||||
for ( ; ((LONG)cSDLRects) > 0; cSDLRects--, pSDLRects++) {
|
||||
memset(&pbLineMask[pSDLRects->y], 1, pSDLRects->h);
|
||||
}
|
||||
|
||||
ulRC = DiveBlitImageLines(pVOData->hDive, pVOData->ulDIVEBufNum,
|
||||
DIVE_BUFFER_SCREEN, pbLineMask);
|
||||
SDL_stack_free(pbLineMask);
|
||||
|
||||
if (ulRC != DIVE_SUCCESS) {
|
||||
debug_os2("DiveBlitImageLines(), rc = 0x%X", ulRC);
|
||||
}
|
||||
} else {
|
||||
ulRC = DiveBlitImage(pVOData->hDive, pVOData->ulDIVEBufNum,
|
||||
DIVE_BUFFER_SCREEN);
|
||||
if (ulRC != DIVE_SUCCESS) {
|
||||
debug_os2("DiveBlitImage(), rc = 0x%X", ulRC);
|
||||
}
|
||||
}
|
||||
|
||||
return ulRC == DIVE_SUCCESS;
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user