improved readability for references to the platform specific metal storage mode option; removed support for btstack since its not compiling and is less relevant for the iOS platform; removed commented out code

This commit is contained in:
Yoshi Sugawara 2020-07-19 07:48:07 -10:00
parent fd9ac64d55
commit a2327be378
6 changed files with 41 additions and 45 deletions

View File

@ -9,6 +9,7 @@
#import "Context.h"
#import "Filter.h"
#import <QuartzCore/QuartzCore.h>
#import "metal_common.h"
@interface BufferNode : NSObject
@property (nonatomic, readonly) id<MTLBuffer> 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]];

View File

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

View File

@ -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);

View File

@ -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<MTLBuffer> buf = [_context.device newBufferWithLength:size options:MTLResourceStorageModeShared];
#else
id<MTLBuffer> buf = [_context.device newBufferWithLength:size options:MTLResourceStorageModeManaged];
#endif
id<MTLBuffer> 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++)

View File

@ -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;

View File

@ -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)";