Commit Graph
387 Commits
Author SHA1 Message Date
Mike-Solar 2a84027ff9 fix(renderer): macOS TBDR cross-context sync and OFX instance thread-safety
This commit fixes crashes (SIGSEGV in CImg blur_bilateral) and black-frame
corruption artifacts during playback and scrubbing on macOS Apple Silicon.

Root cause analysis:
1. macOS uses Tile-Based Deferred Rendering (TBDR). glFlush() does not
   guarantee tile memory writeback, causing glReadPixels to read incomplete
   tiles (black/corrupted frames) and cache them to disk.
2. Olive uses multiple shared OpenGL contexts (RenderProcessor contexts vs.
   thread-local PluginRenderer context). glFinish() only waits for the
   current context, not the shared context that produced the texture. CPU
   readback in PluginRenderer could read partially-rendered tiles.
3. OlivePluginInstance and OliveClipInstance are not thread-safe. Concurrent
   RenderProcessors could corrupt internal QMap/images_ and params_ via
   setInputTexture/renderAction races.

Fixes:
- OpenGLRenderer::Flush() on macOS now uses glFinish() unconditionally.
- OpenGLRenderer::DownloadFromTexture() and OpenGLRenderer::Blit() insert
  glFinish() before readback/detach to ensure tile writeback completes.
- PluginRenderer::RenderPlugin() now acquires a per-instance mutex to
  serialize concurrent OFX render calls.
- Before CPU readback in PluginRenderer, flush the renderer that originally
  produced each input texture, ensuring cross-context synchronization.
- RenderProcessor::ProcessVideoFootage() flushes after BlitColorManaged.
- Add black-frame detection in ProcessVideoCacheJob() to auto-purge TBDR-
   corrupted cache files.
- Add diagnostic qDebug() logging in viewer, decoder, renderer, and plugin
  paths to aid future debugging.
2026-05-17 14:54:49 +08:00
Mike-Solar 3845c31b37 perf(plugin): eliminate GPU↔CPU ping-pong in OFX render path
This commit removes redundant readbacks and uploads in the OpenFX
  plugin pipeline, achieving zero-copy rendering for GL-capable
  plugins and reducing CPU path overhead.

  PluginRenderer (OpenGL path):
  - Skip ReadbackTextureToFrame + ConvertFrameIfNeeded + Upload after
    plugin render. The destination texture is already valid on GPU.
  - Pass readback_cpu=false to setInputTexture() so input textures are
    provided via loadTexture() (GL texture IDs) instead of being
    downloaded to CPU Image buffers.
  - Remove duplicate ReadbackTextureToFrame block between
    getClipPreferences and the second setInputTexture call.

  OliveClipInstance:
  - Add optional bool readback_cpu=true to setInputTexture(). When
    false, only params and input_textures_ are updated; CPU readback
    and memcpy into Image are skipped.
  - Add pruneImagesCache() to prevent unbounded growth of images_.
    Input clips are limited to 8 cached frames; output clips are
    left untouched.

  Micro-optimizations:
  - Replace per-row memcpy loops with single block memcpy when
    src/dst strides are contiguous (common case in Olive pipeline).
  - Remove dead GL_PREAMBLE macro definition.

  fix(viewer): resolve playback head lag, frozen frames, and pause delay

  Three playback pipeline behavioral issues are fixed:

  1. Prequeue blocked playhead start:
     Reduce kVideoPlaybackInterval from 0.5s to 0.1s. This lowers
     prequeue length from 15–30 frames to 3–6 frames, so the
     playback timer starts much sooner after pressing Play.

  2. Frozen display during playback:
     Relax the hard frame-drop logic in RendererGeneratedFrameForQueue.
     When the queue has fewer than 2 frames, keep late frames instead
     of dropping them, preventing the viewer from freezing entirely
     when rendering cannot keep up with playback speed.

  3. Delayed frame update after pause:
     Cancel in-flight render tickets in PauseInternal() before
     deleting queue watchers. Previously the render thread continued
     processing stale playback frames, blocking the single-frame
     render requested by UpdateTextureFromNode().
2026-05-16 16:45:13 +08:00
Mike-Solar 43ba1c4642 fix ofx plugin bug 2026-05-14 20:26:17 +08:00
Mike-Solar eb79be87a4 add smoke test 2026-04-12 01:26:41 +08:00
Mike-Solar bfb1b2fce4 update copyright back 2026-01-16 21:22:05 +08:00
Mike-Solar e851653fa3 尝试修复粉紫屏未果 2026-01-16 21:11:24 +08:00
Mike-Solar 8ed5660faf solve some bugs 2026-01-05 18:01:13 +08:00
Mike-Solar b8669f6a11 Change project name; 2026-01-05 16:22:26 +08:00
Mike Solar 22fd521951 Merge branch 'refs/heads/dev' into plugin
# Conflicts:
#	.gitmodules
#	CMakeLists.txt
#	ext/core
2025-12-13 21:45:46 +08:00
Mike-Solar 1e33a31b73 Update FFmpeg handling and focus management
Refactor FFmpeg frame processing and improve focus management in panels. Add memory sanitization for debug builds and update KDDockWidgets integration.
2025-11-23 16:35:09 +08:00
Mike Solar 6fdfd03ffd update: update copyright 2025-08-05 17:12:49 +08:00
Mike Solar 74f73ab3be change: change code style to Linux style except indent. 2025-08-03 03:09:40 +08:00
Mike Solar 65ab76edc8 fix: fix exceptions when import video 2025-08-03 02:06:45 +08:00
itsmattkc e9c97407aa viewer: improve visual appearance of scrubbing 2023-03-20 10:41:47 -07:00
itsmattkc 2c2df99963 name every undo command 2023-03-12 00:49:03 -08:00
itsmattkc 019f095ee4 implement history panel 2023-03-11 22:26:21 -08:00
itsmattkc 82454c09c9 viewer: force valid sample type
Fixes #2183
2023-02-27 18:12:13 -08:00
itsmattkc 060c3b0883 viewersizer: use float for all calculations, center manual zoom 2023-02-22 10:41:17 -08:00
itsmattkc 11e4e051c3 move undo files around for better organization 2023-02-20 16:09:22 -08:00
itsmattkc 9745b536f6 nodes: remove graph and merge into project 2023-02-17 14:13:03 -08:00
itsmattkc aa5c2f0541 viewer: remove note, we'll find another way to implement this later 2023-02-08 18:16:05 -08:00
itsmattkc 5da72e4d35 Squashed commit of the following:
commit dec7ca6b96c58decf2c5e5194b665fa2342951b2
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Wed Feb 8 12:32:12 2023 -0800

    moved previewautocacher to rendermanager

commit d289d74d82c3911f3fdaa707abe9994c7363594d
Merge: a8a049a28 70d34c674
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Wed Feb 8 12:15:31 2023 -0800

    Merge branch 'master' into move-cacher-to-renderman

commit a8a049a2857c438cbab0f1ab21e3299fdfbf1fa1
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Wed Feb 8 11:18:25 2023 -0800

    initial work
2023-02-08 12:40:19 -08:00
itsmattkc c1c6893713 various: moved more to core lib 2023-01-19 16:01:31 -08:00
itsmattkc dd9c52ab59 start moving core frameworks to external libraries 2023-01-19 09:51:47 -08:00
itsmattkc 328efac841 viewer: allow viewing export color spaces 2022-11-29 18:32:01 -08:00
itsmattkc f6cbcf8ef9 viewer: respond to wheel events for moving and zooming 2022-11-11 11:06:31 -08:00
itsmattkc 6a394b4e48 viewer: only detect multicam nodes if a viewer is connected
Fixes null ref crash
2022-11-06 21:04:53 -08:00
itsmattkc c357b04e82 viewer: don't attempt to update still image
Fixes crash when playing audio with muxed still
2022-11-05 10:13:04 -07:00
itsmattkc 451de7030b Merge branch 'move-time-to-viewer' 2022-11-01 18:20:22 -07:00
itsmattkc 4d80044d6d upgrade to qt 6 compliance 2022-10-28 19:42:14 -07:00
itsmattkc bdbfb56879 shift timelineview scroll code into base classes
Fixes #2060
2022-10-24 12:01:47 -07:00
itsmattkc f81445527f timebasedwidget: automatically connect scale and scrollbars 2022-10-24 11:18:42 -07:00
itsmattkc d1545745d8 various: moved time from viewer UI to viewer node 2022-10-23 20:56:04 -07:00
itsmattkc 906f802422 viewer: only render sequence waveforms when waveform view is visible 2022-10-04 21:51:05 -07:00
itsmattkc 42ba84bf5f multicam: finished UI implementation 2022-10-03 17:24:09 -07:00
itsmattkc 681e66f34c multicam: ensure node is disconnected when closing 2022-10-02 12:02:50 -07:00
itsmattkc 8a2f2912b4 multicam: allow overrides by selecting multicam nodes in nodeview 2022-10-02 11:23:55 -07:00
itsmattkc 14c7bd6dbc multicam: implemented queuing of future node selections during playback 2022-10-02 10:39:35 -07:00
itsmattkc 14bf515d3f multicam: various improvements 2022-10-01 16:57:46 -07:00
itsmattkc 640e6741f4 multicam: prioritize current clip under playhead 2022-09-29 19:45:38 -07:00
itsmattkc 6e183fe4be multicam: refactor to heavily optimize multicam monitor retrieval 2022-09-29 17:50:09 -07:00
itsmattkc 80a900d105 multicam: show highlight around selected source 2022-09-27 18:22:47 -07:00
itsmattkc 01c3c6050d restored audio functionality 2022-09-27 13:46:42 -07:00
itsmattkc a6b8b7ccbc multicam: finished usable implementation 2022-09-25 20:26:10 -07:00
itsmattkc d017d2c143 viewer: add shortcut to save frame as image 2022-09-16 12:19:47 -07:00
itsmattkc ea8a2fad9d menus: hide sequence cache options 2022-09-13 21:30:54 -07:00
itsmattkc d78e87aa3a viewer: fix scrubbing regression 2022-09-13 20:16:07 -07:00
itsmattkc bc9f8c2e3b Merge branch 'master' into cache-update 2022-08-27 10:54:20 -07:00
itsmattkc 3d92f1f54d viewertexteditor: use hack to forward drag events 2022-08-24 13:25:20 -07:00
itsmattkc b361ba8c51 viewer: ignore scrub events when time changes programmatically 2022-08-21 10:03:07 -07:00