- Notifications
You must be signed in to change notification settings - Fork 15.3k
Labels
HLSLHLSL Language SupportHLSL Language Supportclang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"
Description
Today Matrix initalization is just taking in the index from the initalizer list:
llvm-project/clang/lib/Sema/SemaInit.cpp
Lines 1907 to 1913 in 15bbdd1
| while (NumEltsInit < MaxElts && Index < IList->getNumInits()) { | |
| // Not a sublist: just consume directly. | |
| ElemEnt.setElementIndex(Index); | |
| CheckSubElementType(ElemEnt, IList, ElemTy, Index, StructuredList, | |
| StructuredIndex); | |
| ++NumEltsInit; | |
| } |
This means we aren't reordering the index to account for layout DXC is expecting.
The fix seems to be
@@ -1906,10 +1906,12 @@ void InitListChecker::CheckMatrixType(const InitializedEntity &Entity, while (NumEltsInit < MaxElts && Index < IList->getNumInits()) { // Not a sublist: just consume directly. - ElemEnt.setElementIndex(Index); - CheckSubElementType(ElemEnt, IList, ElemTy, Index, StructuredList, + unsigned ColMajorIndex = (Index % MT->getNumRows()) * MT->getNumColumns() + (Index / MT->getNumRows()); + ElemEnt.setElementIndex(ColMajorIndex); + CheckSubElementType(ElemEnt, IList, ElemTy, ColMajorIndex, StructuredList, StructuredIndex); ++NumEltsInit; + ++Index; }Metadata
Metadata
Assignees
Labels
HLSLHLSL Language SupportHLSL Language Supportclang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"
Type
Projects
Status
Closed