[llvm] [HLSLSemanticSignatures] Implement the stacked packing of elements (PR #218060)
Finn Plummer via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 10 11:54:03 PDT 2026
================
@@ -0,0 +1,342 @@
+//===- HLSLSemanticSignaturePackingTest.cpp -------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/Frontend/HLSL/SemanticSignaturePacking.h"
+#include "llvm/TargetParser/Triple.h"
+#include "llvm/Testing/Support/Error.h"
+#include "gtest/gtest.h"
+#include <algorithm>
+#include <initializer_list>
+
+using namespace llvm;
+using namespace llvm::hlsl;
+
+namespace {
+
+class HLSLSemanticSignaturePackingTest : public testing::Test {
+protected:
+ struct ElementConfig {
+ dxbc::PSV::SemanticKind SemanticKind;
+ uint32_t Rows;
+ uint8_t Cols;
+ dxil::ElementType CompType;
+ dxbc::PSV::InterpolationMode InterpMode;
+ };
+
+ struct ExpectedLocation {
+ uint32_t Row;
+ uint8_t Col;
+ };
+
+ static constexpr ExpectedLocation Unallocated = {UnallocatedRow,
+ UnallocatedCol};
+
+ struct TestConfig {
+ Triple::EnvironmentType ShaderStage;
+ IOType IOTy;
+ SmallVector<ElementConfig> Elements;
+
+ TestConfig(Triple::EnvironmentType ShaderStage, IOType IOTy,
+ std::initializer_list<ElementConfig> Elements)
+ : ShaderStage(ShaderStage), IOTy(IOTy), Elements(Elements) {}
+ };
+
+ SmallVector<SemanticSignatureElement>
+ makeSignature(const TestConfig &Config) {
+ SmallVector<SemanticSignatureElement> Elements;
+ for (const ElementConfig &Element : Config.Elements) {
+ SmallVector<uint32_t> SemanticIndices;
+ for (uint32_t Row = 0; Row != Element.Rows; ++Row)
+ SemanticIndices.push_back(Row);
+
+ Elements.emplace_back(
+ /*SigId=*/static_cast<uint32_t>(Elements.size()),
+ /*SemanticName=*/"TEST",
+ /*CompType=*/Element.CompType,
+ /*SemanticKind=*/Element.SemanticKind,
+ /*SemanticIndices=*/SemanticIndices,
+ /*Cols=*/Element.Cols);
+ Elements.back().InterpMode = Element.InterpMode;
+ }
+ return Elements;
+ }
+
+ Error packStacked(SmallVectorImpl<SemanticSignatureElement> &Elements,
+ const TestConfig &Config) {
+ return packSignatureStacked(Elements, Config.ShaderStage, Config.IOTy);
+ }
+
+ void expectPacking(const TestConfig &Config, unsigned ExpectedRows,
----------------
inbelic wrote:
Updated to verify so that we don't just rename it in the next (indexed) pr
https://github.com/llvm/llvm-project/pull/218060
More information about the llvm-commits
mailing list