Disabling inlining of counterSet checks

To help debug a suspect crash in these functions.

Also, change some of the counter checks to use more
Objective-C style checks instead of std::find.

Bug: dawn:1102
Change-Id: I693d1f2489116200b2c0608ca60bc3eb8ddb8571
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/71242
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Hao Li <hao.x.li@intel.com>
Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
Austin Eng 2021-11-30 04:16:18 +00:00 committed by Dawn LUCI CQ
parent 2f18b26c1d
commit 6e83e6284e
2 changed files with 18 additions and 11 deletions

View File

@ -64,6 +64,7 @@
# if defined(NDEBUG)
# define DAWN_FORCE_INLINE inline __attribute__((always_inline))
# endif
# define DAWN_NOINLINE __attribute__((noinline))
// MSVC
#elif defined(_MSC_VER)
@ -83,6 +84,7 @@ extern void __cdecl __debugbreak(void);
# if defined(NDEBUG)
# define DAWN_FORCE_INLINE __forceinline
# endif
# define DAWN_NOINLINE __declspec(noinline)
#else
# error "Unsupported compiler"
@ -106,6 +108,9 @@ extern void __cdecl __debugbreak(void);
#if !defined(DAWN_FORCE_INLINE)
# define DAWN_FORCE_INLINE inline
#endif
#if !defined(DAWN_NOINLINE)
# define DAWN_NOINLINE
#endif
#if defined(__clang__)
# define DAWN_FALLTHROUGH [[clang::fallthrough]]

View File

@ -174,7 +174,7 @@ namespace dawn_native { namespace metal {
# error "Unsupported Apple platform."
#endif
bool IsCounterSamplingBoundarySupport(id<MTLDevice> device)
DAWN_NOINLINE bool IsCounterSamplingBoundarySupport(id<MTLDevice> device)
API_AVAILABLE(macos(11.0), ios(14.0)) {
bool isBlitBoundarySupported =
[device supportsCounterSampling:MTLCounterSamplingPointAtBlitBoundary];
@ -187,9 +187,9 @@ namespace dawn_native { namespace metal {
isDrawBoundarySupported;
}
bool IsGPUCounterSupported(id<MTLDevice> device,
MTLCommonCounterSet counterSetName,
std::vector<MTLCommonCounter> counters)
DAWN_NOINLINE bool IsGPUCounterSupported(id<MTLDevice> device,
MTLCommonCounterSet counterSetName,
std::vector<MTLCommonCounter> counterNames)
API_AVAILABLE(macos(10.15), ios(14.0)) {
// MTLDevices counterSets property declares which counter sets it supports. Check
// whether it's available on the device before requesting a counter set.
@ -209,13 +209,15 @@ namespace dawn_native { namespace metal {
// A GPU might support a counter set, but only support a subset of the counters in that
// set, check if the counter set supports all specific counters we need. Return false
// if there is a counter unsupported.
std::vector<NSString*> supportedCounters;
for (id<MTLCounter> counter in counterSet.counters) {
supportedCounters.push_back(counter.name);
}
for (const auto& counterName : counters) {
if (std::find(supportedCounters.begin(), supportedCounters.end(), counterName) ==
supportedCounters.end()) {
for (MTLCommonCounter counterName : counterNames) {
bool found = false;
for (id<MTLCounter> counter in counterSet.counters) {
if ([counter.name caseInsensitiveCompare:counterName] == NSOrderedSame) {
found = true;
break;
}
}
if (!found) {
return false;
}
}