-
Notifications
You must be signed in to change notification settings - Fork 51
Add 8-bit integers back. #538
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
Open
Anteru
wants to merge
6
commits into
microsoft:main
Choose a base branch
from
Anteru:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+81
−0
Open
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a5d8301
First stab at 8-bit types.
Anteru 83e6e35
Add list of supported elementwise operations.
Anteru 8bb446f
Address first round of review feedback.
Anteru 482329e
Rename file, target SM 6.x.
Anteru e0c93c7
Update proposals/NNNN-8-bit-integers.md
Anteru 25459a3
Address review feedback.
Anteru File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| --- | ||
| title: NNNN - 8-bit integer support | ||
| params: | ||
| authors: | ||
| - anteru: Matthäus Chajdas | ||
| sponsors: | ||
| - llvm-beanz: Chris Bieneman | ||
| status: Under Consideration | ||
| --- | ||
|
|
||
| * Planned Version: SM 6.x | ||
| * Issues: [HLSL 337](https://github.com/microsoft/hlsl-specs/issues/337) | ||
|
|
||
| ## Introduction | ||
|
|
||
| This proposal introduces 8-bit integer types to HLSL, to align it more closely with C/C++ and other languages, and allow tight interop with the 8-bit types used in the cooperative vector proposal. | ||
damyanp marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Motivation | ||
|
|
||
| 8-bit types are very special in HLSL as they only exist for some arithmetic instructions, but aren't generally accessible. For example, cooperative vectors allow inputs to be specified as 8-bit quantities, but only by packing them into 32-bit. This is cumbersome if for example an application needs to modify the values before passing in, for example, to add a bias -- the application is now forced to unpack the value, modify it, and pack it back in. | ||
|
|
||
| ## Proposed solution | ||
|
|
||
| Introduce two new, native types: | ||
|
|
||
| * `uint8_t`: 8-bit unsigned integer | ||
| * `int8_t`: 8-bit signed integer | ||
|
|
||
| For support and conversion rules, those new types would match the [16-bit scalar types](https://github.com/microsoft/DirectXShaderCompiler/wiki/16-Bit-Scalar-Types), that is, new `uint8_t`. | ||
|
|
||
| ### DXIL changes | ||
|
|
||
| [DXIL](https://github.com/microsoft/DirectXShaderCompiler/blob/main/docs/DXIL.rst) mentions under [Primitive types](https://github.com/microsoft/DirectXShaderCompiler/blob/main/docs/DXIL.rst#primitive-types) that `i8` is supported only for limited operations. With this proposal: `i8` gets supported for computation by shader. For memory access, we'd only support loading multiples of 4 `i8`. | ||
|
|
||
| DXIL/LLVM IR doesn't discern between `i8` and `u8`, so during lowering, we need to restrict/select between the `I` and `U` instructions. | ||
|
|
||
| For the elementwise overloads defined in [DXIL vectors](0030-dxil-vectors.md), the following subset would be supported: | ||
|
|
||
| | Opcode | Name | Class | Note | | ||
| | ------ | -------------- | -------- | ---- | | ||
| | 30 | Bfrev | Unary | See note | | ||
| | 31 | Countbits | UnaryBits | | | ||
| | 32 | FirstBitLo | UnaryBits | | | ||
| | 33 | FirstBitHi | UnaryBits | | | ||
| | 34 | FirstBitSHi | UnaryBits | | | ||
| | 37 | IMax | Binary | `i8` only | | ||
| | 38 | IMin | Binary | `i8` only | | ||
| | 39 | UMax | Binary | `u8` only | | ||
| | 40 | UMin | Binary | `u8` only | | ||
| | 48 | IMad | Tertiary | `i8` only | | ||
| | 49 | UMad | Tertiary | `u8` only | | ||
| | 115 | WaveActiveAllEqual | WaveActiveAllEqual | | | ||
| | 117 | WaveReadLaneAt | WaveReadLaneAt | | | ||
| | 118 | WaveReadLaneFirst | WaveReadLaneFirst | | | ||
| | 119 | WaveActiveOp | WaveActiveOp | | | ||
| | 120 | WaveActiveBit | WaveActiveBit | | | ||
| | 121 | WavePrefixOp | WavePrefixOp | | | ||
| | 122 | QuadReadLaneAt | QuadReadLaneAt | | | ||
| | 123 | QuadOp | QuadOp | | | ||
| | 165 | WaveMatch | WaveMatch | | | ||
|
|
||
| TODO: Do we really need `Bfrev`? | ||
|
|
||
| ### SPIR-V changes | ||
|
|
||
| SPIR-V already supports 8-bit integers. | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.