1

I need to interleave* the bits of three unsigned integers in a GLSL program that will be compiled to SPIR-V. In C, I would use the intrinsic _pdep_u32 but I can't find something like that in the OpenGL reference. Does it exist with some other name? Alternatively, does it exist in HLSL or in raw SPIR-V? I am aware that there is a tool for converting LLVM IR to SPIR-V. Is it possible to use it to generate _pdep_u32-equivalent bytecode? Otherwise, can this behavior be implemented in some other way that is also very fast?

*That is, the bits from the 32-bit integers A, B and C must appear in the order ABCABC...etc

Marcel Pi
  • 63
  • 1
  • 7
  • 1
    I assume you are aware that `_pdep_u32` is not standard C, but a machine-specific *intrinsic* specifically for x86_64 platforms? That makes it unlikely to exist in standard GLSL or HSL, and I am not aware of anything functionally similar in those languages nor the underlying GPU hardware. – njuffa Sep 10 '20 at 18:12
  • 2
    I provided a `PDEP` emulation for CUDA in [this answer](https://stackoverflow.com/a/35881440/780717) – njuffa Sep 10 '20 at 18:14
  • Oh sorry, I focused too much on _pdep_u32 in the question when I what I actually want is the functionality. I will look into your CUDA code later. Thank you very much! :) – Marcel Pi Sep 10 '20 at 18:24
  • 2
    It's similar to [interleave the bits of 3 ints](https://stackoverflow.com/q/1024754/555045) – harold Sep 10 '20 at 19:44

0 Answers0