Skip to content

Commit

Permalink
Fix warning when use implicit launch type. (#6837) (#6841)
Browse files Browse the repository at this point in the history
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 #6836

---------

Co-authored-by: Damyan Pepper <[email protected]>
(cherry picked from commit ef043e9)
  • Loading branch information
python3kgae authored Jul 31, 2024
1 parent 37cd83f commit 416fab6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tools/clang/lib/Sema/SemaHLSLDiagnoseTU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,10 +529,13 @@ void hlsl::DiagnoseTranslationUnit(clang::Sema *self) {
// attribute.
if (const auto *Attr = FDecl->getAttr<clang::HLSLShaderAttr>())
EntrySK = ShaderModel::KindFromFullName(Attr->getStage());
if (EntrySK == DXIL::ShaderKind::Node)
if (EntrySK == DXIL::ShaderKind::Node) {
if (const auto *pAttr = FDecl->getAttr<HLSLNodeLaunchAttr>())
NodeLaunchTy =
ShaderModel::NodeLaunchTypeFromName(pAttr->getLaunchType());
else
NodeLaunchTy = DXIL::NodeLaunchType::Broadcasting;
}
}
// Visit all visited functions in call graph to collect illegal intrinsic
// calls.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,15 @@ void node02(RWThreadNodeInputRecord<RECORD> input,
Barrier(threadRec, DEVICE_SCOPE);
threadRec.OutputComplete();
}

// Default launch type is broadcasting which has a visible group.
// It is OK to use GROUP_SYNC or GROUP_SCOPE.
[Shader("node")]
[NumThreads(64,1,1)]
[NodeDispatchGrid(1, 1, 1)]
void defaultBroadcastingLaunch(RWDispatchNodeInputRecord<RECORD> input,
[MaxRecords(11)] NodeOutput<RECORD> output) {
Barrier(UAV_MEMORY, GROUP_SYNC);
Barrier(UAV_MEMORY, GROUP_SCOPE);
Barrier(UAV_MEMORY, GROUP_SCOPE|GROUP_SYNC);
}

0 comments on commit 416fab6

Please sign in to comment.