Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support built-in offsetof macro #257

Open
tex3d opened this issue May 10, 2019 · 14 comments
Open

Support built-in offsetof macro #257

tex3d opened this issue May 10, 2019 · 14 comments
Labels
enhancement New feature or request needs-triage
Milestone

Comments

@tex3d
Copy link
Collaborator

tex3d commented May 10, 2019

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 microsoft/DirectXShaderCompiler#1291 to allow independent resolution.

@tristanlabelle
Copy link

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.

@ehsannas
Copy link

I'm going to give up ownership of this issue as I'm not actively working on it.

@ehsannas ehsannas removed their assignment Jun 16, 2020
@Jasper-Bekkers
Copy link

With the new addition of templated loads in ByteAddressBuffer this would be a huge win 😊

@alextardif-zmi
Copy link

Came looking for this so I guess +1 from me, for the same reason Jasper listed.

@curldivergence
Copy link

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?

@jshopf
Copy link

jshopf commented Apr 5, 2022

+1, would love to have this :)

@Ipotrick
Copy link

Ipotrick commented Aug 9, 2022

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.

@SakibSaikia
Copy link

I'll add my voice to this request as well.

+1

@devshgraphicsprogramming

metoo

@manas-kulkarni
Copy link

+1

@mcbouterse
Copy link

+1 Would be super helpful when dealing with ByteAddressBuffer

@ajmiles
Copy link

ajmiles commented Jun 10, 2023

+1

@devshgraphicsprogramming

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.

#59 (comment)

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

@devshgraphicsprogramming

the SPIR-V support could be limited to only when -fvk-scalar-layout is present to reduce implementation headaches

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs-triage
Projects
Status: Triaged
Development

No branches or pull requests