JBR-5580 J2DBench: ~15% drop performance  because of non optimal synchronization in metal (MBP 16'' x64)

Replaced NSMutableArray with NSMutableSet, removed unnecessary __block modifier.

(cherry picked from commit fd940831a2)
This commit is contained in:
Alexey Ushakov
2023-05-09 19:04:40 +02:00
committed by jbrbot
parent fa30807ca9
commit 819132723d
2 changed files with 4 additions and 5 deletions

View File

@@ -185,7 +185,7 @@ extern void initSamplers(id<MTLDevice> device);
_tempTransform = [[MTLTransform alloc] init];
if (isDisplaySyncEnabled()) {
_layers = [[NSMutableArray alloc] init];
_layers = [[NSMutableSet alloc] init];
_displayLinkCount = 0;
CVDisplayLinkCreateWithCGDisplay(displayID, &_displayLink);
CVDisplayLinkSetOutputCallback(_displayLink, &mtlDisplayLinkCallback, (__bridge void *) self);

View File

@@ -143,11 +143,10 @@ BOOL isDisplaySyncEnabled() {
}
[commandBuf presentDrawable:mtlDrawable];
__block MTLLayer* layer = self;
[layer retain];
[self retain];
[commandBuf addCompletedHandler:^(id <MTLCommandBuffer> commandBuf) {
layer.nextDrawableCount--;
[layer release];
self.nextDrawableCount--;
[self release];
}];
[commandBuf commit];