mirror of
https://github.com/g-truc/glm.git
synced 2024-11-29 11:24:35 +00:00
constexpr simd vec: fix more runtime issues
This commit is contained in:
parent
f0b305ce43
commit
d950f21404
@ -3,8 +3,10 @@
|
|||||||
namespace glm::detail
|
namespace glm::detail
|
||||||
{
|
{
|
||||||
consteval bool NotEmpty(length_t I, length_t L) { return I <= L; }
|
consteval bool NotEmpty(length_t I, length_t L) { return I <= L; }
|
||||||
template <bool IsEmpty, typename T, length_t I, length_t L>
|
template <bool IsNotEmpty, typename T, length_t I, length_t L>
|
||||||
struct Element
|
struct Element;
|
||||||
|
template <typename T, length_t I, length_t L> requires (!NotEmpty(I, L))
|
||||||
|
struct Element<false, T, I, L>
|
||||||
{
|
{
|
||||||
constexpr operator auto() {
|
constexpr operator auto() {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -189,17 +189,18 @@ namespace glm
|
|||||||
|
|
||||||
// -- Data --
|
// -- Data --
|
||||||
#define GLM_N [[no_unique_address]]
|
#define GLM_N [[no_unique_address]]
|
||||||
|
#define GLM_MA __attribute__((__may_alias__))
|
||||||
template <length_t I>
|
template <length_t I>
|
||||||
using E = detail::Element<detail::NotEmpty(I,L),T,I,L>;
|
using E = detail::Element<detail::NotEmpty(I,L),T,I,L>;
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
struct {
|
GLM_MA struct {
|
||||||
union { T x, r, s; };
|
union { T x, r, s; };
|
||||||
GLM_N union { GLM_N E<2> y; GLM_N E<2> g; GLM_N E<2> t; };
|
union { GLM_N E<2> y GLM_MA; GLM_N E<2> g; GLM_N E<2> t; };
|
||||||
GLM_N union { GLM_N E<3> z; GLM_N E<3> b; GLM_N E<3> p; };
|
union { GLM_N E<3> z GLM_MA; GLM_N E<3> b; GLM_N E<3> p; };
|
||||||
GLM_N union { GLM_N E<4> w; GLM_N E<4> a; GLM_N E<4> q; };
|
union { GLM_N E<4> w GLM_MA; GLM_N E<4> a; GLM_N E<4> q; };
|
||||||
};
|
};
|
||||||
data_t data;
|
GLM_MA data_t data;
|
||||||
};
|
};
|
||||||
#undef GLM_N
|
#undef GLM_N
|
||||||
# if GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR
|
# if GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR
|
||||||
|
@ -31,7 +31,8 @@ int main()
|
|||||||
v1.x;
|
v1.x;
|
||||||
avec4 vfin = glm::max(v1, v2) + v3;
|
avec4 vfin = glm::max(v1, v2) + v3;
|
||||||
static_assert(sizeof(vfin)>0);
|
static_assert(sizeof(vfin)>0);
|
||||||
|
double w = v3.w;
|
||||||
printf("vfin = %f %f %f %f\n", vfin[0], vfin[1], vfin[2], vfin[3]);
|
printf("vfin = %f %f %f %f\n", vfin[0], vfin[1], vfin[2], vfin[3]);
|
||||||
printf("v3 = %f %f %f %f\n", v3[0], v3[1], v3[2], v3[3]);
|
printf("v3 = %f %f %f %f\n", v3[0], v3[1], v3.y, w);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user