Consider GL_EXT_scalar_block_layout when validating SPIR-V
authorCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Wed, 27 Jan 2021 08:30:59 +0000 (00:30 -0800)
committerCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Thu, 28 Jan 2021 22:11:24 +0000 (14:11 -0800)
If GL_EXT_scalar_block_layout is requested by the shader, set the
option to allow scalar blocks in the SPIR-V validator.

Fix the existing tests using scalar layout to not expect "Validation
failed".

Fixes #2400.

SPIRV/SpvTools.cpp
Test/baseResults/spv.scalarlayout.frag.out
Test/baseResults/spv.scalarlayoutfloat16.frag.out
glslang/MachineIndependent/localintermediate.h

index 16d051a..56eb248 100644 (file)
@@ -153,6 +153,7 @@ void SpirvToolsValidate(const glslang::TIntermediate& intermediate, std::vector<
     spv_validator_options options = spvValidatorOptionsCreate();
     spvValidatorOptionsSetRelaxBlockLayout(options, intermediate.usingHlslOffsets());
     spvValidatorOptionsSetBeforeHlslLegalization(options, prelegalization);
+    spvValidatorOptionsSetScalarBlockLayout(options, intermediate.usingScalarBlockLayout());
     spvValidateWithOptions(context, options, &binary, &diagnostic);
 
     // report
index 549efaa..e08721f 100644 (file)
@@ -1,5 +1,4 @@
 spv.scalarlayout.frag
-Validation failed
 // Module Version 10000
 // Generated by (magic number): 8000a
 // Id's are bound by 20
index fc0dca8..4f22730 100644 (file)
@@ -1,5 +1,4 @@
 spv.scalarlayoutfloat16.frag
-Validation failed
 // Module Version 10000
 // Generated by (magic number): 8000a
 // Id's are bound by 18
index f8d8e80..d581959 100644 (file)
@@ -858,6 +858,14 @@ public:
     bool usingHlslIoMapping() { return false; }
 #endif
 
+    bool usingScalarBlockLayout() const {
+        for (auto extIt = requestedExtensions.begin(); extIt != requestedExtensions.end(); ++extIt) {
+            if (*extIt == E_GL_EXT_scalar_block_layout)
+                return true;
+        }
+        return false;
+    };
+
     void addToCallGraph(TInfoSink&, const TString& caller, const TString& callee);
     void merge(TInfoSink&, TIntermediate&);
     void finalCheck(TInfoSink&, bool keepUncalled);