metal(ish): Adds platform function for logging cache hits/misses

And adds call from metal.
This way chrome can log overall cache stats.

Bug: chromium:1423136
Change-Id: Iba5b3bd138adf15fe5e999d3dee0002f140edac1
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4484260
Commit-Queue: Scott Violet <sky@chromium.org>
Reviewed-by: Kenneth Russell <kbr@chromium.org>
This commit is contained in:
Scott Violet
2023-04-27 16:13:06 -07:00
committed by Angle LUCI CQ
parent a52c37bafb
commit 059bfe8909
2 changed files with 9 additions and 2 deletions

View File

@@ -243,6 +243,11 @@ constexpr PostWorkerTaskFunc DefaultPostWorkerTask = nullptr;
using PlaceholderCallbackFunc = void (*)(...);
inline void DefaultPlaceholderCallback(...) {}
// The boolean indicates whether the shader was in the cache or not. A value of true indicates it
// was, where as false means it was not and needed to be compiled.
using RecordShaderCacheUseFunc = void (*)(bool);
inline void DefaultRecordShaderCacheUse(bool) {}
// Platform methods are enumerated here once.
#define ANGLE_PLATFORM_OP(OP) \
OP(currentTime, CurrentTime) \
@@ -261,7 +266,8 @@ inline void DefaultPlaceholderCallback(...) {}
OP(placeholder2, PlaceholderCallback) \
OP(cacheProgram, CacheProgram) \
OP(placeholder3, PlaceholderCallback) \
OP(postWorkerTask, PostWorkerTask)
OP(postWorkerTask, PostWorkerTask) \
OP(recordShaderCacheUse, RecordShaderCacheUse)
#define ANGLE_PLATFORM_METHOD_DEF(Name, CapsName) CapsName##Func Name = Default##CapsName;
@@ -287,7 +293,7 @@ constexpr unsigned int g_NumPlatformMethods = (sizeof(PlatformMethods) / sizeof(
// No further uses of platform methods is allowed. EGL extensions should be used instead. While
// methods are being removed, use PlaceholderCallback to keep the layout of PlatformMethods
// constant.
static_assert(g_NumPlatformMethods == 17, "Avoid adding methods to PlatformMethods");
static_assert(g_NumPlatformMethods == 18, "Avoid adding methods to PlatformMethods");
#define ANGLE_PLATFORM_METHOD_STRING(Name) #Name
#define ANGLE_PLATFORM_METHOD_STRING2(Name, CapsName) ANGLE_PLATFORM_METHOD_STRING(Name),

View File

@@ -167,6 +167,7 @@ AutoObjCPtr<id<MTLLibrary>> LibraryCache::getOrCompileShaderLibrary(
entry.library = NewMetalLibraryFromMetallib(context, value.data(), value.size());
}
ANGLE_HISTOGRAM_BOOLEAN("GPU.ANGLE.MetalShaderInBlobCache", entry.library);
ANGLEPlatformCurrent()->recordShaderCacheUse(entry.library);
if (entry.library)
{
return entry.library;