From f2f3680a7ce40141e0736a7f7b479d4c7c55d0be Mon Sep 17 00:00:00 2001 From: rogerman Date: Tue, 19 Dec 2017 15:35:20 -0800 Subject: [PATCH] Cocoa Port: Fix a bug where Metal display view backing textures weren't updating their custom framebuffer sizes. (Regression from commit 4c01e66.) --- .../userinterface/MacMetalDisplayView.mm | 46 ++++++++++--------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/desmume/src/frontend/cocoa/userinterface/MacMetalDisplayView.mm b/desmume/src/frontend/cocoa/userinterface/MacMetalDisplayView.mm index dddf784b1..274647fed 100644 --- a/desmume/src/frontend/cocoa/userinterface/MacMetalDisplayView.mm +++ b/desmume/src/frontend/cocoa/userinterface/MacMetalDisplayView.mm @@ -391,31 +391,32 @@ _texDisplayPostprocessNative[NDSDisplayID_Main][i] = [device newTextureWithDescriptor:newTexPostprocessNativeDesc]; _texDisplayPostprocessNative[NDSDisplayID_Touch][i] = [device newTextureWithDescriptor:newTexPostprocessNativeDesc]; + } + + if ( (_fetchPixelBytes != dispInfo.pixelBytes) || + ([_texDisplayFetchCustom[NDSDisplayID_Main][i] width] != w) || + ([_texDisplayFetchCustom[NDSDisplayID_Main][i] height] != h) ) + { + [_texDisplayFetchCustom[NDSDisplayID_Main][i] release]; + [_texDisplayFetchCustom[NDSDisplayID_Touch][i] release]; + [_texDisplayPostprocessCustom[NDSDisplayID_Main][i] release]; + [_texDisplayPostprocessCustom[NDSDisplayID_Touch][i] release]; - if ( ([_texDisplayFetchCustom[NDSDisplayID_Main][i] width] != w) || - ([_texDisplayFetchCustom[NDSDisplayID_Main][i] height] != h) ) - { - [_texDisplayFetchCustom[NDSDisplayID_Main][i] release]; - [_texDisplayFetchCustom[NDSDisplayID_Touch][i] release]; - [_texDisplayPostprocessCustom[NDSDisplayID_Main][i] release]; - [_texDisplayPostprocessCustom[NDSDisplayID_Touch][i] release]; - #ifdef MAC_OS_X_VERSION_10_13 - if (_isSharedBufferTextureSupported) - { - _texDisplayFetchCustom[NDSDisplayID_Main][i] = [_bufDisplayFetchCustom[NDSDisplayID_Main][i] newTextureWithDescriptor:newTexDisplayCustomDesc offset:0 bytesPerRow:_customLineSize]; - _texDisplayFetchCustom[NDSDisplayID_Touch][i] = [_bufDisplayFetchCustom[NDSDisplayID_Touch][i] newTextureWithDescriptor:newTexDisplayCustomDesc offset:0 bytesPerRow:_customLineSize]; - } - else -#endif - { - _texDisplayFetchCustom[NDSDisplayID_Main][i] = [device newTextureWithDescriptor:newTexDisplayCustomDesc]; - _texDisplayFetchCustom[NDSDisplayID_Touch][i] = [device newTextureWithDescriptor:newTexDisplayCustomDesc]; - } - - _texDisplayPostprocessCustom[NDSDisplayID_Main][i] = [device newTextureWithDescriptor:newTexPostprocessCustomDesc]; - _texDisplayPostprocessCustom[NDSDisplayID_Touch][i] = [device newTextureWithDescriptor:newTexPostprocessCustomDesc]; + if (_isSharedBufferTextureSupported) + { + _texDisplayFetchCustom[NDSDisplayID_Main][i] = [_bufDisplayFetchCustom[NDSDisplayID_Main][i] newTextureWithDescriptor:newTexDisplayCustomDesc offset:0 bytesPerRow:_customLineSize]; + _texDisplayFetchCustom[NDSDisplayID_Touch][i] = [_bufDisplayFetchCustom[NDSDisplayID_Touch][i] newTextureWithDescriptor:newTexDisplayCustomDesc offset:0 bytesPerRow:_customLineSize]; } + else +#endif + { + _texDisplayFetchCustom[NDSDisplayID_Main][i] = [device newTextureWithDescriptor:newTexDisplayCustomDesc]; + _texDisplayFetchCustom[NDSDisplayID_Touch][i] = [device newTextureWithDescriptor:newTexDisplayCustomDesc]; + } + + _texDisplayPostprocessCustom[NDSDisplayID_Main][i] = [device newTextureWithDescriptor:newTexPostprocessCustomDesc]; + _texDisplayPostprocessCustom[NDSDisplayID_Touch][i] = [device newTextureWithDescriptor:newTexPostprocessCustomDesc]; } } @@ -675,6 +676,7 @@ } id targetDestination = _texDisplayFetchNative[displayID][bufferIndex]; + const NDSDisplayInfo ¤tDisplayInfo = GPUFetchObject->GetFetchDisplayInfoForBufferIndex(bufferIndex); [targetDestination replaceRegion:MTLRegionMake2D(0, 0, GPU_FRAMEBUFFER_NATIVE_WIDTH, GPU_FRAMEBUFFER_NATIVE_HEIGHT)