support ApplePlatform for iOS and conform app delegate class to it, move app delegate class to apple_platform.h, fix metal references for iOS

This commit is contained in:
Yoshi Sugawara 2020-07-07 05:03:42 -10:00
parent 2e115baf36
commit 6308ba1acb
15 changed files with 254 additions and 89 deletions

View File

@ -5,7 +5,7 @@
#import "Context.h"
#import "MenuDisplay.h"
#import "ShaderTypes.h"
#import "menu_driver.h"
//#import "menu_driver.h"
#import <Metal/Metal.h>
/* TODO(sgc): this dependency is incorrect */
#import "../metal_common.h"

View File

@ -23,9 +23,14 @@
- (NSString *)debugDescription
{
#if defined(HAVE_COCOATOUCH)
NSString *sizeDesc = [NSString stringWithFormat:@"width: %f, height: %f",_size.width,_size.height];
#else
NSString *sizeDesc = NSStringFromSize(_size);
#endif
return [NSString stringWithFormat:@"( format = %@, frame = %@ )",
NSStringFromRPixelFormat(_format),
NSStringFromSize(_size)];
sizeDesc];
}
@end

View File

@ -27,7 +27,8 @@
#import "metal_common.h"
#import "../../ui/drivers/cocoa/cocoa_common.h"
#import "Context.h"
//#import "Context.h"
#include "metal/Context.h"
#ifdef HAVE_MENU
#import "../../menu/menu_driver.h"
@ -50,9 +51,11 @@
@implementation MetalView
#if !defined(HAVE_COCOATOUCH)
- (void)keyDown:(NSEvent*)theEvent
{
}
#endif
/* Stop the annoying sound when pressing a key. */
- (BOOL)acceptsFirstResponder
@ -690,7 +693,11 @@ typedef struct MTLALIGN(16)
switch (i)
{
case RARCH_WRAP_BORDER:
#if defined(HAVE_COCOATOUCH)
sd.sAddressMode = MTLSamplerAddressModeClampToZero;
#else
sd.sAddressMode = MTLSamplerAddressModeClampToBorderColor;
#endif
break;
case RARCH_WRAP_EDGE:
@ -1010,7 +1017,9 @@ typedef struct MTLALIGN(16)
if (buffer_sem->stage_mask & SLANG_STAGE_FRAGMENT_MASK)
[rce setFragmentBuffer:buffer offset:0 atIndex:buffer_sem->binding];
#if !defined(HAVE_COCOATOUCH)
[buffer didModifyRange:NSMakeRange(0, buffer.length)];
#endif
}
}
@ -1343,7 +1352,11 @@ typedef struct MTLALIGN(16)
if (size == 0)
continue;
#if defined(HAVE_COCOATOUCH)
id<MTLBuffer> buf = [_context.device newBufferWithLength:size options:MTLResourceStorageModeShared];
#else
id<MTLBuffer> buf = [_context.device newBufferWithLength:size options:MTLResourceStorageModeManaged];
#endif
STRUCT_ASSIGN(_engine.pass[i].buffers[j], buf);
}
} @finally
@ -1459,7 +1472,11 @@ typedef struct MTLALIGN(16)
NSUInteger needed = sizeof(SpriteVertex) * count * 4;
if (!_vert || _vert.length < needed)
{
#if defined(HAVE_COCOATOUCH)
_vert = [_context.device newBufferWithLength:needed options:MTLResourceStorageModeShared];
#else
_vert = [_context.device newBufferWithLength:needed options:MTLResourceStorageModeManaged];
#endif
}
for (NSUInteger i = 0; i < count; i++)
@ -1477,11 +1494,13 @@ typedef struct MTLALIGN(16)
- (void)drawWithEncoder:(id<MTLRenderCommandEncoder>)rce
{
#if !defined(HAVE_COCOATOUCH)
if (_vertDirty)
{
[_vert didModifyRange:NSMakeRange(0, _vert.length)];
_vertDirty = NO;
}
#endif
NSUInteger count = _images.count;
for (NSUInteger i = 0; i < count; ++i)

View File

@ -23,7 +23,7 @@
#else
#include <ApplicationServices/ApplicationServices.h>
#endif
#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
#if !defined(HAVE_COCOATOUCH) && (defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL))
#include <OpenGL/CGLTypes.h>
#include <OpenGL/OpenGL.h>
#include <AppKit/NSScreen.h>
@ -115,7 +115,7 @@ void nsview_set_ptr(CocoaView *p)
g_instance = p;
}
#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
#if !defined(HAVE_COCOATOUCH) && (defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL))
static NSOpenGLPixelFormat* g_format;
void *glcontext_get_ptr(void)
@ -239,7 +239,7 @@ float get_backing_scale_factor(void)
return backing_scale_def;
backing_scale_def = 1.0f;
#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
#if !defined(HAVE_COCOATOUCH) && (defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL))
screen = (BRIDGE RAScreen*)get_chosen_screen();
if (screen)
@ -268,7 +268,7 @@ void cocoagl_gfx_ctx_update(void)
{
case GFX_CTX_OPENGL_API:
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) || defined(HAVE_OPENGL_CORE)
#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
#if !defined(HAVE_COCOATOUCH) && (defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL))
#if MAC_OS_X_VERSION_10_7
CGLUpdateContext(g_hw_ctx.CGLContextObj);
CGLUpdateContext(g_context.CGLContextObj);
@ -298,7 +298,7 @@ static void cocoagl_gfx_ctx_destroy(void *data)
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) || defined(HAVE_OPENGL_CORE)
[GLContextClass clearCurrentContext];
#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
#if !defined(HAVE_COCOATOUCH) && (defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL))
[g_context clearDrawable];
RELEASE(g_context);
RELEASE(g_format);
@ -339,7 +339,7 @@ static void cocoagl_gfx_ctx_show_mouse(void *data, bool state)
{
(void)data;
#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
#if !defined(HAVE_COCOATOUCH) && (defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL))
if (state)
[NSCursor unhide];
else
@ -368,7 +368,7 @@ float cocoagl_gfx_ctx_get_native_scale(void)
return ret;
}
#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
#if !defined(HAVE_COCOATOUCH) && (defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL))
static void cocoagl_gfx_ctx_update_title(void *data)
{
const ui_window_t *window = ui_companion_driver_get_window_ptr();
@ -391,7 +391,7 @@ static bool cocoagl_gfx_ctx_get_metrics(void *data, enum display_metric_types ty
float *value)
{
RAScreen *screen = (BRIDGE RAScreen*)get_chosen_screen();
#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
#if !defined(HAVE_COCOATOUCH) && (defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL))
NSDictionary *description = [screen deviceDescription];
NSSize display_pixel_size = [[description objectForKey:NSDeviceSize] sizeValue];
CGSize display_physical_size = CGDisplayScreenSize(
@ -481,7 +481,7 @@ static void cocoagl_gfx_ctx_input_driver(void *data,
static void cocoagl_gfx_ctx_get_video_size(void *data, unsigned* width, unsigned* height)
{
float screenscale = cocoagl_gfx_ctx_get_native_scale();
#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
#if !defined(HAVE_COCOATOUCH) && (defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL))
CGRect size, cgrect;
GLsizei backingPixelWidth, backingPixelHeight;
#if defined(HAVE_COCOA_METAL)
@ -629,7 +629,7 @@ static void cocoagl_gfx_ctx_swap_buffers(void *data)
if (!(--g_fast_forward_skips < 0))
return;
#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
#if !defined(HAVE_COCOATOUCH) && (defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL))
[g_context flushBuffer];
[g_hw_ctx flushBuffer];
#elif defined(HAVE_COCOATOUCH)
@ -691,12 +691,12 @@ static void *cocoagl_gfx_ctx_get_context_data(void *data)
static bool cocoagl_gfx_ctx_set_video_mode(void *data,
unsigned width, unsigned height, bool fullscreen)
{
#if defined(HAVE_COCOA_METAL)
#if !defined(HAVE_COCOATOUCH) && defined(HAVE_COCOA_METAL)
NSView *g_view = apple_platform.renderView;
#elif defined(HAVE_COCOA)
CocoaView *g_view = (CocoaView*)nsview_get_ptr();
#endif
#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
#if !defined(HAVE_COCOATOUCH) && (defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL))
cocoa_ctx_data_t *cocoa_ctx = (cocoa_ctx_data_t*)data;
cocoa_ctx->width = width;
cocoa_ctx->height = height;
@ -707,7 +707,7 @@ static bool cocoagl_gfx_ctx_set_video_mode(void *data,
case GFX_CTX_OPENGL_API:
case GFX_CTX_OPENGL_ES_API:
{
#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
#if !defined(HAVE_COCOATOUCH) && (defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL))
if ([g_view respondsToSelector: @selector(setWantsBestResolutionOpenGLSurface:)])
[g_view setWantsBestResolutionOpenGLSurface:YES];
@ -783,7 +783,7 @@ static bool cocoagl_gfx_ctx_set_video_mode(void *data,
break;
}
#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
#if !defined(HAVE_COCOATOUCH) && (defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL))
static bool has_went_fullscreen = false;
/* TODO: Screen mode support. */
@ -913,7 +913,7 @@ const gfx_ctx_driver_t gfx_ctx_cocoagl = {
NULL, /* get_video_output_next */
cocoagl_gfx_ctx_get_metrics,
NULL, /* translate_aspect */
#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
#if !defined(HAVE_COCOATOUCH) && (defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL))
cocoagl_gfx_ctx_update_title,
#else
NULL, /* update_title */

View File

@ -79,18 +79,32 @@
{
_buffer = [_context.device newBufferWithBytes:_atlas->buffer
length:(NSUInteger)(_stride * _atlas->height)
options:MTLResourceStorageModeManaged];
options:
#if defined(HAVE_COCOATOUCH)
MTLResourceStorageModeShared
#else
MTLResourceStorageModeManaged
#endif
];
// Even though newBufferWithBytes will copy the initial contents
// from our atlas, it doesn't seem to invalidate the buffer when
// doing so, causing corrupted text rendering if we hit this code
// path. To work around it we manually invalidate the buffer.
#if !defined(HAVE_COCOATOUCH)
[_buffer didModifyRange:NSMakeRange(0, _buffer.length)];
#endif
}
else
{
_buffer = [_context.device newBufferWithLength:(NSUInteger)(_stride * _atlas->height)
options:MTLResourceStorageModeManaged];
options:
#if defined(HAVE_COCOATOUCH)
MTLResourceStorageModeShared
#else
MTLResourceStorageModeManaged
#endif
];
void *dst = _buffer.contents;
void *src = _atlas->buffer;
for (unsigned i = 0; i < _atlas->height; i++)
@ -99,7 +113,9 @@
dst += _stride;
src += _atlas->width;
}
[_buffer didModifyRange:NSMakeRange(0, _buffer.length)];
#if !defined(HAVE_COCOATOUCH)
[_buffer didModifyRange:NSMakeRange(0, _buffer.length)];
#endif
}
MTLTextureDescriptor *td = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatR8Unorm
@ -111,7 +127,13 @@
_capacity = 12000;
_vert = [_context.device newBufferWithLength:sizeof(SpriteVertex) *
_capacity options:MTLResourceStorageModeManaged];
_capacity options:
#if defined(HAVE_COCOATOUCH)
MTLResourceStorageModeShared
#else
MTLResourceStorageModeManaged
#endif
];
if (![self _initializeState])
{
return nil;
@ -181,7 +203,9 @@
NSUInteger offset = glyph->atlas_offset_y;
NSUInteger len = glyph->height * _stride;
#if !defined(HAVE_COCOATOUCH)
[_buffer didModifyRange:NSMakeRange(offset, len)];
#endif
_atlas->dirty = false;
}
@ -324,7 +348,9 @@ static INLINE void write_quad6(SpriteVertex *pv,
- (void)_flush
{
NSUInteger start = _offset * sizeof(SpriteVertex);
#if !defined(HAVE_COCOATOUCH)
[_vert didModifyRange:NSMakeRange(start, sizeof(SpriteVertex) * _vertices)];
#endif
id<MTLRenderCommandEncoder> rce = _context.rce;
[rce pushDebugGroup:@"render fonts"];

View File

@ -304,7 +304,7 @@ float gfx_display_get_dpi_scale_internal(unsigned width, unsigned height)
* unfortunate, and needs to be fixed at the gfx context driver
* level. Until this is done, all we can do is fallback to using
* the old legacy 'magic number' scaling on Mac platforms. */
#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
#if !defined(HAVE_COCOATOUCH) && (defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL))
if (true)
{
scale = (diagonal_pixels / 6.5f) / 212.0f;

View File

@ -41,7 +41,7 @@
#else
#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
#if !defined(HAVE_COCOATOUCH) && (defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL))
#include "../ui/drivers/cocoa/ui_cocoa_window.m"
#include "../ui/drivers/cocoa/ui_cocoa_browser_window.m"
#include "../ui/drivers/cocoa/ui_cocoa_application.m"

View File

@ -26,6 +26,12 @@
9204BE201D319EF300BD49DB /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96AFAE3116C1D4EA009DE44C /* OpenGLES.framework */; };
9204BE231D319EF300BD49DB /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 967894611788EBD800D6CA69 /* InfoPlist.strings */; };
9204BE261D319EF300BD49DB /* iOS/modules in Resources */ = {isa = PBXBuildFile; fileRef = 83EB675F19EEAF050096F441 /* iOS/modules */; };
9210C2F224B3A19100E6FE7C /* MetalKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9210C2F024B3A19100E6FE7C /* MetalKit.framework */; };
9210C2F324B3A19100E6FE7C /* Metal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9210C2F124B3A19100E6FE7C /* Metal.framework */; };
9210C2F624B3A32D00E6FE7C /* griffin_cpp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9210C2F424B3A32D00E6FE7C /* griffin_cpp.cpp */; };
9210C2F724B3A32D00E6FE7C /* griffin_cpp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9210C2F424B3A32D00E6FE7C /* griffin_cpp.cpp */; };
9210C2F824B3A32D00E6FE7C /* griffin_glslang.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9210C2F524B3A32D00E6FE7C /* griffin_glslang.cpp */; };
9210C2F924B3A32D00E6FE7C /* griffin_glslang.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9210C2F524B3A32D00E6FE7C /* griffin_glslang.cpp */; };
9222F1FF2314BA7C0097C0FD /* assets.zip in Resources */ = {isa = PBXBuildFile; fileRef = 9222F1FE2314BA7C0097C0FD /* assets.zip */; };
9222F2002314BA7C0097C0FD /* assets.zip in Resources */ = {isa = PBXBuildFile; fileRef = 9222F1FE2314BA7C0097C0FD /* assets.zip */; };
9222F2092315DAD50097C0FD /* Launch Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9222F2082315DAD50097C0FD /* Launch Screen.storyboard */; };
@ -85,7 +91,11 @@
696012F119F3389A006A1088 /* CoreText.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreText.framework; path = System/Library/Frameworks/CoreText.framework; sourceTree = SDKROOT; };
69D31DE31A547EC800EF4C92 /* iOS/Resources/Media.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = iOS/Resources/Media.xcassets; sourceTree = SOURCE_ROOT; };
83EB675F19EEAF050096F441 /* iOS/modules */ = {isa = PBXFileReference; lastKnownFileType = folder; path = iOS/modules; sourceTree = SOURCE_ROOT; };
9204BE2B1D319EF300BD49DB /* RetroArch.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RetroArch.app; sourceTree = BUILT_PRODUCTS_DIR; };
9204BE2B1D319EF300BD49DB /* RADEBUG.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RADEBUG.app; sourceTree = BUILT_PRODUCTS_DIR; };
9210C2F024B3A19100E6FE7C /* MetalKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MetalKit.framework; path = System/Library/Frameworks/MetalKit.framework; sourceTree = SDKROOT; };
9210C2F124B3A19100E6FE7C /* Metal.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Metal.framework; path = System/Library/Frameworks/Metal.framework; sourceTree = SDKROOT; };
9210C2F424B3A32D00E6FE7C /* griffin_cpp.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = griffin_cpp.cpp; path = ../../griffin/griffin_cpp.cpp; sourceTree = "<group>"; };
9210C2F524B3A32D00E6FE7C /* griffin_glslang.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = griffin_glslang.cpp; path = ../../griffin/griffin_glslang.cpp; sourceTree = "<group>"; };
9222F1FE2314BA7C0097C0FD /* assets.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = assets.zip; sourceTree = "<group>"; };
9222F2082315DAD50097C0FD /* Launch Screen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = "Launch Screen.storyboard"; sourceTree = "<group>"; };
9222F20A2315DD3D0097C0FD /* retroarch_logo.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = retroarch_logo.png; sourceTree = "<group>"; };
@ -153,6 +163,8 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
9210C2F224B3A19100E6FE7C /* MetalKit.framework in Frameworks */,
9210C2F324B3A19100E6FE7C /* Metal.framework in Frameworks */,
92CC05C721FEDD0B00FF79F0 /* MobileCoreServices.framework in Frameworks */,
92CC05C521FEDC9F00FF79F0 /* CFNetwork.framework in Frameworks */,
9204BE121D319EF300BD49DB /* libz.dylib in Frameworks */,
@ -343,7 +355,7 @@
96AFAE2616C1D4EA009DE44C /* Products */ = {
isa = PBXGroup;
children = (
9204BE2B1D319EF300BD49DB /* RetroArch.app */,
9204BE2B1D319EF300BD49DB /* RADEBUG.app */,
926C77D721FD1E6500103EDE /* RetroArchTV.app */,
);
name = Products;
@ -352,6 +364,8 @@
96AFAE2816C1D4EA009DE44C /* Frameworks */ = {
isa = PBXGroup;
children = (
9210C2F124B3A19100E6FE7C /* Metal.framework */,
9210C2F024B3A19100E6FE7C /* MetalKit.framework */,
92CC05C621FEDD0B00FF79F0 /* MobileCoreServices.framework */,
92CC05C421FEDC9F00FF79F0 /* CFNetwork.framework */,
926C77F021FD26E800103EDE /* GameController.framework */,
@ -398,6 +412,8 @@
children = (
50521A431AA23BF500185CC9 /* griffin_objc.m */,
501232C9192E5FC40063A359 /* griffin.c */,
9210C2F424B3A32D00E6FE7C /* griffin_cpp.cpp */,
9210C2F524B3A32D00E6FE7C /* griffin_glslang.cpp */,
);
name = griffin;
sourceTree = "<group>";
@ -420,7 +436,7 @@
);
name = RetroArchiOS11;
productName = RetroArch;
productReference = 9204BE2B1D319EF300BD49DB /* RetroArch.app */;
productReference = 9204BE2B1D319EF300BD49DB /* RADEBUG.app */;
productType = "com.apple.product-type.application";
};
926C77D621FD1E6500103EDE /* RetroArchTV */ = {
@ -554,6 +570,7 @@
92CC05B621FE3C1700FF79F0 /* GCDWebServerMultiPartFormRequest.m in Sources */,
92CC05AC21FE3C1700FF79F0 /* GCDWebServerErrorResponse.m in Sources */,
92CC05A621FE3C1700FF79F0 /* GCDWebServerFunctions.m in Sources */,
9210C2F824B3A32D00E6FE7C /* griffin_glslang.cpp in Sources */,
92CC05A821FE3C1700FF79F0 /* GCDWebServer.m in Sources */,
9204BE0D1D319EF300BD49DB /* griffin_objc.m in Sources */,
9204BE101D319EF300BD49DB /* griffin.c in Sources */,
@ -562,6 +579,7 @@
92CC05C221FE3C6D00FF79F0 /* WebServer.m in Sources */,
92CC05BA21FE3C1700FF79F0 /* GCDWebServerFileRequest.m in Sources */,
92CC05AE21FE3C1700FF79F0 /* GCDWebServerFileResponse.m in Sources */,
9210C2F624B3A32D00E6FE7C /* griffin_cpp.cpp in Sources */,
92CC05B221FE3C1700FF79F0 /* GCDWebServerStreamedResponse.m in Sources */,
92CC05A221FE3C1700FF79F0 /* GCDWebServerResponse.m in Sources */,
);
@ -578,6 +596,7 @@
92CC05B721FE3C1700FF79F0 /* GCDWebServerMultiPartFormRequest.m in Sources */,
92CC05AD21FE3C1700FF79F0 /* GCDWebServerErrorResponse.m in Sources */,
92CC05A721FE3C1700FF79F0 /* GCDWebServerFunctions.m in Sources */,
9210C2F924B3A32D00E6FE7C /* griffin_glslang.cpp in Sources */,
92CC05A921FE3C1700FF79F0 /* GCDWebServer.m in Sources */,
926C77EA21FD20C100103EDE /* griffin_objc.m in Sources */,
926C77EB21FD20C400103EDE /* griffin.c in Sources */,
@ -586,6 +605,7 @@
92CC05C321FE3C6D00FF79F0 /* WebServer.m in Sources */,
92CC05BB21FE3C1700FF79F0 /* GCDWebServerFileRequest.m in Sources */,
92CC05AF21FE3C1700FF79F0 /* GCDWebServerFileResponse.m in Sources */,
9210C2F724B3A32D00E6FE7C /* griffin_cpp.cpp in Sources */,
92CC05B321FE3C1700FF79F0 /* GCDWebServerStreamedResponse.m in Sources */,
92CC05A321FE3C1700FF79F0 /* GCDWebServerResponse.m in Sources */,
);
@ -610,11 +630,13 @@
buildSettings = {
ARCHS = "$(ARCHS_STANDARD)";
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_CXX_LIBRARY = "libstdc++";
CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
CLANG_CXX_LIBRARY = "libc++";
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_RESOURCE_RULES_PATH = "$(SDKROOT)/ResourceRules.plist";
CURRENT_PROJECT_VERSION = 1.8.5;
CURRENT_PROJECT_VERSION = 1.8.9;
DEPS_DIR = "$(SRCBASE)/deps";
DEVELOPMENT_TEAM = R72X3BF4KE;
ENABLE_BITCODE = NO;
GCC_PRECOMPILE_PREFIX_HEADER = NO;
@ -626,12 +648,18 @@
../../deps/stb,
../../deps/rcheevos/include,
../../deps,
"$(DEPS_DIR)/glslang",
"$(DEPS_DIR)/SPIRV-Cross",
"$(DEPS_DIR)/glslang/glslang/glslang/Public",
"$(DEPS_DIR)/glslang/glslang/glslang/OSDependent/Unix",
"$(DEPS_DIR)/glslang/glslang/SPIRV",
"$(DEPS_DIR)/glslang/glslang/glslang/MachineIndependent",
);
INFOPLIST_FILE = "$(SRCROOT)/iOS/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_NO_PIE = YES;
LIBRARY_SEARCH_PATHS = "";
MARKETING_VERSION = 1.8.5;
MARKETING_VERSION = 1.8.9;
ONLY_ACTIVE_ARCH = NO;
OTHER_CFLAGS = (
"-DDONT_WANT_ARM_OPTIMIZATIONS",
@ -690,10 +718,20 @@
"-DHAVE_MFI",
"-DHAVE_BTSTACK",
"-DHAVE_KEYMAPPER",
"-DHAVE_COCOA_METAL",
"-DHAVE_METAL",
"-DHAVE_SLANG",
"-DHAVE_SPIRV_CROSS",
"-DHAVE_GLSLANG",
"-DWANT_GLSLANG",
"-DGLSLANG_OSINCLUDE_UNIX",
"-DENABLE_HLSL",
"-DHAVE_BUILTINGLSLANG",
);
PRODUCT_BUNDLE_IDENTIFIER = com.libretro.dist.ios.RetroArch;
PRODUCT_NAME = RetroArch;
PRODUCT_BUNDLE_IDENTIFIER = com.libretro.RetroArchDBUG;
PRODUCT_NAME = RADEBUG;
PROVISIONING_PROFILE = "";
SRCBASE = "$(SRCROOT)/../..";
VALID_ARCHS = "armv7 arm64";
WARNING_CFLAGS = "-Wno-invalid-source-encoding";
WRAPPER_EXTENSION = app;
@ -705,11 +743,13 @@
buildSettings = {
ARCHS = "$(ARCHS_STANDARD)";
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_CXX_LIBRARY = "libstdc++";
CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
CLANG_CXX_LIBRARY = "libc++";
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_RESOURCE_RULES_PATH = "$(SDKROOT)/ResourceRules.plist";
CURRENT_PROJECT_VERSION = 1.8.5;
CURRENT_PROJECT_VERSION = 1.8.9;
DEPS_DIR = "$(SRCBASE)/deps";
DEVELOPMENT_TEAM = R72X3BF4KE;
ENABLE_BITCODE = NO;
GCC_PRECOMPILE_PREFIX_HEADER = NO;
@ -721,12 +761,18 @@
../../deps/stb,
../../deps/rcheevos/include,
../../deps,
"$(DEPS_DIR)/glslang",
"$(DEPS_DIR)/SPIRV-Cross",
"$(DEPS_DIR)/glslang/glslang/glslang/Public",
"$(DEPS_DIR)/glslang/glslang/glslang/OSDependent/Unix",
"$(DEPS_DIR)/glslang/glslang/SPIRV",
"$(DEPS_DIR)/glslang/glslang/glslang/MachineIndependent",
);
INFOPLIST_FILE = "$(SRCROOT)/iOS/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_NO_PIE = YES;
LIBRARY_SEARCH_PATHS = "";
MARKETING_VERSION = 1.8.5;
MARKETING_VERSION = 1.8.9;
"OTHER_CFLAGS[arch=*]" = (
"-DNS_BLOCK_ASSERTIONS=1",
"-DNDEBUG",
@ -788,9 +834,10 @@
"-DHAVE_BTSTACK",
"-DHAVE_KEYMAPPER",
);
PRODUCT_BUNDLE_IDENTIFIER = com.libretro.dist.ios.RetroArch;
PRODUCT_NAME = RetroArch;
PRODUCT_BUNDLE_IDENTIFIER = com.libretro.RetroArchDBUG;
PRODUCT_NAME = RADEBUG;
PROVISIONING_PROFILE = "";
SRCBASE = "$(SRCROOT)/../..";
VALID_ARCHS = "armv7 arm64";
WARNING_CFLAGS = "-Wno-invalid-source-encoding";
WRAPPER_EXTENSION = app;
@ -828,7 +875,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1.8.5;
CURRENT_PROJECT_VERSION = 1.8.9;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = R72X3BF4KE;
ENABLE_STRICT_OBJC_MSGSEND = YES;
@ -850,7 +897,7 @@
);
INFOPLIST_FILE = "$(SRCROOT)/tvOS/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 1.8.5;
MARKETING_VERSION = 1.8.9;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
@ -950,7 +997,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1.8.5;
CURRENT_PROJECT_VERSION = 1.8.9;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = R72X3BF4KE;
ENABLE_NS_ASSERTIONS = NO;
@ -972,7 +1019,7 @@
);
INFOPLIST_FILE = "$(SRCROOT)/tvOS/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 1.8.5;
MARKETING_VERSION = 1.8.9;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
OTHER_CFLAGS = (

View File

@ -15,7 +15,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9204BE091D319EF300BD49DB"
BuildableName = "RetroArchiOS11.app"
BuildableName = "RADEBUG.app"
BlueprintName = "RetroArchiOS11"
ReferencedContainer = "container:RetroArch_iOS11.xcodeproj">
</BuildableReference>
@ -27,19 +27,17 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9204BE091D319EF300BD49DB"
BuildableName = "RetroArchiOS11.app"
BuildableName = "RADEBUG.app"
BlueprintName = "RetroArchiOS11"
ReferencedContainer = "container:RetroArch_iOS11.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
@ -56,13 +54,11 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9204BE091D319EF300BD49DB"
BuildableName = "RetroArchiOS11.app"
BuildableName = "RADEBUG.app"
BlueprintName = "RetroArchiOS11"
ReferencedContainer = "container:RetroArch_iOS11.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
@ -75,7 +71,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9204BE091D319EF300BD49DB"
BuildableName = "RetroArchiOS11.app"
BuildableName = "RADEBUG.app"
BlueprintName = "RetroArchiOS11"
ReferencedContainer = "container:RetroArch_iOS11.xcodeproj">
</BuildableReference>

View File

@ -15,7 +15,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9204BE091D319EF300BD49DB"
BuildableName = "RetroArchiOS11.app"
BuildableName = "RADEBUG.app"
BlueprintName = "RetroArchiOS11"
ReferencedContainer = "container:RetroArch_iOS11.xcodeproj">
</BuildableReference>
@ -27,19 +27,17 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9204BE091D319EF300BD49DB"
BuildableName = "RetroArchiOS11.app"
BuildableName = "RADEBUG.app"
BlueprintName = "RetroArchiOS11"
ReferencedContainer = "container:RetroArch_iOS11.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Release"
@ -56,13 +54,11 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9204BE091D319EF300BD49DB"
BuildableName = "RetroArchiOS11.app"
BuildableName = "RADEBUG.app"
BlueprintName = "RetroArchiOS11"
ReferencedContainer = "container:RetroArch_iOS11.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
@ -75,7 +71,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9204BE091D319EF300BD49DB"
BuildableName = "RetroArchiOS11.app"
BuildableName = "RADEBUG.app"
BlueprintName = "RetroArchiOS11"
ReferencedContainer = "container:RetroArch_iOS11.xcodeproj">
</BuildableReference>

View File

@ -920,7 +920,7 @@ static const ui_companion_driver_t *ui_companion_drivers[] = {
#if defined(_WIN32) && !defined(_XBOX) && !defined(__WINRT__)
&ui_companion_win32,
#endif
#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
#if !defined(HAVE_COCOATOUCH) && (defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL))
&ui_companion_cocoa,
#endif
#ifdef HAVE_COCOATOUCH

View File

@ -5,6 +5,7 @@
#import <Metal/Metal.h>
#import <MetalKit/MetalKit.h>
#if !defined(HAVE_COCOATOUCH)
@interface WindowListener : NSResponder<NSWindowDelegate>
@end
@ -22,6 +23,7 @@
}
@end
#endif
@protocol ApplePlatform
@ -48,6 +50,36 @@
extern id<ApplePlatform> apple_platform;
id<ApplePlatform> apple_platform;
#if defined(HAVE_COCOATOUCH)
#if defined(HAVE_COCOA_METAL)
@interface RetroArch_iOS : UINavigationController<ApplePlatform, UIApplicationDelegate,
UINavigationControllerDelegate> {
UIView *_renderView;
apple_view_type_t _vt;
}
#else
@interface RetroArch_iOS : UINavigationController<UIApplicationDelegate,
UINavigationControllerDelegate>
#endif
@property (nonatomic) UIWindow* window;
@property (nonatomic) NSString* documentsDirectory;
@property (nonatomic) RAMenuBase* mainmenu;
@property (nonatomic) int menu_count;
+ (RetroArch_iOS*)get;
- (void)showGameView;
- (void)toggleUI;
- (void)supportOtherAudioSessions;
- (void)refreshSystemConfig;
- (void)mainMenuPushPop: (bool)pushp;
- (void)mainMenuRefresh;
@end
#else
@interface RetroArch_OSX : NSObject<ApplePlatform, NSApplicationDelegate> {
NSWindow *_window;
apple_view_type_t _vt;
@ -55,6 +87,8 @@ id<ApplePlatform> apple_platform;
id _sleepActivity;
WindowListener *_listener;
}
#endif
#elif defined(HAVE_COCOA)
id apple_platform;
#if (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__)))
@ -67,7 +101,7 @@ id apple_platform;
}
#endif
#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
#if !defined(HAVE_COCOATOUCH) && (defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL))
@property(nonatomic, retain) NSWindow IBOutlet *window;
@end

View File

@ -81,25 +81,6 @@ typedef enum apple_view_type {
+ (CocoaView*)get;
@end
@interface RetroArch_iOS : UINavigationController<UIApplicationDelegate,
UINavigationControllerDelegate>
@property (nonatomic) UIWindow* window;
@property (nonatomic) NSString* documentsDirectory;
@property (nonatomic) RAMenuBase* mainmenu;
@property (nonatomic) int menu_count;
+ (RetroArch_iOS*)get;
- (void)showGameView;
- (void)toggleUI;
- (void)supportOtherAudioSessions;
- (void)refreshSystemConfig;
- (void)mainMenuPushPop: (bool)pushp;
- (void)mainMenuRefresh;
@end
void get_ios_version(int *major, int *minor);
#endif
@ -112,7 +93,7 @@ typedef struct
} apple_frontend_settings_t;
extern apple_frontend_settings_t apple_frontend_settings;
#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
#if !defined(HAVE_COCOATOUCH) && (defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL))
#include <AppKit/AppKit.h>
@interface CocoaView : NSView

View File

@ -46,13 +46,13 @@ void *glkitview_init(void);
@implementation CocoaView
#if defined(HAVE_COCOA_METAL)
#if !defined(HAVE_COCOATOUCH) && defined(HAVE_COCOA_METAL)
- (BOOL)layer:(CALayer *)layer shouldInheritContentsScale:(CGFloat)newScale fromWindow:(NSWindow *)window {
return YES;
}
#endif
#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
#if !defined(HAVE_COCOATOUCH) && (defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL))
- (void)scrollWheel:(NSEvent *)theEvent {
cocoa_input_data_t *apple = (cocoa_input_data_t*)input_driver_get_data();
(void)apple;
@ -74,7 +74,7 @@ void *glkitview_init(void);
{
self = [super init];
#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
#if !defined(HAVE_COCOATOUCH) && (defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL))
[self setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
#endif
@ -83,7 +83,7 @@ void *glkitview_init(void);
cocoa_view.data = (CocoaView*)self;
[self registerForDraggedTypes:[NSArray arrayWithObjects:NSColorPboardType, NSFilenamesPboardType, nil]];
#elif defined(HAVE_COCOA_METAL)
#elif !defined(HAVE_COCOATOUCH) && defined(HAVE_COCOA_METAL)
[self registerForDraggedTypes:@[NSColorPboardType, NSFilenamesPboardType]];
#elif defined(HAVE_COCOATOUCH)
self.view = (BRIDGE GLKView*)glkitview_init();
@ -108,7 +108,7 @@ void *glkitview_init(void);
return self;
}
#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
#if !defined(HAVE_COCOATOUCH) && (defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL))
- (void)setFrame:(NSRect)frameRect
{
[super setFrame:frameRect];
@ -169,7 +169,7 @@ void *glkitview_init(void);
#elif TARGET_OS_IOS
-(void) showNativeMenu {
dispatch_async(dispatch_get_main_queue(), ^{
[[RetroArch_iOS get] toggleUI];
// [[RetroArch_iOS get] toggleUI];
});
}

View File

@ -26,6 +26,7 @@
#include <retro_timers.h>
#include "cocoa/cocoa_common.h"
#include "cocoa/apple_platform.h"
#include "../ui_companion_driver.h"
#include "../../configuration.h"
#include "../../frontend/frontend.h"
@ -317,6 +318,66 @@ enum
@implementation RetroArch_iOS
#pragma mark - ApplePlatform
#ifdef HAVE_COCOA_METAL
-(id)renderView {
return _renderView;
}
-(bool)hasFocus {
return YES;
}
- (void)setViewType:(apple_view_type_t)vt {
if (vt == _vt)
return;
RARCH_LOG("[Cocoa]: change view type: %d ? %d\n", _vt, vt);
_vt = vt;
if (_renderView != nil)
{
// _renderView.wantsLayer = NO;
// _renderView.layer = nil;
[_renderView removeFromSuperview];
// self.window.contentView = nil;
_renderView = nil;
}
switch (vt) {
case APPLE_VIEW_TYPE_VULKAN:
case APPLE_VIEW_TYPE_METAL:
{
MetalView *v = [MetalView new];
v.paused = YES;
v.enableSetNeedsDisplay = NO;
_renderView = v;
}
break;
case APPLE_VIEW_TYPE_OPENGL:
{
_renderView = [CocoaView get];
break;
}
case APPLE_VIEW_TYPE_NONE:
default:
return;
}
// _renderView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
[_renderView setFrame:self.window.bounds];
[self.window addSubview:_renderView];
// self.window.contentView.nextResponder = _listener;
}
- (apple_view_type_t)viewType {
return _vt;
}
#endif
+ (RetroArch_iOS*)get
{
return (RetroArch_iOS*)[[UIApplication sharedApplication] delegate];