From 8d67365b36ea43d339911eba5ee1693d75ae58e2 Mon Sep 17 00:00:00 2001 From: "James Helferty (NVIDIA)" Date: Wed, 17 Sep 2025 10:51:36 -0700 Subject: Diagnostic for metal ref mesh output assignment (#8365) When slang detects assignment to a mesh output reference on metal, generate a diagnostic message. (Metal mesh shader outputs must be assigned via 'set' instead of 'ref'.) Fixes #7498 --- source/slang/slang-diagnostic-defs.h | 6 +++++- source/slang/slang-ir-metal-legalize.cpp | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'source/slang') diff --git a/source/slang/slang-diagnostic-defs.h b/source/slang/slang-diagnostic-defs.h index 1f2fdd693..08e852547 100644 --- a/source/slang/slang-diagnostic-defs.h +++ b/source/slang/slang-diagnostic-defs.h @@ -2960,12 +2960,16 @@ DIAGNOSTIC( Error, 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( + 56104, + Error, + assignToRefNotSupported, + "whole struct must be assiged to mesh output at once for Metal target.") DIAGNOSTIC(57001, Warning, spirvOptFailed, "spirv-opt failed. $0") DIAGNOSTIC(57002, Error, unknownPatchConstantParameter, "unknown patch constant parameter '$0'.") diff --git a/source/slang/slang-ir-metal-legalize.cpp b/source/slang/slang-ir-metal-legalize.cpp index 116feeab4..fd950b91a 100644 --- a/source/slang/slang-ir-metal-legalize.cpp +++ b/source/slang/slang-ir-metal-legalize.cpp @@ -214,6 +214,9 @@ static void processInst(IRInst* inst, DiagnosticSink* sink) case kIROp_Leq: legalizeBinaryOp(inst, sink, CodeGenTarget::Metal); break; + case kIROp_MeshOutputRef: + sink->diagnose(getDiagnosticPos(inst), Diagnostics::assignToRefNotSupported); + break; case kIROp_MetalCastToDepthTexture: { // If the operand is already a depth texture, don't do anything. -- cgit v1.2.3