Metal Shader Converter

RSS for tag

Automatically convert all of your existing HLSL GPU shaders to Metal.

Posts under Metal Shader Converter tag

4 Posts
Sort by:
Post not yet marked as solved
1 Replies
357 Views
Seems that metal-shaderconverter can build a metallib, but I need .air files. Then I link the .air files into a single metallib and metallibdsym file. HLSL -> dxc -> DXIL -> metal-shaderconverter -> .metallib But there's no way to link together multiple metallib into a single metallib is there?
Posted
by Alecazam.
Last updated
.
Post not yet marked as solved
3 Replies
975 Views
Hello, I’ve started testing the Metal Shader Converter to convert my HLSL shaders to metallib directly, and I was wondering if the option ’-frecord-sources’ was supported in any way? Usually I’m compiling my shaders as follows (from Metal): xcrun -sdk macosx metal -c -frecord-sources shaders/shaders.metal -o shaders/shaders.air xcrun -sdk macosx metallib shaders/shaders.air -o shaders/shaders.metallib The -frecord-sources allow me to see the source when debugging and profiling a Metal frame. Now with DXC we have a similar option, I can compile a typical HLSL shader with embedded debug symbols with: dxc -T vs_6_0 -E VSMain shaders/triangle.hlsl -Fo shaders/triangle.dxil -Zi -O0 -Qembed_debug The important options here are ’-Zi` and ’-Qembed_debug’, as they make sure debug symbols are embedded in the DXIL. It seems that right now Metal Shader Converter doesn’t pass through the DXIL debug information, and I was wondering if it was possible. I’ve looked at all the options in the utility and haven’t seen anything that looked like it. Right now debug symbols in my shaders is a must-have, so I’ll explore other routes to convert my HLSL shaders to Metal (I’ve been testing spir-v cross to do the conversion, I haven’t actually tested the debug symbols yet, I’ll report back later). Thank you for your time!
Posted
by jmbn.
Last updated
.
Post not yet marked as solved
0 Replies
576 Views
Hello, I’ve started testing the Metal Shader Converter to convert my HLSL shaders to metallib directly, and I was wondering if the option ’-frecord-sources’ was supported in any way? Usually I’m compiling my shaders as follows (from Metal): xcrun -sdk macosx metal -c -frecord-sources shaders/shaders.metal -o shaders/shaders.air xcrun -sdk macosx metallib shaders/shaders.air -o shaders/shaders.metallib The -frecord-sources allow me to see the source when debugging and profiling a Metal frame. Now with DXC we have a similar option, I can compile a typical HLSL shader with embedded debug symbols with: dxc -T vs_6_0 -E VSMain shaders/triangle.hlsl -Fo shaders/triangle.dxil -Zi -O0 -Qembed_debug The important options here are ’-Zi` and ’-Qembed_debug’, as they make sure debug symbols are embedded in the DXIL. It seems that right now Metal Shader Converter doesn’t pass through the DXIL debug information, and I was wondering if it was possible. I’ve looked at all the options in the utility and haven’t seen anything that looked like it. Right now debug symbols in my shaders is a must-have both for profiling and debugging. For reference an alternative pipeline would be to use spir-v cross instead. For reference here's what a typical pipeline with dxc and spir-v cross look like: HLSL -> SPIRV -> AIR -> METALLIB dxc -T ps_6_0 -E PSMain -spirv shaders/triangle.hlsl -Zi -Qembed_debug -O0 -Fo shaders/triangle.frag.spirv spirv-cross --msl shaders/triangle.frag.spirv --output shaders/triangle.frag.metal xcrun -sdk macosx metal -c -frecord-sources shaders/triangle.frag.metal -o shaders/triangle.frag.air xcrun -sdk macosx metallib shaders/triangle.frag.air -o shaders/triangle.frag.metallib As you can see, it's a lot more steps than metal shader converter, but after all those steps you can get some sort of shader symbols in xcode when debugging a metal frame, which is better than nothing: Please let me know if I can provide files, projects or anything that can help supporting shader symbols directly with metal shader converter. Thank you for your time!
Posted
by jmbn.
Last updated
.
Post not yet marked as solved
1 Replies
661 Views
So I have been working on using the new Metal Shader Converter to create a graphics abstraction between D3D12 and Metal. One thing I cannot wrap my head around is how someone would do bindless buffers in Metal. Take this for example... the metal shader converter easily converts this code into Metal `ByteAdressBuffer bindless_buffers[] : register(space1); v2f vertMain(vertIn in){ Mesh m = bindless_buffers[1].Load(0); v2f out; out.pos = in.pos * m.pos; return out;` And using the new Shader Converter one can easily create a DescriptorTable from a root signature that holds this unbounded array of ByteAdressBuffers. But when you try to fill an argument buffer using the DescriptorTableEntry struct, it looks like you can only place one resource at a time and cannot even access the array in the descriptor. For textures this is okay because you can supply a MTLTexture that holds other textures. But you can't have a MTLBuffer hold different kinds of buffers. Is it possible to do this ByteAdressBuffer style of full bindless in Metal? The shader converter allows it but I don't know how to get the API to supply the shaders with the correct data... Any Help would be GREATLY appreciated and all the work I do will be posted online for others to learn about using Metal :)
Posted Last updated
.