c7ce92a95b
Some Metal devices have a bug where `simd_is_helper_thread()` won't return true after a fragment has been discarded. We can work around this by manually setting `gl_HelperInvocation` upon discarding a fragment. This is fairly unintrusive, so it is enabled by default. I've made it an option so that, when the bug is fixed, we can disable it.
29 lines
599 B
JavaScript
29 lines
599 B
JavaScript
#pragma clang diagnostic ignored "-Wmissing-prototypes"
|
|
|
|
#include <metal_stdlib>
|
|
#include <simd/simd.h>
|
|
|
|
using namespace metal;
|
|
|
|
static inline __attribute__((always_inline))
|
|
void foo(thread bool& gl_HelperInvocation)
|
|
{
|
|
gl_HelperInvocation = true, discard_fragment();
|
|
}
|
|
|
|
static inline __attribute__((always_inline))
|
|
void bar(thread bool& gl_HelperInvocation)
|
|
{
|
|
bool _13 = gl_HelperInvocation;
|
|
bool helper = _13;
|
|
}
|
|
|
|
fragment void main0()
|
|
{
|
|
bool gl_HelperInvocation = {};
|
|
gl_HelperInvocation = simd_is_helper_thread();
|
|
foo(gl_HelperInvocation);
|
|
bar(gl_HelperInvocation);
|
|
}
|
|
|