Bug 502844 - DMABUF format NV12 not advertised with NVIDIA card
Summary: DMABUF format NV12 not advertised with NVIDIA card
Status: CONFIRMED
Alias: None
Product: kwin
Classification: Plasma
Component: wayland-generic (other bugs)
Version First Reported In: 6.3.3
Platform: Manjaro Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-04-15 16:10 UTC by klozher
Modified: 2025-06-02 15:55 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description klozher 2025-04-15 16:10:08 UTC
by checking info center, there's only one NV12 format with LINEAR modifier, which doesn't work for me.

i checked the EGL api  with GBM platform for DMABUF formats with NVIDIA proprietary driver, some supported formats are shown as follows
```
format: NV12(3231564e), modifier: 3000000004fe010, external_only: true
format: NV12(3231564e), modifier: 3000000004fe011, external_only: true
format: NV12(3231564e), modifier: 3000000004fe012, external_only: true
format: NV12(3231564e), modifier: 3000000004fe013, external_only: true
format: NV12(3231564e), modifier: 3000000004fe014, external_only: true
format: NV12(3231564e), modifier: 3000000004fe015, external_only: true
format: NV12(3231564e), modifier: 0, external_only: true
format: R8  (20203852), modifier: 3000000004fe010, external_only: false
format: R8  (20203852), modifier: 3000000004fe011, external_only: false
format: R8  (20203852), modifier: 3000000004fe012, external_only: false
format: R8  (20203852), modifier: 3000000004fe013, external_only: false
format: R8  (20203852), modifier: 3000000004fe014, external_only: false
format: R8  (20203852), modifier: 3000000004fe015, external_only: false
format: R8  (20203852), modifier: 0, external_only: true
format: RG88(38384752), modifier: 3000000004fe010, external_only: false
format: RG88(38384752), modifier: 3000000004fe011, external_only: false
format: RG88(38384752), modifier: 3000000004fe012, external_only: false
format: RG88(38384752), modifier: 3000000004fe013, external_only: false
format: RG88(38384752), modifier: 3000000004fe014, external_only: false
format: RG88(38384752), modifier: 3000000004fe015, external_only: false
format: RG88(38384752), modifier: 0, external_only: true
 ```

kwin has special treatment for NV12, at src/utils/drm_format_helper.h:35, that trying to convert NV12 to R8 and GR88, while the driver only support R8 and RG88 on my setup.
```
static const QHash<uint32_t, YuvConversion> s_drmConversions = {
    {DRM_FORMAT_NV12, YuvConversion{
                          {YuvFormat{DRM_FORMAT_R8, 1, 1}, YuvFormat{DRM_FORMAT_GR88, 2, 2}},
                      }},
};
```

i believe kwin removes NV12 modifiers at src/platformsupport/scenes/opengl/abstract_egl_backend.cpp:142, by removing all modifiers that not present in R8 and GR88, so it removes all modifiers since GR88 not exists at all.

related [merge request](https://invent.kde.org/plasma/kwin/-/merge_requests/4581)

i compiled kwin with GR88 replaced by RG88, then NV12 shows at info center, though i don't know if it's the proper solution.

i can confirm it works by using mpv with dmabuf-wayland, and a modified nvidia-vaapi-driver.


SOFTWARE/OS VERSIONS
Operating System: Manjaro Linux 
KDE Plasma Version: 6.3.3
KDE Frameworks Version: 6.12.0
Qt Version: 6.8.2
Kernel Version: 6.14.0-1-MANJARO (64-bit)
Graphics Platform: Wayland
Processors: 8 × Intel® Core™ i7-7700HQ CPU @ 2.80GHz
Memory: 23.4 GiB of RAM
Graphics Processor 1: NVIDIA GeForce GTX 1050/PCIe/SSE2
Graphics Processor 2: NVIDIA GeForce GTX 1050/PCIe/SSE2
Comment 1 Zamundaaa 2025-06-02 15:55:24 UTC
> i compiled kwin with GR88 replaced by RG88, then NV12 shows at info center, though i don't know if it's the proper solution.
I'm surprised that works, I would've expected it to switch the color channels...