Skip to content

Commit ef043e9

Browse files
python3kgaedamyanp
andauthored
Fix warning when use implicit launch type. (microsoft#6837)
By default, the launch type should be set to ‘Broadcast’ when diagnosing barriers. However, the current behavior sets the default launch type to ‘Invalid,’ resulting in warnings when the launch type is not explicitly specified as an attribute. To address this issue, we’ll adjust the default setting to ‘Broadcast’ and thereby resolve the problem. Fixes microsoft#6836 --------- Co-authored-by: Damyan Pepper <[email protected]>
1 parent b6f7ff8 commit ef043e9

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

tools/clang/lib/Sema/SemaHLSLDiagnoseTU.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,10 +529,13 @@ void hlsl::DiagnoseTranslationUnit(clang::Sema *self) {
529529
// attribute.
530530
if (const auto *Attr = FDecl->getAttr<clang::HLSLShaderAttr>())
531531
EntrySK = ShaderModel::KindFromFullName(Attr->getStage());
532-
if (EntrySK == DXIL::ShaderKind::Node)
532+
if (EntrySK == DXIL::ShaderKind::Node) {
533533
if (const auto *pAttr = FDecl->getAttr<HLSLNodeLaunchAttr>())
534534
NodeLaunchTy =
535535
ShaderModel::NodeLaunchTypeFromName(pAttr->getLaunchType());
536+
else
537+
NodeLaunchTy = DXIL::NodeLaunchType::Broadcasting;
538+
}
536539
}
537540
// Visit all visited functions in call graph to collect illegal intrinsic
538541
// calls.

tools/clang/test/SemaHLSL/hlsl/intrinsics/barrier/barrier-node-errors.hlsl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,15 @@ void node02(RWThreadNodeInputRecord<RECORD> input,
192192
Barrier(threadRec, DEVICE_SCOPE);
193193
threadRec.OutputComplete();
194194
}
195+
196+
// Default launch type is broadcasting which has a visible group.
197+
// It is OK to use GROUP_SYNC or GROUP_SCOPE.
198+
[Shader("node")]
199+
[NumThreads(64,1,1)]
200+
[NodeDispatchGrid(1, 1, 1)]
201+
void defaultBroadcastingLaunch(RWDispatchNodeInputRecord<RECORD> input,
202+
[MaxRecords(11)] NodeOutput<RECORD> output) {
203+
Barrier(UAV_MEMORY, GROUP_SYNC);
204+
Barrier(UAV_MEMORY, GROUP_SCOPE);
205+
Barrier(UAV_MEMORY, GROUP_SCOPE|GROUP_SYNC);
206+
}

0 commit comments

Comments
 (0)