summaryrefslogtreecommitdiffstats
path: root/source/slang
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-06-12 09:40:27 -0700
committerGitHub <noreply@github.com>2024-06-12 09:40:27 -0700
commitc194af81a5b1f7d2869d9617dc06cd50609362bf (patch)
tree01018eed11a9cccb1176f70a085b948b825d07bc /source/slang
parent7a4757d2e97f92aae3ddb5dc353a54f72e23351e (diff)
Fix crash on invalid entrypoint varying parameter. (#4349)
* Fix crash on invalid entrypoint varying parameter. * Fix test.
Diffstat (limited to 'source/slang')
-rw-r--r--source/slang/slang-diagnostic-defs.h2
-rw-r--r--source/slang/slang-parameter-binding.cpp9
2 files changed, 9 insertions, 2 deletions
diff --git a/source/slang/slang-diagnostic-defs.h b/source/slang/slang-diagnostic-defs.h
index eb7b5b993..f4bad6664 100644
--- a/source/slang/slang-diagnostic-defs.h
+++ b/source/slang/slang-diagnostic-defs.h
@@ -695,6 +695,8 @@ DIAGNOSTIC(39026, Error, matrixLayoutModifierOnNonMatrixType, "matrix layout mod
DIAGNOSTIC(39027, Error, getAttributeAtVertexMustReferToPerVertexInput, "'GetAttributeAtVertex' must reference a vertex input directly, and the vertex input must be decorated with 'pervertex' or 'nointerpolation'.")
+DIAGNOSTIC(39028, Error, notValidVaryingParameter, "parameter '$0' is not a valid varying parameter.")
+
//
// 4xxxx - IL code generation.
diff --git a/source/slang/slang-parameter-binding.cpp b/source/slang/slang-parameter-binding.cpp
index 523ba9287..bce9b5d05 100644
--- a/source/slang/slang-parameter-binding.cpp
+++ b/source/slang/slang-parameter-binding.cpp
@@ -2185,9 +2185,11 @@ static RefPtr<TypeLayout> processEntryPointVaryingParameter(
state,
fieldVarLayout);
- SLANG_ASSERT(fieldTypeLayout);
- if(!fieldTypeLayout)
+ if (!fieldTypeLayout)
+ {
+ getSink(context)->diagnose(field, Diagnostics::notValidVaryingParameter, field);
continue;
+ }
fieldVarLayout->typeLayout = fieldTypeLayout;
// The field needs to have offset information stored
@@ -4169,6 +4171,9 @@ ProgramLayout* TargetProgram::getOrCreateLayout(DiagnosticSink* sink)
if( !m_layout )
{
m_layout = generateParameterBindings(this, sink);
+ if (sink->getErrorCount() != 0)
+ return nullptr;
+
if( m_layout )
{
m_irModuleForLayout = createIRModuleForLayout(sink);