-
Notifications
You must be signed in to change notification settings - Fork 67
New morton class with arithmetic and comparison operators #860
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
… on HLSL side by specializing , a bunch of morton operators
…or both cpp and hlsl
| } | ||
| }; | ||
|
|
||
| // The default version above only works for fundamental scalars, vectors and matrices. This is because you can't call `~x` unless `x` is one of the former. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then constrain the version above to only do FundamentalType
the thing which you have as a specialization you should have as the general case, and the general you should have as a specialization
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is_fundamental_v is set to is_scalar_v or void. Should we add fundamental to include concepts::Vector and concepts::Matrix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no do not change is_fundamental_v, just extend the partial specialization of unary_minus to also allow Vector and Matrix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can mark as resolved, you have the negate done correctly
| template<typename T NBL_STRUCT_CONSTRAINABLE > | ||
| struct ternary_operator | ||
| { | ||
| using type_t = T; | ||
|
|
||
| T operator()(bool condition, NBL_CONST_REF_ARG(T) lhs, NBL_CONST_REF_ARG(T) rhs) | ||
| NBL_CONSTEXPR_FUNC T operator()(NBL_CONST_REF_ARG(bool) condition, NBL_CONST_REF_ARG(T) lhs, NBL_CONST_REF_ARG(T) rhs) | ||
| { | ||
| return select<bool, T>(condition, lhs, rhs); | ||
| } | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm actually I noticed something, in C++ and HLSL the ? shortcircuits (whereas select shouldn't)
This means that ternary_operator can only be defined as
template<typename F1, typename F2> requires is_same_v<decltype(std::declval<F1>()()),decltype(std::declval<F2>()())>
struct ternary_operator
{
using type_t = decltype(std::declval<F1>().operator());
NBL_CONSTEXPR_FUNC type_t operator()(const bool condition, NBL_CONST_REF_ARG(F1) lhs, NBL_CONST_REF_ARG(F2) rhs)
{
if (condition)
return lhs();
else
return rhs();
}
};simply to take lambdas and short-circuit (not call/evaluate the branch that is false)
so sorry about telling you to reimplement ternary_operator in terms of select
(but most ccrrent uses of ternary_operator should be replaced with select)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Nabla itself there should only be this, which needs to change to select_helper partial spec
Nabla/include/nbl/builtin/hlsl/complex.hlsl
Line 440 in 407051c
| struct ternary_operator< complex_t<Scalar> > |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the example the ternary should be replaced with select
https://github.com/search?q=repo%3ADevsh-Graphics-Programming%2FNabla-Examples-and-Tests%20ternary_operator%20&type=code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. I cannot find the complex_t specialization of ternary_operator
| #define NBL_CONSTEXPR_OOL_MEMBER const | ||
| #define NBL_CONSTEXPR_INLINE_OOL_MEMBER const | ||
| #define NBL_IF_CONSTEXPR(...) if (__VA_ARGS__) | ||
| #define NBL_ASSERT(...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wel aready have a shader assert somwhere, it does a vk::RawBufferStore to an invalid (0) BDA
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See its actually here:
Nabla/include/nbl/builtin/hlsl/macros.h
Line 13 in 1e637c4
| #define assert(...) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so remove NBL_ASSERT
Description
Adds a new class for 2,3 and 4-dimensional morton codes, with arithmetic and comparison operators
Testing
TODO
TODO list:
Need to make sure all operators work properly before merging