diff --git a/src/libANGLE/renderer/d3d/HLSLCompiler.cpp b/src/libANGLE/renderer/d3d/HLSLCompiler.cpp index 2a351ab1f..115786f9a 100644 --- a/src/libANGLE/renderer/d3d/HLSLCompiler.cpp +++ b/src/libANGLE/renderer/d3d/HLSLCompiler.cpp @@ -215,6 +215,8 @@ angle::Result HLSLCompiler::compileToBinary(d3d::Context *context, writeFile(sourcePath.c_str(), sourceText.c_str(), sourceText.size()); #endif + auto *platform = ANGLEPlatformCurrent(); + const D3D_SHADER_MACRO *macros = overrideMacros ? overrideMacros : nullptr; for (size_t i = 0; i < configs.size(); ++i) @@ -223,6 +225,8 @@ angle::Result HLSLCompiler::compileToBinary(d3d::Context *context, ID3DBlob *binary = nullptr; HRESULT result = S_OK; + double startTime = platform->currentTime(platform); + { ANGLE_TRACE_EVENT1("gpu.angle", "D3DCompile", "source", hlsl); result = mD3DCompileFunc(hlsl.c_str(), hlsl.length(), gl::g_fakepath, macros, nullptr, @@ -230,6 +234,8 @@ angle::Result HLSLCompiler::compileToBinary(d3d::Context *context, &errorMessage); } + double compileTime = platform->currentTime(platform) - startTime; + if (errorMessage) { std::string message = static_cast(errorMessage->GetBufferPointer()); @@ -285,6 +291,12 @@ angle::Result HLSLCompiler::compileToBinary(d3d::Context *context, if (SUCCEEDED(result)) { + int compileUs = static_cast(compileTime * 1000'000.0); + ANGLE_HISTOGRAM_COUNTS("GPU.ANGLE.D3DShaderCompilationTimeUs", compileUs); + + ANGLE_HISTOGRAM_MEMORY_KB("GPU.ANGLE.D3DShaderBlobSizeKB", + static_cast(binary->GetBufferSize() / 1024)); + *outCompiledBlob = binary; (*outDebugInfo) += diff --git a/src/libANGLE/renderer/metal/mtl_utils.mm b/src/libANGLE/renderer/metal/mtl_utils.mm index d14c2cab7..2e0c6fe3b 100644 --- a/src/libANGLE/renderer/metal/mtl_utils.mm +++ b/src/libANGLE/renderer/metal/mtl_utils.mm @@ -17,11 +17,13 @@ #include "common/string_utils.h" #include "common/system_utils.h" #include "gpu_info_util/SystemInfo_internal.h" +#include "libANGLE/histogram_macros.h" #include "libANGLE/renderer/metal/ContextMtl.h" #include "libANGLE/renderer/metal/DisplayMtl.h" #include "libANGLE/renderer/metal/RenderTargetMtl.h" #include "libANGLE/renderer/metal/mtl_render_utils.h" #include "libANGLE/renderer/metal/process.h" +#include "platform/PlatformMethods.h" // Compiler can turn on programmatical frame capture in release build by defining // ANGLE_METAL_FRAME_CAPTURE flag. @@ -917,6 +919,9 @@ AutoObjCPtr> CreateShaderLibrary( options.preprocessorMacros = macroDict; } + auto *platform = ANGLEPlatformCurrent(); + double startTime = platform->currentTime(platform); + auto library = metalDevice.newLibraryWithSource(nsSource, options, &nsError); if (angle::GetEnvironmentVar(kANGLEPrintMSLEnv)[0] == '1') { @@ -925,6 +930,10 @@ AutoObjCPtr> CreateShaderLibrary( [nsSource ANGLE_MTL_AUTORELEASE]; *errorOut = std::move(nsError); + double endTime = platform->currentTime(platform); + int us = static_cast((endTime - startTime) * 1000'000.0); + ANGLE_HISTOGRAM_COUNTS("GPU.ANGLE.MetalShaderCompilationTimeUs", us); + return library; } } @@ -1018,9 +1027,16 @@ AutoObjCPtr> CreateShaderLibrary(id metalDevice, freeWhenDone:NO]; auto options = [[[MTLCompileOptions alloc] init] ANGLE_MTL_AUTORELEASE]; + auto *platform = ANGLEPlatformCurrent(); + double startTime = platform->currentTime(platform); + NSError *nsError = nil; auto library = [metalDevice newLibraryWithSource:nsSource options:options error:&nsError]; + double endTime = platform->currentTime(platform); + ERR() << "CreateShaderLibrary newLibraryWithSource duration: " + << (endTime - startTime) * 1000.0 << "ms"; + [nsSource ANGLE_MTL_AUTORELEASE]; *errorOut = std::move(nsError);