hello, when I do Metal drawing into an MTKView in full screen, there's an issue with frame scheduling, it seems. There is visible stutter, and the Metal HUD shows the frame rate jittering about.
happens in Ventura and Sonoma b2 on my Macbook Pro.
here's a really minimal example. Not even actively drawing anything, just presenting the drawable.
#import "ViewController.h"
#import <Metal/Metal.h>
#import <MetalKit/MetalKit.h>
@interface ViewController() <MTKViewDelegate>
@property (nonatomic, weak) IBOutlet MTKView *mtkView;
@property (nonatomic) id<MTLDevice> device;
@property (nonatomic) id<MTLCommandQueue> commandQueue;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
_device = MTLCreateSystemDefaultDevice();
_mtkView.device = _device;
_mtkView.delegate = self;
_commandQueue = [_device newCommandQueue];
}
- (void)drawInMTKView:(MTKView *)view {
MTLRenderPassDescriptor *viewRPD = view.currentRenderPassDescriptor;
if(viewRPD) {
id<MTLCommandBuffer> commandBuffer = [_commandQueue commandBuffer];
[commandBuffer presentDrawable:view.currentDrawable];
[commandBuffer commit];
}
}
- (void)mtkView:(MTKView *)view drawableSizeWillChange:(CGSize)size {
NSLog(@"%@", NSStringFromSize(size));
}
Looks like there's some collision between display and render timer, or something. what gives? I would like to be able to render stutter free on this very nice machine? how would I go about that?