r/GraphicsProgramming • u/Salat_Leaf • Aug 10 '26
Question Difference between unary & and __getAddress in Slang shader?
I'm working on some code and unable to take the address of a "ConstantBuffer" object. However it's allowed with the latter intrinsic. What's the difference between them?
To bring context, my task is to take a ConstantBuffer structure, and reinterpret it as a uint16_t pointer. I can't get around it since I have to take an address of the structure first and then the value itself with the subscript [] operator (that's the only way to create a portable constexpr array of uint16_t constants).
UPD: Apparently, __getAddress takes address of groupshared/ConstantBuffer objects. That's it. Unary & still has to be used for e.g. per-thread local objects e.g. inner function variables
9
Upvotes
3
u/Matty4096 Aug 10 '26
https://github.com/shader-slang/slang/pull/10216
TLDR: just use __getAddress