Open Ravbug opened 2 years ago
I am experiencing the same issue on my MacBook Air M1, which supports Metal 3.
I was wondering if there is a way to specify the Metal version for shader compilation using shaderc
, as it currently defaults to version 1.0. In my application, I rely on gl_PrimitiveID
, so setting the target version to 2 would be sufficient for my requirements.
I have searched through the documentation, as well as other related issues and Discord channels, but I couldn't find any information on how to achieve this.
Describe the bug This shader
compiled to the metal backend with the following flags results in
Abort trap: 6
:shaderc -f shader.fsh -o fragment.bin -i bgfx/src --type fragment --platform osx --varyingdef varying.def.sc --profile metal --debug
To Reproduce Steps to reproduce the behavior:
Expected behavior shaderc should print an error message containing the compile error, because this shader uses a feature (
gl_PrimitiveID
) that is not supported on the default shaderc metal version of 1.0.Additional context shaderc does not crash if the
--preprocess
flag is passed.When compiling shaderc in debug mode and attaching a debugger, the crash occurs when executing shaderc_metal.cpp:629
The error occurs inside spirv-cross (
spirv_cross_error_handling.hpp:57
):It prints
There was a compiler error: PrimitiveId on macOS requires MSL 2.2.
but only if shaderc is compiled in debug mode. In release, you only getAbort trap: 6
.One possible fix is to disable the
SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS
define, which means that even in release if shaderc crashes in spirv-cross, the error message will print:libc++abi: terminating with uncaught exception of type spirv_cross::CompilerError: PrimitiveId on macOS requires MSL 2.2.