Fix the Metal HDR colour space lookup that crashed macOS at start
wgpu-hal's Metal backend read the CoreGraphics colour space names (kCGColorSpaceITUR_2100_PQ and others) as if dlsym returned the string, but it returns the address of the global that holds it. Configuring a PQ swapchain passed that address to CGColorSpaceCreateWithName, which faulted with no Rust panic. Read through the pointer.
This commit is contained in:
+4
-2
@@ -60,8 +60,10 @@ large_enum_variant = "allow"
|
||||
# wgpu-hal 30.0.1 with gfx-rs/wgpu#10124: wgpu 30 creates a Vulkan descriptor
|
||||
# pool with no pool sizes while it creates the device, which Vulkan allows only
|
||||
# since 1.3.215, and Intel's Windows driver for 6th-10th gen iGPUs (HD 520/530,
|
||||
# UHD 620/630) crashes on it with an access violation (#746). Drop this and the
|
||||
# folder once a wgpu release has the fix.
|
||||
# UHD 620/630) crashes on it with an access violation (#746). It also fixes the
|
||||
# Metal backend's lookup of the CoreGraphics HDR colour space names, which handed
|
||||
# CoreGraphics a symbol's address as the string and crashed HDR output on macOS.
|
||||
# Drop this and the folder once a wgpu release has both fixes.
|
||||
[patch.crates-io]
|
||||
wgpu-hal = { path = "third_party/wgpu-hal" }
|
||||
|
||||
|
||||
+5
-2
@@ -228,9 +228,12 @@ static COLOR_SPACES: LazyLock<Result<ColorSpaces, crate::SurfaceError>> = LazyLo
|
||||
lib: &libloading::Library,
|
||||
name: &[u8],
|
||||
) -> Result<&'static CFString, crate::SurfaceError> {
|
||||
let sym = unsafe { lib.get(name) }
|
||||
// The symbols are `CFStringRef` globals, so `dlsym` returns the address of the
|
||||
// global and the symbol's type is a pointer to the reference. Typing it as
|
||||
// the reference itself would hand CoreGraphics that address as the string.
|
||||
let sym = unsafe { lib.get::<*const &'static CFString>(name) }
|
||||
.map_err(|_| crate::SurfaceError::Other("error resolving symbol in CoreGraphics"))?;
|
||||
Ok(*sym)
|
||||
Ok(unsafe { **sym })
|
||||
}
|
||||
let extended_display_p3 = lookup(&lib, b"kCGColorSpaceExtendedDisplayP3\0")?;
|
||||
let itur_bt2100_pq = lookup(&lib, b"kCGColorSpaceITUR_2100_PQ\0")?;
|
||||
|
||||
Reference in New Issue
Block a user