DirectXShaderCompiler
DirectXShaderCompiler copied to clipboard
Support built-in offsetof macro
We should consider supporting offsetof in the future. Since this normally requires stddef.h/cstddef, we should consider adding built-in version under hlsl namespace with default/auto using namespace hlsl;
when compiling hlsl source.
Separating this issue from the sizeof issue #1291 to allow independent resolution.
Offsetof is a macro in C/C++ and it's not expressible as a normal function, so I'm not sure it could even live in a namespace.
I'm going to give up ownership of this issue as I'm not actively working on it.
With the new addition of templated loads in ByteAddressBuffer this would be a huge win 😊
Came looking for this so I guess +1 from me, for the same reason Jasper listed.
Hi! Are there any news, by any chance? :) I've tried it on a recent build from the main branch, and the error I'm getting from
offsetof(SimpleStruct, uintValue)
says 'SimpleStruct' does not refer to a value
, so it looks like the macro itself is recognized by dxc, but still doesn't work?
+1, would love to have this :)
Is there any update? In sight of RWStructuredBuffers not beeing supported in array bindings for spirv output, the only real alternative is RWByteAdressBuffer for vulkan users in a bindless model. Without offsetof writing and reading individual fields of a struct becomes very error prone and ugly, as one needs to define the offsets to struct members manually.
I'll add my voice to this request as well.
+1
metoo
+1
+1 Would be super helpful when dealing with ByteAddressBuffer
+1
I'm trying to make my own BDA pointer and reference structs (because I'm impatient) and offsetof
is one of the things I'm missing.
https://github.com/microsoft/hlsl-specs/pull/59#issuecomment-1693661117
and one of the things that's blocking me is the lack of decltype
and offsetof
, but offsetof
far more.
btw __builtin_offsetof
seems to be a reserved keyword in DXC, so we could have a "compiler instrinsic" like in GCC