Skip to content

feat: improved vendor QSGBatchRenderer as WSGBatchRenderer - #1308

Open
LFRon wants to merge 4 commits into
linuxdeepin:masterfrom
LFRon:zccrs/wsg-batch-renderer
Open

feat: improved vendor QSGBatchRenderer as WSGBatchRenderer #1308
LFRon wants to merge 4 commits into
linuxdeepin:masterfrom
LFRon:zccrs/wsg-batch-renderer

Conversation

@LFRon

@LFRon LFRon commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

基于 #1275 的改进版PR

Summary by Sourcery

Replace Qt's batch renderer integration with a Waylib damage-aware renderer and add comprehensive diagnostics, examples, and tests for partial rendering correctness.

New Features:

  • Add runtime damage-debug modes with menu controls and a standalone damage-rendering playground.
  • Provide precise scene damage tracking, visual overlays, and optional surface content-damage propagation for Wayland surfaces.
  • Vendor a Waylib scene-graph batch renderer with damage-aware rendering across Qt RHI and software paths.

Bug Fixes:

  • Preserve recycled render-target contents and redraw only stale or changed regions to prevent visual artifacts and incorrect damage commits.
  • Ensure cursor visibility and software-cursor rendering state update correctly when cursor position or visibility changes.
  • Correct output state copying and support additional DRM buffer formats.

Enhancements:

  • Integrate the vendored renderer and damage tracker with output rendering, nested render targets, transforms, fractional scaling, and hardware cursors.
  • Improve render and damage diagnostics with structured logging and configurable overlay behavior.
  • Add Qt-version compatibility handling and renderer context integration for supported Qt releases.

Build:

  • Include the vendored scene-graph sources and the damage example in the build.
  • Add build configuration for damage-related dependencies and examples.

Documentation:

  • Document the vendored WSGBatchRenderer, damage tracking behavior, debug modes, testing workflow, and Qt upgrade guidance.

Tests:

  • Add tracker, scene-graph, visual-overlay, cursor, popup, transform, surface-damage, and rerender coverage across supported rendering backends.

Chores:

  • Update copyright years and package metadata.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @LFRon, your pull request is larger than the review limit of 150000 diff characters

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: LFRon

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@deepin-ci-robot

Copy link
Copy Markdown

Hi @LFRon. Thanks for your PR.

I'm waiting for a linuxdeepin member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@sourcery-ai

sourcery-ai Bot commented Aug 20, 2026

Copy link
Copy Markdown

Reviewer's Guide

Introduces a vendored WSGBatchRenderer-based scene graph pipeline with damage tracking and debug overlay, wires it into Wayland output rendering, adds QML tooling to control damage modes, and provides automated and visual tests plus a damage playground example while simplifying cursor handling.

Sequence diagram for damage debug mode control and rendering

sequenceDiagram
    actor User
    participant OutputMenuBar as OutputMenuBar_qml
    participant Helper
    participant WRenderHelper
    participant WSGDamageDebug
    participant WBufferRenderer
    participant WOutputRenderWindow as WOutputRenderWindowPrivate

    User->>OutputMenuBar: select damage menu item
    OutputMenuBar->>Helper: setDamageDebugMode(mode)
    Helper->>WRenderHelper: setDamageDebugMode(mode)
    WRenderHelper->>WSGDamageDebug: setModeName(mode)

    loop each frame
        WOutputRenderWindow->>WBufferRenderer: beginRender(...)
        WBufferRenderer->>WSGDamageDebug: mode()
        WBufferRenderer->>WSGDamageDebug: applyToTracker(tracker)
        WBufferRenderer->>WOutputRenderWindow: damageDebugNeedsFrame()
        WOutputRenderWindow->>WBufferRenderer: render(...)
        WBufferRenderer->>WSGDamageDebug: prepareOverlay(renderer, rhi, updates)
        WBufferRenderer->>WSGDamageDebug: renderOverlay(renderer, commandBuffer)
    end
Loading

File-Level Changes

Change Details Files
Add a damage debug control to the debug output menu bar and expose damage debug helpers in seat Helper.
  • Extend OutputMenuBar.qml with a 'Damage' ToolButton and submenu to switch damage modes (Off/Highlight/Log/Rerender) via Helper.setDamageDebugMode
  • Expose Q_INVOKABLE Helper::damageDebugMode and Helper::setDamageDebugMode and forward to WRenderHelper
  • Implement WRenderHelper::damageDebugMode()/setDamageDebugMode() using WSGDamageDebug’s mode helpers
src/core/qml/OutputMenuBar.qml
src/seat/helper.cpp
src/seat/helper.h
waylib/src/server/qtquick/wrenderhelper.cpp
waylib/src/server/qtquick/wrenderhelper.h
Force software cursor rendering via Wayland output and remove forceSoftwareCursor plumbing from QML PrimaryOutput and Helper.
  • Remove forceSoftwareCursor property and OutputLayer settings from PrimaryOutput.qml cursor delegate
  • Change Output::create to always call output->setForceSoftwareCursor(true) and stop passing forceSoftwareCursor into the QML PrimaryOutput
  • Drop TreelandConfig forceSoftwareCursorChanged connection and NVIDIA-specific forceSoftwareCursor override in Helper::createNormalOutput
src/core/qml/PrimaryOutput.qml
src/output/output.cpp
src/seat/helper.cpp
Integrate a vendored WSGBatchRenderer and damage tracking overlay into the server’s scene graph and replace direct QSGBatchRenderer usage.
  • Add WSGBatchRenderer sources and private headers (batch renderer, context, image node, damage tracker, damage debug, visualizer) to waylib server CMake and include paths
  • Switch wbufferrenderer and wrenderbuffernode from Qt’s QSGBatchRenderer to WSGBatchRenderer, updating accessors and renderer creation
  • Implement WBufferRenderer damage ring integration using WSGBatchRenderer::flushRegion, including GPU scissor expansion and software renderer flushing
  • Provide WSGDamageDebug overlay logic with modes none/rerender/highlight/log, including fade-out and overlay rendering via QRhi
  • Implement WSGDamageTracker to track per-node damage in scene coordinates and expose flushRegion/pendingRegion APIs
waylib/src/server/CMakeLists.txt
waylib/src/server/qtquick/private/wbufferrenderer.cpp
waylib/src/server/qtquick/private/wbufferrenderer_p.h
waylib/src/server/qtquick/private/wrenderbuffernode.cpp
waylib/src/server/qtquick/scenegraph/README.md
waylib/src/server/qtquick/scenegraph/wsgbatchrenderer.cpp
waylib/src/server/qtquick/scenegraph/wsgbatchrenderer_p.h
waylib/src/server/qtquick/scenegraph/wsgcontext.cpp
waylib/src/server/qtquick/scenegraph/wsgcontext_p.h
waylib/src/server/qtquick/scenegraph/wsgdamagedebug.cpp
waylib/src/server/qtquick/scenegraph/wsgdamagedebug_p.h
waylib/src/server/qtquick/scenegraph/wsgdamagetracker.cpp
waylib/src/server/qtquick/scenegraph/wsgdamagetracker_p.h
waylib/src/server/qtquick/scenegraph/wsgimagenode.cpp
waylib/src/server/qtquick/scenegraph/wsgimagenode_p.h
waylib/src/server/qtquick/scenegraph/wsgrhivisualizer.cpp
waylib/src/server/qtquick/scenegraph/wsgrhivisualizer_p.h
Ensure WSGContext is installed before any QQuickRenderControl and use it for OutputRenderWindow render control creation.
  • Have WRenderHelper::getGraphicsApi() and WOutputRenderWindow construct QQuickRenderControl via WSGContext::ensureInstalled to install the custom scenegraph context
  • Implement WSGContext to either replace QSGDefaultContext with WSGDefaultContext+WSGBatchRenderer or keep non-default contexts
waylib/src/server/qtquick/woutputrenderwindow.cpp
waylib/src/server/qtquick/wrenderhelper.cpp
waylib/src/server/qtquick/scenegraph/wsgcontext.cpp
waylib/src/server/qtquick/scenegraph/wsgcontext_p.h
Adjust WOutputRenderWindow to render damage overlays even when content is not dirty and to expose per-output helpers.
  • Add OutputHelper::damageDebugNeedsFrame() and use it in WOutputRenderWindowPrivate::doRenderOutputs to force rendering when overlays need another frame
  • Propagate damageDebugNeedsFrame into the skip-render logic so PreserveColorContents overlays are erased correctly
waylib/src/server/qtquick/woutputrenderwindow.cpp
Fix cursor visibility updates to react to both position and visibility changes.
  • Refactor WOutputItemPrivate::updateCursors to share an updateVisible lambda and connect it to both WCursor::positionChanged and visibleChanged
waylib/src/server/qtquick/woutputitem.cpp
Change WSurfaceItemContent to drive damage tracking from wl_surface effective damage and feed it into WSGImageNode.
  • Add surfaceDamageInItem helper mapping wl_surface effective damage through bufferSourceBox to item coordinates using QTransform
  • Update WSurfaceItemContent::updatePaintNode to set WSGImageNode’s damage region before updating the texture/geometry, using mapped surface damage
  • Trigger QQuickItem::update on buffer or damage changes when live mode is enabled
waylib/src/server/qtquick/wsurfaceitem.cpp
Extend WTools to support XBGR8888 drm format for buffer dumping.
  • Map DRM_FORMAT_XBGR8888 to QImage::Format_RGBX8888 in WTools::toImageFormat
waylib/src/server/utils/wtools.cpp
Add automated unit tests for WSGBatchRenderer damage tracking and overlay painting plus a visual compositor test using wlroots.
  • Introduce test_wsgdamage unit test with tracker tests (node-level and QML scene) and overlay painting checks using WSGContext and offscreen QQuickRenderControl
  • Expose detailed scenarios for add/move/remove/rotate/scale/transform, caret blink, idle frames, and overlay fade behavior
  • Add test_wsgdamage_visual which runs a headless wlroots compositor, drives a DamageScene QML, compares dump vs grabToImage including overlay and cursor paths, and tests rerender and frostGlass behavior
waylib/tests/unit_tests/CMakeLists.txt
waylib/tests/unit_tests/test_wsgdamage/CMakeLists.txt
waylib/tests/unit_tests/test_wsgdamage/main.cpp
waylib/tests/unit_tests/test_wsgdamage/scenetest.cpp
waylib/tests/unit_tests/test_wsgdamage_visual/CMakeLists.txt
waylib/tests/unit_tests/test_wsgdamage_visual/TestWindow.qml
waylib/tests/unit_tests/test_wsgdamage_visual/DamageScene.qml
waylib/tests/unit_tests/test_wsgdamage_visual/helper.h
waylib/tests/unit_tests/test_wsgdamage_visual/helper.cpp
waylib/tests/unit_tests/test_wsgdamage_visual/damageclient.h
waylib/tests/unit_tests/test_wsgdamage_visual/damageclient.c
waylib/tests/unit_tests/test_wsgdamage_visual/xdg-shell-client-protocol.c
waylib/tests/unit_tests/test_wsgdamage_visual/xdg-shell-client-protocol.h
waylib/tests/unit_tests/test_wsgdamage_visual/main.cpp
Add a Wayland damage playground example using the new damage debug APIs.
  • Register waylib/examples/damage in CMake and link against Qt Quick, QuickControls2, waylibserver, pixman, and wayland-server
  • Implement a DamagePlayground QML scene that renders a motion-rich scene, allows switching damage modes and toggling software cursor, and shows root transform controls
  • Provide a Helper singleton that sets up a minimal Wayland server, backend, output layout, and cursor and exposes an outputCreator to the QML example
waylib/examples/CMakeLists.txt
waylib/examples/damage/CMakeLists.txt
waylib/examples/damage/Main.qml
waylib/examples/damage/helper.h
waylib/examples/damage/main.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@LFRon
LFRon force-pushed the zccrs/wsg-batch-renderer branch 2 times, most recently from f447e60 to 459d3db Compare August 21, 2026 09:21
@deepin-bot

deepin-bot Bot commented Aug 21, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 0.9.0
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #1312

LFRon added 4 commits August 21, 2026 21:17
Vendor Qt Quick's QSGBatchRenderer and QSGRhiVisualizer as WSGBatchRenderer, install WSGContext before QQuickRenderControl creation, and route RHI rendering paths through the Waylib renderer while preserving the software adaptation.

Log: RHI path uses a vendored Scene Graph batch renderer; damage tracking is added separately.
Track Qt Quick Scene Graph damage, preserve recycled wlroots buffers, and clip GLES/Vulkan redraws with per-region GPU scissors. Add surface damage propagation, runtime damage diagnostics, examples, and unit/visual coverage.

Log: Partial redraw follows Scene Graph damage; WAYLIB_DEBUG_DAMAGE provides highlight, log, and rerender diagnostics.
Keep cursor rendering in the main QML scene instead of repeatedly rebuilding clipped hardware cursor buffers. Propagate damage-only surface commits, keep ancestor damage bounds current after child geometry changes, include output viewport transforms in damage mapping, isolate damage overlays from offscreen render targets, and synchronize cursor visibility updates.

Log: Stabilize GLES QML partial updates and software cursor composition without changing Vulkan behavior.
Carry wlroots buffer reuse damage into the QML Scene Graph repaint region and RHI output scissor, using conservative buffer mapping for fractional device pixel ratios.

Accumulate the actual rendered damage for output commits so stale swapchain contents are reported correctly, while preserving the existing integer-DPR path and isolating native scissors to output passes.

Harden output state copy and finish handling, and add categorized damage diagnostics for buffer, offscreen, scissor, flush, and commit stages.
@LFRon
LFRon force-pushed the zccrs/wsg-batch-renderer branch from 459d3db to 0492d9d Compare August 21, 2026 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants