Title: [280010] trunk/Source/ThirdParty/ANGLE
Revision
280010
Author
kpidding...@apple.com
Date
2021-07-16 16:59:37 -0700 (Fri, 16 Jul 2021)

Log Message

Build Default Metal library offline
https://bugs.webkit.org/show_bug.cgi?id=227333

<rdar://79923371>

This patch compiles and creates a Metal library at build time, storing
the library as a compiled binary file. This library is baked into the dylib,
and is loaded at context creation time.

Unlike the previous version of this patch, this patch does not save or store the .metallib on disk, but rather
bakes it into a binary.

Fixed internal build breaks by skipping Metallib bake script.

Reviewed by Kenneth Russell.

* ANGLE.xcodeproj/project.pbxproj:
* Configurations/ANGLE-dynamic.xcconfig:
* src/libANGLE/renderer/metal/DisplayMtl.mm:
(rx::DisplayMtl::initializeShaderLibrary):
* src/libANGLE/renderer/metal/mtl_utils.h:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/ThirdParty/ANGLE/ANGLE.xcodeproj/project.pbxproj (280009 => 280010)


--- trunk/Source/ThirdParty/ANGLE/ANGLE.xcodeproj/project.pbxproj	2021-07-16 23:53:23 UTC (rev 280009)
+++ trunk/Source/ThirdParty/ANGLE/ANGLE.xcodeproj/project.pbxproj	2021-07-16 23:59:37 UTC (rev 280010)
@@ -838,6 +838,13 @@
 		FF2D2F5525C8B14A002FB699 /* FixTypeConstructors.h in Headers */ = {isa = PBXBuildFile; fileRef = FF2D2F5225C8B14A002FB699 /* FixTypeConstructors.h */; };
 		FF582E1626544FC4006DA5B8 /* ProvokingVertexHelper.mm in Sources */ = {isa = PBXBuildFile; fileRef = FF582E1426544FC4006DA5B8 /* ProvokingVertexHelper.mm */; };
 		FF582E1726544FC4006DA5B8 /* ProvokingVertexHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = FF582E1526544FC4006DA5B8 /* ProvokingVertexHelper.h */; };
+		FFDA50CC269F848200AE11E2 /* blit.metal in Sources */ = {isa = PBXBuildFile; fileRef = FF81FEAA25818D6800894E24 /* blit.metal */; };
+		FFDA50CD269F848200AE11E2 /* clear.metal in Sources */ = {isa = PBXBuildFile; fileRef = FF81FEB125818D6800894E24 /* clear.metal */; };
+		FFDA50CE269F848200AE11E2 /* copy_buffer.metal in Sources */ = {isa = PBXBuildFile; fileRef = FF81FEAF25818D6800894E24 /* copy_buffer.metal */; };
+		FFDA50CF269F848200AE11E2 /* gen_indices.metal in Sources */ = {isa = PBXBuildFile; fileRef = FF81FEB325818D6800894E24 /* gen_indices.metal */; };
+		FFDA50D0269F848200AE11E2 /* gen_mipmap.metal in Sources */ = {isa = PBXBuildFile; fileRef = FF81FEB225818D6800894E24 /* gen_mipmap.metal */; };
+		FFDA50D1269F848200AE11E2 /* rewrite_indices.metal in Sources */ = {isa = PBXBuildFile; fileRef = FF582E1826544FE5006DA5B8 /* rewrite_indices.metal */; };
+		FFDA50D2269F848200AE11E2 /* visibility.metal in Sources */ = {isa = PBXBuildFile; fileRef = FF81FEAB25818D6800894E24 /* visibility.metal */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXBuildRule section */
@@ -864,6 +871,13 @@
 			remoteGlobalIDString = 31CDFDF32491819E00486F27;
 			remoteInfo = "ANGLE (dynamic)";
 		};
+		FFDA50D3269F84A000AE11E2 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = FB39D0701200ED9200088E69 /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = FFDA50C4269F845100AE11E2;
+			remoteInfo = ANGLEMetalLib;
+		};
 /* End PBXContainerItemProxy section */
 
 /* Begin PBXCopyFilesBuildPhase section */
@@ -1813,6 +1827,8 @@
 		FF81FF9A2581A3C200894E24 /* IntermRebuild.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IntermRebuild.h; sourceTree = "<group>"; };
 		FFA0C2C525CB6A7600105306 /* NameEmbeddedUniformStructsMetal.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NameEmbeddedUniformStructsMetal.cpp; sourceTree = "<group>"; };
 		FFA0C2C625CB6A7700105306 /* NameEmbeddedUniformStructsMetal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NameEmbeddedUniformStructsMetal.h; sourceTree = "<group>"; };
+		FFDA50D6269F9E5800AE11E2 /* create_mtl_internal_shaders.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = create_mtl_internal_shaders.py; sourceTree = "<group>"; };
+		FFE0D91526A0B4E80071ADAE /* AngleMetalLib.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AngleMetalLib.xcconfig; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -2769,6 +2785,7 @@
 			children = (
 				31CDFDEE24917F8900486F27 /* ANGLE-dynamic.xcconfig */,
 				31CDFDEF24917F8900486F27 /* ANGLE-static.xcconfig */,
+				FFE0D91526A0B4E80071ADAE /* AngleMetalLib.xcconfig */,
 				5D7C59C61208C68B001C873E /* Base.xcconfig */,
 				5D7C59C71208C68B001C873E /* DebugRelease.xcconfig */,
 				A1B89B89221E003A00EB4CEA /* SDKVariant.xcconfig */,
@@ -3056,6 +3073,7 @@
 				FF81FEAD25818D6800894E24 /* common.h */,
 				FF81FEAC25818D6800894E24 /* constants.h */,
 				FF81FEAF25818D6800894E24 /* copy_buffer.metal */,
+				FFDA50D6269F9E5800AE11E2 /* create_mtl_internal_shaders.py */,
 				FF81FEB025818D6800894E24 /* format_autogen.h */,
 				FF81FEB325818D6800894E24 /* gen_indices.metal */,
 				FF81FEB225818D6800894E24 /* gen_mipmap.metal */,
@@ -3571,6 +3589,7 @@
 			buildConfigurationList = 31CDFDF52491819E00486F27 /* Build configuration list for PBXNativeTarget "ANGLE (dynamic)" */;
 			buildPhases = (
 				31CDFDF02491819E00486F27 /* Headers */,
+				FFDA50D5269F895400AE11E2 /* Bake Metal Library to NSData */,
 				31CDFDF12491819E00486F27 /* Sources */,
 				31CDFDF22491819E00486F27 /* Frameworks */,
 				31CD00CE2491974C00486F27 /* CopyFiles */,
@@ -3581,6 +3600,7 @@
 				31A9E9A0249AA04200C7E243 /* PBXBuildRule */,
 			);
 			dependencies = (
+				FFDA50D4269F84A000AE11E2 /* PBXTargetDependency */,
 			);
 			name = "ANGLE (dynamic)";
 			productName = "ANGLE (dynamic)";
@@ -3587,6 +3607,20 @@
 			productReference = 31CDFDF42491819E00486F27 /* libANGLE-shared.dylib */;
 			productType = "com.apple.product-type.library.dynamic";
 		};
+		FFDA50C4269F845100AE11E2 /* ANGLEMetalLib */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = FFDA50CB269F845100AE11E2 /* Build configuration list for PBXNativeTarget "ANGLEMetalLib" */;
+			buildPhases = (
+				FFDA50C3269F845100AE11E2 /* Sources */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+			);
+			name = ANGLEMetalLib;
+			productName = ANGLEMetalLib;
+			productType = "com.apple.product-type.metal-library";
+		};
 /* End PBXNativeTarget section */
 
 /* Begin PBXProject section */
@@ -3604,6 +3638,10 @@
 						CreatedOnToolsVersion = 12.0;
 						ProvisioningStyle = Automatic;
 					};
+					FFDA50C4269F845100AE11E2 = {
+						CreatedOnToolsVersion = 13.0;
+						ProvisioningStyle = Automatic;
+					};
 				};
 			};
 			buildConfigurationList = FB39D0731200ED9200088E69 /* Build configuration list for PBXProject "ANGLE" */;
@@ -3620,6 +3658,7 @@
 			targets = (
 				31DB794F2491C33300982878 /* ANGLE */,
 				31CDFDF32491819E00486F27 /* ANGLE (dynamic) */,
+				FFDA50C4269F845100AE11E2 /* ANGLEMetalLib */,
 			);
 		};
 /* End PBXProject section */
@@ -3643,6 +3682,27 @@
 			shellPath = /bin/sh;
 			shellScript = "if [ \"${XCODE_VERSION_ACTUAL}\" -ge \"1140\" -a \"${WK_USE_NEW_BUILD_SYSTEM}\" = \"YES\" ]; then\n    # In this configuration, post-processing is performed at the same time as copying in the postprocess-header-rule script, so there's no need for this separate step.\n    exit 0\nfi\n\nexec \"$SRCROOT/adjust-angle-include-paths.py\"\n";
 		};
+		FFDA50D5269F895400AE11E2 /* Bake Metal Library to NSData */ = {
+			isa = PBXShellScriptBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+			);
+			inputFileListPaths = (
+			);
+			inputPaths = (
+				"$(BUILT_PRODUCTS_DIR)/ANGLEMetalLib.metallib",
+				"$(SRCROOT)/src/libANGLE/renderer/metal/shaders/create_mtl_internal_shaders.py",
+			);
+			name = "Bake Metal Library to NSData";
+			outputFileListPaths = (
+			);
+			outputPaths = (
+				"$(DERIVED_FILE_DIR)/mtl_default_shaders_compiled.inc",
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+			shellPath = /bin/sh;
+			shellScript = "if [ \"${ACTION}\" = \"build\" ] || [ \"${ACTION}\" = \"install\" ]; then\necho python \"${SRCROOT}/src/libANGLE/renderer/metal/shaders/create_mtl_internal_shaders.py\" \"$SCRIPT_INPUT_FILE_0\" \"$SCRIPT_OUTPUT_FILE_0\"\npython \"${SRCROOT}/src/libANGLE/renderer/metal/shaders/create_mtl_internal_shaders.py\" \"$SCRIPT_INPUT_FILE_0\" \"$SCRIPT_OUTPUT_FILE_0\"\nfi\n";
+		};
 /* End PBXShellScriptBuildPhase section */
 
 /* Begin PBXSourcesBuildPhase section */
@@ -4053,6 +4113,20 @@
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
+		FFDA50C3269F845100AE11E2 /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				FFDA50CC269F848200AE11E2 /* blit.metal in Sources */,
+				FFDA50CD269F848200AE11E2 /* clear.metal in Sources */,
+				FFDA50CE269F848200AE11E2 /* copy_buffer.metal in Sources */,
+				FFDA50CF269F848200AE11E2 /* gen_indices.metal in Sources */,
+				FFDA50D0269F848200AE11E2 /* gen_mipmap.metal in Sources */,
+				FFDA50D1269F848200AE11E2 /* rewrite_indices.metal in Sources */,
+				FFDA50D2269F848200AE11E2 /* visibility.metal in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
 /* End PBXSourcesBuildPhase section */
 
 /* Begin PBXTargetDependency section */
@@ -4061,6 +4135,11 @@
 			target = 31CDFDF32491819E00486F27 /* ANGLE (dynamic) */;
 			targetProxy = 31DB79562491C35400982878 /* PBXContainerItemProxy */;
 		};
+		FFDA50D4269F84A000AE11E2 /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = FFDA50C4269F845100AE11E2 /* ANGLEMetalLib */;
+			targetProxy = FFDA50D3269F84A000AE11E2 /* PBXContainerItemProxy */;
+		};
 /* End PBXTargetDependency section */
 
 /* Begin XCBuildConfiguration section */
@@ -4088,7 +4167,6 @@
 		31DB79502491C33300982878 /* Debug */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
-				CODE_SIGN_STYLE = Automatic;
 				PRODUCT_NAME = "$(TARGET_NAME)";
 			};
 			name = Debug;
@@ -4096,7 +4174,6 @@
 		31DB79512491C33300982878 /* Release */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
-				CODE_SIGN_STYLE = Automatic;
 				PRODUCT_NAME = "$(TARGET_NAME)";
 			};
 			name = Release;
@@ -4104,7 +4181,6 @@
 		31DB79522491C33300982878 /* Production */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
-				CODE_SIGN_STYLE = Automatic;
 				PRODUCT_NAME = "$(TARGET_NAME)";
 			};
 			name = Production;
@@ -4131,6 +4207,27 @@
 			};
 			name = Release;
 		};
+		FFDA50C8269F845100AE11E2 /* Debug */ = {
+			isa = XCBuildConfiguration;
+			baseConfigurationReference = FFE0D91526A0B4E80071ADAE /* AngleMetalLib.xcconfig */;
+			buildSettings = {
+			};
+			name = Debug;
+		};
+		FFDA50C9269F845100AE11E2 /* Release */ = {
+			isa = XCBuildConfiguration;
+			baseConfigurationReference = FFE0D91526A0B4E80071ADAE /* AngleMetalLib.xcconfig */;
+			buildSettings = {
+			};
+			name = Release;
+		};
+		FFDA50CA269F845100AE11E2 /* Production */ = {
+			isa = XCBuildConfiguration;
+			baseConfigurationReference = FFE0D91526A0B4E80071ADAE /* AngleMetalLib.xcconfig */;
+			buildSettings = {
+			};
+			name = Production;
+		};
 /* End XCBuildConfiguration section */
 
 /* Begin XCConfigurationList section */
@@ -4164,6 +4261,16 @@
 			defaultConfigurationIsVisible = 0;
 			defaultConfigurationName = Production;
 		};
+		FFDA50CB269F845100AE11E2 /* Build configuration list for PBXNativeTarget "ANGLEMetalLib" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				FFDA50C8269F845100AE11E2 /* Debug */,
+				FFDA50C9269F845100AE11E2 /* Release */,
+				FFDA50CA269F845100AE11E2 /* Production */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Production;
+		};
 /* End XCConfigurationList section */
 	};
 	rootObject = FB39D0701200ED9200088E69 /* Project object */;

Modified: trunk/Source/ThirdParty/ANGLE/ChangeLog (280009 => 280010)


--- trunk/Source/ThirdParty/ANGLE/ChangeLog	2021-07-16 23:53:23 UTC (rev 280009)
+++ trunk/Source/ThirdParty/ANGLE/ChangeLog	2021-07-16 23:59:37 UTC (rev 280010)
@@ -1,3 +1,27 @@
+2021-07-16  Kyle Piddington  <kpidding...@apple.com>
+
+        Build Default Metal library offline
+        https://bugs.webkit.org/show_bug.cgi?id=227333
+
+        <rdar://79923371>
+
+        This patch compiles and creates a Metal library at build time, storing
+        the library as a compiled binary file. This library is baked into the dylib,
+        and is loaded at context creation time.
+
+        Unlike the previous version of this patch, this patch does not save or store the .metallib on disk, but rather
+        bakes it into a binary.
+
+        Fixed internal build breaks by skipping Metallib bake script.
+
+        Reviewed by Kenneth Russell.
+
+        * ANGLE.xcodeproj/project.pbxproj:
+        * Configurations/ANGLE-dynamic.xcconfig:
+        * src/libANGLE/renderer/metal/DisplayMtl.mm:
+        (rx::DisplayMtl::initializeShaderLibrary):
+        * src/libANGLE/renderer/metal/mtl_utils.h:
+
 2021-07-16  Truitt Savell  <tsav...@apple.com>
 
         Unreviewed, reverting r279980.

Modified: trunk/Source/ThirdParty/ANGLE/Configurations/ANGLE-dynamic.xcconfig (280009 => 280010)


--- trunk/Source/ThirdParty/ANGLE/Configurations/ANGLE-dynamic.xcconfig	2021-07-16 23:53:23 UTC (rev 280009)
+++ trunk/Source/ThirdParty/ANGLE/Configurations/ANGLE-dynamic.xcconfig	2021-07-16 23:59:37 UTC (rev 280010)
@@ -27,7 +27,7 @@
 DYLIB_INSTALL_NAME_BASE_WK_RELOCATABLE_FRAMEWORKS_ = $(DYLIB_INSTALL_NAME_BASE);
 DYLIB_INSTALL_NAME_BASE_WK_RELOCATABLE_FRAMEWORKS_YES = @loader_path/../../../;
 
-HEADER_SEARCH_PATHS = include src src/common/third_party/numerics third_party/base src/common/third_party/base third_party/zlib/google;
+HEADER_SEARCH_PATHS = include src src/common/third_party/numerics third_party/base src/common/third_party/base third_party/zlib/google ${DERIVED_FILES_DIR};
 
 ANGLE_HEADERS_FOLDER_PATH = /usr/local/include/ANGLE;
 
@@ -36,7 +36,7 @@
 PUBLIC_HEADERS_FOLDER_PATH_macosx = $(ANGLE_HEADERS_FOLDER_PATH);
 PUBLIC_HEADERS_FOLDER_PATH_maccatalyst = $(WK_ALTERNATE_FRAMEWORKS_DIR)/$(ANGLE_HEADERS_FOLDER_PATH);
 
-GCC_PREPROCESSOR_DEFINITIONS = $(DEBUG_DEFINES) LIBGLESV2_IMPLEMENTATION LIBANGLE_IMPLEMENTATION ANGLE_ENABLE_OPENGL ANGLE_ENABLE_GLSL ANGLE_ENABLE_ESSL GL_SILENCE_DEPRECATION GLES_SILENCE_DEPRECATION ANGLE_ENABLE_METAL;
+GCC_PREPROCESSOR_DEFINITIONS = $(DEBUG_DEFINES) LIBGLESV2_IMPLEMENTATION LIBANGLE_IMPLEMENTATION ANGLE_ENABLE_OPENGL ANGLE_ENABLE_GLSL ANGLE_ENABLE_ESSL GL_SILENCE_DEPRECATION GLES_SILENCE_DEPRECATION ANGLE_ENABLE_METAL ANGLE_METAL_XCODE_BUILDS_SHADERS;
 
 DEAD_CODE_STRIPPING = YES;
 DEAD_CODE_STRIPPING[config=Debug] = NO;

Added: trunk/Source/ThirdParty/ANGLE/Configurations/AngleMetalLib.xcconfig (0 => 280010)


--- trunk/Source/ThirdParty/ANGLE/Configurations/AngleMetalLib.xcconfig	                        (rev 0)
+++ trunk/Source/ThirdParty/ANGLE/Configurations/AngleMetalLib.xcconfig	2021-07-16 23:59:37 UTC (rev 280010)
@@ -0,0 +1,20 @@
+#include "Version.xcconfig"
+#include "WebKitTargetConditionals.xcconfig"
+
+PRODUCT_NAME = ANGLEMetalLib;
+SKIP_INSTALL = YES;
+
+HEADER_SEARCH_PATHS = include src src/common/third_party/numerics third_party/base src/common/third_party/base third_party/zlib/google;
+
+ANGLE_HEADERS_FOLDER_PATH = /usr/local/include/ANGLE;
+
+PUBLIC_HEADERS_FOLDER_PATH = $(ANGLE_HEADERS_FOLDER_PATH);
+PUBLIC_HEADERS_FOLDER_PATH[sdk=macosx*] = $(PUBLIC_HEADERS_FOLDER_PATH_$(WK_PLATFORM_NAME));
+PUBLIC_HEADERS_FOLDER_PATH_macosx = $(ANGLE_HEADERS_FOLDER_PATH);
+PUBLIC_HEADERS_FOLDER_PATH_maccatalyst = $(WK_ALTERNATE_FRAMEWORKS_DIR)/$(ANGLE_HEADERS_FOLDER_PATH);
+
+MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE
+MTL_FAST_MATH = YES
+
+STRIP_INSTALLED_PRODUCT = YES;
+STRIP_INSTALLED_PRODUCT[config=Debug] = NO;

Modified: trunk/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/DisplayMtl.mm (280009 => 280010)


--- trunk/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/DisplayMtl.mm	2021-07-16 23:53:23 UTC (rev 280009)
+++ trunk/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/DisplayMtl.mm	2021-07-16 23:59:37 UTC (rev 280010)
@@ -22,8 +22,13 @@
 #include "libANGLE/renderer/metal/SyncMtl.h"
 #include "libANGLE/renderer/metal/mtl_common.h"
 #include "libANGLE/renderer/metal/shaders/mtl_default_shaders_src_autogen.inc"
+#include "libANGLE/renderer/metal/mtl_utils.h"
 #include "platform/Platform.h"
 
+#ifdef ANGLE_METAL_XCODE_BUILDS_SHADERS
+#include "mtl_default_shaders_compiled.inc"
+#endif
+
 #include "EGL/eglext.h"
 
 #if defined(ANGLE_PLATFORM_MACOS) || defined(ANGLE_PLATFORM_MACCATALYST)
@@ -993,23 +998,16 @@
 #ifdef ANGLE_METAL_XCODE_BUILDS_SHADERS
     mDefaultShadersAsyncInfo.reset(new DefaultShaderAsyncInfoMtl);
 
-    NSString *path = [NSBundle bundleWithIdentifier:@"com.apple.WebKit"].bundlePath;
-    NSError *error = nullptr;
-    mDefaultShadersAsyncInfo->defaultShaders =
-        [getMetalDevice() newDefaultLibraryWithBundle:[NSBundle bundleWithPath:path] error:&error];
-
-    if (error && !mDefaultShadersAsyncInfo->defaultShaders)
-    {
-        ANGLE_MTL_OBJC_SCOPE
-        {
-            ERR() << "Internal error: newDefaultLibraryWithBundle failed. "
-                  << error.localizedDescription.UTF8String;
-        }
-        mDefaultShadersAsyncInfo->defaultShadersCompileError = std::move(error);
-        return angle::Result::Stop;
-    }
+    const uint8_t *compiled_shader_binary;
+    size_t compiled_shader_binary_len;
+    compiled_shader_binary     = gMetalBinaryShaders;
+    compiled_shader_binary_len = gMetalBinaryShaders_len;
+    mtl::AutoObjCPtr<NSError *> err = nil;
+    mtl::AutoObjCPtr<id<MTLLibrary>> mDefaultShaders = mtl::CreateShaderLibraryFromBinary(getMetalDevice(), compiled_shader_binary,
+                                                                        compiled_shader_binary_len, &err);
+    mDefaultShadersAsyncInfo->defaultShaders = std::move(mDefaultShaders.get());
+    mDefaultShadersAsyncInfo->defaultShadersCompileError = std::move(err.get());
     mDefaultShadersAsyncInfo->compiled = true;
-
 #else
     mDefaultShadersAsyncInfo.reset(new DefaultShaderAsyncInfoMtl);
 

Modified: trunk/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/mtl_utils.h (280009 => 280010)


--- trunk/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/mtl_utils.h	2021-07-16 23:53:23 UTC (rev 280009)
+++ trunk/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/mtl_utils.h	2021-07-16 23:59:37 UTC (rev 280010)
@@ -105,7 +105,6 @@
 AutoObjCPtr<id<MTLLibrary>> CreateShaderLibraryFromBinary(id<MTLDevice> metalDevice,
                                                           const uint8_t *binarySource,
                                                           size_t binarySourceLen,
-                                                          NSDictionary<NSString *, NSObject *> * substitutionDictionary,
                                                           AutoObjCPtr<NSError *> *error);
 
 bool SupportsIOSGPUFamily(id<MTLDevice> device, uint8_t iOSFamily);

Added: trunk/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/shaders/create_mtl_internal_shaders.py (0 => 280010)


--- trunk/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/shaders/create_mtl_internal_shaders.py	                        (rev 0)
+++ trunk/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/shaders/create_mtl_internal_shaders.py	2021-07-16 23:59:37 UTC (rev 280010)
@@ -0,0 +1,79 @@
+#!/usr/bin/python
+# Copyright 2021 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.
+#
+# create_mtl_internal_shaders.py:
+#   Script to compile a metalLib into NSData, for including the compilded
+#       library in the ANGLE dylib.
+
+import os
+import sys
+import json
+from datetime import datetime
+
+sys.path.append('../..')
+
+template_header_boilerplate = """// GENERATED FILE - DO NOT EDIT.
+// Generated by {script_name}
+//
+// Copyright {copyright_year} 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.
+//
+"""
+
+
+# Convert content of a file to byte array and store in a header file.
+# variable_name: name of C++ variable that will hold the file content as byte array.
+# filename: the file whose content will be converted to C++ byte array.
+# dest_src_file: destination header file that will contain the byte array.
+def append_file_as_byte_array_string(variable_name, filename, dest_src_file):
+    string = '// Generated from {0}:\n'.format(filename)
+    string += 'constexpr uint8_t {0}[]={{\n'.format(variable_name)
+    bytes_ = open(filename, "rb").read()
+    for byte in bytes_:
+        string += '0x{:02x}'.format(ord(byte)) + ", "
+    string += "\n};\n"
+    with open(dest_src_file, "a") as out_file:
+        out_file.write(string)
+        
+
+
+# Compile metal shader.
+# compiled_file: The compiled metallib
+# variable_name: name of C++ variable that will hold the compiled binary data as a C array.
+# additional_flags: additional shader compiler flags
+# src_files: metal source files
+def gen_precompiled_shaders(compiled_file, variable_name, output_file):
+    append_file_as_byte_array_string(variable_name,
+                                     compiled_file,
+                                     output_file)
+    os.system('echo "constexpr size_t {0}_len=sizeof({0});" >> \"{1}\"'
+              .format(variable_name, output_file))
+
+def main():
+    input_file = sys.argv[1]
+    output_file = sys.argv[2]
+    os.chdir(sys.path[0])
+    
+    boilerplate_code = template_header_boilerplate.format(
+        script_name=sys.argv[0], copyright_year=datetime.today().year)
+
+    # -------- Compile shaders -----------
+    # boiler plate code
+    os.system("echo \"{0}\" > \"{1}\"".format(boilerplate_code, output_file))
+    os.system(
+        'echo "// Compiled binary for Metal default shaders.\n\n" >>  \"{0}\"'.format(output_file)
+    )
+    os.system('echo "#include <TargetConditionals.h>\n\n" >>  \"{0}\"'.format(output_file))
+
+    os.system('echo "// clang-format off" >> \"{0}\"'.format(output_file))
+    
+    gen_precompiled_shaders(input_file, 'gMetalBinaryShaders', output_file)
+
+    os.system('echo "// clang-format on" >> \"{0}\"'.format(output_file))
+
+
+if __name__ == '__main__':
+    sys.exit(main())
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to