[llvm] [HLSL] Leave out entryname from string table for PSV versions < 3 (PR #191528)

Tex Riddell via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 30 14:57:22 PDT 2026


================
@@ -1249,3 +1250,47 @@ TEST(RootSignature, ParseStaticSamplers) {
     ASSERT_EQ(Sampler.Flags, 1U);
   }
 }
+
+// PSVInfo:
+//   Version:         2
+//   ShaderStage:     5
+//   MinimumWaveLaneCount: 0
+//   MaximumWaveLaneCount: 4294967295
+//   NumThreadsX:     8
+//   NumThreadsY:     1
+//   NumThreadsZ:     1
+//   EntryName:       CSMain  <--- not serialized for version < 3
+//   ResourceStride:  0
+//   Resources:       []
+TEST(DXCFile, PSVv2EntryNameNotInStringTable) {
+  // Verify that when EntryName is set but PSV version is < 3,
+  // the entry name does not appear in the serialized string table.
+  mcdxbc::PSVRuntimeInfo PSV;
+  PSV.BaseData.ShaderStage =
+      static_cast<uint8_t>(Triple::EnvironmentType::Compute - Triple::Pixel);
+  PSV.BaseData.MinimumWaveLaneCount = 0;
+  PSV.BaseData.MaximumWaveLaneCount = 0xFFFFFFFF;
+  PSV.BaseData.NumThreadsX = 8;
+  PSV.BaseData.NumThreadsY = 1;
+  PSV.BaseData.NumThreadsZ = 1;
+  PSV.EntryName = "CSMain";
+
+  PSV.finalize(Triple::EnvironmentType::Compute, 2);
+
+  SmallVector<char> Buffer;
+  raw_svector_ostream OS(Buffer);
+  PSV.write(OS, 2);
+
+  // The serialized PSV data should not contain the entry name string.
+  StringRef Data(Buffer.data(), Buffer.size());
+  EXPECT_FALSE(Data.contains("CSMain"));
+
+  // Deserialize and verify the string table is empty (only null byte).
----------------
tex3d wrote:

> verify the string table is empty (only null byte)

The code doesn't really verify that the string table is empty, it looks for "CSMain" in the string table. I'm not sure how that could find "CSMain" if the check above already didn't find "CSMain", so it seems redundant.

If you want to follow the comment, you could update the check to actually make sure the string table size == 4 and contains only null bytes. I believe that's the exact expected state, since we always should be adding a single null byte to the beginning of the string table, and the table's size gets aligned to 4 bytes and padded with null bytes.

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


More information about the llvm-commits mailing list