【Vulkan后端增强】Enhance Vulkan Renderer backend - #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. |
3d74e19 to
49ea9e2
Compare
|
@zccrs 对了大佬, 这个实现里我顺便把CPU-GPU的等待模型改成了GPU内异步等待模型降低了画面延迟且减少了开销, 目前测试下来没啥问题, 大佬是否能参考一下( |
c0942c0 to
ec9999c
Compare
ec9999c to
32acd40
Compare
9e19f70 to
ac5f77d
Compare
|
TAG Bot New tag: 0.8.16 |
a973cd3 to
9990d35
Compare
|
TAG Bot New tag: 0.8.17 |
9990d35 to
f47d018
Compare
e5fc4d0 to
cb59c5f
Compare
|
TAG Bot New tag: 0.8.18 |
|
TAG Bot New tag: 0.9.0 |
|
TAG Bot New tag: 0.9.1 |
781fd43 to
cf0e723
Compare
Expose the Vulkan texture and render-buffer primitives Waylib needs to share wlroots-owned images with the Qt Quick QRhi bridge. - Add an image_usage out-parameter to vulkan_import_dmabuf() so callers can learn the actual usage flags a render image was created with. - Store it on struct wlr_vk_render_buffer and return it through waylib_vk_renderer_get_render_buffer_attribs() via a new usage field on struct wlr_vk_image_attribs. - Add waylib_vk_renderer_get_queue() to expose the VkQueue so Qt and wlroots can be verified to share the same queue. No GLES2 behavior is affected; these are additive waylib bridge helpers.
Enable the device capabilities Qt Quick needs to implement the Vulkan blur/backdrop effect (RenderBufferBlitter) with split render passes. - Probe and enable VK_KHR_separate_depth_stencil_layouts on the device and expose it via waylib_vk_renderer_has_separate_depth_stencil_layouts() so Qt can safely split and resume render passes around a depth-stencil pass. - Advertise transfer-source usage for render modifiers and record the max transfer-source extent, so render buffers can be created with VK_IMAGE_USAGE_TRANSFER_SRC_BIT when supported (used to sample the output buffer as the blur source). - Include color-attachment reads in both compatible render-pass external dependencies so preserved color attachments (effect split passes) observe the load operation as well as attachment writes. This fixes color issues in apps such as Youdao Cloud Notes that rely on preserved contents. No GLES2 behavior is affected; these are additive waylib bridge helpers.
Bridge the Qt/QRhi render path to wlroots' Vulkan textures when both share the same VkQueue, so client DMA-BUF/shm textures can be sampled by Qt Quick without per-frame CPU stalls. - waylib_vk_renderer_prepare_texture_for_sampling() / finish_texture_sampling(): record the queue-family-ownership and layout transition for one imported texture on Qt's command buffer. - Texture sync batch (begin/flush/abort_texture_sync_batch): collect the foreign-texture DMA-BUF sync_files for a frame, import them into reusable binary semaphores, and submit a single wait-only bridge command buffer that also records an all-commands memory barrier, so the later Qt submission observes the producer's writes. - Texture barrier batch (begin/flush/abort_texture_barrier_batch): defer the per-texture acquire/release barriers and record a single vkCmdPipelineBarrier per phase instead of one per texture. - Same-frame producer dependency barrier: a render buffer written by the current frame's command buffer (output/layer/cursor buffers) can be re-imported as a sampled texture within that same command buffer (layer-buffer compositing, cross-output canvases, cached render targets). An ownership-transfer acquire barrier cannot order those writes - the source access mask of an acquire operation is ignored and produces no availability - so remember such buffers (frame_render_buffers) and record one extra plain barrier with equal queue families and equal layouts before the sampling. With synchronization2 the equal layout values preserve the image contents, and the barrier's submission-order scopes extend the producer's color-attachment writes to the sampling reads. - waylib_vk_renderer_set_stage_async_enabled() + vulkan_submit_stage_async(): submit SHM staging uploads without blocking the CPU; the texture-sync bridge orders the upload before the consumer samples it. WLR_VK_FORCE_STAGE_BLOCK and WLR_VK_FORCE_SYNC_POLL force the legacy blocking paths. - wlr_vk_texture_get_image_attribs(): report the layout of DMA-BUF textures from the owned state instead of the stale "transitioned" flag, so the reported layout matches the acquire/release GENERAL <-> SHADER_READ_ONLY_OPTIMAL ping-pong; pixel textures keep the permanent post-upload layout. - Add new renderer state (timeline semaphore, semaphore pool, barrier arrays, stage-async flags) with matching create/destroy handling. No GLES2 behavior is affected.
Make Qt Quick (QRhi) render the compositor canvas, layer buffers, and cursor buffers directly into renderer-allocated DMA-BUFs, so every frame is produced in one offscreen QRhi pass and handed to wlroots as a plain wlr_buffer - no intermediate copies, and GLES2/Pixman paths keep their existing behavior. - WRenderHelper: wrap renderer render buffers and wlroots textures into QRhiTexture/QQuickRenderTarget objects with exact-format Vulkan image views (including the opaque alpha swizzle), record acquire/release ownership-transfer barriers around Qt's use of a render buffer, and defer retired render-buffer/swapchain destruction until the frame's GPU work has completed. - WOutputRenderWindow/WBufferRenderer: run outputs and layers inside one synchronous offscreen frame (beginFrameChecked/endFrameChecked); release every render buffer before the frame is submitted and retire replaced swapchains afterwards; expose the last buffer per output viewport for cache sampling. - WOutput::configurePrimarySwapchain()/configureCursorSwapchain(): hand the replaced swapchain out to the caller instead of destroying it immediately, so its buffers can outlive GPU work still referencing them. - WSGTextureProvider/WSurfaceItem: keep a client buffer and its wlroots texture as one ownership tuple, rebuild Qt wrappers when the buffer changes, and defer texture cleanup to render jobs so GPU sampling has finished before destruction. - Harden WOutputHelperPrivate::acquireBuffer(): this legacy path has no Vulkan callers and destroys a replaced swapchain immediately, which can race with GPU work still referencing its buffers; refuse it on the Vulkan renderer instead of introducing an untested retire mechanism. - Add the renderer-backed linux-dmabuf v4 protocol wrapper and the VKTRACE logging helper (WAYLIB_VULKAN_TRACE) covering frames, passes, texture wrapping, sampling dispositions, cleanups, and output present/commit results.
Render the cursor QML item into a cursor-plane scanout buffer and hand it to the KMS cursor plane, instead of always compositing it through the canvas. This keeps the cursor cheap on the Vulkan path, where a canvas repaint per pointer move would cost a full synchronous frame. - SourceOutput.qml detaches the cursor item geometry from the live pointer position (pinned at (0,0)) when an output layer carries the cursor, so moving the pointer no longer dirties the main scene. The on-screen placement is computed from wlroots cursor/output coordinates during layer rendering, and moves go through move_cursor; woutputitem schedules an explicit output frame for the placement update, since the detached geometry no longer dirties the scene itself. - OutputHelper::tryToHardwareCursor(): on Vulkan, re-render the cursor QML item directly into a cursor-format scanout buffer (sampling the already FOREIGN-released layer buffer would yield undefined contents), falling back to software compositing when no suitable cursor size exists or the plane rejects the buffer. - Defer set_cursor() until the frame's command buffer has been submitted and completed (endFrameChecked waits on a fence): the buffer handed to the cursor plane is produced by that command buffer, so committing it earlier could let the plane scan out content the GPU has not rendered yet. move_cursor stays in-frame for pointer latency; the deferred commit is cancelled whenever the frame does not complete or the fallback to the software cursor is taken, and a failed deferred set_cursor keeps the cursor on the software canvas path until its content is re-rendered.
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, which showed up as wrong colors and flicker, while leaving the non-Vulkan wl_drm path unchanged.
Clients select buffer formats that the compositor must import, wrap into Qt, and sample. Two gaps let them end up with formats that render as a blank white screen: - Restrict the advertised dmabuf/shm texture format sets to the subset the Qt wrapper displays exactly: waylib_vk_renderer_restrict_texture_formats() rebuilds dev->dmabuf_texture_formats and dev->shm_texture_formats from a DRM format whitelist, and Helper::init applies it before wl_shm and linux-dmabuf hand the sets to clients. Verified against RADV: 17/40 dmabuf and 17/31 shm formats kept - the dropped ones are the 16-bit packed, 3-channel, and YCbCr families QRhi cannot map. - Wrap packed 10-bit A2R10G10B10 buffers (XWayland depth-30 windows, e.g. Command & Conquer: Mental Omega under Wine) exactly instead of rejecting them: Qt maps both 10-bit channel orders to RGB10A2 and its Vulkan backend derives an A2B10G10R10 initial view, which cannot be created on a non-MUTABLE A2R10 image. Construct the QVkTexture manually (mirroring the attachment-only depth path) with the exact wlroots format and the alpha swizzle instead of createFrom(). XWayland selects buffer formats from the X visual depth and does not consult the advertised sets, so the exact wrapping is required even with the restriction in place; both mechanisms share the same goal - no client-visible format may fall outside what the compositor can display. Verified with Mental Omega: 817 XR30/AR30 wraps with zero discards, the format sets restricted, and no other rendering behavior changed. GLES2 is not touched.
444b196 to
ddee3fb
Compare
该PR是 #1032 的更新版, 改动的wlroots由外侧转为treeland内侧的wlroots
Summary by Sourcery
Enhance the compositor’s Vulkan backend with synchronized Qt/wlroots rendering, robust resource lifetimes, Vulkan effects and cursor handling, capture support, and related Wayland protocol integration.
New Features:
Bug Fixes:
Enhancements:
Build:
Documentation:
Chores: