1
0
mirror of https://github.com/TomHarte/CLK.git synced 2026-04-21 02:17:08 +00:00

Eliminate interframe blending if emulator is running in sync with display.

This commit is contained in:
Thomas Harte
2026-02-26 15:58:29 -05:00
parent e3d137f443
commit 92b17173c8
4 changed files with 24 additions and 6 deletions
@@ -823,12 +823,15 @@ struct ActivityObserver: public Activity::Observer {
);
if(canSynchronise) {
const double multiplier = strongSelf->_scanSynchroniser.next_speed_multiplier(
strongSelf->_machine->scan_producer()->get_scan_status()
);
const auto scan_status = strongSelf->_machine->scan_producer()->get_scan_status();
const double multiplier = strongSelf->_scanSynchroniser.next_speed_multiplier(scan_status);
timed_machine->set_speed_multiplier(multiplier);
strongSelf->_view.scanTarget.isFrameSynced =
scan_status.current_position > 0.9f || scan_status.current_position < 0.1f;
} else {
timed_machine->set_speed_multiplier(1.0);
strongSelf->_view.scanTarget.isFrameSynced = NO;
}
// Ask Metal to rasterise all that just happened and present it.
@@ -24,4 +24,6 @@
- (void)willChangeOwner;
@property (nonatomic, assign) BOOL isFrameSynced;
@end
@@ -271,9 +271,22 @@ using BufferingScanTarget = Outputs::Display::BufferingScanTarget;
return reinterpret_cast<Uniforms *>(_uniformsBuffer.contents);
}
- (void)setIsFrameSynced:(BOOL)isFrameSynced {
if(_isFrameSynced == isFrameSynced) {
return;
}
_isFrameSynced = isFrameSynced;
[self setAlpha];
}
- (void)setAlpha {
self.uniforms->outputAlpha = __fp16(BufferingScanTarget::TwoFrameAlpha);
self.uniforms->weightedMixAlpha = __fp16(BufferingScanTarget::InterframeAlpha);
if(_isFrameSynced) {
self.uniforms->outputAlpha = __fp16(1.0f);
self.uniforms->weightedMixAlpha = __fp16(1.0f);
} else {
self.uniforms->outputAlpha = __fp16(BufferingScanTarget::TwoFrameAlpha);
self.uniforms->weightedMixAlpha = __fp16(BufferingScanTarget::InterframeAlpha);
}
}
- (nonnull instancetype)initWithView:(nonnull MTKView *)view {
+1 -1
View File
@@ -600,7 +600,7 @@ struct ScanStatus {
/// 0 (start of visible area field) to 1 (end of field).
///
/// This will increase monotonically, being a measure
/// of the current vertical position — i.e. if current_position = 0.8 then a caller can
/// of the current vertical position — i.e. if `current_position` = 0.8 then a caller can
/// conclude that the top 80% of the visible part of the display has been painted.
float current_position = 0.0f;
/// The total number of hsyncs so far encountered;