Skip to content

【Vulkan后端增强】Enhance Vulkan Renderer backend - #1171

Open
LFRon wants to merge 19 commits into
linuxdeepin:masterfrom
LFRon:feat-and-refactor/enable-vulkan-renderer
Open

【Vulkan后端增强】Enhance Vulkan Renderer backend#1171
LFRon wants to merge 19 commits into
linuxdeepin:masterfrom
LFRon:feat-and-refactor/enable-vulkan-renderer

Conversation

@LFRon

@LFRon LFRon commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

该PR是 #1032 的更新版, 改动的wlroots由外侧转为treeland内侧的wlroots

@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.

@LFRon
LFRon force-pushed the feat-and-refactor/enable-vulkan-renderer branch 3 times, most recently from 3d74e19 to 49ea9e2 Compare July 21, 2026 03:34
@LFRon

LFRon commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

@zccrs 对了大佬, 这个实现里我顺便把CPU-GPU的等待模型改成了GPU内异步等待模型降低了画面延迟且减少了开销, 目前测试下来没啥问题, 大佬是否能参考一下(

@LFRon
LFRon force-pushed the feat-and-refactor/enable-vulkan-renderer branch 3 times, most recently from c0942c0 to ec9999c Compare July 22, 2026 13:41
@LFRon LFRon changed the title 【Beta】Enable Vulkan Renderer 【重大更改】Add Vulkan Renderer backend Jul 22, 2026
@LFRon

LFRon commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

@zccrs 大佬, 我做了Blur效果支持, 目前我这边测试没问题:

treeland侧的提交: c3e99a7

wlroots侧的提交:
ec9999c

希望对大佬有参考(

@LFRon
LFRon force-pushed the feat-and-refactor/enable-vulkan-renderer branch from ec9999c to 32acd40 Compare July 22, 2026 13:43
@LFRon
LFRon force-pushed the feat-and-refactor/enable-vulkan-renderer branch 3 times, most recently from 9e19f70 to ac5f77d Compare July 24, 2026 03:26
@deepin-bot

deepin-bot Bot commented Jul 24, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 0.8.16
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #1203

@LFRon
LFRon force-pushed the feat-and-refactor/enable-vulkan-renderer branch 9 times, most recently from a973cd3 to 9990d35 Compare July 30, 2026 07:50
@deepin-bot

deepin-bot Bot commented Jul 31, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 0.8.17
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #1229

@LFRon
LFRon force-pushed the feat-and-refactor/enable-vulkan-renderer branch from 9990d35 to f47d018 Compare July 31, 2026 06:00
zccrs added a commit to zccrs/treeland that referenced this pull request Jul 31, 2026
Reuse wlroots wlr_vk_render_buffer for Qt Quick RHI (same path as tinywl),
with FOREIGN_EXT acquire/release around the Qt pass and QRhi setNativeLayout.
Keep SHM partial updates and flush stage CB before Qt samples.

No parallel dmabuf VkImage import. Aligns with the core approach in linuxdeepin#1171
without pulling the full presentation/blitter rewrite.

通过复用 wlroots 的 wlr_vk_render_buffer(与 tinywl 同路径)修复 Vulkan
scanout:Qt 绘制前后做 FOREIGN_EXT acquire/release,并同步 QRhi layout。
保留 SHM 局部更新与 stage flush。不再平行 import dmabuf。

Log: 修复 Vulkan scanout 与 SHM 上传
Influence: Vulkan 下输出缓冲与 tinywl 一致的所有权转移,避免白/黑屏。
@LFRon
LFRon force-pushed the feat-and-refactor/enable-vulkan-renderer branch 3 times, most recently from 25d784b to 5af243c Compare August 4, 2026 06:36
@LFRon
LFRon force-pushed the feat-and-refactor/enable-vulkan-renderer branch 3 times, most recently from 40c13d9 to e5fc4d0 Compare August 13, 2026 11:51
LFRon added 19 commits August 13, 2026 20:57
Expose the Vulkan texture and render-buffer primitives Waylib needs to share wlroots-owned images with Qt Quick QRhi.

Add image attribute queries, queue-family ownership barriers, imported-texture sampling transitions, and direct wlr_vk_renderer_* entry points. Keep compatibility wrappers for the mainline waylib_* names while leaving GLES2 untouched.
Waiting for every imported DMA-BUF sync_file on the CPU stalls Qt Quick frame recording and serializes producer and compositor work.

Collect foreign-texture fences for the frame, discard fences that are already signaled, import pending fences into reusable binary Vulkan semaphores, and submit a single wait-only batch on the renderer queue. Signal an internal timeline semaphore to retire imported semaphore payloads safely; queue ordering then covers the following Qt submission on the shared queue.

Keep bounded CPU polling as a fallback when implicit-sync interop is unavailable or WLR_VK_FORCE_SYNC_POLL is set. Add batch cleanup, failure handling, and a queue accessor used to validate the shared-queue requirement.
Advertise transfer-source usage for render buffers when the selected DRM modifier supports it, and expose the actual image usage to callers.

Enable and expose separate depth/stencil layouts so Qt Quick can safely split and resume render passes around backdrop copies.
The Qt/QRhi path prepares every sampled foreign texture once per pass via
wlr_vk_renderer_prepare_texture_for_sampling() and releases it via
wlr_vk_renderer_finish_texture_sampling(). Each call recorded its own
vkCmdPipelineBarrier for the queue-family-ownership/layout transition, so a
frame sampling N client textures emitted N separate acquire and N separate
release barrier commands.

Add an optional renderer-side barrier batch. While a batch is active,
prepare/finish accumulate their VkImageMemoryBarrier into a per-phase array
instead of recording it immediately; a single vkCmdPipelineBarrier covering
every accumulated barrier is then recorded once per phase (acquire before the
Qt draw, release after it). This mirrors how the wlroots render pass already
batches its foreign-texture barriers. A call belonging to the opposite phase
still records immediately, so the two phases can never mix in one flush, and
when no batch is active the previous immediate behaviour is kept unchanged.

The batch is driven by the compositor through the new
begin/flush/abort_texture_barrier_batch() entry points; the acquire/release
arrays are initialised and freed with the renderer and aborted on destroy.
Shared-memory (CPU-rendered) client buffers are uploaded through a staging
buffer. The Qt/QRhi path flushed pending uploads in
submit_pending_stage_uploads() via vulkan_submit_stage_wait(), which ends in
vkWaitSemaphoresKHR(): the render thread blocked until the GPU finished every
staging copy before it could go on recording the frame. For a redrawing shm
client this stall happened once per frame.

Add vulkan_submit_stage_async(), which submits the staging command buffer
signalling its timeline point but does not block. The staging buffers the
submission used are moved onto the command buffer's existing stage_buffers
list, so they stay hidden from the span allocator and are returned (with their
allocations reset) by release_command_buffer_resources() once the submission's
timeline point is reached - reusing the same reclamation the render pass already
relies on. The CPU therefore never reuses a span the GPU is still reading, and
a consumer that submits its own command buffer to the same queue afterwards is
guaranteed by queue submission ordering to sample the texture only after the
upload completes.

The async path is opt-in through wlr_vk_renderer_set_stage_async_enabled()
(default off, blocking behaviour preserved) and can be force-disabled with
WLR_VK_FORCE_STAGE_BLOCK=1 for A/B comparison, since it is only safe when the
consumer shares the renderer's VkQueue.
Queue submission order alone does not make foreign DMA-BUF waits or asynchronous staging writes visible to a later Qt/QRhi submission.

Record an all-commands memory barrier in a wlroots bridge command buffer, submit it with the imported semaphore waits, and carry asynchronous staging uploads through the same bridge. Keep CPU-wait fallbacks and command-buffer lifetime tracking intact.
Qt Quick may preserve and read the existing render target contents when effects split rendering into multiple passes.

Include color-attachment reads in both compatible render-pass external dependencies so validation and execution dependencies cover load operations as well as attachment writes.
Bridge wlroots Vulkan textures and renderer-owned output buffers into Qt Quick QRhi render targets while preserving the existing GLES2 and software paths.

Keep imported buffers, Vulkan images, render targets, and frame resources alive through submission, and provide the Waylib plumbing used by render-buffer effects and diagnostics.
Select the Qt Quick Vulkan backend automatically when WLR_RENDERER=vulkan, initialize the matching wl_shm and linux-dmabuf path, and preserve the existing GLES2 renderer setup.

Treat fatal Vulkan scene-graph failures as compositor failures so rendering cannot continue with invalid GPU state.
Wrap wp_presentation with display-owned Waylib lifetime management and attach it to the Vulkan startup path.

Report surfaces as textured only for their frame-pacing output and submit feedback immediately before a successful output commit.
Batch foreign-texture synchronization waits into the shared Vulkan queue before Qt Quick submits each frame.

Validate that Qt and wlroots use the same device, queue family, and queue once; retain the immediate CPU-wait fallback when batching is unavailable, and abort incomplete batches on every failure path.
Read screenshot and image-copy data from renderer-owned wlroots buffers instead of relying on an OpenGL framebuffer.

Track capture frame ownership and damage explicitly so the Vulkan path releases buffers safely while leaving the existing GLES2 capture path unchanged.
Advertise the legacy wl_drm global for Vulkan only when the renderer exposes an implicit-modifier DMA-BUF texture format.

This prevents legacy-buffer clients such as Youdao Note from selecting DRM formats the Vulkan renderer cannot import, while leaving the non-Vulkan wl_drm path unchanged.
Render Vulkan cursor layers directly into scanout buffers, preserve software fallback when preparation fails, and scale cursor content and hotspots consistently for fractional outputs.

Detach Vulkan cursor motion from the main QML scene and schedule cursor-layer frames explicitly. All behavior changes are Vulkan-gated; the GLES2 cursor path remains unchanged.
Record each render pass's foreign-texture acquire and release transitions as one Vulkan pipeline barrier per phase.

Flush deferred acquires before rollback on preparation failures and abort incomplete batches on every exit path. Non-Vulkan rendering remains unchanged.
Enable wlroots GPU-side staging uploads only after the imported-texture synchronization path verifies that Qt and wlroots share the same Vulkan queue.

Queue ordering then replaces per-frame semaphore waits for CPU-backed client buffers; failed validation and WLR_VK_FORCE_STAGE_BLOCK retain the blocking fallback. GLES2 is unaffected.
Give Waylib-managed Vulkan render passes the same conservative external attachment dependency for a given attachment topology, independent of load and store flags.

This keeps reused Qt pipelines compatible and makes preserved color and depth contents depend on preceding writes and layout transitions. Non-Vulkan QRhi render-pass creation stays unchanged.
Use the Vulkan RenderBufferBlitter as the backdrop source for MultiEffect and GlassEffect, including rounded clipping and the existing blur and glass configuration.

Keep the implementation behind the Vulkan QML file selector so the GLES2 blur component and its lifecycle are unchanged.
Drop WITH_SUBMODULE_QWLROOTS from the English and Chinese build instructions now that mainline Waylib consumes wlroots directly.
@LFRon
LFRon force-pushed the feat-and-refactor/enable-vulkan-renderer branch from e5fc4d0 to cb59c5f Compare August 13, 2026 12:57
@LFRon LFRon changed the title 【重大更改】Add Vulkan Renderer backend 【增强的Vulkan后端】Enhance Vulkan Renderer backend Aug 14, 2026
@LFRon LFRon changed the title 【增强的Vulkan后端】Enhance Vulkan Renderer backend 【Vulkan后端增强】Enhance Vulkan Renderer backend Aug 14, 2026
@deepin-bot

deepin-bot Bot commented Aug 14, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 0.8.18
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #1286

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