Skip to content

Improved rendering - #173

Open
kunitoki wants to merge 12 commits into
mainfrom
dev/rendering_thread
Open

Improved rendering#173
kunitoki wants to merge 12 commits into
mainfrom
dev/rendering_thread

Conversation

@kunitoki

@kunitoki kunitoki commented Aug 17, 2026

Copy link
Copy Markdown
Owner

This pull request introduces a major architectural improvement to the rendering model for SDLComponentNative, moving each window's rendering to its own dedicated render thread. This change decouples rendering from the message thread, improving responsiveness and allowing multiple windows to render in parallel without serializing on vsync waits. The update also introduces a clear separation between native UI attachment (which must happen on the message thread) and GPU resource management (which now happens on the render thread), and makes several thread-safety and performance improvements throughout the rendering pipeline.

The most important changes are:

Render Thread Architecture:

  • SDLComponentNative now renders each window on its own dedicated render thread. The component-tree walk and animation/logic run under a MessageManagerLock, while GL command submission and buffer swap happen unlocked, allowing multiple windows to render in parallel and keeping the message thread responsive. [1] [2]

Native UI and GPU Resource Management Separation:

  • Added a new attachToWindow method to GraphicsContext (and implemented it for Metal) to attach rendering surfaces to native UI on the message thread. GPU resource resizing is now handled separately on the render thread via onSizeChanged, ensuring thread safety and correct resource management. [1] [2] [3] [4]

Render Loop and Synchronization Improvements:

  • Refactored the render loop in SDLComponentNative to use a dedicated thread (or timer on Emscripten), with explicit signaling for repaint requests and fine-grained sleep for frame timing. The rendering logic is now encapsulated in a new renderFrame method, and thread-safe atomic access is used for render flags. [1] [2] [3] [4] [5]

Repaint and Resource Handling Fixes:

  • Improved repaint area management with proper locking, and ensured that resizing and resource attachment are handled on the correct threads. Also, fixed the logic for getting content size and buffer swapping for OpenGL contexts. [1] [2] [3] [4] [5] [6] [7] [8] [9]

Platform and Build Configuration Updates:

  • Updated the logic for renderDrivenByTimer to ensure correct behavior on Emscripten and other platforms, and removed unused AsyncUpdater inheritance. [1] [2]

@codecov

codecov Bot commented Aug 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 52.21239% with 54 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.97%. Comparing base (8bb6b67) to head (60fd5cc).

Files with missing lines Patch % Lines
modules/yup_gui/component/yup_Component.cpp 42.42% 38 Missing ⚠️
modules/yup_rhi/rhi/yup_GpuBuffer.cpp 40.00% 12 Missing ⚠️
modules/yup_core/threads/yup_WaitableTimer.cpp 93.33% 1 Missing ⚠️
modules/yup_gui/component/yup_ComponentNative.h 0.00% 1 Missing ⚠️
modules/yup_rhi/context/yup_GpuDevice.h 50.00% 1 Missing ⚠️
modules/yup_rhi/rhi/yup_GpuComputePipeline.cpp 85.71% 1 Missing ⚠️

❌ Your patch check has failed because the patch coverage (52.21%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #173      +/-   ##
==========================================
- Coverage   80.98%   80.97%   -0.01%     
==========================================
  Files         786      787       +1     
  Lines       82265    82333      +68     
==========================================
+ Hits        66620    66670      +50     
- Misses      15645    15663      +18     
Files with missing lines Coverage Δ
modules/yup_core/yup_core.cpp 100.00% <ø> (ø)
modules/yup_graphics/context/yup_GraphicsContext.h 75.00% <100.00%> (+8.33%) ⬆️
modules/yup_rhi/context/yup_GpuDevice.cpp 85.56% <100.00%> (ø)
modules/yup_rhi/rhi/yup_GpuBuffer.h 50.00% <ø> (ø)
modules/yup_core/threads/yup_WaitableTimer.cpp 93.33% <93.33%> (ø)
modules/yup_gui/component/yup_ComponentNative.h 33.33% <0.00%> (-16.67%) ⬇️
modules/yup_rhi/context/yup_GpuDevice.h 50.00% <50.00%> (-7.15%) ⬇️
modules/yup_rhi/rhi/yup_GpuComputePipeline.cpp 44.18% <85.71%> (+2.93%) ⬆️
modules/yup_rhi/rhi/yup_GpuBuffer.cpp 68.88% <40.00%> (-17.32%) ⬇️
modules/yup_gui/component/yup_Component.cpp 76.02% <42.42%> (-0.76%) ⬇️

... and 6 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8bb6b67...60fd5cc. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant