【Beta】Enable Vulkan Renderer#1171
Conversation
There was a problem hiding this comment.
Sorry @LFRon, your pull request is larger than the review limit of 150000 diff characters
|
[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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
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 Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
dd513c2 to
3d74e19
Compare
… patched wlroots) Select Qt Quick Vulkan when WLR_RENDERER=vulkan is requested while keeping the default OpenGL/GLES path unchanged. Wire linux-dmabuf to the wlroots renderer and use the patched wlroots Vulkan helpers to render Qt Quick directly into compositor-owned output buffers. Keep client buffers on the wlroots texture path: surfaces still become wlroots-provided QSGTextures for read-only Qt sampling, with per-pass sampling preparation and provider lifetime fixes. Do not add syncobj support or a Treeland-owned client dmabuf cache/fence/direct-import pipeline. Acquire and release wlroots render buffers around Qt RenderControl frames. Disable Vulkan backdrop blits that copy from the output buffer, use a software cursor for the first Vulkan path, and create a separate preserve render target for overlay passes so Vulkan load/store state is fixed before QRhi creates the render pass. With the patched wlroots 0.19 helpers installed, the explicit Vulkan path now displays DDM, dde-shell, DTK and ordinary clients correctly.
Remove the branch-local VulkanSamplingPolicy API and the Raw/ShmUpload classification in WSGTextureProvider. All valid wlroots Vulkan textures are now declared to Qt as shader-read sampled textures, while per-render-pass sampling still uses wlroots' Vulkan helper to prepare and finish the active texture set. Keep the established Vulkan correctness boundaries intact: client buffers remain wlroots-provided QSGTextures, output rendering still uses wlroots render-buffer acquire/release, and primary output renderers are not exposed as texture providers on Vulkan. Also remove high-frequency success debug logs from the Vulkan sampling/cache paths and keep the Vulkan RenderBufferBlitter fallback as an explicit backdrop source policy.
Add a waylib WPresentation wrapper around wlroots wp_presentation and attach it for the Vulkan backend. Track surfaces actually sampled by the Qt Quick render pass, then submit textured-on-output feedback before committing the matching wlroots output buffer. Fix the qwlroots wlroots-0.19 presentation create signature, keep the presentation global lifetime owned by wlroots, and add the centralized waylib.protocols.presentation logging category.
Keep cursor contents on the existing QtQuick/software cursor path, but stop binding cursor item geometry to the live cursor position when it is rendered through OutputLayer. Schedule output frames on cursor motion and compute cursor layer placement from wlroots cursor/output coordinates during layer rendering. This avoids dirtying the main QML scene on cursor movement while preserving the existing cursor content generation and fallback behavior.
Pair Vulkan texture sampling prepare with a matching per-pass finish. Release prepared wlroots textures in LIFO order after Qt records the pass commands, continue best-effort on failures, and fail the render pass if any release cannot be recorded. Defer destruction of Vulkan render resources that may still be referenced by the current QRhi frame. Let WOutput swapchain configuration optionally return the replaced swapchain, retire old Vulkan swapchains in WBufferRenderer, and retire old WRenderHelper BufferData/render target wrappers until several completed frames after rc()->endFrame(). Keep non-Vulkan paths on the existing immediate cleanup behavior. This prevents stale foreign texture ownership and avoids destroying wlroots VkImages while Qt/Vulkan command buffers may still reference them.
When wrapping wlroots Vulkan textures for Qt Quick sampling, create an exact VkImageView using the original format instead of Qt's mapped format. Qt's QSGRhiSupport maps both VK_FORMAT_A2R10G10B10_UNORM_PACK32 and VK_FORMAT_A2B10G10R10_UNORM_PACK32 to a single QRhiTexture::RGB10A2 format, but the Vulkan backend creates an A2B10G10R10 view first. This causes channel order mismatches for A2R10 images (e.g. BGRA buffers from Electron apps like Youdao Note) resulting in color corruption. The fix: - Create a candidate QRhiTexture wrapper for the external VkImage - Replace Qt's default image view with an exact view using the wlroots texture's actual format - Apply correct alpha swizzle based on wlroots texture's has_alpha flag - Reject A2R10G10B10 format that cannot be precisely represented without MUTABLE_FORMAT Also includes: - Add qw_vulkan namespace for type-safe wlroots Vulkan API wrappers - Add WVulkanTrace debug tracing system (enabled via WAYLIB_VULKAN_TRACE=1) - Improve texture provider lifecycle with 4-frame delayed cleanup for Vulkan resources - Add helper methods to qw_client_buffer for texture/source access Fixes color corruption in Electron-based applications (e.g. Youdao Note) running under the Vulkan renderer backend.
Avoid QRhi texture readback for treeland interactive capture. The Vulkan backend wraps wlroots-owned images for rendering/sampling, not for Qt-side transfer readback, which can leave portal screenshot clients waiting forever. Route one-shot capture through qw_buffer/qw_renderer-based WBufferDumper, use the output viewport's last buffer for output/region sources, and report frame failures when image creation or client-buffer copy fails.
Cursor output layers cache their rendered buffer and previously only redrew when geometry or render state changed. With the Vulkan render path, cursor shape/image updates can keep the same geometry, so the compositor could keep committing a stale cursor layer until another output repaint happened. Track WQuickCursor content revisions and mark cursor layers dirty when the cursor content changes. Schedule the owning output conservatively: reuse an already-dirty output when possible, otherwise force an output update so software-composited Vulkan cursors repaint in the same frame. Avoid duplicate dirty notifications when WCursorImage already emitted imageChanged. Also route Vulkan textures created during updatePaintNode() through the current render pass prepare list, so late-created cursor textures are finished together with the rest of the pass instead of being prepared out of band.
Keep QRhi's native output layout in sync with the GENERAL layout recorded by the wlroots release barrier, so reused render buffers get the required transition back to COLOR_ATTACHMENT_OPTIMAL. Treat Vulkan rendering as an all-or-nothing frame transaction. Preserve QRhi begin/end results, reject output commits after acquire, release, submission, or device-loss failures, and terminate the compositor on unrecoverable scene graph errors. Stage sampled texture candidates until preparation succeeds and keep the previous valid texture on failure. Restrict active provider scans to the Vulkan path so GLES2 and software rendering retain their existing behavior. Replace the four-frame Vulkan cleanup delay with exact retirement after successful synchronous offscreen completion and output state handling. Destroy QRhi wrappers before owned wlroots textures and buffer locks, and remove the forced updates previously used to advance cleanup. Also drop unsupported async-offscreen claims from Vulkan tracing. This keeps the existing wlroots texture -> Qt Quick composition -> wlroots output buffer architecture without modifying Qt or wlroots.
Vulkan renderers may expose DMA-BUF import formats only through explicit modifiers. Advertising the legacy wl_drm global unconditionally lets clients select the implicit DMA-BUF path even when the renderer cannot import DRM_FORMAT_MOD_INVALID buffers. Add qwlroots helpers to inspect the renderer's DMA-BUF texture format set and check for DRM_FORMAT_MOD_INVALID. Only create the legacy wl_drm global when the renderer actually supports implicit DMA-BUF import; otherwise keep zwp_linux_dmabuf_v1 as the DMA-BUF path exposed to clients. This preserves the GLES2 compatibility case while avoiding a misleading legacy global for the Vulkan renderer. wl_drm remains owned and destroyed by wlroots as before.
Foreign DMA-BUF textures were synchronized with immediate CPU waits while Qt Quick recorded each frame, serializing producer and compositor work. Start a wlroots texture synchronization batch before Vulkan frame recording, validate that QRhi and wlroots share the same device and queue, and flush the batch before QRhi submits its command buffer. Abort outstanding batches on every frame exit path and retain the immediate-wait fallback when batching is unavailable. Expose the required operations through qwlroots. GLES rendering remains unchanged.
Treeland now builds against the vendored wlroots under 3rdparty/wlroots instead of the previously patched wlroots-upstream tree. The Vulkan render path still needs the wlroots Vulkan helper entry points used by qwlroots and waylib to bridge Qt Quick RHI rendering with wlroots-owned buffers and textures. Port the existing Vulkan helper patch into the vendored wlroots tree: - expose render-buffer VkImage attributes for compositor-owned output buffers - record acquire/release barriers around Qt rendering into wlroots buffers - prepare wlroots Vulkan textures before Qt samples them - flush pending stage uploads for shm/pixel textures - wait DMA-BUF fences and return foreign texture ownership after sampling The change is limited to the Vulkan renderer. GLES2 behavior is unchanged, and this does not enable the linux-drm-syncobj protocol or add a separate Treeland-side client buffer import/cache pipeline. Verification: - cmake --build --preset default - ctest --test-dir build --output-on-failure - nm -D build/wlroots/libwaylib-wlroots.so confirms the new helpers are exported
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.
3d74e19 to
49ea9e2
Compare
|
@zccrs 对了大佬, 这个实现里我顺便把CPU-GPU的等待模型改成了GPU内异步等待模型降低了画面延迟且减少了开销, 目前测试下来没啥问题, 大佬是否能参考一下( |
该PR是 #1032 的更新版, 改动的wlroots由外侧转为treeland内侧的wlroots