@@ -81,13 +81,18 @@ void PSVRuntimeInfo::write(raw_ostream &OS, uint32_t Version) const {
81
81
BindingSize = sizeof (dxbc::PSV::v0::ResourceBindInfo);
82
82
break ;
83
83
case 2 :
84
- default :
85
84
InfoSize = sizeof (dxbc::PSV::v2::RuntimeInfo);
86
85
BindingSize = sizeof (dxbc::PSV::v2::ResourceBindInfo);
86
+ break ;
87
+ case 3 :
88
+ default :
89
+ InfoSize = sizeof (dxbc::PSV::v3::RuntimeInfo);
90
+ BindingSize = sizeof (dxbc::PSV::v2::ResourceBindInfo);
87
91
}
88
- // Write the size of the info.
89
92
93
+ // Write the size of the info.
90
94
support::endian::write (OS, InfoSize, llvm::endianness::little);
95
+
91
96
// Write the info itself.
92
97
OS.write (reinterpret_cast <const char *>(&BaseData), InfoSize);
93
98
@@ -104,32 +109,12 @@ void PSVRuntimeInfo::write(raw_ostream &OS, uint32_t Version) const {
104
109
if (Version == 0 )
105
110
return ;
106
111
107
- StringTableBuilder StrTabBuilder ((StringTableBuilder::DXContainer));
108
- SmallVector<uint32_t , 64 > IndexBuffer;
109
- SmallVector<v0::SignatureElement, 32 > SignatureElements;
110
- SmallVector<StringRef, 32 > SemanticNames;
111
-
112
- ProcessElementList (StrTabBuilder, IndexBuffer, SignatureElements,
113
- SemanticNames, InputElements);
114
- ProcessElementList (StrTabBuilder, IndexBuffer, SignatureElements,
115
- SemanticNames, OutputElements);
116
- ProcessElementList (StrTabBuilder, IndexBuffer, SignatureElements,
117
- SemanticNames, PatchOrPrimElements);
118
-
119
- StrTabBuilder.finalize ();
120
- for (auto ElAndName : zip (SignatureElements, SemanticNames)) {
121
- v0::SignatureElement &El = std::get<0 >(ElAndName);
122
- StringRef Name = std::get<1 >(ElAndName);
123
- El.NameOffset = static_cast <uint32_t >(StrTabBuilder.getOffset (Name));
124
- if (sys::IsBigEndianHost)
125
- El.swapBytes ();
126
- }
127
-
128
- support::endian::write (OS, static_cast <uint32_t >(StrTabBuilder.getSize ()),
112
+ support::endian::write (OS,
113
+ static_cast <uint32_t >(DXConStrTabBuilder.getSize ()),
129
114
llvm::endianness::little);
130
115
131
116
// Write the string table.
132
- StrTabBuilder .write (OS);
117
+ DXConStrTabBuilder .write (OS);
133
118
134
119
// Write the index table size, then table.
135
120
support::endian::write (OS, static_cast <uint32_t >(IndexBuffer.size ()),
@@ -162,6 +147,46 @@ void PSVRuntimeInfo::write(raw_ostream &OS, uint32_t Version) const {
162
147
llvm::endianness::little);
163
148
}
164
149
150
+ void PSVRuntimeInfo::finalize (Triple::EnvironmentType Stage) {
151
+ IsFinalized = true ;
152
+ BaseData.SigInputElements = static_cast <uint32_t >(InputElements.size ());
153
+ BaseData.SigOutputElements = static_cast <uint32_t >(OutputElements.size ());
154
+ BaseData.SigPatchOrPrimElements =
155
+ static_cast <uint32_t >(PatchOrPrimElements.size ());
156
+
157
+ SmallVector<StringRef, 32 > SemanticNames;
158
+
159
+ // Build a string table and set associated offsets to be written when
160
+ // write() is called
161
+ ProcessElementList (DXConStrTabBuilder, IndexBuffer, SignatureElements,
162
+ SemanticNames, InputElements);
163
+ ProcessElementList (DXConStrTabBuilder, IndexBuffer, SignatureElements,
164
+ SemanticNames, OutputElements);
165
+ ProcessElementList (DXConStrTabBuilder, IndexBuffer, SignatureElements,
166
+ SemanticNames, PatchOrPrimElements);
167
+
168
+ DXConStrTabBuilder.add (EntryName);
169
+
170
+ DXConStrTabBuilder.finalize ();
171
+ for (auto ElAndName : zip (SignatureElements, SemanticNames)) {
172
+ llvm::dxbc::PSV::v0::SignatureElement &El = std::get<0 >(ElAndName);
173
+ StringRef Name = std::get<1 >(ElAndName);
174
+ El.NameOffset = static_cast <uint32_t >(DXConStrTabBuilder.getOffset (Name));
175
+ if (sys::IsBigEndianHost)
176
+ El.swapBytes ();
177
+ }
178
+
179
+ BaseData.EntryNameOffset =
180
+ static_cast <uint32_t >(DXConStrTabBuilder.getOffset (EntryName));
181
+
182
+ if (!sys::IsBigEndianHost)
183
+ return ;
184
+ BaseData.swapBytes ();
185
+ BaseData.swapBytes (Stage);
186
+ for (auto &Res : Resources)
187
+ Res.swapBytes ();
188
+ }
189
+
165
190
void Signature::write (raw_ostream &OS) {
166
191
SmallVector<dxbc::ProgramSignatureElement> SigParams;
167
192
SigParams.reserve (Params.size ());
0 commit comments