🐛 Take an Apple GPU's texture rules on an arm64 guest's device

14.6.1's WindowServer ended at the bundle's descriptor validation: it makes a
texture of a two-plane format (550), which the x86 Macs' rules call lacking,
and the bundle chose those rules because the device answers no Apple family,
as the host lets it answer none. An arm64 Mac's GPU is always Apple's, so in
an arm64 guest the device now takes an Apple GPU's rules (the M3 Max's),
whose creators answer nil for a two-plane format. The choice is the device's
own (RgfxAppleRulesDevice), built for arm64 alone; an x86-64 build is the
same code as before. rgfxAppleGPU is the bundle's one place that chooses a
behaviour by Apple-family answers; RgfxCaps's Mac2 asks are feature answers.
This commit is contained in:
Anees Iqbal committed 2026-11-09 11:02:31 -08:00
1 parent b3dedd3c90
commit 2a7078b2bd
4 files changed
+64 -2

No files matched your search

+13
View File
@@ -520,6 +520,11 @@ bool rgfxKextQueueOpener(void *context, const RgfxQueueCreate &q)
- (uint64_t)rgfxListenQueue;
@end
#if defined(__arm64__)
@interface RgfxMetalDevice () <RgfxAppleRulesDevice>
@end
#endif
namespace {
void rgfxDeviceDoorbell(void *context, uint32_t ring_id)
{
@@ -1399,6 +1404,14 @@ RGFX_LOG_UNRECOGNIZED
return _caps.supportsFamily(static_cast<int64_t>(gpuFamily));
}
#if defined(__arm64__)
// In an arm64 guest, Metal's texture rules are an Apple GPU's (RgfxAppleRulesDevice).
- (BOOL)rgfxAppleRules
{
return YES;
}
#endif
- (BOOL)supportsFeatureSet:(MTLFeatureSet)featureSet
{
return _caps.supportsFeatureSet(static_cast<uint64_t>(featureSet));
+15 -2
View File
@@ -164,8 +164,10 @@ NS_ASSUME_NONNULL_BEGIN
/// multisample formats and the storage it takes, and its compressed formats (RgfxTexture.mm).
void rgfxEndAtInvalidTextureDescriptor(MTLTextureDescriptor *descriptor, id<MTLDevice> device = nil);
/// Whether `device` answers as an Apple GPU, an Apple family (Apple7, every Apple-silicon Mac's),
/// as the device answers in an arm64 guest, where Metal's rules are an Apple GPU's: false for nil.
/// Whether Metal's rules for `device` are an Apple GPU's: where `device` answers an Apple family
/// (Apple7, every Apple-silicon Mac's), and in an arm64 guest where it is the guest's device
/// (RgfxAppleRulesDevice), whatever families it answers, as every GPU an arm64 Mac has is Apple's.
/// False for nil.
bool rgfxAppleGPU(id<MTLDevice> _Nullable device);
/// Whether `format` is a block-compressed format the device has: BC1 to BC7, and on an Apple GPU
@@ -232,6 +234,17 @@ void rgfxEndAtViewMetalEnds(MTLPixelFormat from, MTLTextureType fromType, uint64
- (NSUInteger)rgfxLinearTextureAlignmentForPixelFormat:(MTLPixelFormat)format;
@end
#if defined(__arm64__)
/// The device of an arm64 guest (RgfxMetalDevice), whose texture rules are an Apple GPU's
/// (rgfxAppleGPU) though it answers no Apple family while the host lets it answer none
/// (device_info.rs, cap_apple_families): an arm64 Mac's GPU is always Apple's, and the guest's
/// frameworks make what an Apple GPU takes, such as a texture of a two-plane format, which the
/// x86 Macs' rules end the process at.
@protocol RgfxAppleRulesDevice <NSObject>
- (BOOL)rgfxAppleRules;
@end
#endif
NS_ASSUME_NONNULL_END
#endif // RGFX_TEXTURE_H_
+5
View File
@@ -701,6 +701,11 @@ bool rgfxAppleCompressedFormat(uint64_t f)
bool rgfxAppleGPU(id<MTLDevice> device)
{
#if defined(__arm64__)
if ([device respondsToSelector:@selector(rgfxAppleRules)] &&
[(id<RgfxAppleRulesDevice>)device rgfxAppleRules])
return true;
#endif
return device != nil && [device respondsToSelector:@selector(supportsFamily:)] &&
[device supportsFamily:MTLGPUFamilyApple7];
}
+31
View File
@@ -185,6 +185,24 @@ void syncAsCommitted(std::initializer_list<id> textures);
}
@end
// A device as an arm64 guest's answers: no Apple family, as the host lets it answer none, and an
// Apple GPU's texture rules (RgfxAppleRulesDevice, on arm64 builds).
@interface RgfxGuestRulesDevice : NSObject
- (BOOL)supportsFamily:(MTLGPUFamily)family;
- (BOOL)rgfxAppleRules;
@end
@implementation RgfxGuestRulesDevice
- (BOOL)supportsFamily:(MTLGPUFamily)family
{
(void)family;
return NO;
}
- (BOOL)rgfxAppleRules
{
return YES;
}
@end
namespace {
// A ring + id space + serialiser over a plain-buffer region, the fixture every
@@ -2699,6 +2717,19 @@ void test_texture_descriptor_validation_as_an_apple_gpu()
id<MTLDevice> apple = (id<MTLDevice>)[RgfxAppleFamilyDevice new];
CHECK(rgfxAppleGPU(apple) && !rgfxAppleGPU(nil) &&
!rgfxAppleGPU((id<MTLDevice>)[NSObject new]));
// An arm64 guest's device takes an Apple GPU's rules though it answers no Apple family, so
// its creators answer nil for a two-plane format (550, which 14.6.1's WindowServer makes)
// where the x86 Macs' rules end the process; an x86-64 build keeps the x86 Macs' rules.
id<MTLDevice> guest = (id<MTLDevice>)[RgfxGuestRulesDevice new];
MTLTextureDescriptor *twoPlane = [MTLTextureDescriptor new];
twoPlane.pixelFormat = (MTLPixelFormat)550;
twoPlane.width = 64;
twoPlane.height = 64;
#if defined(__arm64__)
CHECK(rgfxAppleGPU(guest) && rgfxDeviceMakesNoTextureOf(twoPlane, guest));
#else
CHECK(!rgfxAppleGPU(guest) && !rgfxDeviceMakesNoTextureOf(twoPlane, guest));
#endif
for (const DescriptorCase &c : kDescriptorCases) {
if (const char *words = appleWords(c)) {
checkDies(("apple-texdesc-" + std::string(c.name)).c_str(), words);