summaryrefslogtreecommitdiff
path: root/source/slang/slang-check-shader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/slang-check-shader.cpp')
-rw-r--r--source/slang/slang-check-shader.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/source/slang/slang-check-shader.cpp b/source/slang/slang-check-shader.cpp
index 29134131c..ed62e948d 100644
--- a/source/slang/slang-check-shader.cpp
+++ b/source/slang/slang-check-shader.cpp
@@ -531,6 +531,50 @@ void validateEntryPoint(EntryPoint* entryPoint, DiagnosticSink* sink)
}
}
+ // Attribute and keyword diagnostics. Check for the [[vk::binding]] and [[vk::push_constants]]
+ // attributes, and the register() and packoffset() keywords on entry point parameters. Slang
+ // currently ignores these, which can lead to user confusion whenever the output does not
+ // correspond to what was requested. Conversely, Slang silently generating output that just
+ // happens to align with what's requested can also lead to user confusion, with the user
+ // mistakenly believing that the modifiers are working as intended.
+ //
+ // Note that this only checks when they're used on entry point parameters.
+ for (const auto& param : entryPointFuncDecl->getParameters())
+ {
+ if (param->findModifier<GLSLBindingAttribute>())
+ {
+ sink->diagnose(
+ param,
+ Diagnostics::unhandledModOnEntryPointParameter,
+ "attribute '[[vk::binding(...)]]'",
+ param->getName());
+ }
+ if (param->findModifier<PushConstantAttribute>())
+ {
+ sink->diagnose(
+ param,
+ Diagnostics::unhandledModOnEntryPointParameter,
+ "attribute '[[vk::push_constant]]'",
+ param->getName());
+ }
+ if (param->findModifier<HLSLRegisterSemantic>())
+ {
+ sink->diagnose(
+ param,
+ Diagnostics::unhandledModOnEntryPointParameter,
+ "keyword 'register'",
+ param->getName());
+ }
+ if (param->findModifier<HLSLPackOffsetSemantic>())
+ {
+ sink->diagnose(
+ param,
+ Diagnostics::unhandledModOnEntryPointParameter,
+ "keyword 'packoffset'",
+ param->getName());
+ }
+ }
+
for (auto target : linkage->targets)
{
auto targetCaps = target->getTargetCaps();