Skip to content

Commit

Permalink
Allow node input record to be a class (#6123)
Browse files Browse the repository at this point in the history
Node input records may be a struct or a class, but CodeGen failed to
correctly handle the case when a class was used. This change fixes the
error, and adds a test case.

Fixes #6119

---------

Co-authored-by: Tim Corringham <[email protected]>
  • Loading branch information
tcorringham and Tim Corringham authored Jan 15, 2024
1 parent f94fe82 commit 28fb8fb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
3 changes: 1 addition & 2 deletions tools/clang/lib/CodeGen/CGHLSLMS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2600,8 +2600,7 @@ void CGMSHLSLRuntime::AddHLSLNodeRecordTypeInfo(
auto &Rec = TemplateArgs.get(0);
clang::QualType RecType = Rec.getAsType();
llvm::Type *Type = CGM.getTypes().ConvertType(RecType);
const RecordType *recordtype = RecType->getAsStructureType();
RecordDecl *RD = recordtype->getDecl();
CXXRecordDecl *RD = RecType->getAsCXXRecordDecl();

// Get the TrackRWInputSharing flag from the record attribute
if (RD->hasAttr<HLSLNodeTrackRWInputSharingAttr>()) {
Expand Down
18 changes: 18 additions & 0 deletions tools/clang/test/SemaHLSL/hlsl/workgraph/class_input_record.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// RUN: %dxc -T lib_6_8 -verify %s
// ==================================================================
// Broadcasting launch node with class input record
// ==================================================================

// expected-no-diagnostics

class ClassInputRecord
{
uint a;
};

[Shader("node")]
[NodeLaunch("broadcasting")]
[NodeDispatchGrid(2,3,2)]
[NumThreads(1024,1,1)]
void node01(DispatchNodeInputRecord<ClassInputRecord> input)
{ }

0 comments on commit 28fb8fb

Please sign in to comment.