Fix Metal build

This commit is contained in:
Jean-André Santoni 2019-11-30 12:49:52 +07:00
parent f349784bd6
commit c0dfcd2adf
No known key found for this signature in database
GPG Key ID: 9D694E373914CC36
3 changed files with 68 additions and 100 deletions

View File

@ -40,43 +40,16 @@ extern MTLPixelFormat SelectOptimalPixelFormat(MTLPixelFormat fmt);
@interface MetalView : MTKView @interface MetalView : MTKView
@end @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<ApplePlatform> apple_platform;
#endif
@interface FrameView : NSObject @interface FrameView : NSObject
@property (nonatomic, readonly) RPixelFormat format; @property(nonatomic, readonly) RPixelFormat format;
@property (nonatomic, readonly) RTextureFilter filter; @property(nonatomic, readonly) RTextureFilter filter;
@property (nonatomic, readwrite) BOOL visible; @property(nonatomic, readwrite) BOOL visible;
@property (nonatomic, readwrite) CGRect frame; @property(nonatomic, readwrite) CGRect frame;
@property (nonatomic, readwrite) CGSize size; @property(nonatomic, readwrite) CGSize size;
@property (nonatomic, readonly) ViewDrawState drawState; @property(nonatomic, readonly) ViewDrawState drawState;
@property (nonatomic, readonly) struct video_shader *shader; @property(nonatomic, readonly) struct video_shader *shader;
@property (nonatomic, readwrite) uint64_t frameCount; @property(nonatomic, readwrite) uint64_t frameCount;
- (void)setFilteringIndex:(int)index smooth:(bool)smooth; - (void)setFilteringIndex:(int)index smooth:(bool)smooth;
- (BOOL)setShaderFromPath:(NSString *)path; - (BOOL)setShaderFromPath:(NSString *)path;
@ -87,21 +60,21 @@ extern id<ApplePlatform> apple_platform;
@interface MetalMenu : NSObject @interface MetalMenu : NSObject
@property (nonatomic, readonly) bool hasFrame; @property(nonatomic, readonly) bool hasFrame;
@property (nonatomic, readwrite) bool enabled; @property(nonatomic, readwrite) bool enabled;
@property (nonatomic, readwrite) float alpha; @property(nonatomic, readwrite) float alpha;
- (void)updateFrame:(void const *)source; - (void)updateFrame:(void const *)source;
- (void)updateWidth:(int)width - (void)updateWidth:(int)width
height:(int)height height:(int)height
format:(RPixelFormat)format format:(RPixelFormat)format
filter:(RTextureFilter)filter; filter:(RTextureFilter)filter;
@end @end
@interface Overlay : NSObject @interface Overlay : NSObject
@property (nonatomic, readwrite) bool enabled; @property(nonatomic, readwrite) bool enabled;
@property (nonatomic, readwrite) bool fullscreen; @property(nonatomic, readwrite) bool fullscreen;
- (bool)loadImages:(const struct texture_image *)images count:(NSUInteger)count; - (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; - (void)updateVertexX:(float)x y:(float)y w:(float)w h:(float)h index:(NSUInteger)index;
@ -111,27 +84,27 @@ extern id<ApplePlatform> apple_platform;
@interface MetalDriver : NSObject<MTKViewDelegate> @interface MetalDriver : NSObject<MTKViewDelegate>
@property (nonatomic, readonly) video_viewport_t *viewport; @property(nonatomic, readonly) video_viewport_t *viewport;
@property (nonatomic, readwrite) bool keepAspect; @property(nonatomic, readwrite) bool keepAspect;
@property (nonatomic, readonly) MetalMenu *menu; @property(nonatomic, readonly) MetalMenu *menu;
@property (nonatomic, readonly) FrameView *frameView; @property(nonatomic, readonly) FrameView *frameView;
@property (nonatomic, readonly) MenuDisplay *display; @property(nonatomic, readonly) MenuDisplay *display;
@property (nonatomic, readonly) Overlay *overlay; @property(nonatomic, readonly) Overlay *overlay;
@property (nonatomic, readonly) Context *context; @property(nonatomic, readonly) Context *context;
@property (nonatomic, readonly) Uniforms *viewportMVP; @property(nonatomic, readonly) Uniforms *viewportMVP;
- (instancetype)initWithVideo:(const video_info_t *)video - (instancetype)initWithVideo:(const video_info_t *)video
input:(input_driver_t **)input input:(input_driver_t **)input
inputData:(void **)inputData; inputData:(void **)inputData;
- (void)setVideo:(const video_info_t *)video; - (void)setVideo:(const video_info_t *)video;
- (bool)renderFrame:(const void *)data - (bool)renderFrame:(const void *)data
width:(unsigned)width width:(unsigned)width
height:(unsigned)height height:(unsigned)height
frameCount:(uint64_t)frameCount frameCount:(uint64_t)frameCount
pitch:(unsigned)pitch pitch:(unsigned)pitch
msg:(const char *)msg msg:(const char *)msg
info:(video_frame_info_t *)video_info; info:(video_frame_info_t *)video_info;
/*! @brief setNeedsResize triggers a display resize */ /*! @brief setNeedsResize triggers a display resize */
- (void)setNeedsResize; - (void)setNeedsResize;

View File

@ -5,47 +5,65 @@
#import <Metal/Metal.h> #import <Metal/Metal.h>
#import <MetalKit/MetalKit.h> #import <MetalKit/MetalKit.h>
@interface WindowListener : NSResponder <NSWindowDelegate> @interface WindowListener : NSResponder<NSWindowDelegate>
@end @end
@implementation WindowListener @implementation WindowListener
/* Similarly to SDL, we'll respond to key events by doing nothing so we don't beep. /* 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 @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<ApplePlatform> apple_platform;
id<ApplePlatform> apple_platform; id<ApplePlatform> apple_platform;
@interface RetroArch_OSX : NSObject <ApplePlatform, NSApplicationDelegate> @interface RetroArch_OSX : NSObject<ApplePlatform, NSApplicationDelegate> {
{ NSWindow *_window;
NSWindow *_window; apple_view_type_t _vt;
apple_view_type_t _vt; NSView *_renderView;
NSView *_renderView; id _sleepActivity;
id _sleepActivity; WindowListener *_listener;
WindowListener *_listener;
} }
#elif defined(HAVE_COCOA) #elif defined(HAVE_COCOA)
id apple_platform; id apple_platform;
#if (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__))) #if (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__)))
@interface RetroArch_OSX : NSObject @interface RetroArch_OSX : NSObject
#else #else
@interface RetroArch_OSX : NSObject <NSApplicationDelegate> @interface RetroArch_OSX : NSObject<NSApplicationDelegate>
#endif #endif
{ {
NSWindow *_window; NSWindow *_window;
} }
#endif #endif

View File

@ -41,29 +41,6 @@
#include "../../tasks/tasks_internal.h" #include "../../tasks/tasks_internal.h"
#include ".././verbosity.h" #include ".././verbosity.h"
#if defined(HAVE_COCOA_METAL)
#import <Metal/Metal.h>
#import <MetalKit/MetalKit.h>
@interface WindowListener : NSResponder<NSWindowDelegate>
@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) static void app_terminate(void)
{ {
[[NSApplication sharedApplication] terminate:nil]; [[NSApplication sharedApplication] terminate:nil];