Hash :
9b00af52
Author :
Date :
2023-02-01T11:10:32
Metal: Add an in-memory MTLLibrary cache. Add a small cache for (msl + compile parameters) -> MTLLibrary at the egl::Display level. In regular executions of Chrome, the same shaders (particularly vertex) are compiled multiple times in different programs. Tested for a regular Chrome startup + open wikipedia + motionmark 1.2: 112/282 (40%) cache hits. Several different caching methods were profiled (LinkProgram perf test) - struct key with std::map : 303309 - struct key with std::unordered_map : 308090 - binary blob key with std::map : 263595 - binary blob key with std::unordered_map : 286051 - struct key + is_transparent with std::unordered_map : 304877 - struct key + is_transparent with absl::flat_hash_map : 335686 Using is_transparent allows us to search the hash map without copying the shader source string to construct the key structure. Bug: chromium:1385510 Change-Id: Ieec4ba526fe286276a4af7114d89cde32a8f9e1d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4214012 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
# Copyright 2022 The ANGLE Project Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("../../../../gni/angle.gni")
metal_backend_sources = [
"BufferMtl.h",
"BufferMtl.mm",
"CompilerMtl.h",
"CompilerMtl.mm",
"ContextMtl.h",
"ContextMtl.mm",
"DeviceMtl.h",
"DeviceMtl.mm",
"DisplayMtl.h",
"DisplayMtl.mm",
"DisplayMtl_api.h",
"FrameBufferMtl.h",
"FrameBufferMtl.mm",
"IOSurfaceSurfaceMtl.h",
"IOSurfaceSurfaceMtl.mm",
"ImageMtl.h",
"ImageMtl.mm",
"ProgramMtl.h",
"ProgramMtl.mm",
"ProvokingVertexHelper.h",
"ProvokingVertexHelper.mm",
"QueryMtl.h",
"QueryMtl.mm",
"RenderBufferMtl.h",
"RenderBufferMtl.mm",
"RenderTargetMtl.h",
"RenderTargetMtl.mm",
"SamplerMtl.h",
"SamplerMtl.mm",
"ShaderMtl.h",
"ShaderMtl.mm",
"SurfaceMtl.h",
"SurfaceMtl.mm",
"SyncMtl.h",
"SyncMtl.mm",
"TextureMtl.h",
"TextureMtl.mm",
"TransformFeedbackMtl.h",
"TransformFeedbackMtl.mm",
"VertexArrayMtl.h",
"VertexArrayMtl.mm",
"blocklayoutMetal.cpp",
"blocklayoutMetal.h",
"mtl_buffer_manager.h",
"mtl_buffer_manager.mm",
"mtl_buffer_pool.h",
"mtl_buffer_pool.mm",
"mtl_command_buffer.h",
"mtl_command_buffer.mm",
"mtl_common.h",
"mtl_common.mm",
"mtl_context_device.h",
"mtl_context_device.mm",
"mtl_default_shaders_compiled.inc",
"mtl_format_table_autogen.mm",
"mtl_format_utils.h",
"mtl_format_utils.mm",
"mtl_library_cache.h",
"mtl_library_cache.mm",
"mtl_msl_utils.h",
"mtl_msl_utils.mm",
"mtl_occlusion_query_pool.h",
"mtl_occlusion_query_pool.mm",
"mtl_render_utils.h",
"mtl_render_utils.mm",
"mtl_resource_spi.h",
"mtl_resources.h",
"mtl_resources.mm",
"mtl_state_cache.h",
"mtl_state_cache.mm",
"mtl_utils.h",
"mtl_utils.mm",
"renderermtl_utils.cpp",
"renderermtl_utils.h",
"shaders/constants.h",
"shaders/format_autogen.h",
"shaders/mtl_default_shaders_src_autogen.inc",
"shaders/rewrite_indices_shared.h",
]