Is there an equivalent of assert in metal? I'm looking for a way to abnormally halt a shader and indicate it ought to be debugged.
assert itself is defined ((void) 0), so that won't work. __builtin_trap() will halt execution, but there's no indication the shader was trapped other than lack of side effects of it completing.
I'm wondering if there is some "other" way to trap, like emitting an invalid instruction into the shader, or doing something the metal API validator will flag as illegal.
assert itself is defined ((void) 0), so that won't work. __builtin_trap() will halt execution, but there's no indication the shader was trapped other than lack of side effects of it completing.
I'm wondering if there is some "other" way to trap, like emitting an invalid instruction into the shader, or doing something the metal API validator will flag as illegal.
One limitation of buffer out-of-bounds, is that a buffer is not always in-scope (such as inside a math function). Adding a buffer argument for the sole purpose of trapping is not ideal.
Based on your suggestion, I am now using this pattern
which seems to trap OK without an explicit buffer. I had previously filed FB7731230 for assert.
Based on your suggestion, I am now using this pattern
Code Block device float *f = 0; *f = 12;
which seems to trap OK without an explicit buffer. I had previously filed FB7731230 for assert.