1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-03 11:30:02 +00:00

The penny has finally dropped that I can drive the CPU stuff in a manner completely decoupled from the GPU stuff. For much improved parallelisation.

This commit is contained in:
Thomas Harte 2016-04-06 19:34:34 -04:00
parent 5aa6da221f
commit e885438363
2 changed files with 6 additions and 19 deletions

View File

@ -41,12 +41,10 @@ class MachineDocument: NSDocument, CSOpenGLViewDelegate, CSOpenGLViewResponderDe
let cycleCount = cycleCountLow + cycleCountHigh
if let lastCycleCount = lastCycleCount {
let elapsedTime = cycleCount - lastCycleCount
// if the emulation has fallen too far behind then silently swallow the request;
// if the emulation has fallen too far behind then silently limit the request;
// some actions e.g. the host computer waking after sleep may give us a
// prohibitive backlog
if elapsedTime < intendedCyclesPerSecond / 25 {
runForNumberOfCycles(Int32(elapsedTime))
}
runForNumberOfCycles(max(Int32(elapsedTime), Int32(intendedCyclesPerSecond / 25)))
}
lastCycleCount = cycleCount
}

View File

@ -13,7 +13,6 @@
@implementation CSOpenGLView {
CVDisplayLinkRef _displayLink;
uint32_t _updateIsOngoing;
int _missedFrames;
}
- (void)prepareOpenGL
@ -53,28 +52,18 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
- (void)drawAtTime:(const CVTimeStamp *)now
{
// Always post a -didUpdateToTime:. This is the hook upon which the substantial processing occurs.
[self.delegate openGLView:self didUpdateToTime:*now];
// Draw the display only if a previous draw is not still ongoing.
const uint32_t activityMask = 0x01;
if(!OSAtomicTestAndSet(activityMask, &_updateIsOngoing))
{
_missedFrames = 0;
CVTimeStamp time = *now;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
[self.delegate openGLView:self didUpdateToTime:time];
[self drawViewOnlyIfDirty:YES];
OSAtomicTestAndClear(activityMask, &_updateIsOngoing);
});
}
else
{
_missedFrames++;
if(_missedFrames == 10)
{
_missedFrames = 0;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
[self drawViewOnlyIfDirty:YES];
});
}
}
}
- (void)invalidate