🐛 Send x86-64 textures' swizzles to the host

The x86-64 AppleParavirtGPUMetal plugin's -[PGSerializer
supportsSwizzledTextures] and -[PGSerializer supportsTextureDescriptor2]
read flags nothing in that plugin sets (the arm64 plugin sets them from the
guest's features), so both answer NO. Every texture then goes to the host in
the first descriptor form, which has no swizzle and 8 bits of usage, and a
texture made with a swizzle reads unswizzled. macOS 26's Clear and Tinted
icon styles draw their glyphs from RG8Unorm luminance-alpha textures
swizzled (R, R, R, G); unswizzled they read (L, A, 0, 1), and the white
glyphs come out yellow.

Version 245, which the kext negotiates, has both features, and the host
reads the second forms at any version. A third UserPatch makes both getters
answer YES, so the plugin sends every texture in the second form, as the
arm64 plugin does. In an x86-64 macOS 26 guest on a reims-vgpu Vulkan host,
an RG8Unorm texture swizzled (R, R, R, G), over an 'LA08' surface or of its
own, now samples (0.2, 0.2, 0.2, 0.4) as Metal does, not (0.2, 0.4, 0, 1),
and Clear and Tinted draw their glyphs white.

A swizzled texture view still reads unswizzled: the plugin serializes every
view without its swizzle, and sending it needs new code, not a getter.
This commit is contained in:
Anees Iqbal committed 2026-10-16 16:14:46 +03:00
1 parent 5405b2d13b
commit b302389a95
3 files changed
+25 -1

No files matched your search

Binary file not shown.
+1 -1
View File
@@ -1,5 +1,5 @@
3ec63afddb95abf8466806bbc82f04ce72700c7f10342fa99159aaae6c08a2b8 Makefile
3d8e398c438d167642e4b049c1fd70e21e7d2a6717139137bebbac7644cc8d4c src/Info.plist
f223b598bfde601dac0adb67e005f821ca78d281e56edfee25df06aab5bb9dfa src/ReimsVgpu.cpp
2c4fc9ce88267a7a5cd655304ba018ecf74280232eebfbf079ec79df870434f8 src/ReimsVgpu.cpp
fe381ec5d40012a54dcbcc171a35ed9680650fb7e65334221a45ee80dff74077 src/UserPatch.cpp
d60b1464920b628f5033a9ddd50de385e3d5e2ccdcb83db114ed621944e94402 src/UserPatch.hpp
+24
View File
@@ -52,9 +52,33 @@ const uint8_t tiledBoundsFind[] {0x4c, 0x89, 0xe7, 0x4c, 0x89, 0xf6, 0x41, 0xff,
const uint8_t tiledBoundsReplace[] {0x4c, 0x89, 0xe7, 0x4c, 0x89, 0xf6, 0x41, 0xff, 0xd5,
0x49, 0x39, 0xc7, 0xeb, 0x4e};
// -[PGSerializer supportsSwizzledTextures] and -[PGSerializer supportsTextureDescriptor2] read
// flags that nothing in the x86-64 plugin sets (the arm64 plugin sets them from the guest's
// features), so both answer NO. Every texture then goes to the host in the first descriptor
// form, which has no swizzle and 8 bits of usage: the host never sees a texture's swizzle, and
// one made with a swizzle reads unswizzled. macOS 26's Clear and Tinted icon styles draw their
// glyphs from RG8Unorm luminance-alpha textures swizzled (R, R, R, G), which then read
// (L, A, 0, 1), so white glyphs come out yellow. Version 245 has both features (110 and 237),
// and the host reads the second forms whatever the version: both getters answer YES. Each is
// `movsbl 0x3x(%rdi), %eax` between `push rbp; mov rbp, rsp` and `pop rbp; ret`, and becomes
// `xor eax, eax; inc eax`. The two getters and the setter between them are one pattern, on a
// page of their own. A texture view's swizzle still goes nowhere: the x86-64 plugin serializes
// every view without one.
const uint8_t textureFormsFind[] {
0x55, 0x48, 0x89, 0xe5, 0x0f, 0xbe, 0x47, 0x32, 0x5d, 0xc3, // supportsSwizzledTextures
0x55, 0x48, 0x89, 0xe5, 0x88, 0x57, 0x32, 0x5d, 0xc3, // setSupportsSwizzledTextures:
0x55, 0x48, 0x89, 0xe5, 0x0f, 0xbe, 0x47, 0x33, 0x5d, 0xc3, // supportsTextureDescriptor2
};
const uint8_t textureFormsReplace[] {
0x55, 0x48, 0x89, 0xe5, 0x31, 0xc0, 0xff, 0xc0, 0x5d, 0xc3,
0x55, 0x48, 0x89, 0xe5, 0x88, 0x57, 0x32, 0x5d, 0xc3,
0x55, 0x48, 0x89, 0xe5, 0x31, 0xc0, 0xff, 0xc0, 0x5d, 0xc3,
};
UserPatch::Patch pluginPatches[] {
{metalPlugin, featureProfileFind, featureProfileReplace, sizeof(featureProfileFind)},
{metalPlugin, tiledBoundsFind, tiledBoundsReplace, sizeof(tiledBoundsFind)},
{metalPlugin, textureFormsFind, textureFormsReplace, sizeof(textureFormsFind)},
};
constexpr size_t RegistersOffset = 0xe28;