You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The SDL_GPU Metal backend accepts two shader formats -- MSL and metallib. MSL is the plain-text shader which is compiled at runtime via Metal APIs. Metallib is essentially the compiled bytecode form of MSL.
The only way to obtain metallib binaries is to use the Xcode Metal compiler or the Metal Developer Tools for Windows. Apple does not provide any libraries for shader compilation and there is no way to serialize a runtime-compiled Metal library into metallib format. The compilation process is extremely sparsely documented and there is no official reference material; even xcrun metal --help isn't very helpful since it shows the full list of options for clang, not for Metal specifically.
So basically Metal offline compilation is a huge pain. But, of course, it's more efficient than runtime compilation. So it'd be nice if we could support it from in some capacity from the shadercross CLI to save developers the trouble of figuring out the magic invocations themselves.
On Windows/Mac, we could invoke the Metal compiler executable directly if the destination format is METALLIB. Due to the proprietary license (and massive binary size), we can't ship the Metal shader toolchain with shadercross, so we'd have to ask the developer to install the toolchain themselves. No idea what to do about Linux though since it's not officially supported... Maybe there's some way to run the Windows Metal toolchain with Wine?
There's also the question of how to define which platforms the generated metallib code should support. You can compile binaries for macOS, iOS Simulator, tvOS, and tvOS Simulator. I suppose we could add a "shader model"-style optional command line flag for this.
The text was updated successfully, but these errors were encountered:
The SDL_GPU Metal backend accepts two shader formats -- MSL and metallib. MSL is the plain-text shader which is compiled at runtime via Metal APIs. Metallib is essentially the compiled bytecode form of MSL.
The only way to obtain metallib binaries is to use the Xcode Metal compiler or the Metal Developer Tools for Windows. Apple does not provide any libraries for shader compilation and there is no way to serialize a runtime-compiled Metal library into metallib format. The compilation process is extremely sparsely documented and there is no official reference material; even
xcrun metal --help
isn't very helpful since it shows the full list of options for clang, not for Metal specifically.So basically Metal offline compilation is a huge pain. But, of course, it's more efficient than runtime compilation. So it'd be nice if we could support it from in some capacity from the shadercross CLI to save developers the trouble of figuring out the magic invocations themselves.
On Windows/Mac, we could invoke the Metal compiler executable directly if the destination format is METALLIB. Due to the proprietary license (and massive binary size), we can't ship the Metal shader toolchain with shadercross, so we'd have to ask the developer to install the toolchain themselves. No idea what to do about Linux though since it's not officially supported... Maybe there's some way to run the Windows Metal toolchain with Wine?
There's also the question of how to define which platforms the generated metallib code should support. You can compile binaries for macOS, iOS Simulator, tvOS, and tvOS Simulator. I suppose we could add a "shader model"-style optional command line flag for this.
The text was updated successfully, but these errors were encountered: