microsoft / hlsl-specs

HLSL Specifications
MIT License
121 stars 33 forks source link

[0003] Numeric Constants - Detailed Design #227

Open llvm-beanz opened 5 months ago

llvm-beanz commented 5 months ago

Which proposal does this relate to? 0003 - Numeric Constants

Describe the issue or outstanding question. This feature needs a completed detailed design. Since this feature implements a replacement for a non-conformant HLSL language feature that we may not want to implement in Clang, it would be nice to get this feature into HLSL 202x so that users can adopt the new feature in DXC before transitioning to Clang.

Additional Context I did some experimentation in Clang and came up with these two source files as a proof of concept for a Clang header-based implementation:

hlsl_limits.h.txt hlsl_type_traits.h.txt

devshgraphicsprogramming commented 4 months ago

you'd have to actually provide a constexpr for functions as well,

My own numeric traits define the members as static const variables simply so I can feed them into templates later ( numeric_limits with int types)

devshgraphicsprogramming commented 4 months ago

Also I'm happy to donate whatever parts of my own type_traits you'd find useful https://github.com/Devsh-Graphics-Programming/Nabla/blob/923c1c56168a4a316094c25a9369527d5ae48c24/include/nbl/builtin/hlsl/type_traits.hlsl

Dont mind the macros at the end, they're just copium for working around the lack of alignof and typeid