[SM6.10] Add BFloat16 Support - #8734
Conversation
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
There was a problem hiding this comment.
Pull request overview
Adds BFloat16 support to the Shader Model 6.10 LinAlg API and DXIL validation.
Changes:
- Defines and exposes the BFloat16 component type.
- Adds packed two-per-
uinttype traits. - Allows BFloat16 matrices in validation and serialization.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
include/dxc/DXIL/DxilConstants.h |
Defines the DXIL component value. |
include/dxc/DxilContainer/RDAT_LibraryTypes.inl |
Adds RDAT enum serialization. |
lib/DxilValidation/DxilValidation.cpp |
Permits BFloat16 LinAlg matrices. |
lib/DxilValidation/DxilValidationUtils.cpp |
Formats the component name. |
tools/clang/lib/Headers/hlsl/dx/linalg.h |
Exposes BFloat16 and its packing traits. |
tools/clang/lib/Sema/SemaHLSL.cpp |
Adds Sema string conversion. |
tools/clang/test/LitDXILValidation/LinAlgMatrix/linalgmatrix-illegal-component-type.ll |
Verifies validator acceptance. |
Suppressed comments (1)
tools/clang/lib/Headers/hlsl/dx/linalg.h:143
- Marking BFloat16 as non-native invalidates the
Matrixclass comment at lines 241-242, which says every non-native scalar is an 8-bit type with four elements per scalar. Update that comment to describe packed component types generically (or explicitly include the two-BFloat16 case) so it matches this specialization.
static const bool IsNativeScalar = false;
static const uint ElementsPerScalar = 2;
| PackedU8x32 = 18, | ||
|
|
||
| // BEGIN NEW FOR SM 6.10 | ||
| // BEGIN NEW FOR SM 6.9 |
There was a problem hiding this comment.
We didn't ship linalg.h for SM 6.9 did we?
There was a problem hiding this comment.
Nope, but we shipped the type in DxilConstants.h in SM6.9!
I updated this here because the header says this type needs to exactly match the DxilConstants.h type
There was a problem hiding this comment.
We could update the type in DxilConstants.h to say "new for 6.10" which would be fine by me but not wholly accurate (I don't think the new types could actually be used for anything even though they are published in 6.9)
d254c93 to
1287f83
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.
Suppressed comments (1)
include/dxc/DXIL/DxilConstants.h:203
- This adds a user-visible Shader Model 6.10 feature, so it needs an entry under Experimental Shader Model 6.10 in
docs/ReleaseNotes.mdper the release-note policy inCONTRIBUTING.md. Please add the release note (or point to the related PR that will provide the shared coverage).
BFloat16 = 23,
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.
Suppressed comments (2)
docs/ReleaseNotes.md:45
- BFloat16 is gated to experimental SM 6.10, but this entry is under
Upcoming Release, which makes it appear to ship in the next non-preview release. Move it underUpcoming Preview Release→Experimental Shader Model 6.10(and match the surrounding past-tense, period-terminated style).
#### LinAlg Matrix
- Adds `BFloat16` to the ComponentType enum in DxilConstants and the linalg
header [#8722](https://github.com/microsoft/DirectXShaderCompiler/issues/8722)
tools/clang/lib/Headers/hlsl/dx/linalg.h:143
- This specialization makes a non-native component contain two values per scalar, so the
Matrixcomment at lines 241–242 (“we have an 8-bit type” and “4 elements”) is now false for BFloat16. Please generalize that comment to describe packed/non-native component types and useElementsPerScalarrather than asserting the 8-bit layout.
template <> struct ComponentTypeTraits<ComponentType::BFloat16> {
using Type = uint;
static const bool IsNativeScalar = false;
static const uint ElementsPerScalar = 2;
Fixes #8722
microsoft/hlsl-specs#907 added
BFloat16as an allowed ComponentType in the LinAlg API. This PR adds support for it to the implementation.