refactor: replace MTLPixelFormatBGR10A2Unorm with MTLPixelFormatBGRA10_XR for older devices

This commit is contained in:
Acaki committed 2025-08-28 21:31:14 +08:00
1 parent e4d6be3bb3
commit 2b40224b2b
2 files changed
+8 -8

No files matched your search

+5 -5
View File
@@ -404,11 +404,11 @@ CFStringRef __currentColorSpace;
} else { } else {
newColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceITUR_2020); newColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceITUR_2020);
} }
newPixelFormat = MTLPixelFormatBGR10A2Unorm; newPixelFormat = MTLPixelFormatBGRA10_XR;
} else { } else {
// SDR 2020, I'm not sure it's possible to stream this though // SDR 2020, I'm not sure it's possible to stream this though
newColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceITUR_2020); newColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceITUR_2020);
newPixelFormat = MTLPixelFormatBGR10A2Unorm; newPixelFormat = MTLPixelFormatBGRA10_XR;
} }
if (isHDR) { if (isHDR) {
paramBuffer.cscParams = (fullRange ? k_CscParams_Bt2020Full_10bit : k_CscParams_Bt2020Lim_10bit); paramBuffer.cscParams = (fullRange ? k_CscParams_Bt2020Full_10bit : k_CscParams_Bt2020Lim_10bit);
@@ -439,11 +439,11 @@ CFStringRef __currentColorSpace;
Log(LOG_I, Log(LOG_I,
@"Frame pixel format %@ - changing MetalLayer's pixel format to %@", @"Frame pixel format %@ - changing MetalLayer's pixel format to %@",
layer.pixelFormat == MTLPixelFormatBGRA8Unorm ? @"MTLPixelFormatBGRA8Unorm" layer.pixelFormat == MTLPixelFormatBGRA8Unorm ? @"MTLPixelFormatBGRA8Unorm"
: layer.pixelFormat == MTLPixelFormatBGR10A2Unorm ? @"MTLPixelFormatBGR10A2Unorm" : layer.pixelFormat == MTLPixelFormatBGRA10_XR ? @"MTLPixelFormatBGRA10_XR"
: [NSString stringWithFormat:@"Unknown: %lu", layer.pixelFormat], : [NSString stringWithFormat:@"Unknown: %lu", layer.pixelFormat],
newPixelFormat == MTLPixelFormatBGRA8Unorm ? @"MTLPixelFormatBGRA8Unorm" newPixelFormat == MTLPixelFormatBGRA8Unorm ? @"MTLPixelFormatBGRA8Unorm"
: newPixelFormat == MTLPixelFormatBGR10A2Unorm ? @"MTLPixelFormatBGR10A2Unorm" : newPixelFormat == MTLPixelFormatBGRA10_XR ? @"MTLPixelFormatBGRA10_XR"
: [NSString stringWithFormat:@"Unknown: %lu", (unsigned long)layer.pixelFormat]); : [NSString stringWithFormat:@"Unknown: %lu", (unsigned long)newPixelFormat]);
} }
#if TARGET_OS_TV #if TARGET_OS_TV
+3 -3
View File
@@ -63,14 +63,14 @@
// Use TARGET_OS_SIMULATOR to detect simulator environment // Use TARGET_OS_SIMULATOR to detect simulator environment
MTLPixelFormat pixelFormat; MTLPixelFormat pixelFormat;
#if TARGET_OS_SIMULATOR #if TARGET_OS_SIMULATOR
// iOS Simulator doesn't support BGR10A2Unorm // iOS Simulator doesn't support BGRA10_XR
pixelFormat = MTLPixelFormatBGRA8Unorm; pixelFormat = MTLPixelFormatBGRA8Unorm;
Log(LOG_W, @"Running on iOS Simulator, using BGRA8Unorm pixel format"); Log(LOG_W, @"Running on iOS Simulator, using BGRA8Unorm pixel format");
#else #else
// On real devices, check if we should enable HDR // On real devices, check if we should enable HDR
if (_enableHdr) { if (_enableHdr) {
pixelFormat = MTLPixelFormatBGR10A2Unorm; pixelFormat = MTLPixelFormatBGRA10_XR;
Log(LOG_I, @"HDR enabled, using BGR10A2Unorm pixel format"); Log(LOG_I, @"HDR enabled, using BGRA10_XR pixel format");
} else { } else {
pixelFormat = MTLPixelFormatBGRA8Unorm; pixelFormat = MTLPixelFormatBGRA8Unorm;
Log(LOG_I, @"HDR disabled, using BGRA8Unorm pixel format"); Log(LOG_I, @"HDR disabled, using BGRA8Unorm pixel format");