Skip to content

Commit

Permalink
Initial shot at a renderer target for Apple's Metal API.
Browse files Browse the repository at this point in the history
This isn't complete, but is enough to run testsprite2. It's currently
Mac-only; with a little work to figure out how to properly glue in a Metal
layer to a UIView, this will likely work on iOS, too.

This is only wired up to the configure script right now, and disabled by
default. CMake and Xcode still need their bits filled in as appropriate.
  • Loading branch information
icculus committed Apr 21, 2016
1 parent cadf3e4 commit 2a2c8d4
Show file tree
Hide file tree
Showing 10 changed files with 1,633 additions and 2 deletions.
22 changes: 20 additions & 2 deletions configure.in
Expand Up @@ -2053,6 +2053,19 @@ AC_HELP_STRING([--enable-video-cocoa], [use Cocoa video driver [[default=yes]]])
fi
}

CheckMETAL()
{
AC_ARG_ENABLE(render-metal,
AC_HELP_STRING([--enable-render-metal], [enable the Metal render driver [[default=no]]]),
, enable_render_metal=no)
if test x$enable_render = xyes -a x$enable_render_metal = xyes; then
dnl This should maybe make sure you have a supported SDK version.
AC_DEFINE(SDL_VIDEO_RENDER_METAL, 1, [ ])
SOURCES="$SOURCES $srcdir/src/render/metal/*.m"
fi
}


dnl Find DirectFB
CheckDirectFB()
{
Expand Down Expand Up @@ -2103,7 +2116,6 @@ AC_HELP_STRING([--enable-directfb-shared], [dynamically load directfb support [[
, enable_directfb_shared=yes)

AC_DEFINE(SDL_VIDEO_DRIVER_DIRECTFB, 1, [ ])
AC_DEFINE(SDL_VIDEO_RENDER_DIRECTFB, 1, [ ])
SOURCES="$SOURCES $srcdir/src/video/directfb/*.c"
EXTRA_CFLAGS="$EXTRA_CFLAGS $DIRECTFB_CFLAGS"

Expand Down Expand Up @@ -3636,8 +3648,9 @@ AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau
CheckDiskAudio
CheckDummyAudio
CheckDLOPEN
CheckPTHREAD
CheckMETAL
CheckVulkan
CheckPTHREAD

# Set up files for the audio library
if test x$enable_audio = xyes; then
Expand Down Expand Up @@ -3701,6 +3714,10 @@ AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,OpenGLES"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,QuartzCore"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,UIKit"

if test x$enable_render = xyes -a x$enable_render_metal = xyes; then
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Metal"
fi
;;
*-*-darwin* )
# This could be either full "Mac OS X", or plain "Darwin" which is
Expand All @@ -3719,6 +3736,7 @@ AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau
CheckDummyAudio
CheckDLOPEN
CheckCOCOA
CheckMETAL
CheckX11
CheckMacGL
CheckOpenGLX11
Expand Down
1 change: 1 addition & 0 deletions include/SDL_config.h.cmake
Expand Up @@ -356,6 +356,7 @@
#cmakedefine SDL_VIDEO_RENDER_OGL_ES @SDL_VIDEO_RENDER_OGL_ES@
#cmakedefine SDL_VIDEO_RENDER_OGL_ES2 @SDL_VIDEO_RENDER_OGL_ES2@
#cmakedefine SDL_VIDEO_RENDER_DIRECTFB @SDL_VIDEO_RENDER_DIRECTFB@
#cmakedefine SDL_VIDEO_RENDER_METAL @SDL_VIDEO_RENDER_METAL@

/* Enable OpenGL support */
#cmakedefine SDL_VIDEO_OPENGL @SDL_VIDEO_OPENGL@
Expand Down
1 change: 1 addition & 0 deletions include/SDL_config.h.in
Expand Up @@ -354,6 +354,7 @@
#undef SDL_VIDEO_RENDER_OGL_ES
#undef SDL_VIDEO_RENDER_OGL_ES2
#undef SDL_VIDEO_RENDER_DIRECTFB
#undef SDL_VIDEO_RENDER_METAL

/* Enable OpenGL support */
#undef SDL_VIDEO_OPENGL
Expand Down
4 changes: 4 additions & 0 deletions include/SDL_config_macosx.h
Expand Up @@ -183,6 +183,10 @@
#define SDL_VIDEO_RENDER_OGL_ES2 1
#endif

#ifndef SDL_VIDEO_RENDER_METAL
#define SDL_VIDEO_RENDER_METAL 1
#endif

/* Enable OpenGL support */
#ifndef SDL_VIDEO_OPENGL
#define SDL_VIDEO_OPENGL 1
Expand Down
3 changes: 3 additions & 0 deletions src/render/SDL_render.c
Expand Up @@ -92,6 +92,9 @@ static const SDL_RenderDriver *render_drivers[] = {
#if SDL_VIDEO_RENDER_DIRECTFB
&DirectFB_RenderDriver,
#endif
#if SDL_VIDEO_RENDER_METAL
&METAL_RenderDriver,
#endif
#if SDL_VIDEO_RENDER_PSP
&PSP_RenderDriver,
#endif
Expand Down
1 change: 1 addition & 0 deletions src/render/SDL_sysrender.h
Expand Up @@ -184,6 +184,7 @@ extern SDL_RenderDriver GL_RenderDriver;
extern SDL_RenderDriver GLES2_RenderDriver;
extern SDL_RenderDriver GLES_RenderDriver;
extern SDL_RenderDriver DirectFB_RenderDriver;
extern SDL_RenderDriver METAL_RenderDriver;
extern SDL_RenderDriver PSP_RenderDriver;
extern SDL_RenderDriver SW_RenderDriver;

Expand Down

0 comments on commit 2a2c8d4

Please sign in to comment.