[llvm] [DX] Add support for program signatures (PR #67346)

Justin Bogner via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 27 10:51:07 PDT 2023


================
@@ -232,6 +233,33 @@ class PSVRuntimeInfo {
   }
 };
 
+class Signature {
+  ViewArray<dxbc::ProgramSignatureElement> Parameters;
+  uint32_t StringTableOffset;
+  StringRef StringTable;
+
+public:
+  ViewArray<dxbc::ProgramSignatureElement>::iterator begin() const {
+    return Parameters.begin();
+  }
+
+  ViewArray<dxbc::ProgramSignatureElement>::iterator end() const {
+    return Parameters.end();
+  }
+
+  StringRef getName(uint32_t Offset) const {
+    // Name offsets are from the start of the signature data, not from the start
+    // of the string table. The header encodes the start offset of the sting
+    // table, so we convert the offset here.
+    uint32_t TableOffset = Offset - StringTableOffset;
+    return StringTable.slice(TableOffset, StringTable.find('\0', TableOffset));
----------------
bogner wrote:

I'm not sure if it matters too much, since we do the validation elsewhere and the result would just be an empty string, but should we maybe assert that `Offset >= StringTableOffset`?

https://github.com/llvm/llvm-project/pull/67346


More information about the llvm-commits mailing list