1*8975f5c5SAndroid Build Coastguard Worker# Metal Backend Shaders 2*8975f5c5SAndroid Build Coastguard Worker 3*8975f5c5SAndroid Build Coastguard WorkerANGLE's Metal backend provides a couple of features for inspecting the 4*8975f5c5SAndroid Build Coastguard WorkerMetal Shading Language (MSL) produced by ANGLE's shader translator. 5*8975f5c5SAndroid Build Coastguard Worker 6*8975f5c5SAndroid Build Coastguard Worker## printMetalShaders 7*8975f5c5SAndroid Build Coastguard Worker 8*8975f5c5SAndroid Build Coastguard WorkerThe [`printMetalShaders` 9*8975f5c5SAndroid Build Coastguard Workerfeature](https://chromium-review.googlesource.com/c/angle/angle/+/4480976), 10*8975f5c5SAndroid Build Coastguard Workerwhich can be enabled in Chromium via the command line argument 11*8975f5c5SAndroid Build Coastguard Worker`--enable-angle-features=printMetalShaders`, dumps the blob cache key 12*8975f5c5SAndroid Build Coastguard Workerand translated MSL for all shaders compiled by ANGLE. This is 13*8975f5c5SAndroid Build Coastguard Workercurrently used to [regenerate precompiled 14*8975f5c5SAndroid Build Coastguard Workershaders](https://crbug.com/1423136) shipped with Chrome. 15*8975f5c5SAndroid Build Coastguard Worker 16*8975f5c5SAndroid Build Coastguard Worker## Environment variable 17*8975f5c5SAndroid Build Coastguard Worker 18*8975f5c5SAndroid Build Coastguard WorkerSetting the environment variable `ANGLE_METAL_PRINT_MSL_ENABLE` to `1` 19*8975f5c5SAndroid Build Coastguard Workerindicates to the Metal backend to print the translated shaders as 20*8975f5c5SAndroid Build Coastguard Workerthey're compiled: 21*8975f5c5SAndroid Build Coastguard Worker 22*8975f5c5SAndroid Build Coastguard Worker``` 23*8975f5c5SAndroid Build Coastguard Workerexport ANGLE_METAL_PRINT_MSL_ENABLE=1 24*8975f5c5SAndroid Build Coastguard Worker/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary --use-angle=metal 25*8975f5c5SAndroid Build Coastguard Worker``` 26*8975f5c5SAndroid Build Coastguard Worker 27*8975f5c5SAndroid Build Coastguard WorkerTo pass this environment to WebKit / Safari's GPU process, set the 28*8975f5c5SAndroid Build Coastguard Workerenvironment variable `__XPC_ANGLE_METAL_PRINT_MSL_ENABLE` to `1`: 29*8975f5c5SAndroid Build Coastguard Worker 30*8975f5c5SAndroid Build Coastguard Worker``` 31*8975f5c5SAndroid Build Coastguard Workerexport __XPC_ANGLE_METAL_PRINT_MSL_ENABLE=1 32*8975f5c5SAndroid Build Coastguard Worker/Applications/Safari\ Technology\ Preview.app/Contents/MacOS/Safari\ Technology\ Preview 33*8975f5c5SAndroid Build Coastguard Worker``` 34