Skip to content

Revert "[HLSL][RootSignature] Implement serialization of RootConstants and RootFlags" #142005

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 29, 2025

Conversation

inbelic
Copy link
Contributor

@inbelic inbelic commented May 29, 2025

The commit caused build failures, here, due to a missing linked llvm library (HLSLFrontend) into clang/unittests/Parse/CMakeLists.txt.

While it seems like the fix is straightforwardly to just add this library, I will revert now to build and verify locally it correctly fixes it.

Reverts #141130

@llvmbot llvmbot added the HLSL HLSL Language Support label May 29, 2025
@llvmbot
Copy link
Member

llvmbot commented May 29, 2025

@llvm/pr-subscribers-hlsl

Author: Finn Plummer (inbelic)

Changes

The commit caused build failures, here, due to a missing linked llvm library (HLSLFrontend) into clang/unittests/Parse/CMakeLists.txt.

While it seems like the fix is straightforwardly to just add this library, I will revert now to build and verify locally it correctly fixes it.

Reverts llvm/llvm-project#141130


Full diff: https://github.com/llvm/llvm-project/pull/142005.diff

3 Files Affected:

  • (modified) llvm/include/llvm/Frontend/HLSL/HLSLRootSignature.h (-4)
  • (modified) llvm/lib/Frontend/HLSL/HLSLRootSignature.cpp (-73)
  • (modified) llvm/unittests/Frontend/HLSLRootSignatureDumpTest.cpp (-69)
diff --git a/llvm/include/llvm/Frontend/HLSL/HLSLRootSignature.h b/llvm/include/llvm/Frontend/HLSL/HLSLRootSignature.h
index 14f5ddea3f978..fea9a9962991c 100644
--- a/llvm/include/llvm/Frontend/HLSL/HLSLRootSignature.h
+++ b/llvm/include/llvm/Frontend/HLSL/HLSLRootSignature.h
@@ -46,8 +46,6 @@ enum class RootFlags : uint32_t {
   ValidFlags = 0x00000fff
 };
 
-raw_ostream &operator<<(raw_ostream &OS, const RootFlags &Flags);
-
 enum class RootDescriptorFlags : unsigned {
   None = 0,
   DataVolatile = 0x2,
@@ -95,8 +93,6 @@ struct RootConstants {
   ShaderVisibility Visibility = ShaderVisibility::All;
 };
 
-raw_ostream &operator<<(raw_ostream &OS, const RootConstants &Constants);
-
 enum class DescriptorType : uint8_t { SRV = 0, UAV, CBuffer };
 // Models RootDescriptor : CBV | SRV | UAV, by collecting like parameters
 struct RootDescriptor {
diff --git a/llvm/lib/Frontend/HLSL/HLSLRootSignature.cpp b/llvm/lib/Frontend/HLSL/HLSLRootSignature.cpp
index 6e0e0cdcd5946..ec0d130a6767c 100644
--- a/llvm/lib/Frontend/HLSL/HLSLRootSignature.cpp
+++ b/llvm/lib/Frontend/HLSL/HLSLRootSignature.cpp
@@ -132,79 +132,6 @@ static raw_ostream &operator<<(raw_ostream &OS,
   return OS;
 }
 
-raw_ostream &operator<<(raw_ostream &OS, const RootFlags &Flags) {
-  OS << "RootFlags(";
-  bool FlagSet = false;
-  unsigned Remaining = llvm::to_underlying(Flags);
-  while (Remaining) {
-    unsigned Bit = 1u << llvm::countr_zero(Remaining);
-    if (Remaining & Bit) {
-      if (FlagSet)
-        OS << " | ";
-
-      switch (static_cast<RootFlags>(Bit)) {
-      case RootFlags::AllowInputAssemblerInputLayout:
-        OS << "AllowInputAssemblerInputLayout";
-        break;
-      case RootFlags::DenyVertexShaderRootAccess:
-        OS << "DenyVertexShaderRootAccess";
-        break;
-      case RootFlags::DenyHullShaderRootAccess:
-        OS << "DenyHullShaderRootAccess";
-        break;
-      case RootFlags::DenyDomainShaderRootAccess:
-        OS << "DenyDomainShaderRootAccess";
-        break;
-      case RootFlags::DenyGeometryShaderRootAccess:
-        OS << "DenyGeometryShaderRootAccess";
-        break;
-      case RootFlags::DenyPixelShaderRootAccess:
-        OS << "DenyPixelShaderRootAccess";
-        break;
-      case RootFlags::AllowStreamOutput:
-        OS << "AllowStreamOutput";
-        break;
-      case RootFlags::LocalRootSignature:
-        OS << "LocalRootSignature";
-        break;
-      case RootFlags::DenyAmplificationShaderRootAccess:
-        OS << "DenyAmplificationShaderRootAccess";
-        break;
-      case RootFlags::DenyMeshShaderRootAccess:
-        OS << "DenyMeshShaderRootAccess";
-        break;
-      case RootFlags::CBVSRVUAVHeapDirectlyIndexed:
-        OS << "CBVSRVUAVHeapDirectlyIndexed";
-        break;
-      case RootFlags::SamplerHeapDirectlyIndexed:
-        OS << "SamplerHeapDirectlyIndexed";
-        break;
-      default:
-        OS << "invalid: " << Bit;
-        break;
-      }
-
-      FlagSet = true;
-    }
-    Remaining &= ~Bit;
-  }
-
-  if (!FlagSet)
-    OS << "None";
-
-  OS << ")";
-
-  return OS;
-}
-
-raw_ostream &operator<<(raw_ostream &OS, const RootConstants &Constants) {
-  OS << "RootConstants(num32BitConstants = " << Constants.Num32BitConstants
-     << ", " << Constants.Reg << ", space = " << Constants.Space
-     << ", visibility = " << Constants.Visibility << ")";
-
-  return OS;
-}
-
 raw_ostream &operator<<(raw_ostream &OS, const DescriptorTable &Table) {
   OS << "DescriptorTable(numClauses = " << Table.NumClauses
      << ", visibility = " << Table.Visibility << ")";
diff --git a/llvm/unittests/Frontend/HLSLRootSignatureDumpTest.cpp b/llvm/unittests/Frontend/HLSLRootSignatureDumpTest.cpp
index 8597ed78b4fbb..3f92fa0f05794 100644
--- a/llvm/unittests/Frontend/HLSLRootSignatureDumpTest.cpp
+++ b/llvm/unittests/Frontend/HLSLRootSignatureDumpTest.cpp
@@ -108,73 +108,4 @@ TEST(HLSLRootSignatureTest, DescriptorTableDump) {
   EXPECT_EQ(Out, Expected);
 }
 
-TEST(HLSLRootSignatureTest, DefaultRootConstantsDump) {
-  RootConstants Constants;
-  Constants.Num32BitConstants = 1;
-  Constants.Reg = {RegisterType::BReg, 3};
-
-  std::string Out;
-  llvm::raw_string_ostream OS(Out);
-  OS << Constants;
-  OS.flush();
-
-  std::string Expected = "RootConstants(num32BitConstants = 1, b3, space = 0, "
-                         "visibility = All)";
-  EXPECT_EQ(Out, Expected);
-}
-
-TEST(HLSLRootSignatureTest, SetRootConstantsDump) {
-  RootConstants Constants;
-  Constants.Num32BitConstants = 983;
-  Constants.Reg = {RegisterType::BReg, 34593};
-  Constants.Space = 7;
-  Constants.Visibility = ShaderVisibility::Pixel;
-
-  std::string Out;
-  llvm::raw_string_ostream OS(Out);
-  OS << Constants;
-  OS.flush();
-
-  std::string Expected = "RootConstants(num32BitConstants = 983, b34593, "
-                         "space = 7, visibility = Pixel)";
-  EXPECT_EQ(Out, Expected);
-}
-
-TEST(HLSLRootSignatureTest, NoneRootFlagsDump) {
-  RootFlags Flags = RootFlags::None;
-
-  std::string Out;
-  llvm::raw_string_ostream OS(Out);
-  OS << Flags;
-  OS.flush();
-
-  std::string Expected = "RootFlags(None)";
-  EXPECT_EQ(Out, Expected);
-}
-
-TEST(HLSLRootSignatureTest, AllRootFlagsDump) {
-  RootFlags Flags = RootFlags::ValidFlags;
-
-  std::string Out;
-  llvm::raw_string_ostream OS(Out);
-  OS << Flags;
-  OS.flush();
-
-  std::string Expected = "RootFlags("
-                         "AllowInputAssemblerInputLayout | "
-                         "DenyVertexShaderRootAccess | "
-                         "DenyHullShaderRootAccess | "
-                         "DenyDomainShaderRootAccess | "
-                         "DenyGeometryShaderRootAccess | "
-                         "DenyPixelShaderRootAccess | "
-                         "AllowStreamOutput | "
-                         "LocalRootSignature | "
-                         "DenyAmplificationShaderRootAccess | "
-                         "DenyMeshShaderRootAccess | "
-                         "CBVSRVUAVHeapDirectlyIndexed | "
-                         "SamplerHeapDirectlyIndexed)";
-
-  EXPECT_EQ(Out, Expected);
-}
-
 } // namespace

@jplehr
Copy link
Contributor

jplehr commented May 29, 2025

Thank you.

@inbelic inbelic merged commit dd56693 into main May 29, 2025
8 of 12 checks passed
@inbelic inbelic deleted the revert-141130-inbelic/rs-serialize-cur branch May 29, 2025 18:21
svkeerthy pushed a commit that referenced this pull request May 29, 2025
…ts` and `RootFlags`" (#142005)

The commit caused build failures,
[here](https://lab.llvm.org/buildbot/#/builders/10/builds/6308), due to
a missing linked llvm library (HLSLFrontend) into
`clang/unittests/Parse/CMakeLists.txt`.

While it seems like the fix is straightforwardly to just add this
library, I will revert now to build and verify locally it correctly
fixes it.

Reverts #141130
google-yfyang pushed a commit to google-yfyang/llvm-project that referenced this pull request May 29, 2025
…ts` and `RootFlags`" (llvm#142005)

The commit caused build failures,
[here](https://lab.llvm.org/buildbot/#/builders/10/builds/6308), due to
a missing linked llvm library (HLSLFrontend) into
`clang/unittests/Parse/CMakeLists.txt`.

While it seems like the fix is straightforwardly to just add this
library, I will revert now to build and verify locally it correctly
fixes it.

Reverts llvm#141130
inbelic added a commit that referenced this pull request Jun 3, 2025
`HLSLRootSignature.h` was originally created to hold the struct
definitions of an `llvm::hlsl::rootsig::RootElement` and some helper
functions for it.

However, there many users of the structs that don't require any of the
helper methods. This requires us to link the `FrontendHLSL` library,
where we otherwise wouldn't need to.

For instance:
- This [revert](#142005) was
required as it requires linking to the unrequired `FrontendHLSL` library
- As part of the change required here:
#126557. We will want to add
an `HLSLRootSignatureVersion` enum. Ideally this could live with the
root signature struct defs, but we don't want to link the helper objects
into `clang/Basic/TargetOptions.h`

This change allows the struct definitions to be kept in a single header
file and to then have the `FrontendHLSL` library only be linked when
required.
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Jun 3, 2025
…42491)

`HLSLRootSignature.h` was originally created to hold the struct
definitions of an `llvm::hlsl::rootsig::RootElement` and some helper
functions for it.

However, there many users of the structs that don't require any of the
helper methods. This requires us to link the `FrontendHLSL` library,
where we otherwise wouldn't need to.

For instance:
- This [revert](llvm/llvm-project#142005) was
required as it requires linking to the unrequired `FrontendHLSL` library
- As part of the change required here:
llvm/llvm-project#126557. We will want to add
an `HLSLRootSignatureVersion` enum. Ideally this could live with the
root signature struct defs, but we don't want to link the helper objects
into `clang/Basic/TargetOptions.h`

This change allows the struct definitions to be kept in a single header
file and to then have the `FrontendHLSL` library only be linked when
required.
sivan-shani pushed a commit to sivan-shani/llvm-project that referenced this pull request Jun 3, 2025
…ts` and `RootFlags`" (llvm#142005)

The commit caused build failures,
[here](https://lab.llvm.org/buildbot/#/builders/10/builds/6308), due to
a missing linked llvm library (HLSLFrontend) into
`clang/unittests/Parse/CMakeLists.txt`.

While it seems like the fix is straightforwardly to just add this
library, I will revert now to build and verify locally it correctly
fixes it.

Reverts llvm#141130
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
HLSL HLSL Language Support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants