Skip to content

Commit

Permalink
vcc-std: bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugobros3 committed Jul 19, 2024
1 parent 195bff9 commit 3d01cc1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
2 changes: 2 additions & 0 deletions vcc-std/include/shady.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ namespace vcc {
#define shared __attribute__((annotate("shady::extern::3")))
#define private __attribute__((annotate("shady::extern::5")))

float sqrtf(float f) __asm__("shady::prim_op::sqrt");

#if defined(__cplusplus) & !defined(SHADY_CPP_NO_NAMESPACE)
}
#endif
Expand Down
18 changes: 9 additions & 9 deletions vcc-std/include/shady_vec.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ struct vec_impl {
vec_impl(T x, T y, T z, T w) requires (len >= 4) {
this->arr[0] = x;
this->arr[1] = y;
this->arr[2] = x;
this->arr[2] = z;
this->arr[3] = w;
}

Expand All @@ -105,7 +105,7 @@ struct vec_impl {
vec_impl(T x, T y, T z) requires (len >= 3) {
this->arr[0] = x;
this->arr[1] = y;
this->arr[2] = x;
this->arr[2] = z;
}

vec_impl(vec_impl<T, 2> xy, T z) requires (len >= 3) : vec_impl(xy.x, xy.y, z) {}
Expand Down Expand Up @@ -138,7 +138,7 @@ struct vec_impl {
operator That() const requires(dst_len > 1 && fits<dst_len>(len, mapping)) {
auto src = reinterpret_cast<const This*>(this);
That dst;
for_range<0, len>([&]<auto i>(){
for_range<0, dst_len>([&]<auto i>(){
dst.arr[i] = src->arr[mapping.data[i]];
});
return dst;
Expand All @@ -150,18 +150,18 @@ struct vec_impl {
}

operator T() const requires(dst_len == 1 && fits<dst_len>(len, mapping)) {
auto src = reinterpret_cast<const T*>(this);
return *src;
auto src = reinterpret_cast<const This*>(this);
return src->arr[mapping.data[0]];
}

void operator=(const T& t) requires(dst_len == 1 && fits<dst_len>(len, mapping)) {
auto src = reinterpret_cast<T*>(this);
*src = t;
auto src = reinterpret_cast<This*>(this);
src->arr[mapping.data[0]] = t;
}

void operator=(const That& src) requires(dst_len > 1 && fits<dst_len>(len, mapping)) {
auto dst = reinterpret_cast<This*>(this);
for_range<0, len>([&]<auto i>(){
for_range<0, dst_len>([&]<auto i>(){
dst->arr[mapping.data[i]] = src.arr[i];
});
}
Expand Down Expand Up @@ -277,7 +277,7 @@ float lengthSquared(vec_impl<float, len> vec) {

template<unsigned len>
float length(vec_impl<float, len> vec) {
return __builtin_sqrtf(lengthSquared(vec));
return sqrtf(lengthSquared(vec));
}

template<unsigned len>
Expand Down

0 comments on commit 3d01cc1

Please sign in to comment.