diff --git a/gfx/common/metal/Context.m b/gfx/common/metal/Context.m index c56bfbc691..1ab4403a04 100644 --- a/gfx/common/metal/Context.m +++ b/gfx/common/metal/Context.m @@ -9,6 +9,7 @@ #import "Context.h" #import "Filter.h" #import +#import "metal_common.h" @interface BufferNode : NSObject @property (nonatomic, readonly) id src; @@ -759,15 +760,9 @@ static const NSUInteger kConstantAlignment = 4; - (bool)allocRange:(BufferRange *)range length:(NSUInteger)length { MTLResourceOptions opts; - + opts = PLATFORM_METAL_RESOURCE_STORAGE_MODE; memset(range, 0, sizeof(*range)); -#if TARGET_OS_OSX - opts = MTLResourceStorageModeManaged; -#else - opts = MTLResourceStorageModeShared; -#endif - if (!_head) { _head = [[BufferNode alloc] initWithBuffer:[_device newBufferWithLength:_blockLen options:opts]]; diff --git a/gfx/common/metal/MenuDisplay.m b/gfx/common/metal/MenuDisplay.m index c340744cfa..a7cf8e267d 100644 --- a/gfx/common/metal/MenuDisplay.m +++ b/gfx/common/metal/MenuDisplay.m @@ -5,7 +5,7 @@ #import "Context.h" #import "MenuDisplay.h" #import "ShaderTypes.h" -//#import "menu_driver.h" +#include "../../../menu/menu_driver.h" #import /* TODO(sgc): this dependency is incorrect */ #import "../metal_common.h" diff --git a/gfx/common/metal_common.h b/gfx/common/metal_common.h index fb4f7197f9..e7df4ee3de 100644 --- a/gfx/common/metal_common.h +++ b/gfx/common/metal_common.h @@ -28,6 +28,12 @@ #include "../../config.h" #endif +#ifdef HAVE_COCOATOUCH +#define PLATFORM_METAL_RESOURCE_STORAGE_MODE MTLResourceStorageModeShared +#else +#define PLATFORM_METAL_RESOURCE_STORAGE_MODE MTLResourceStorageModeManaged +#endif + RETRO_BEGIN_DECLS extern MTLPixelFormat glslang_format_to_metal(glslang_format fmt); diff --git a/gfx/common/metal_common.m b/gfx/common/metal_common.m index 0b94dd2b77..8b87bdd880 100644 --- a/gfx/common/metal_common.m +++ b/gfx/common/metal_common.m @@ -505,9 +505,6 @@ NSLog(@"mtkView drawableSizeWillChange to: %f x %f",size.width,size.height); #ifdef HAVE_COCOATOUCH CGFloat scale = [[UIScreen mainScreen] scale]; -// // due to autolayout constraints? -//// if (size.width == INFINITY || size.height == INFINITY) { -// NSLog(@"mtkView drawableSizeWillChange width or height is infinity, flipping..."); [self setViewportWidth:(unsigned int)view.bounds.size.width*scale height:(unsigned int)view.bounds.size.height*scale forceFull:NO allowRotate:YES]; #else [self setViewportWidth:(unsigned int)size.width height:(unsigned int)size.height forceFull:NO allowRotate:YES]; @@ -1373,11 +1370,7 @@ typedef struct MTLALIGN(16) if (size == 0) continue; -#if defined(HAVE_COCOATOUCH) - id buf = [_context.device newBufferWithLength:size options:MTLResourceStorageModeShared]; -#else - id buf = [_context.device newBufferWithLength:size options:MTLResourceStorageModeManaged]; -#endif + id buf = [_context.device newBufferWithLength:size options:PLATFORM_METAL_RESOURCE_STORAGE_MODE]; STRUCT_ASSIGN(_engine.pass[i].buffers[j], buf); } } @finally @@ -1493,11 +1486,7 @@ 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 + _vert = [_context.device newBufferWithLength:needed options:PLATFORM_METAL_RESOURCE_STORAGE_MODE]; } for (NSUInteger i = 0; i < count; i++) diff --git a/gfx/drivers_font/metal_raster_font.m b/gfx/drivers_font/metal_raster_font.m index 376f30f093..2783461f68 100644 --- a/gfx/drivers_font/metal_raster_font.m +++ b/gfx/drivers_font/metal_raster_font.m @@ -79,13 +79,7 @@ { _buffer = [_context.device newBufferWithBytes:_atlas->buffer length:(NSUInteger)(_stride * _atlas->height) - options: -#if defined(HAVE_COCOATOUCH) - MTLResourceStorageModeShared -#else - MTLResourceStorageModeManaged -#endif - ]; + options:PLATFORM_METAL_RESOURCE_STORAGE_MODE]; // Even though newBufferWithBytes will copy the initial contents // from our atlas, it doesn't seem to invalidate the buffer when @@ -98,13 +92,7 @@ else { _buffer = [_context.device newBufferWithLength:(NSUInteger)(_stride * _atlas->height) - options: -#if defined(HAVE_COCOATOUCH) - MTLResourceStorageModeShared -#else - MTLResourceStorageModeManaged -#endif - ]; + options:PLATFORM_METAL_RESOURCE_STORAGE_MODE]; void *dst = _buffer.contents; void *src = _atlas->buffer; for (unsigned i = 0; i < _atlas->height; i++) @@ -127,13 +115,7 @@ _capacity = 12000; _vert = [_context.device newBufferWithLength:sizeof(SpriteVertex) * - _capacity options: -#if defined(HAVE_COCOATOUCH) - MTLResourceStorageModeShared -#else - MTLResourceStorageModeManaged -#endif - ]; + _capacity options:PLATFORM_METAL_RESOURCE_STORAGE_MODE]; if (![self _initializeState]) { return nil; diff --git a/pkg/apple/RetroArch_iOS11_Metal.xcodeproj/project.pbxproj b/pkg/apple/RetroArch_iOS11_Metal.xcodeproj/project.pbxproj index 6c9042ed3d..88d745b7e5 100644 --- a/pkg/apple/RetroArch_iOS11_Metal.xcodeproj/project.pbxproj +++ b/pkg/apple/RetroArch_iOS11_Metal.xcodeproj/project.pbxproj @@ -842,8 +842,16 @@ "-DHAVE_SHADERPIPELINE", "-D_LZMA_UINT32_IS_ULONG", "-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.RetroArchDBUG; PRODUCT_NAME = RADEBUG; @@ -965,8 +973,16 @@ "-DHAVE_SHADERPIPELINE", "-D_LZMA_UINT32_IS_ULONG", "-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.tvos.RetroArch; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -1089,8 +1105,16 @@ "-DHAVE_SHADERPIPELINE", "-D_LZMA_UINT32_IS_ULONG", "-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.tvos.RetroArch; PRODUCT_NAME = "$(TARGET_NAME)";