Cocoa Port: Fix a rare crash with debug and profiling builds (but not release builds) where Metal display views running CPU-based pixel scalers can make the Metal debugger assert if the pixel scalers are switched very very quickly under low frame rate conditions (less than 30 FPS).

This commit is contained in:
rogerman 2022-05-17 04:10:27 -07:00
parent 1bbb065786
commit 9f6ee8c55a
1 changed files with 24 additions and 8 deletions

View File

@ -1565,10 +1565,10 @@
cb = [self newCommandBuffer];
dispatch_semaphore_wait(((MacMetalDisplayPresenter *)cdp)->GetCPUFilterSemaphore(NDSDisplayID_Main), DISPATCH_TIME_FOREVER);
[cb addScheduledHandler:^(id<MTLCommandBuffer> block) {
dispatch_semaphore_wait(((MacMetalDisplayPresenter *)cdp)->GetCPUFilterSemaphore(NDSDisplayID_Main), DISPATCH_TIME_FOREVER);
vfMain->RunFilter();
dispatch_semaphore_signal(((MacMetalDisplayPresenter *)cdp)->GetCPUFilterSemaphore(NDSDisplayID_Main));
}];
bce = [cb blitCommandEncoder];
@ -1591,6 +1591,10 @@
}
[bce endEncoding];
[cb addCompletedHandler:^(id<MTLCommandBuffer> block) {
dispatch_semaphore_signal(((MacMetalDisplayPresenter *)cdp)->GetCPUFilterSemaphore(NDSDisplayID_Main));
}];
}
}
@ -1632,10 +1636,10 @@
cb = [self newCommandBuffer];
dispatch_semaphore_wait(((MacMetalDisplayPresenter *)cdp)->GetCPUFilterSemaphore(NDSDisplayID_Touch), DISPATCH_TIME_FOREVER);
[cb addScheduledHandler:^(id<MTLCommandBuffer> block) {
dispatch_semaphore_wait(((MacMetalDisplayPresenter *)cdp)->GetCPUFilterSemaphore(NDSDisplayID_Touch), DISPATCH_TIME_FOREVER);
vfTouch->RunFilter();
dispatch_semaphore_signal(((MacMetalDisplayPresenter *)cdp)->GetCPUFilterSemaphore(NDSDisplayID_Touch));
}];
bce = [cb blitCommandEncoder];
@ -1653,6 +1657,10 @@
newTexProcess.touch = _texDisplayPixelScaler[NDSDisplayID_Touch];
[bce endEncoding];
[cb addCompletedHandler:^(id<MTLCommandBuffer> block) {
dispatch_semaphore_signal(((MacMetalDisplayPresenter *)cdp)->GetCPUFilterSemaphore(NDSDisplayID_Touch));
}];
}
}
@ -1680,10 +1688,10 @@
if (shouldProcessDisplayMain && (_texDisplayPixelScaler[NDSDisplayID_Main] != nil))
{
dispatch_semaphore_wait(((MacMetalDisplayPresenter *)cdp)->GetCPUFilterSemaphore(NDSDisplayID_Main), DISPATCH_TIME_FOREVER);
[cb addScheduledHandler:^(id<MTLCommandBuffer> block) {
dispatch_semaphore_wait(((MacMetalDisplayPresenter *)cdp)->GetCPUFilterSemaphore(NDSDisplayID_Main), DISPATCH_TIME_FOREVER);
vfMain->RunFilter();
dispatch_semaphore_signal(((MacMetalDisplayPresenter *)cdp)->GetCPUFilterSemaphore(NDSDisplayID_Main));
}];
id<MTLBlitCommandEncoder> bce = [cb blitCommandEncoder];
@ -1700,6 +1708,10 @@
[bce endEncoding];
[cb addCompletedHandler:^(id<MTLCommandBuffer> block) {
dispatch_semaphore_signal(((MacMetalDisplayPresenter *)cdp)->GetCPUFilterSemaphore(NDSDisplayID_Main));
}];
[cb commit];
cb = [self newCommandBuffer];
@ -1713,10 +1725,10 @@
if (shouldProcessDisplayTouch && (_texDisplayPixelScaler[NDSDisplayID_Touch] != nil))
{
dispatch_semaphore_wait(((MacMetalDisplayPresenter *)cdp)->GetCPUFilterSemaphore(NDSDisplayID_Touch), DISPATCH_TIME_FOREVER);
[cb addScheduledHandler:^(id<MTLCommandBuffer> block) {
dispatch_semaphore_wait(((MacMetalDisplayPresenter *)cdp)->GetCPUFilterSemaphore(NDSDisplayID_Touch), DISPATCH_TIME_FOREVER);
vfTouch->RunFilter();
dispatch_semaphore_signal(((MacMetalDisplayPresenter *)cdp)->GetCPUFilterSemaphore(NDSDisplayID_Touch));
}];
id<MTLBlitCommandEncoder> bce = [cb blitCommandEncoder];
@ -1733,6 +1745,10 @@
[bce endEncoding];
[cb addCompletedHandler:^(id<MTLCommandBuffer> block) {
dispatch_semaphore_signal(((MacMetalDisplayPresenter *)cdp)->GetCPUFilterSemaphore(NDSDisplayID_Touch));
}];
newTexProcess.touch = _texDisplayPixelScaler[NDSDisplayID_Touch];
}