Skip to content

Alignof operator #159

@KStocky

Description

@KStocky

Is your feature request related to a problem? Please describe.
It used to be that every type in HLSL was 4 bytes in size. Even bools are 4 bytes. So you could assume that everything was 4 byte aligned. However, this is no longer the case. We now have types like float16_t which have an alignment of 2 and uint64_t which have an alignment of 8. This is important if we are using templated ByteAddressBuffer stores because we have to be able to align our writes. However, there is currently no way to query what a struct's alignment is, so writing generic code that makes use of byte address buffer stores is difficult. The best we can do is just align every unknown type by 8 bytes.

Describe the solution you'd like
I would like an alignof operator like in C++11 to simply query a type's alignment.

Describe alternatives you've considered
The only workaround now (that I know of) is to make all stores of unknown types be 8 byte aligned.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Triaged

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions