···11+/*
22+ This file is part of Darling.
33+44+ Copyright (C) 2020 Lubos Dolezel
55+66+ Darling is free software: you can redistribute it and/or modify
77+ it under the terms of the GNU General Public License as published by
88+ the Free Software Foundation, either version 3 of the License, or
99+ (at your option) any later version.
1010+1111+ Darling is distributed in the hope that it will be useful,
1212+ but WITHOUT ANY WARRANTY; without even the implied warranty of
1313+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414+ GNU General Public License for more details.
1515+1616+ You should have received a copy of the GNU General Public License
1717+ along with Darling. If not, see <http://www.gnu.org/licenses/>.
1818+*/
1919+2020+#ifndef SIMD_H
2121+#define SIMD_H
2222+2323+#include <simd/vector_make.h>
2424+#include <simd/vector_types.h>
2525+2626+#endif
+33
src/simd/include/simd/vector_make.h
···11+/*
22+ This file is part of Darling.
33+44+ Copyright (C) 2020 Lubos Dolezel
55+66+ Darling is free software: you can redistribute it and/or modify
77+ it under the terms of the GNU General Public License as published by
88+ the Free Software Foundation, either version 3 of the License, or
99+ (at your option) any later version.
1010+1111+ Darling is distributed in the hope that it will be useful,
1212+ but WITHOUT ANY WARRANTY; without even the implied warranty of
1313+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414+ GNU General Public License for more details.
1515+1616+ You should have received a copy of the GNU General Public License
1717+ along with Darling. If not, see <http://www.gnu.org/licenses/>.
1818+*/
1919+2020+#ifndef VECTOR_MAKE_H
2121+#define VECTOR_MAKE_H
2222+2323+#include <simd/vector_types.h>
2424+2525+inline simd_float3 simd_make_float3(float x, float y, float z) {
2626+ return (simd_float3){x, y, z};
2727+}
2828+2929+inline simd_uint2 simd_make_uint2(unsigned int x, unsigned int y) {
3030+ return (simd_uint2){x, y};
3131+}
3232+3333+#endif
+78
src/simd/include/simd/vector_types.h
···11+/*
22+ This file is part of Darling.
33+44+ Copyright (C) 2020 Lubos Dolezel
55+66+ Darling is free software: you can redistribute it and/or modify
77+ it under the terms of the GNU General Public License as published by
88+ the Free Software Foundation, either version 3 of the License, or
99+ (at your option) any later version.
1010+1111+ Darling is distributed in the hope that it will be useful,
1212+ but WITHOUT ANY WARRANTY; without even the implied warranty of
1313+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414+ GNU General Public License for more details.
1515+1616+ You should have received a copy of the GNU General Public License
1717+ along with Darling. If not, see <http://www.gnu.org/licenses/>.
1818+*/
1919+2020+#ifndef VECTOR_TYPE_H
2121+#define VECTOR_TYPE_H
2222+2323+// typedef __attribute__((ext_vector_type())) ;
2424+#define simd_struct(NAME_TYPE, A, B) \
2525+typedef struct { \
2626+ simd_float##B columns[A]; \
2727+} simd_##NAME_TYPE##A##x##B
2828+2929+#define simd_type(TYPE, NAME_TYPE, SIZE) \
3030+typedef TYPE __attribute__((ext_vector_type(SIZE))) simd_##NAME_TYPE##SIZE
3131+3232+simd_type(int, int, 2); // simd_int2
3333+simd_type(int, int, 3); // simd_int3
3434+simd_type(int, int, 4); // simd_int4
3535+3636+simd_type(unsigned int, uint, 2); // simd_uint2
3737+simd_type(unsigned int, uint, 3); // simd_uint3
3838+simd_type(unsigned int, uint, 4); // simd_uint4
3939+4040+simd_type(float, float, 2); // simd_float2
4141+simd_type(float, float, 3); // simd_float3
4242+simd_type(float, float, 4); // simd_float4
4343+4444+simd_type(double, double, 2); // simd_double2
4545+simd_type(double, double, 3); // simd_double3
4646+simd_type(double, double, 4); // simd_double4
4747+4848+simd_struct(float, 2, 2); // simd_float2x2
4949+simd_struct(float, 3, 2); // simd_float3x2
5050+simd_struct(float, 4, 2); // simd_float4x2
5151+simd_struct(float, 2, 3); // simd_float2x3
5252+simd_struct(float, 3, 3); // simd_float3x3
5353+simd_struct(float, 4, 3); // simd_float4x3
5454+simd_struct(float, 2, 4); // simd_float2x4
5555+simd_struct(float, 3, 4); // simd_float3x4
5656+simd_struct(float, 4, 4); // simd_float4x4
5757+5858+simd_struct(double, 2, 2); // simd_double2x2
5959+simd_struct(double, 3, 2); // simd_double3x2
6060+simd_struct(double, 4, 2); // simd_double4x2
6161+simd_struct(double, 2, 3); // simd_double2x3
6262+simd_struct(double, 3, 3); // simd_double3x3
6363+simd_struct(double, 4, 3); // simd_double4x3
6464+simd_struct(double, 2, 4); // simd_double2x4
6565+simd_struct(double, 3, 4); // simd_double3x4
6666+simd_struct(double, 4, 4); // simd_double4x4
6767+6868+typedef struct {
6969+ simd_double4 vector;
7070+} simd_quatd;
7171+7272+typedef struct {
7373+ simd_float4 vector;
7474+} simd_quatf;
7575+7676+#undef simd_struct
7777+#undef simd_type
7878+#endif