[ad_1]
With the publication of macOS SonomaApple has also updated the latest versions of the Metal developer tools for use on Windows. Here’s how to get and use them.
Metal is Apple’s graphics framework for MacOS. Metal lets you create rich, powerful 2D and 3D graphics using Apple’s graphics engine, optimized for all Apple devices.
While Metal runs on Apple devices, you can also use Microsoft Windows as a platform for creating assets, images, shaders, and textures for use in Metal.
Apple offers two Metal for Windows downloads on its developer tools website: Metal Developer Tools 4.0 for Windows and Metal Shader Converter for Windows. You can download both by logging into your Apple developer account online.
To download Metal Developer Tools for Windows, sign in to your Apple developer account and go to Download page in your web browser and scroll down to Metal developer tools for Windows:
Press that Show details arrow, then click Metal Developer Tools 4.0 Windows.pdf And Metal Developer Tools 4.0 Windows.exe to download them to your computer’s memory.
Next, scroll down a bit Metal shader converter for Windows and click Show details arrow, then click Metal Shader Converter for Windows.pdf And Metal Shader Converter for Windows.exe To download them to your computer’s memory:
installation
Move all downloaded items to a new folder. You should now have four items. You may want to read through both PDF files before installing:
Next, once you have downloaded the files to your Mac, connect a Windows-compatible USB stick or other storage device and copy the four items to it. You use the USB stick to copy the files to your Windows 10 or 11 computer.
Once the copying process is complete, connect the USB drive to your Windows computer and copy the four files. Run both EXE installation files to install the tools on your Windows computer.
The Metal Developer Tools for Windows PDF file states:
“By default the package is installed in %PROGRAMFILES%\Metal Developer Tools
. During installation you will find:
bin
includes the TextureConverter tool.
include
contains the headers for the AppleTextureConverter library.
lib
contains the AppleTextureConverter library.
metal\ios
contains the tools to be used in targeting iOS And tvOS. metal\macos
contains the tools to use when targeting macOS.
The Metal Developer Tools should match the version of the operating system SDKs you want to target for your release.”
It also states that in addition to GUI installations, the installer can also support command line installations as follows:
"Metal Developer Tools-Windows.exe" /S /D=C:\Users\My Name\Sandbox\Tools
Once installed, you can use the tools to convert shaders and assets on your Windows computer to formats used by Metal.
The first tool TextureConverter
Converts textures created by Windows into GPU-compressed texture formats that Metal accepts. To view details and execute options TextureConverter
Type:
TextureConverter.exe --h
Type in a command prompt in Windows and press To return or Input.
As the developer note shows, for embedding TextureConverter
into your own Windows texture tools, use the provided AppleTextureConverter library and read the AppleTextureConverter.h
See the header file for more information.
Also included are tools for compiling Windows graphics and compute shaders into Metal Library objects using the Apple Metal Shading Language.
The Windows tools don’t come with a note about this, so you’ll have to read it Creating a shader library by precompiling source files in the Shader library Section of Documentation->Metal Apple’s online metal documentation section.
In fact, you use the tools to go from Windows DXIL formats to the intermediate .air format and then to a .metalar and .metallib file to load into Xcode and run at runtime from your app. From the documentation:
“The Metal compiler tool converts each shader source file into an intermediate rendering file. The Metallib and Metal-AR tools then compile intermediate representation files into a library and binary archive, respectively.”
As stated in the documentation, the Metal command line tools for Windows use the same options and arguments as their macOS counterparts.
The other tool for Windows that is installed is the Metal Shader Converter for Windows.
This tool converts intermediate representations in LLVM-IR bytecode format into bytecode suitable for loading into Metal.
LLVM is the open source compiler infrastructure that Xcode uses when compiling projects.
For more information about LLVM, see llvm.org and the bytecode format (LLVM calls it “bitcode”) on the bitcode page of this site.
The bytecode format is also covered in the book LLVM Cookbook by PACKT Publishing.
The Metal Shader Converter is provided both as a standalone tool and as a library that you can integrate into your own tools if necessary.
Also see the header file provided metal_irconverter_runtime.h
.
Metal Shader Converter for Windows requires Microsoft Windows 10 or later and Microsoft Visual Studio 2019 or later.
Libraries created with the Metal Shader Converter for Windows only work with macOS 14 Sonoma and iOS 17. If created for previous operating system versions, some features may not be available.
The first and easiest use of Metal Shader Converter for Windows is to convert a Windows DirectX DXIL (DirectX Intermediate Language) shader to a metal shader library. This can be done with the metal-shaderconverter
Command line tool.
metal-shaderconverter shader.dxil -o ./shader.metallib
For more information, please contact metal-shaderconverter
on Windows by running metal-shaderconverter --help
in a command prompt.
There is also one libmetalirconverter
Dynamic code library (Dylib) provided that works with C, C++, Objective-C and Fast Projects that allow you to convert DXIL to Metal using the provided file IRCompiler
Class.
Such conversion code is fairly simple and example code of less than a page is provided in the Metal Shader Converter PDF.
Essentially, to use what is provided IRCompiler
In the class, you first create an instance of the object, set an entry point name, and convert a DXIL object to an IR object using the IRObject
Great, compile it to Metal with that IRCompilerAllocCompileAndLink()
function and check the output.
Which provided
The fairly lengthy, 30-page Metal Shader Compiler for Windows PDF goes into a variety of other options you can use to convert Windows to Apple Metal, including vertex attributes, sampler state objects, argument buffers, ray tracing, and more.
There are also tips for achieving optimal Metal performance and tips for dealing with complex shader pipelines, including geometry and tessellation.
The PDF also recommends taking a look at Apple’s Metal sample code project, Learn Metal with C++ Example code for metal Page.
Additional resources
If you are not familiar with C++, you should first start with a simple classic book about C, such as the Standard C book The C programming language by Brian Kernighan and the late Dennis Ritchie, both of whom wrote the C language at Bell Labs in the 1970s to develop the UNIX operating system.
C++, created by Bjarne Stroustrup, is based on C but provides object-oriented (OOP) features such as classes, objects, a standard template library (STL), and other modern features. Stroustrup’s text The C++ programming language 4th edition is a must read.
Stroustrup also has one website at and several additional useful C++ books and tutorials.
An annual C++ conference, CppCon takes place every October – this year from October 1st to 6th in Aurora, CO. CppCon also has one Youtube channel with a whole series of great C++ tutorials.
C++ gained widespread popularity in 1994 when the limitations of procedural languages like C became clear. There are several standards for C, including C99, C11, C14, C17 and C22. APRESS had some good books on each of the standards.
You can specify which of these standards the Xcode compiler uses in the Build Settings pane of Xcode.
The NeXT team founded NeXT Computer in 1989 Goal ca similar OOP language based on C but with additional benefits such as dynamic linking and object introspection.
It’s also worth noting that some third-party 3D standards also have specific requirements, many of which are based on Windows DirectX/Direct3D DXIL standards.
Steam, for example, has certain DirectX requirements that must be met. So if you’re publishing on Steam and Apple platforms simultaneously, you should be aware of these requirements. Steam has one Page which lists the requirements in detail.
Microsoft also has a DirectX Specs page and DirectX Shader Model 6 in its DirectX Specs and DirectXTK12 repos on GitHub.
Debugging and optimizing Windows DXIL PIX Tool is also available.
There is also a DirectX developer blog at Microsoft.
Finally, NVIDIA has a Windows-based DirectX debugging tool called Nsight graphicsif you are ready to face the complexity documentation.
With Apple’s addition of Windows Metal tools in macOS Sonoma, it is now much easier to port existing game graphics pipelines to Metal so they can run optimally on Apple platforms. Over time, we can expect Apple to improve its Metal tools, making cross-platform game development significantly less tedious.
[ad_2]