Skip to content
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

Maths for HLSL BxDFs (template cmath, tgmath) #803

Open
wants to merge 54 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
9cac1c9
moved math changes over
keptsecret Dec 16, 2024
8de3ce4
rsqrt not from stl
keptsecret Dec 16, 2024
aa0748e
fix example conflict
keptsecret Dec 16, 2024
b33aaed
moved math funcs to tgmath
keptsecret Dec 16, 2024
dda71b8
some needed math funcs
keptsecret Dec 16, 2024
0b46b67
some more math funcs
keptsecret Dec 16, 2024
acadc15
Merge remote-tracking branch 'origin/cpp_compat_intrinsics_refactor' …
keptsecret Dec 17, 2024
a5d48de
fixed cpp compat types
keptsecret Dec 17, 2024
0064f57
Added ieee754.hlsl and improved intrinsics.hlsl
Przemog1 Dec 18, 2024
89f37f8
Merge branch 'master' into maths_for_bxdfs_hlsl
keptsecret Dec 19, 2024
28427b5
some cpp compat fixes
keptsecret Dec 19, 2024
8e957ce
Merge branch 'master' of https://github.com/Devsh-Graphics-Programmin…
Przemog1 Dec 19, 2024
86cabe4
Improved mul function
Przemog1 Dec 19, 2024
0770eb9
isinf and isnan workaround
Przemog1 Dec 19, 2024
6690cf8
Merge branch 'master' into maths_for_bxdfs_hlsl
keptsecret Dec 20, 2024
a517d22
review changes
keptsecret Dec 20, 2024
911d8fc
use templated glm methods
keptsecret Dec 20, 2024
14e1010
reverted changes, use glm
keptsecret Dec 20, 2024
fb7b643
Updated examples
Przemog1 Dec 20, 2024
845707c
Added tgmath.hlsl
Przemog1 Dec 20, 2024
3f1db30
Moved some functions to tgmath.hlsl
Przemog1 Dec 20, 2024
f0c217f
Resolved conflicts, merged cpp_intrinsics_improvements
Przemog1 Dec 20, 2024
7e1edae
Updated examples
Przemog1 Dec 20, 2024
5fd3934
Added constraints to the `floor` function
Przemog1 Dec 20, 2024
2f38f2a
Refactor
Przemog1 Dec 20, 2024
7e73054
Refactored the `floor` function
Przemog1 Dec 21, 2024
0276f8e
`Floor` func improvement
Przemog1 Dec 21, 2024
4d0d477
Resolved conflicts, merged master
Przemog1 Dec 21, 2024
147c080
Added negate and copy sign functions
Przemog1 Dec 21, 2024
a640976
Moved flipSign function to ieee754.hlsl
Przemog1 Dec 21, 2024
70f2870
Fixed bitcount, added normalize
Przemog1 Dec 23, 2024
9dc8b43
Refactored `hlsl::cross` function
Przemog1 Dec 23, 2024
677b176
Refactor
Przemog1 Dec 23, 2024
949a972
fix
Przemog1 Dec 23, 2024
04f60ab
fix refract functions
keptsecret Dec 26, 2024
6fecfa9
Now every tgmath function utilize helpers
Przemog1 Dec 28, 2024
abf6ed7
Merge branch 'maths_for_bxdfs_hlsl' of https://github.com/Devsh-Graph…
Przemog1 Dec 28, 2024
0d5ede1
Resolved conflicts, merged master
Przemog1 Dec 28, 2024
19c30e5
Fixed NBL_IMPL_CONCEPT_REQ_EXPR_RET_TYPE
Przemog1 Dec 30, 2024
2e56fc9
Added Vector and Matrix concepts
Przemog1 Dec 30, 2024
f99ad10
Added `all` and `any`
Przemog1 Dec 30, 2024
9a8842d
fix cmakelist duplicate entry, float literal
keptsecret Jan 3, 2025
274e56f
Integrated concepts into tgmath.hlsl and intrinsics.hlsl
Przemog1 Jan 3, 2025
e3bf45a
Merge branch 'maths_for_bxdfs_hlsl' of https://github.com/Devsh-Graph…
Przemog1 Jan 3, 2025
6a2bcff
Added `FloatingPointLike` concept
Przemog1 Jan 3, 2025
9a44ce8
Refactored concepts
Przemog1 Jan 7, 2025
5eb02f2
Corrections
Przemog1 Jan 7, 2025
2fb8252
Removed float64_t partial specializations
Przemog1 Jan 8, 2025
96efff4
fix frisvad mat, lp_norm loop
keptsecret Jan 9, 2025
4c0536f
Integrated concepts into intrinsics.hlsl functions and fixed some emu…
Przemog1 Jan 10, 2025
76fbce1
Merge branch 'maths_for_bxdfs_hlsl' of https://github.com/Devsh-Graph…
Przemog1 Jan 10, 2025
18c3257
removed dupe xoroshiro.hlsl
keptsecret Jan 14, 2025
c0531fb
fix length_helper
keptsecret Jan 14, 2025
bf8b628
update example conflict
keptsecret Jan 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples_tests
Submodule examples_tests updated 0 files
11 changes: 9 additions & 2 deletions include/nbl/builtin/hlsl/math/functions.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,8 @@ bool partitionRandVariable(float leftProb, NBL_REF_ARG(float) xi, NBL_REF_ARG(fl
#ifdef __HLSL_VERSION
NBL_CONSTEXPR float NEXT_ULP_AFTER_UNITY = asfloat(0x3f800001u);
#else
NBL_CONSTEXPR uint32_t val = 0x3f800001u;
NBL_CONSTEXPR float32_t NEXT_ULP_AFTER_UNITY = reinterpret_cast<float32_t &>( val );
uint32_t val = 0x3f800001u;
float32_t NEXT_ULP_AFTER_UNITY = reinterpret_cast<float32_t &>( val );
devshgraphicsprogramming marked this conversation as resolved.
Show resolved Hide resolved
#endif
const bool pickRight = xi >= leftProb * NEXT_ULP_AFTER_UNITY;

Expand Down Expand Up @@ -366,7 +366,14 @@ struct bitFields // need template?

uint32_t __overwrite()
{
#ifdef __HLSL_VERSION
return spirv::bitFieldInsert<uint32_t>(base, value, offset, count);
#else
// TODO: double check implementation
const uint32_t shifted_masked_value = ~(0xffffffffu << count) << offset;
base &= ~shifted_masked_value;
return base | (value << offset);
#endif
devshgraphicsprogramming marked this conversation as resolved.
Show resolved Hide resolved
}

uint32_t base;
Expand Down
14 changes: 7 additions & 7 deletions include/nbl/builtin/hlsl/tgmath.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ template<typename T>
inline T floor(NBL_CONST_REF_ARG(T) val)
{
#ifdef __HLSL_VERSION
return spirv::floor(val);
return spirv::floor<T>(val);
#else
return glm::floor(val);
devshgraphicsprogramming marked this conversation as resolved.
Show resolved Hide resolved
#endif
Expand All @@ -105,7 +105,7 @@ template<typename FloatingPoint>
inline FloatingPoint isnan(NBL_CONST_REF_ARG(FloatingPoint) val)
{
#ifdef __HLSL_VERSION
return spirv::isNan(val);
return spirv::isNan<T>(val);
#else
return std::isnan(val);
#endif
Expand All @@ -115,7 +115,7 @@ template<typename FloatingPoint>
inline FloatingPoint isinf(NBL_CONST_REF_ARG(FloatingPoint) val)
{
#ifdef __HLSL_VERSION
return spirv::isInf(val);
return spirv::isInf<T>(val);
#else
return std::isinf(val);
#endif
Expand All @@ -125,7 +125,7 @@ template<typename T>
inline T pow(NBL_CONST_REF_ARG(T) x, NBL_CONST_REF_ARG(T) y)
{
#ifdef __HLSL_VERSION
return spirv::pow(x, y);
return spirv::pow<T>(x, y);
#else
return std::pow(x, y);
#endif
Expand All @@ -135,7 +135,7 @@ template<typename T>
inline T exp(NBL_CONST_REF_ARG(T) val)
{
#ifdef __HLSL_VERSION
return spirv::exp(val);
return spirv::exp<T>(val);
#else
return std::exp(val);
#endif
Expand All @@ -145,7 +145,7 @@ template<typename T>
inline T exp2(NBL_CONST_REF_ARG(T) val)
{
#ifdef __HLSL_VERSION
return spirv::exp2(val);
return spirv::exp2<T>(val);
#else
return std::exp2(val);
#endif
Expand All @@ -169,7 +169,7 @@ template<typename T>
inline T log(NBL_CONST_REF_ARG(T) val)
{
#ifdef __HLSL_VERSION
return spirv::log(val);
return spirv::log<T>(val);
#else
return std::log(val);
#endif
Expand Down