mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-24 08:21:25 +01:00
[metal] report an error instead of panicking on texture view creation (#10145)
This commit is contained in:
1 parent
107e2827f7
commit
252b1dc3dd
2 files changed
+42
-6
No files matched your search
@@ -218,6 +218,7 @@ By @sagudev in [#10109](https://github.com/gfx-rs/wgpu/pull/10109).
|
||||
|
||||
- Fix a crash/hang when configuring a surface with the `Bt2100Pq`, `Bt2100Hlg`, or `ExtendedDisplayP3` color space: the dynamically resolved CoreGraphics color-space constants were read with one level of indirection missing. By @stuartparmenter in [#10175](https://github.com/gfx-rs/wgpu/pull/10175).
|
||||
- Fix bind group resources for the task, mesh, fragment, and compute shader stages being bound from the wrong offsets whenever a bind group contained resources visible to the task or mesh stages, which could bind the wrong buffer, texture, or sampler to a shader slot. By @teoxoy in [#10043](https://github.com/gfx-rs/wgpu/issues/10043).
|
||||
- Report an error instead of panicking when Metal declines to create a texture view, which can occur for some views of textures with `TRANSIENT_ATTACHMENT` usage. By @matthargett in [#10145](https://github.com/gfx-rs/wgpu/pull/10145).
|
||||
- BREAKING: Advertise `CompositeAlphaMode::PreMultiplied` instead of `PostMultiplied`, matching the premultiplied alpha compositing that Core Animation actually performs for a non-opaque `CAMetalLayer`. By @nicoburns in [#9922](https://github.com/gfx-rs/wgpu/pull/9922).
|
||||
- If you previously hard-coded `PostMultiplied` to get a transparent macOS window, you will start receiving `UnsupportedAlphaMode` validation errors for this. Those affected should migrate to `PreMultiplied` instead.
|
||||
- Fix a crash when creating a declared alternate sRGB view of a render-attachment-only surface with Metal API Validation enabled. By @jinleili in [#10280](https://github.com/gfx-rs/wgpu/pull/10280).
|
||||
|
||||
@@ -692,7 +692,7 @@ impl crate::Device for super::Device {
|
||||
.array_layer_count
|
||||
.unwrap_or(texture.array_layers - desc.range.base_array_layer);
|
||||
|
||||
autoreleasepool(|_| {
|
||||
autoreleasepool(|_| -> Result<_, crate::DeviceError> {
|
||||
let level_range = NSRange {
|
||||
location: desc.range.base_mip_level as _,
|
||||
length: mip_level_count as _,
|
||||
@@ -701,7 +701,7 @@ impl crate::Device for super::Device {
|
||||
location: desc.range.base_array_layer as _,
|
||||
length: array_layer_count as _,
|
||||
};
|
||||
let raw = unsafe {
|
||||
let raw_result = unsafe {
|
||||
if let Some(swizzle) = swizzle {
|
||||
texture
|
||||
.raw
|
||||
@@ -712,7 +712,6 @@ impl crate::Device for super::Device {
|
||||
slice_range,
|
||||
swizzle,
|
||||
)
|
||||
.unwrap()
|
||||
} else {
|
||||
texture
|
||||
.raw
|
||||
@@ -722,14 +721,50 @@ impl crate::Device for super::Device {
|
||||
level_range,
|
||||
slice_range,
|
||||
)
|
||||
.unwrap()
|
||||
}
|
||||
};
|
||||
let raw = raw_result.ok_or_else(|| {
|
||||
// Metal refuses some views of memoryless textures. Ideally such cases
|
||||
// would be rejected by `wpgu-core` validation, but at least until that
|
||||
// is implemented, we log a verbose error message.
|
||||
// Related: <https://github.com/gpuweb/gpuweb/issues/6876>.
|
||||
let storage_mode = texture.raw.storageMode();
|
||||
let memoryless = if storage_mode == MTLStorageMode::Memoryless {
|
||||
"This may be because the texture is memoryless (has TRANSIENT_ATTACHMENT usage). "
|
||||
} else {
|
||||
""
|
||||
};
|
||||
log::error!(
|
||||
"Error creating Metal texture view. {memoryless}\
|
||||
Texture: {:?}, {:?}, {}x{}x{}, {} mip level(s), \
|
||||
{} array layer(s), Metal usage {:?}, storage mode {:?}. \
|
||||
Requested view: {:?}. \
|
||||
Metal arguments: pixel format {:?}, texture type {:?}, \
|
||||
levels {}..{}, slices {}..{}.",
|
||||
texture.format,
|
||||
texture.raw_type,
|
||||
texture.copy_size.width,
|
||||
texture.copy_size.height,
|
||||
texture.copy_size.depth,
|
||||
texture.mip_levels,
|
||||
texture.array_layers,
|
||||
texture.raw.usage(),
|
||||
storage_mode,
|
||||
desc,
|
||||
raw_format,
|
||||
raw_type,
|
||||
level_range.location,
|
||||
level_range.location + level_range.length,
|
||||
slice_range.location,
|
||||
slice_range.location + slice_range.length,
|
||||
);
|
||||
crate::DeviceError::Unexpected
|
||||
})?;
|
||||
if let Some(label) = desc.label {
|
||||
raw.setLabel(Some(&NSString::from_str(label)));
|
||||
}
|
||||
raw
|
||||
})
|
||||
Ok(raw)
|
||||
})?
|
||||
};
|
||||
|
||||
self.counters.texture_views.add(1);
|
||||
|
||||
Reference in new issue
Block a user