Closed
Description
Here's a little reproducer:
// compile with:
// slangc -target exe -g -O0 testDeterminant.slang -o testDeterminant &&./ testDeterminant
// slangc -target cpp -g -O0 testDeterminant.slang -o testDeterminant .cpp
export __extern_cpp int main(int argc, NativeString *argv)
{
float3x3 test;
test[0] = float3(42.f, 0.f, 0.f);
test[1] = float3(0.f, 42.f, 0.f);
test[2] = float3(0.f, 0.f, 42.f);
float det = determinant(test);
printf("Determinant is: %f\n", det);
return 0;
}
With -target exe
, the compiler throws a core dump:
gcc 13.3: /tmp/unknown-dRCsn9.cpp(26): warning : #pragma once in main file
26 | #pragma once
| ^~~~
gcc 13.3: /tmp/unknown-dRCsn9.cpp(2261): warning : #pragma once in main file
2261 | #pragma once
| ^~~~
gcc 13.3: /tmp/unknown-dRCsn9.cpp(10098): warning : #pragma once in main file
10098 | #pragma once
| ^~~~
gcc 13.3: hlsl.meta.slang(8556): warning : no return statement in function returning non-void [-Wreturn-type]
Illegal instruction (core dumped)
And when I look at the generated c++ code, the determinant is empty, doesn't return a float when it should, resulting in undefined behavior.
#line 10 "testDeterminant.slang"
struct Tuple_0
{
float value0_0;
};
#line 8556 "hlsl.meta.slang"
static float determinant_0(Matrix<float, 3, 3> m_0)
{
#line 8556
}
#line 3 "testDeterminant.slang"
int32_t main(int32_t argc_0, const char* * argv_0)
{
Matrix<float, 3, 3> test_0;
Vector<float, 3> _S1 = Vector<float, 3> (42.0f, 0.0f, 0.0f);
#line 6
test_0[int(0)] = _S1;
Vector<float, 3> _S2 = Vector<float, 3> (0.0f, 42.0f, 0.0f);
#line 7
test_0[int(1)] = _S2;
Vector<float, 3> _S3 = Vector<float, 3> (0.0f, 0.0f, 42.0f);
#line 8
test_0[int(2)] = _S3;
float det_0 = determinant_0(test_0);
Tuple_0 _S4 = { det_0 };
#line 11
printf("Determinant is: %f\n", det_0);
return int(0);
}
with -target cuda
, I seem to instead get a compilation error:
USER error: /printMain.slang(12): error 36107: entrypoint 'printMain' uses features that are not available in 'compute' stage for 'cuda' target.
void printMain(uint3 dispatchThreadID : SV_DispatchThreadID)
^~~~~~~~~
/user.slang(10): note: see using of 'determinant'
float det = determinant(test);
^~~~~~~~~~~
hlsl.meta.slang(8556): note: see definition of 'determinant'
hlsl.meta.slang(8555): note: see declaration of 'require'
(0): error 39999: import of module 'printMain' failed because of a compilation error
(0): fatal error 39999: compilation ceased
abort compilation: (0): fatal error 39999: compilation ceased
Metadata
Metadata
Assignees
Labels
No labels