Skip to content

Allow dcp interchange to scanout interchange compressed#449

Open
oliverbestmann wants to merge 1 commit intoAsahiLinux:asahifrom
oliverbestmann:asahi-dcp-interchange
Open

Allow dcp interchange to scanout interchange compressed#449
oliverbestmann wants to merge 1 commit intoAsahiLinux:asahifrom
oliverbestmann:asahi-dcp-interchange

Conversation

@oliverbestmann
Copy link

Copy link
Member

@Conan-Kudo Conan-Kudo left a comment

Choose a reason for hiding this comment

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

The UAPI change needs to be separately contributed to Linux directly, not this fork.

See this documentation: https://docs.kernel.org/process/submitting-patches.html

*/
#define DRM_FORMAT_MOD_APPLE_GPU_TILED fourcc_mod_code(APPLE, 1)
#define DRM_FORMAT_MOD_APPLE_GPU_TILED_COMPRESSED fourcc_mod_code(APPLE, 2)
#define DRM_FORMAT_MOD_APPLE_INTERCHANGE_COMPRESSED fourcc_mod_code(APPLE, 3)
Copy link
Member

Choose a reason for hiding this comment

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

For experimenting we should move this into the driver with

#ifndef DRM_FORMAT_MOD_APPLE_INTERCHANGE_COMPRESSED
#define DRM_FORMAT_MOD_APPLE_INTERCHANGE_COMPRESSED fourcc_mod_code(APPLE, 3)
#endif

I'm not sure if we want one or more APPLE_INTERCHANGE_COMPRESSED modifiers to handle YCbCr formats which use 32x32 tiles for Y

Copy link
Member

Choose a reason for hiding this comment

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

Is this enough of a difference to warrant a new format modifier? If the tile size only changes for the luma channel of Y'CbCr textures, can we not just handle that by checking is_yuv for the framebuffer format info struct? E.g.

tile_w = fb->format->is_yuv ? 32 : 16

@jannau jannau force-pushed the asahi-wip branch 2 times, most recently from 0031cb6 to 79a307d Compare February 14, 2026 20:09
@waltmck
Copy link

waltmck commented Feb 23, 2026

Thank you for the exciting work!

I tested this with nixos-apple-silicon 6.10 using your flake, on an M2 Macbook Air. Hyprland fails to launch with the following repeated log message:

kernel: apple-dcp 231c00000.dcp: swap failed! status 4
kernel: dcp: plane 0 modifiers: c00000000000003
kernel: apple-dcp 231c00000.dcp: RTKit: syslog message: UPPipe.cpp:3920: IOMFB verify_uc_surface: Planesize insufficient for data plane size 17039360, data size 17301504
kernel: apple-dcp 231c00000.dcp: RTKit: syslog message: UPPipeDCP_H13P.cpp:4554: bool IOMFB::UPPipeDCP_H13P::verify_surfaces(IOMFB::SwapRequest *): Error with the interchange surface
kernel: apple-dcp 231c00000.dcp: RTKit: syslog message: FramebufferDCP.cpp:2175: AppleCLCD: verify_swap failed for swap id: 4285

@oliverbestmann oliverbestmann force-pushed the asahi-dcp-interchange branch 3 times, most recently from 368641c to cdeaea6 Compare February 24, 2026 11:19
@oliverbestmann
Copy link
Author

@waltmck

I tested this with nixos-apple-silicon 6.10 using your flake, on an M2 Macbook Air.

Thank you. Is that with the notch enabled or disabled? And what's your selected display resolution?

It was not working with hyprland on my machine too. I've fixed the issue now. Please try again with the latest update to the flake.

@waltmck
Copy link

waltmck commented Feb 25, 2026

@waltmck

I tested this with nixos-apple-silicon 6.10 using your flake, on an M2 Macbook Air.

Thank you. Is that with the notch enabled or disabled? And what's your selected display resolution?

It was not working with hyprland on my machine too. I've fixed the issue now. Please try again with the latest update to the flake.

With your latest flake I can run Hyprland (and I've been using it to work for the last few hours without issues). Is there an easy way to check with certainty that compressed scanout is actually being used?

@oliverbestmann
Copy link
Author

You can use drm_info to see that modifier c00000000000003 is used for the plane.

@waltmck
Copy link

waltmck commented Feb 25, 2026

You can use drm_info to see that modifier c00000000000003 is used for the plane.

yep, I do see that so it seems to be working.

@jannau
Copy link
Member

jannau commented Mar 1, 2026

the code misses a check to ensure the computed surface size for interchange framebuffers fits into the framebuffer's reported buffer size

@oliverbestmann
Copy link
Author

the code misses a check to ensure the computed surface size for interchange framebuffers fits into the framebuffer's reported buffer size

Whats the expected behavior in that case? assert and kernel panic, or some logging and quietly ignoring the plane?

@jannau
Copy link
Member

jannau commented Mar 1, 2026

the code misses a check to ensure the computed surface size for interchange framebuffers fits into the framebuffer's reported buffer size

Whats the expected behavior in that case? assert and kernel panic, or some logging and quietly ignoring the plane?

check needs to happen in atomic_check where it can fail, possible that there there are drm_format helpers for that using driver specific formats (I would have to check myself)

@chadmed
Copy link
Member

chadmed commented Mar 1, 2026

Tested as mostly-working on G14G, G14S and G13S, however overlays are broken on kwin. May be size/alignment related, as fractional scaling factors and certain cursor images (notably the Breeze I-beam) cause framebuffer creation to fail. This is most obvious with the cursor, but may occur with other oddly-sized overlay framebuffers.

@oliverbestmann
Copy link
Author

Tested as mostly-working on G14G, G14S and G13S, however overlays are broken on kwin. May be size/alignment related, as fractional scaling factors and certain cursor images (notably the Breeze I-beam) cause framebuffer creation to fail. This is most obvious with the cursor, but may occur with other oddly-sized overlay framebuffers.

Thank you. I had no problems running this with kde. I'll try to reproduce the issues as soon as I can.

Signed-off-by: Oliver Bestmann <oliver.bestmann@googlemail.com>
@oliverbestmann oliverbestmann force-pushed the asahi-dcp-interchange branch from cdeaea6 to 0ddf41f Compare March 2, 2026 18:00
@oliverbestmann oliverbestmann changed the base branch from asahi-wip to asahi March 2, 2026 18:03
* The metadata buffer contains 8 bytes per 16x16 compression tile.
* Addressing is fully twiddled, so both width and height are padded to
* powers-of-two.
*/
Copy link
Member

Choose a reason for hiding this comment

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

the comment from the drm_fourcc.h description would be more more appropriate:

/*
 *  ... The metadata section rounds the image dimensions to
 * powers-of-two and contains 8 bytes for each 16x16 compression subtile.
 * Subtiles are interleaved (Morton order).
 */

It's the most up to date description.

* Addressing is fully twiddled, so both width and height are padded to
* powers-of-two.
*/
unsigned w_tl = DIV_ROUND_UP(roundup_pow_of_two(width), 16);
Copy link
Member

Choose a reason for hiding this comment

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

isn't this the same as as roundup_pow_of_two(tw)?

static struct apple_interchange_layout
get_apple_interchange_layout(u32 width, u32 height, u32 bpp)
{
const u32 cacheline = 0x80;
Copy link
Member

Choose a reason for hiding this comment

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

please use a define


u32 tw = DIV_ROUND_UP(width, 16);
u32 th = DIV_ROUND_UP(height, 16);
u32 tsize_B = 16 * 16 * (bpp / 8);
Copy link
Member

Choose a reason for hiding this comment

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

this should use DIV_ROUND_UP(bpp, 8), not that it matters right now.
That would still be for bit-packed formats. Not sure if dcp supports those or if we want to use them, probably not.
Single component formats with 10- or 12-bit per pixel are more common. Possible that drm_format_info_bpp() includes the padding though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants