microsoft / hlsl-specs

HLSL Specifications
MIT License
125 stars 34 forks source link

`bit_cast` template #318

Open llvm-beanz opened 2 months ago

llvm-beanz commented 2 months ago

Is your feature request related to a problem? Please describe. HLSL has a bunch of different casting builtins that are all spelled differently and not templated. That makes it difficult for template code to cast to the appropriate type if the type is a template parameter.

Describe the solution you'd like It would be awesome to add a templated bit_cast operation. Such a casting operation was added as an implementation detail in:

https://github.com/llvm/llvm-project/pull/107292

I suspect we could create a similar header-implemented interface for DXC as well using type traits.

devshgraphicsprogramming commented 2 months ago

OUr implementations https://github.com/Devsh-Graphics-Programming/Nabla/blob/edd7e6242a3f07bbed957cb9d7b8778c547037be/include/nbl/builtin/hlsl/bit.hlsl#L34