For performance reasons I want my StructuredBuffer to contain halfs, not floats. However, I’m streaming data from the CPU to the buffer. Streaming a float array is easy, but how would you stream an array of halfs? C# does not have native halfs. Just streaming floats and setting the buffer to use halfs works on ATI 5770, but I don’t think it works on nvidia cards. Thanks for the help!
It’s totally possible, just shadow the half data using short or ushort on the C# side and make your own converter function float → ushort which converts to half precision bit layout. It’s easy: Half-precision floating-point format - Wikipedia I made a little struct which wraps the thing and looks a lot like a native type, I’m sure you’d love the code for that. But I’m leaving it as an exercise for the reader, because it’s pretty trivial.