From ba2c870d95f73275c89efb52111be1c1b0d12c4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Sat, 30 Nov 2019 12:37:58 +0700 Subject: [PATCH 1/5] Allow building using make on OSX --- gfx/drivers_context/cocoa_gl_ctx.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gfx/drivers_context/cocoa_gl_ctx.m b/gfx/drivers_context/cocoa_gl_ctx.m index 4e5aea7fbe..e036551ac7 100644 --- a/gfx/drivers_context/cocoa_gl_ctx.m +++ b/gfx/drivers_context/cocoa_gl_ctx.m @@ -38,6 +38,7 @@ #include "../../ui/drivers/ui_cocoa.h" #include "../../ui/drivers/cocoa/cocoa_common.h" +#include "../../ui/drivers/cocoa/apple_platform.h" #include "../../configuration.h" #include "../../retroarch.h" #include "../../verbosity.h" @@ -370,7 +371,7 @@ float cocoagl_gfx_ctx_get_native_scale(void) static void cocoagl_gfx_ctx_update_title(void *data, void *data2) { const ui_window_t *window = ui_companion_driver_get_window_ptr(); - + if (window) { char title[128]; From f349784bd66ab30cba564773dcac17530e0792fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Sat, 30 Nov 2019 12:43:38 +0700 Subject: [PATCH 2/5] Fix the xcode build --- ui/drivers/ui_cocoa.m | 29 ++--------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/ui/drivers/ui_cocoa.m b/ui/drivers/ui_cocoa.m index 3c7ea722c6..2903f893ce 100644 --- a/ui/drivers/ui_cocoa.m +++ b/ui/drivers/ui_cocoa.m @@ -28,6 +28,7 @@ #include "cocoa/cocoa_defines.h" #include "cocoa/cocoa_common.h" +#include "cocoa/apple_platform.h" #include "../ui_companion_driver.h" #include "../../input/drivers/cocoa_input.h" #include "../../input/drivers_keyboard/keyboard_event_apple.h" @@ -63,32 +64,6 @@ @end #endif -#if defined(HAVE_COCOA_METAL) -id apple_platform; -@interface RetroArch_OSX : NSObject -{ - NSWindow* _window; - apple_view_type_t _vt; - NSView* _renderView; - id _sleepActivity; - WindowListener *_listener; -} -#elif defined(HAVE_COCOA) -id apple_platform; -#if (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__))) -@interface RetroArch_OSX : NSObject -#else -@interface RetroArch_OSX : NSObject -#endif -{ - NSWindow* _window; -} -#endif - -@property (nonatomic, retain) NSWindow IBOutlet* window; - -@end - static void app_terminate(void) { [[NSApplication sharedApplication] terminate:nil]; @@ -175,7 +150,7 @@ static void app_terminate(void) apple = (cocoa_input_data_t*)input_driver_get_data(); if (!apple) return; - + pos.x = 0; pos.y = 0; From c0dfcd2adf65e72a1586de01c0de2bcc9b1ff0f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Sat, 30 Nov 2019 12:49:52 +0700 Subject: [PATCH 3/5] Fix Metal build --- gfx/common/metal_common.h | 91 +++++++++++-------------------- ui/drivers/cocoa/apple_platform.h | 54 ++++++++++++------ ui/drivers/ui_cocoa.m | 23 -------- 3 files changed, 68 insertions(+), 100 deletions(-) diff --git a/gfx/common/metal_common.h b/gfx/common/metal_common.h index 33f7f36ef4..0592867bb6 100644 --- a/gfx/common/metal_common.h +++ b/gfx/common/metal_common.h @@ -40,43 +40,16 @@ extern MTLPixelFormat SelectOptimalPixelFormat(MTLPixelFormat fmt); @interface MetalView : MTKView @end -#ifdef HAVE_COCOA_METAL - -@protocol ApplePlatform - -/*! @brief renderView returns the current render view based on the viewType */ -@property (readonly) id renderView; - -/*! @brief isActive returns true if the application has focus */ -@property (readonly) bool hasFocus; - -@property (readwrite) apple_view_type_t viewType; - -/*! @brief setVideoMode adjusts the video display to the specified mode */ -- (void)setVideoMode:(gfx_ctx_mode_t)mode; - -/*! @brief setCursorVisible specifies whether the cursor is visible */ -- (void)setCursorVisible:(bool)v; - -/*! @brief controls whether the screen saver should be disabled and - * the displays should not sleep. - */ -- (bool)setDisableDisplaySleep:(bool)disable; -@end - -extern id apple_platform; -#endif - @interface FrameView : NSObject -@property (nonatomic, readonly) RPixelFormat format; -@property (nonatomic, readonly) RTextureFilter filter; -@property (nonatomic, readwrite) BOOL visible; -@property (nonatomic, readwrite) CGRect frame; -@property (nonatomic, readwrite) CGSize size; -@property (nonatomic, readonly) ViewDrawState drawState; -@property (nonatomic, readonly) struct video_shader *shader; -@property (nonatomic, readwrite) uint64_t frameCount; +@property(nonatomic, readonly) RPixelFormat format; +@property(nonatomic, readonly) RTextureFilter filter; +@property(nonatomic, readwrite) BOOL visible; +@property(nonatomic, readwrite) CGRect frame; +@property(nonatomic, readwrite) CGSize size; +@property(nonatomic, readonly) ViewDrawState drawState; +@property(nonatomic, readonly) struct video_shader *shader; +@property(nonatomic, readwrite) uint64_t frameCount; - (void)setFilteringIndex:(int)index smooth:(bool)smooth; - (BOOL)setShaderFromPath:(NSString *)path; @@ -87,21 +60,21 @@ extern id apple_platform; @interface MetalMenu : NSObject -@property (nonatomic, readonly) bool hasFrame; -@property (nonatomic, readwrite) bool enabled; -@property (nonatomic, readwrite) float alpha; +@property(nonatomic, readonly) bool hasFrame; +@property(nonatomic, readwrite) bool enabled; +@property(nonatomic, readwrite) float alpha; - (void)updateFrame:(void const *)source; - (void)updateWidth:(int)width - height:(int)height - format:(RPixelFormat)format - filter:(RTextureFilter)filter; + height:(int)height + format:(RPixelFormat)format + filter:(RTextureFilter)filter; @end @interface Overlay : NSObject -@property (nonatomic, readwrite) bool enabled; -@property (nonatomic, readwrite) bool fullscreen; +@property(nonatomic, readwrite) bool enabled; +@property(nonatomic, readwrite) bool fullscreen; - (bool)loadImages:(const struct texture_image *)images count:(NSUInteger)count; - (void)updateVertexX:(float)x y:(float)y w:(float)w h:(float)h index:(NSUInteger)index; @@ -111,27 +84,27 @@ extern id apple_platform; @interface MetalDriver : NSObject -@property (nonatomic, readonly) video_viewport_t *viewport; -@property (nonatomic, readwrite) bool keepAspect; -@property (nonatomic, readonly) MetalMenu *menu; -@property (nonatomic, readonly) FrameView *frameView; -@property (nonatomic, readonly) MenuDisplay *display; -@property (nonatomic, readonly) Overlay *overlay; -@property (nonatomic, readonly) Context *context; -@property (nonatomic, readonly) Uniforms *viewportMVP; +@property(nonatomic, readonly) video_viewport_t *viewport; +@property(nonatomic, readwrite) bool keepAspect; +@property(nonatomic, readonly) MetalMenu *menu; +@property(nonatomic, readonly) FrameView *frameView; +@property(nonatomic, readonly) MenuDisplay *display; +@property(nonatomic, readonly) Overlay *overlay; +@property(nonatomic, readonly) Context *context; +@property(nonatomic, readonly) Uniforms *viewportMVP; - (instancetype)initWithVideo:(const video_info_t *)video - input:(input_driver_t **)input - inputData:(void **)inputData; + input:(input_driver_t **)input + inputData:(void **)inputData; - (void)setVideo:(const video_info_t *)video; - (bool)renderFrame:(const void *)data - width:(unsigned)width - height:(unsigned)height - frameCount:(uint64_t)frameCount - pitch:(unsigned)pitch - msg:(const char *)msg - info:(video_frame_info_t *)video_info; + width:(unsigned)width + height:(unsigned)height + frameCount:(uint64_t)frameCount + pitch:(unsigned)pitch + msg:(const char *)msg + info:(video_frame_info_t *)video_info; /*! @brief setNeedsResize triggers a display resize */ - (void)setNeedsResize; diff --git a/ui/drivers/cocoa/apple_platform.h b/ui/drivers/cocoa/apple_platform.h index d3cf4609cd..0bdc062051 100644 --- a/ui/drivers/cocoa/apple_platform.h +++ b/ui/drivers/cocoa/apple_platform.h @@ -5,47 +5,65 @@ #import #import -@interface WindowListener : NSResponder +@interface WindowListener : NSResponder @end @implementation WindowListener /* Similarly to SDL, we'll respond to key events by doing nothing so we don't beep. */ -- (void)flagsChanged:(NSEvent *)event -{ +- (void)flagsChanged:(NSEvent *)event { } -- (void)keyDown:(NSEvent *)event -{ +- (void)keyDown:(NSEvent *)event { } -- (void)keyUp:(NSEvent *)event -{ +- (void)keyUp:(NSEvent *)event { } @end -#endif -#if defined(HAVE_COCOA_METAL) +@protocol ApplePlatform + +/*! @brief renderView returns the current render view based on the viewType */ +@property(readonly) id renderView; + +/*! @brief isActive returns true if the application has focus */ +@property(readonly) bool hasFocus; + +@property(readwrite) apple_view_type_t viewType; + +/*! @brief setVideoMode adjusts the video display to the specified mode */ +- (void)setVideoMode:(gfx_ctx_mode_t)mode; + +/*! @brief setCursorVisible specifies whether the cursor is visible */ +- (void)setCursorVisible:(bool)v; + +/*! @brief controls whether the screen saver should be disabled and + * the displays should not sleep. + */ +- (bool)setDisableDisplaySleep:(bool)disable; +@end + +extern id apple_platform; + id apple_platform; -@interface RetroArch_OSX : NSObject -{ - NSWindow *_window; - apple_view_type_t _vt; - NSView *_renderView; - id _sleepActivity; - WindowListener *_listener; +@interface RetroArch_OSX : NSObject { + NSWindow *_window; + apple_view_type_t _vt; + NSView *_renderView; + id _sleepActivity; + WindowListener *_listener; } #elif defined(HAVE_COCOA) id apple_platform; #if (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__))) @interface RetroArch_OSX : NSObject #else -@interface RetroArch_OSX : NSObject +@interface RetroArch_OSX : NSObject #endif { - NSWindow *_window; + NSWindow *_window; } #endif diff --git a/ui/drivers/ui_cocoa.m b/ui/drivers/ui_cocoa.m index 2903f893ce..e5595bbb98 100644 --- a/ui/drivers/ui_cocoa.m +++ b/ui/drivers/ui_cocoa.m @@ -41,29 +41,6 @@ #include "../../tasks/tasks_internal.h" #include ".././verbosity.h" -#if defined(HAVE_COCOA_METAL) -#import -#import - -@interface WindowListener : NSResponder -@end - -@implementation WindowListener - -/* Similarly to SDL, we'll respond to key events by doing nothing so we don't beep. - */ -- (void)flagsChanged:(NSEvent *)event -{} - -- (void)keyDown:(NSEvent *)event -{} - -- (void)keyUp:(NSEvent *)event -{} - -@end -#endif - static void app_terminate(void) { [[NSApplication sharedApplication] terminate:nil]; From 3ed2cf78126af3050a69cd30961c979f2a3c0701 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Sat, 30 Nov 2019 13:01:43 +0700 Subject: [PATCH 4/5] CI --- .travis.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.travis.yml b/.travis.yml index f0044bdba5..6ac35ea53b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -58,6 +58,12 @@ matrix: env: CXX_BUILD=1 CC=clang-6.0 CXX=clang++-6.0 - os: osx env: CC=clang CXX=clang++ + - name: OSX OpenGL Make + os: osx + osx_image: xcode11.2 + script: + - ./configure --enable-opengl --disable metal + - make - os: osx osx_image: xcode8 script: From 93df88a5d6498c18de49a9a0884b827e66026237 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Sat, 30 Nov 2019 14:24:38 +0700 Subject: [PATCH 5/5] Typo --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6ac35ea53b..4ef141dcca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -62,7 +62,7 @@ matrix: os: osx osx_image: xcode11.2 script: - - ./configure --enable-opengl --disable metal + - ./configure --enable-opengl --disable-metal - make - os: osx osx_image: xcode8