Skip to content

Add int8_t / uint8_t to the language #337

@AdamJMiles

Description

@AdamJMiles

Hi,

While this may/may not come naturally with other endeavours in the land of HLSL, I'd like to keep this on the radar.

HLSL currently lacks an 8-bit datatype both for arithmetic and for storage. The primary motivation for having an 8-bit datatype is not for general-purpose arithmetic, but rather:

  1. Support storage of smaller types in structures (e.g. StructuredBuffer) and in groupshared memory where space is always at a premium.
  2. Ease the sharing of code between C/C++ and HLSL.

It's very difficult to safely load, store and manipulate 8-bit datatypes in groupshared memory without resorting to bitwise operations, masking and even atomics to affect only a single byte of a uint16_t or uint type. CUDA supports char and unsigned char datatypes in its language.

Whether the 8-bit datatypes have any operators (such as +, -, /, * etc) depends on what the level of support for that is in the ecosystem, but Load/Store is the primary motivator here.

Thanks,

Adam

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    Status

    Triaged

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions