@@ -2824,6 +2824,46 @@ DxilMDHelper::EmitDxilNodeIOState(const hlsl::NodeIOProperties &Node) {
2824
2824
return MDNode::get (m_Ctx, MDVals);
2825
2825
}
2826
2826
2827
+ NodeRecordType
2828
+ DxilMDHelper::LoadDxilNodeRecordType (const llvm::MDOperand &MDO) {
2829
+ const MDTuple *pTupleMD = dyn_cast<MDTuple>(MDO.get ());
2830
+ IFTBOOL (pTupleMD != nullptr , DXC_E_INCORRECT_DXIL_METADATA);
2831
+ IFTBOOL ((pTupleMD->getNumOperands () & 0x1 ) == 0 ,
2832
+ DXC_E_INCORRECT_DXIL_METADATA);
2833
+
2834
+ NodeRecordType Record = {};
2835
+ for (unsigned iNode = 0 ; iNode < pTupleMD->getNumOperands (); iNode += 2 ) {
2836
+ unsigned Tag = DxilMDHelper::ConstMDToUint32 (pTupleMD->getOperand (iNode));
2837
+ const MDOperand &MDO = pTupleMD->getOperand (iNode + 1 );
2838
+ IFTBOOL (MDO.get () != nullptr , DXC_E_INCORRECT_DXIL_METADATA);
2839
+
2840
+ switch (Tag) {
2841
+ case DxilMDHelper::kDxilNodeRecordSizeTag : {
2842
+ Record.size = ConstMDToUint32 (MDO);
2843
+ } break ;
2844
+ case DxilMDHelper::kDxilNodeSVDispatchGridTag : {
2845
+ MDTuple *pSVDTupleMD = cast<MDTuple>(MDO.get ());
2846
+ // < 3 if fatal
2847
+ IFTBOOL (pSVDTupleMD->getNumOperands () >= 3 ,
2848
+ DXC_E_INCORRECT_DXIL_METADATA);
2849
+ // > 3 is extra metadata, validator will fail.
2850
+ if (pSVDTupleMD->getNumOperands () > 3 )
2851
+ m_bExtraMetadata = true ;
2852
+ Record.SV_DispatchGrid .ByteOffset =
2853
+ ConstMDToUint32 (pSVDTupleMD->getOperand (0 ));
2854
+ Record.SV_DispatchGrid .ComponentType = static_cast <DXIL::ComponentType>(
2855
+ ConstMDToUint32 (pSVDTupleMD->getOperand (1 )));
2856
+ Record.SV_DispatchGrid .NumComponents =
2857
+ ConstMDToUint32 (pSVDTupleMD->getOperand (2 ));
2858
+ } break ;
2859
+ default :
2860
+ m_bExtraMetadata = true ;
2861
+ break ;
2862
+ }
2863
+ }
2864
+ return Record;
2865
+ }
2866
+
2827
2867
NodeIOProperties DxilMDHelper::LoadDxilNodeIOState (const llvm::MDOperand &MDO) {
2828
2868
const MDTuple *pTupleMD = dyn_cast<MDTuple>(MDO.get ());
2829
2869
IFTBOOL (pTupleMD != nullptr , DXC_E_INCORRECT_DXIL_METADATA);
@@ -2841,20 +2881,7 @@ NodeIOProperties DxilMDHelper::LoadDxilNodeIOState(const llvm::MDOperand &MDO) {
2841
2881
Node.Flags = NodeFlags (ConstMDToUint32 (MDO));
2842
2882
} break ;
2843
2883
case DxilMDHelper::kDxilNodeRecordTypeTag : {
2844
- MDTuple *pTupleMD = cast<MDTuple>(MDO.get ());
2845
- Node.RecordType .size = ConstMDToUint32 (pTupleMD->getOperand (1 ));
2846
- if (pTupleMD->getNumOperands () > 2 ) {
2847
- DXASSERT (pTupleMD->getNumOperands () == 4 ,
2848
- " incorrect number of operands" );
2849
- MDTuple *pSVDTupleMD = cast<MDTuple>(pTupleMD->getOperand (3 ));
2850
- Node.RecordType .SV_DispatchGrid .ByteOffset =
2851
- ConstMDToUint32 (pSVDTupleMD->getOperand (0 ));
2852
- Node.RecordType .SV_DispatchGrid .ComponentType =
2853
- static_cast <DXIL::ComponentType>(
2854
- ConstMDToUint32 (pSVDTupleMD->getOperand (1 )));
2855
- Node.RecordType .SV_DispatchGrid .NumComponents =
2856
- ConstMDToUint32 (pSVDTupleMD->getOperand (2 ));
2857
- }
2884
+ Node.RecordType = LoadDxilNodeRecordType (MDO);
2858
2885
} break ;
2859
2886
case DxilMDHelper::kDxilNodeOutputArraySizeTag : {
2860
2887
Node.OutputArraySize = ConstMDToUint32 (MDO);
0 commit comments