In fact, I get the same behaviour if I modify the LearnMetalCPP texturing example to allow the window to be resizeable, set the preferred framerate to 120 and make the num frames in flight in two places to be 2 rather than 3
void MyAppDelegate::applicationDidFinishLaunching( NS::Notification* pNotification )
{
CGRect frame = (CGRect){ {100.0, 100.0}, {1024.0, 1024.0} };
_pWindow = NS::Window::alloc()->init(
frame,
NS::WindowStyleMaskClosable|NS::WindowStyleMaskTitled | NS::WindowStyleMaskResizable,
NS::BackingStoreBuffered,
false );
_pDevice = MTL::CreateSystemDefaultDevice();
_pMtkView = MTK::View::alloc()->init( frame, _pDevice );
_pMtkView->setColorPixelFormat( MTL::PixelFormat::PixelFormatBGRA8Unorm_sRGB );
_pMtkView->setClearColor( MTL::ClearColor::Make( 0.1, 0.1, 0.1, 1.0 ) );
_pMtkView->setDepthStencilPixelFormat( MTL::PixelFormat::PixelFormatDepth16Unorm );
_pMtkView->setClearDepth( 1.0f );
_pMtkView->setPreferredFramesPerSecond(120);
_pViewDelegate = new MyMTKViewDelegate( _pDevice );
_pMtkView->setDelegate( _pViewDelegate );
_pWindow->setContentView( _pMtkView );
_pWindow->setTitle( NS::String::string( "07 - Texture Mapping", NS::StringEncoding::UTF8StringEncoding ) );
_pWindow->makeKeyAndOrderFront( nullptr );
NS::Application* pApp = reinterpret_cast< NS::Application* >( pNotification->object() );
pApp->activateIgnoringOtherApps( true );
}
static constexpr size_t kMaxFramesInFlight = 2;
const int Renderer::kMaxFramesInFlight = 2;
I get 80Hz on average rather than reliably 120Hz when I switch into fullscreen