aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>2021-01-27 00:30:59 -0800
committerCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>2021-01-28 14:11:24 -0800
commita38df83d3ec985d2fd569a29aac69c074083b4b6 (patch)
tree22b850c6787703009969e6c50910cd0ba4b3cbf6
parentf7c43377f095b96cec8b374ef04120c4b86864f6 (diff)
downloadglslang-a38df83d3ec985d2fd569a29aac69c074083b4b6.tar.gz
Consider GL_EXT_scalar_block_layout when validating SPIR-V
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.
-rw-r--r--SPIRV/SpvTools.cpp1
-rw-r--r--Test/baseResults/spv.scalarlayout.frag.out1
-rw-r--r--Test/baseResults/spv.scalarlayoutfloat16.frag.out1
-rw-r--r--glslang/MachineIndependent/localintermediate.h8
4 files changed, 9 insertions, 2 deletions
diff --git a/SPIRV/SpvTools.cpp b/SPIRV/SpvTools.cpp
index 16d051a9..56eb2484 100644
--- a/SPIRV/SpvTools.cpp
+++ b/SPIRV/SpvTools.cpp
@@ -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
diff --git a/Test/baseResults/spv.scalarlayout.frag.out b/Test/baseResults/spv.scalarlayout.frag.out
index 549efaa8..e08721f8 100644
--- a/Test/baseResults/spv.scalarlayout.frag.out
+++ b/Test/baseResults/spv.scalarlayout.frag.out
@@ -1,5 +1,4 @@
spv.scalarlayout.frag
-Validation failed
// Module Version 10000
// Generated by (magic number): 8000a
// Id's are bound by 20
diff --git a/Test/baseResults/spv.scalarlayoutfloat16.frag.out b/Test/baseResults/spv.scalarlayoutfloat16.frag.out
index fc0dca84..4f22730e 100644
--- a/Test/baseResults/spv.scalarlayoutfloat16.frag.out
+++ b/Test/baseResults/spv.scalarlayoutfloat16.frag.out
@@ -1,5 +1,4 @@
spv.scalarlayoutfloat16.frag
-Validation failed
// Module Version 10000
// Generated by (magic number): 8000a
// Id's are bound by 18
diff --git a/glslang/MachineIndependent/localintermediate.h b/glslang/MachineIndependent/localintermediate.h
index f8d8e801..d581959d 100644
--- a/glslang/MachineIndependent/localintermediate.h
+++ b/glslang/MachineIndependent/localintermediate.h
@@ -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);