mirror of
https://github.com/stenzek/duckstation.git
synced 2025-07-21 17:40:16 +00:00
MetalDevice: Retain references to layer
Apparently the allocate method returns +0 references.
This commit is contained in:
parent
210f492487
commit
b545671d67
@ -163,7 +163,7 @@ void MetalSwapChain::Destroy(bool wait_for_gpu)
|
||||
MetalDevice::GetInstance().WaitForGPUIdle();
|
||||
|
||||
RunOnMainThread([this]() {
|
||||
NSView* view = (__bridge NSView*)m_window_info.window_handle;
|
||||
NSView* view = (NSView*)m_window_info.window_handle;
|
||||
[view setLayer:nil];
|
||||
[view setWantsLayer:FALSE];
|
||||
[m_layer release];
|
||||
@ -219,7 +219,7 @@ std::unique_ptr<GPUSwapChain> MetalDevice::CreateSwapChain(const WindowInfo& wi,
|
||||
@autoreleasepool
|
||||
{
|
||||
INFO_LOG("Creating a {}x{} Metal layer.", wi_copy.surface_width, wi_copy.surface_height);
|
||||
layer = [CAMetalLayer layer]; // TODO: Does this need retain??
|
||||
layer = [[CAMetalLayer layer] retain];
|
||||
if (layer == nil)
|
||||
{
|
||||
Error::SetStringView(error, "Failed to create metal layer.");
|
||||
@ -242,7 +242,7 @@ std::unique_ptr<GPUSwapChain> MetalDevice::CreateSwapChain(const WindowInfo& wi,
|
||||
|
||||
VERBOSE_LOG("Metal layer pixel format is {}.", GPUTexture::GetFormatName(wi_copy.surface_format));
|
||||
|
||||
NSView* view = (__bridge NSView*)wi_copy.window_handle;
|
||||
NSView* view = (NSView*)wi_copy.window_handle;
|
||||
[view setWantsLayer:TRUE];
|
||||
[view setLayer:layer];
|
||||
}
|
||||
|
@ -104,19 +104,19 @@ void* CocoaTools::CreateMetalLayer(const WindowInfo& wi, Error* error)
|
||||
return ret;
|
||||
}
|
||||
|
||||
CAMetalLayer* layer = [CAMetalLayer layer];
|
||||
CAMetalLayer* layer = [[CAMetalLayer layer] retain];
|
||||
if (layer == nil)
|
||||
{
|
||||
Error::SetStringView(error, "Failed to create CAMetalLayer");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
NSView* view = (__bridge NSView*)wi.window_handle;
|
||||
NSView* view = (NSView*)wi.window_handle;
|
||||
[view setWantsLayer:TRUE];
|
||||
[view setLayer:layer];
|
||||
[layer setContentsScale:[[[view window] screen] backingScaleFactor]];
|
||||
|
||||
return (__bridge void*)layer;
|
||||
return layer;
|
||||
}
|
||||
|
||||
void CocoaTools::DestroyMetalLayer(const WindowInfo& wi, void* layer)
|
||||
@ -128,8 +128,8 @@ void CocoaTools::DestroyMetalLayer(const WindowInfo& wi, void* layer)
|
||||
return;
|
||||
}
|
||||
|
||||
NSView* view = (__bridge NSView*)wi.window_handle;
|
||||
CAMetalLayer* clayer = (__bridge CAMetalLayer*)layer;
|
||||
NSView* view = (NSView*)wi.window_handle;
|
||||
CAMetalLayer* clayer = (CAMetalLayer*)layer;
|
||||
[view setLayer:nil];
|
||||
[view setWantsLayer:NO];
|
||||
[clayer release];
|
||||
@ -145,7 +145,7 @@ std::optional<float> CocoaTools::GetViewRefreshRate(const WindowInfo& wi, Error*
|
||||
}
|
||||
|
||||
std::optional<float> ret;
|
||||
NSView* const view = (__bridge NSView*)wi.window_handle;
|
||||
NSView* const view = (NSView*)wi.window_handle;
|
||||
const u32 did = [[[[[view window] screen] deviceDescription] valueForKey:@"NSScreenNumber"] unsignedIntValue];
|
||||
if (CGDisplayModeRef mode = CGDisplayCopyDisplayMode(did))
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user