Guard for [MTLDevice counterSets] being null.

Bug: dawn:1102
Change-Id: I1c8fffba65cba0b04ef72018013f027f0a814f90
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/79361
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Corentin Wallez 2022-02-07 16:12:00 +00:00 committed by Dawn LUCI CQ
parent 839d99cd9a
commit a9a80ef386
1 changed files with 6 additions and 0 deletions

View File

@ -193,6 +193,12 @@ namespace dawn::native::metal {
API_AVAILABLE(macos(10.15), ios(14.0)) { API_AVAILABLE(macos(10.15), ios(14.0)) {
// MTLDevices counterSets property declares which counter sets it supports. Check // MTLDevices counterSets property declares which counter sets it supports. Check
// whether it's available on the device before requesting a counter set. // whether it's available on the device before requesting a counter set.
// On some systems, [device counterSets] is null and not an empty array.
if ([device counterSets] == nil) {
return false;
}
id<MTLCounterSet> counterSet = nil; id<MTLCounterSet> counterSet = nil;
for (id<MTLCounterSet> set in [device counterSets]) { for (id<MTLCounterSet> set in [device counterSets]) {
if ([set.name caseInsensitiveCompare:counterSetName] == NSOrderedSame) { if ([set.name caseInsensitiveCompare:counterSetName] == NSOrderedSame) {