فهرست منبع

[spirv] --relax-logical-pointer to --before-hlsl-legalization (#2220)

Jaebaek Seo 6 سال پیش
والد
کامیت
3333e4e1f8

+ 5 - 13
tools/clang/lib/SPIRV/SpirvEmitter.cpp

@@ -192,7 +192,7 @@ bool spirvToolsOptimize(spv_target_env env, std::vector<uint32_t> *module,
 }
 
 bool spirvToolsValidate(spv_target_env env, const SpirvCodeGenOptions &opts,
-                        bool beforeHlslLegalization, bool relaxLogicalPointer,
+                        bool beforeHlslLegalization,
                         std::vector<uint32_t> *module, std::string *messages) {
   spvtools::SpirvTools tools(env);
 
@@ -203,15 +203,6 @@ bool spirvToolsValidate(spv_target_env env, const SpirvCodeGenOptions &opts,
 
   spvtools::ValidatorOptions options;
   options.SetBeforeHlslLegalization(beforeHlslLegalization);
-  // When beforeHlslLegalization is true and relaxLogicalPointer is false,
-  // options.SetBeforeHlslLegalization() enables --before-hlsl-legalization
-  // and --relax-logical-pointer. If options.SetRelaxLogicalPointer() is
-  // called, it disables --relax-logical-pointer that is not expected
-  // behavior. When beforeHlslLegalization is true, we must enable both
-  // options.
-  if (!beforeHlslLegalization)
-    options.SetRelaxLogicalPointer(relaxLogicalPointer);
-
   // GL: strict block layout rules
   // VK: relaxed block layout rules
   // DX: Skip block layout rules
@@ -679,9 +670,10 @@ void SpirvEmitter::HandleTranslationUnit(ASTContext &context) {
   // Validate the generated SPIR-V code
   if (!spirvOptions.disableValidation) {
     std::string messages;
-    if (!spirvToolsValidate(targetEnv, spirvOptions, beforeHlslLegalization,
-                            declIdMapper.requiresLegalization(), &m,
-                            &messages)) {
+    if (!spirvToolsValidate(targetEnv, spirvOptions,
+                            beforeHlslLegalization ||
+                                declIdMapper.requiresLegalization(),
+                            &m, &messages)) {
       emitFatalError("generated SPIR-V is invalid: %0", {}) << messages;
       emitNote("please file a bug report on "
                "https://github.com/Microsoft/DirectXShaderCompiler/issues "

+ 2 - 2
tools/clang/unittests/SPIRV/CodeGenSpirvTest.cpp

@@ -1372,7 +1372,7 @@ TEST_F(FileTest, SpirvInterpolationError) {
 }
 
 TEST_F(FileTest, SpirvLegalizationOpaqueStruct) {
-  setRelaxLogicalPointer();
+  setBeforeHLSLLegalization();
   runFileTest("spirv.legal.opaque-struct.hlsl");
 }
 TEST_F(FileTest, SpirvLegalizationStructuredBufferUsage) {
@@ -1793,7 +1793,7 @@ TEST_F(FileTest, ComputeShaderGroupShared) {
   runFileTest("cs.groupshared.hlsl");
 }
 TEST_F(FileTest, ComputeShaderGroupSharedFunctionParam) {
-  setRelaxLogicalPointer();
+  setBeforeHLSLLegalization();
   runFileTest("cs.groupshared.function-param.hlsl");
 }
 TEST_F(FileTest, ComputeShaderGroupSharedFunctionParamOut) {

+ 9 - 9
tools/clang/unittests/SPIRV/FileTestFixture.cpp

@@ -62,7 +62,7 @@ bool FileTest::parseInputFile() {
 
 void FileTest::runFileTest(llvm::StringRef filename, Expect expect,
                            bool runValidation) {
-  if (relaxLogicalPointer || beforeHLSLLegalization)
+  if (beforeHLSLLegalization)
     assert(runValidation);
 
   inputFilePath = utils::getAbsPathOfInputDataFile(filename);
@@ -102,9 +102,9 @@ void FileTest::runFileTest(llvm::StringRef filename, Expect expect,
     ASSERT_EQ(result.status(), effcee::Result::Status::Ok);
 
     if (runValidation)
-      EXPECT_TRUE(utils::validateSpirvBinary(
-          targetEnv, generatedBinary, relaxLogicalPointer,
-          beforeHLSLLegalization, glLayout, dxLayout, scalarLayout));
+      EXPECT_TRUE(utils::validateSpirvBinary(targetEnv, generatedBinary,
+                                             beforeHLSLLegalization, glLayout,
+                                             dxLayout, scalarLayout));
   } else if (expect == Expect::Warning) {
     ASSERT_TRUE(compileOk);
 
@@ -128,9 +128,9 @@ void FileTest::runFileTest(llvm::StringRef filename, Expect expect,
     ASSERT_EQ(result.status(), effcee::Result::Status::Ok);
 
     if (runValidation)
-      EXPECT_TRUE(utils::validateSpirvBinary(
-          targetEnv, generatedBinary, relaxLogicalPointer,
-          beforeHLSLLegalization, glLayout, dxLayout, scalarLayout));
+      EXPECT_TRUE(utils::validateSpirvBinary(targetEnv, generatedBinary,
+                                             beforeHLSLLegalization, glLayout,
+                                             dxLayout, scalarLayout));
   } else if (expect == Expect::Failure) {
     ASSERT_FALSE(compileOk);
 
@@ -157,8 +157,8 @@ void FileTest::runFileTest(llvm::StringRef filename, Expect expect,
 
     std::string valMessages;
     EXPECT_FALSE(utils::validateSpirvBinary(
-        targetEnv, generatedBinary, relaxLogicalPointer, beforeHLSLLegalization,
-        glLayout, dxLayout, scalarLayout, &valMessages));
+        targetEnv, generatedBinary, beforeHLSLLegalization, glLayout, dxLayout,
+        scalarLayout, &valMessages));
     auto options = effcee::Options()
                        .SetChecksName(filename.str())
                        .SetInputName("<val-message>");

+ 2 - 4
tools/clang/unittests/SPIRV/FileTestFixture.h

@@ -28,11 +28,10 @@ public:
   };
 
   FileTest()
-      : targetEnv(SPV_ENV_VULKAN_1_0), relaxLogicalPointer(false),
-        beforeHLSLLegalization(false), glLayout(false), dxLayout(false) {}
+      : targetEnv(SPV_ENV_VULKAN_1_0), beforeHLSLLegalization(false),
+        glLayout(false), dxLayout(false) {}
 
   void useVulkan1p1() { targetEnv = SPV_ENV_VULKAN_1_1; }
-  void setRelaxLogicalPointer() { relaxLogicalPointer = true; }
   void setBeforeHLSLLegalization() { beforeHLSLLegalization = true; }
   void setGlLayout() { glLayout = true; }
   void setDxLayout() { dxLayout = true; }
@@ -54,7 +53,6 @@ private:
   std::string checkCommands;             ///< CHECK commands that verify output
   std::string generatedSpirvAsm;         ///< Disassembled binary (SPIR-V code)
   spv_target_env targetEnv;              ///< Environment to validate against
-  bool relaxLogicalPointer;
   bool beforeHLSLLegalization;
   bool glLayout;
   bool dxLayout;

+ 2 - 3
tools/clang/unittests/SPIRV/FileTestUtils.cpp

@@ -35,11 +35,10 @@ bool disassembleSpirvBinary(std::vector<uint32_t> &binary,
 }
 
 bool validateSpirvBinary(spv_target_env env, std::vector<uint32_t> &binary,
-                         bool relaxLogicalPointer, bool beforeHlslLegalization,
-                         bool glLayout, bool dxLayout, bool scalarLayout,
+                         bool beforeHlslLegalization, bool glLayout,
+                         bool dxLayout, bool scalarLayout,
                          std::string *message) {
   spvtools::ValidatorOptions options;
-  options.SetRelaxLogicalPointer(relaxLogicalPointer);
   options.SetBeforeHlslLegalization(beforeHlslLegalization);
   if (dxLayout || scalarLayout) {
     options.SetSkipBlockLayout(true);

+ 2 - 2
tools/clang/unittests/SPIRV/FileTestUtils.h

@@ -33,8 +33,8 @@ bool disassembleSpirvBinary(std::vector<uint32_t> &binary,
 /// \brief Runs the SPIR-V Tools validation on the given SPIR-V binary.
 /// Returns true if validation is successful; false otherwise.
 bool validateSpirvBinary(spv_target_env, std::vector<uint32_t> &binary,
-                         bool relaxLogicalPointer, bool beforeHlslLegalization,
-                         bool glLayout, bool dxLayout, bool scalarLayout,
+                         bool beforeHlslLegalization, bool glLayout,
+                         bool dxLayout, bool scalarLayout,
                          std::string *message = nullptr);
 
 /// \brief Parses the Target Profile and Entry Point from the Run command

+ 1 - 1
tools/clang/unittests/SPIRV/WholeFileTestFixture.cpp

@@ -109,7 +109,7 @@ void WholeFileTest::runWholeFileTest(llvm::StringRef filename,
   if (runSpirvValidation) {
     EXPECT_TRUE(utils::validateSpirvBinary(
         targetEnv, generatedBinary,
-        /*relaxLogicalPointer=*/false, /*beforeHlslLegalization=*/false,
+        /*beforeHlslLegalization=*/false,
         /*glLayout=*/false, /*dxLayout=*/false, /*scalarLayout=*/false));
   }
 }