/
redgpu
/
ispc
Обзор
Документация
Войти
/
redgpu
/
ispc
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
tests/lit-tests/func_template_7.ispc
26 строк
927 B
Dmitry Babokin
Add more tests
28 фев 2023, 09:01
28 фев 2023, 09:01
9e9d427
Код
Авторство
О чём код?
// Check that operator overloading kicks-in for template parameter arguments. // If it doesn't, the test will crash, because type check will alarm binary operation on non-atomic types. // RUN: %{ispc} %s --nostdlib --target=host -o %t.o struct S { float<4> V; }; inline uniform S operator+(const uniform S &A, const uniform S &B) { varying float S0, S1, Result; *((uniform S * uniform) & S0) = *((uniform S * uniform) & A); *((uniform S * uniform) & S1) = *((uniform S * uniform) & B); Result = S0 + S1; return *((uniform S * uniform) & Result); } template <typename T> inline T VectorAdd(const T &A, const T &B) { return A + B; } export void Add(uniform float A[], uniform float B[], uniform float C[], uniform int i) { const uniform S Vb = *((uniform S * uniform) & B[i]); const uniform S Vc = *((uniform S * uniform) & C[i]); *((uniform S * uniform) & A[i]) = VectorAdd(Vb, Vc); }