mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-11 17:45:11 +02:00
7d8c7dd70a
Fixes #19183 Thanks to @schm1dtmac for the fix. @shm1dtmac also mentions that this may have issues when moving the window between displays, but this should still be an improvement for most people.
39 lines
1.0 KiB
Plaintext
39 lines
1.0 KiB
Plaintext
#include "ppsspp_config.h"
|
|
#if PPSSPP_PLATFORM(MAC)
|
|
#import <Cocoa/Cocoa.h>
|
|
#else
|
|
#import <UIKit/UIKit.h>
|
|
#endif
|
|
#import <QuartzCore/CAMetalLayer.h>
|
|
|
|
#include "SDLCocoaMetalLayer.h"
|
|
|
|
void *makeWindowMetalCompatible(void *window) {
|
|
// https://github.com/KhronosGroup/MoltenVK/issues/78#issuecomment-371118536
|
|
#if PPSSPP_PLATFORM(MAC)
|
|
NSView *view = ((NSWindow *)window).contentView;
|
|
assert([view isKindOfClass:[NSView class]]);
|
|
|
|
if (![view.layer isKindOfClass:[CAMetalLayer class]])
|
|
{
|
|
[view setLayer:[CAMetalLayer layer]];
|
|
[[view layer] setContentsScale:[window backingScaleFactor]];
|
|
}
|
|
return view.layer;
|
|
#else
|
|
UIView *view = (UIView *)window;
|
|
assert([view isKindOfClass:[UIView class]]);
|
|
|
|
CAMetalLayer *metalLayer = [CAMetalLayer new];
|
|
|
|
CGSize viewSize = view.frame.size;
|
|
metalLayer.frame = view.frame;
|
|
metalLayer.opaque = true;
|
|
metalLayer.framebufferOnly = true;
|
|
metalLayer.drawableSize = viewSize;
|
|
metalLayer.pixelFormat = (MTLPixelFormat)80;//BGRA8Unorm==80
|
|
[view.layer addSublayer:metalLayer];
|
|
return metalLayer;
|
|
#endif
|
|
}
|