How to convert from XYZ or sRGB to ACEScg/AP1
The discrepancy comes from chromatic adaptation, which is included in the matrix from shadertoy. If you combine XYZ->AP1 with D65->D60 from the aces page you end up with the same matrix that I got by chaining XYZ->sRGB and sRGB->AP1 (with chromatic adaptation) together.