summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/slang/slang-diagnostic-defs.h6
-rw-r--r--source/slang/slang-emit-c-like.h31
-rw-r--r--source/slang/slang-emit-wgsl.cpp10
3 files changed, 45 insertions, 2 deletions
diff --git a/source/slang/slang-diagnostic-defs.h b/source/slang/slang-diagnostic-defs.h
index b3d90f27c..dd7885281 100644
--- a/source/slang/slang-diagnostic-defs.h
+++ b/source/slang/slang-diagnostic-defs.h
@@ -2866,6 +2866,12 @@ DIAGNOSTIC(
divisionByMatrixNotSupported,
"division by matrix is not supported for Metal and WGSL targets.")
+DIAGNOSTIC(
+ 56103,
+ Error,
+ int16NotSupportedInWGSL,
+ "16-bit integer type '$0' is not supported by the WGSL backend.")
+
DIAGNOSTIC(57001, Warning, spirvOptFailed, "spirv-opt failed. $0")
DIAGNOSTIC(57002, Error, unknownPatchConstantParameter, "unknown patch constant parameter '$0'.")
DIAGNOSTIC(57003, Error, unknownTessPartitioning, "unknown tessellation partitioning '$0'.")
diff --git a/source/slang/slang-emit-c-like.h b/source/slang/slang-emit-c-like.h
index 1e9deaa0d..caf1a913b 100644
--- a/source/slang/slang-emit-c-like.h
+++ b/source/slang/slang-emit-c-like.h
@@ -228,6 +228,30 @@ public:
/// Get the diagnostic sink
DiagnosticSink* getSink() { return m_codeGenContext->getSink(); }
+ /// Diagnose a diagnostic only once per diagnostic ID and all parameters
+ template<typename... Args>
+ void diagnoseOnce(SourceLoc loc, DiagnosticInfo const& diagnostic, Args&&... args)
+ {
+ // For diagnostics with parameters, we'll use all parameters to create a unique key
+ // This prevents duplicate diagnostics while allowing different parameter combinations
+ if constexpr (sizeof...(args) > 0)
+ {
+ String key = String(diagnostic.id);
+ ((key = key + "|" + String(args)), ...); // Fold expression to append all args
+ if (!m_reportedDiagnosticKeys.add(key))
+ return;
+ }
+ else
+ {
+ // For diagnostics without parameters, just use the ID
+ if (!m_reportedDiagnosticIds.add(diagnostic.id))
+ return;
+ }
+
+ // Report the diagnostic
+ getSink()->diagnose(loc, diagnostic, std::forward<Args>(args)...);
+ }
+
/// Get the code gen target
CodeGenTarget getTarget() { return m_target; }
/// Get the source style
@@ -747,6 +771,13 @@ protected:
// Indicates if we are emiting for Optix cooperative vector.
bool isOptixCoopVec = false;
+
+ // Set of diagnostic IDs that have already been reported to prevent duplicates
+ HashSet<int> m_reportedDiagnosticIds;
+
+ // Set of diagnostic keys (ID + all parameters) that have already been reported to prevent
+ // duplicates
+ HashSet<String> m_reportedDiagnosticKeys;
};
} // namespace Slang
diff --git a/source/slang/slang-emit-wgsl.cpp b/source/slang/slang-emit-wgsl.cpp
index 97b57d352..fbcb54d10 100644
--- a/source/slang/slang-emit-wgsl.cpp
+++ b/source/slang/slang-emit-wgsl.cpp
@@ -515,8 +515,10 @@ void WGSLSourceEmitter::emitSimpleTypeImpl(IRType* type)
return;
}
case kIROp_Int16Type:
+ diagnoseOnce(SourceLoc(), Diagnostics::int16NotSupportedInWGSL, "int16_t");
+ return;
case kIROp_UInt16Type:
- SLANG_UNEXPECTED("16 bit integer value emitted");
+ diagnoseOnce(SourceLoc(), Diagnostics::int16NotSupportedInWGSL, "uint16_t");
return;
case kIROp_Int64Type:
case kIROp_IntPtrType:
@@ -976,9 +978,13 @@ void WGSLSourceEmitter::emitSimpleValueImpl(IRInst* inst)
break;
}
case BaseType::Int16:
+ {
+ diagnoseOnce(SourceLoc(), Diagnostics::int16NotSupportedInWGSL, "int16_t");
+ break;
+ }
case BaseType::UInt16:
{
- SLANG_UNEXPECTED("16 bit integer value emitted");
+ diagnoseOnce(SourceLoc(), Diagnostics::int16NotSupportedInWGSL, "uint16_t");
break;
}
case BaseType::Int: