-
Notifications
You must be signed in to change notification settings - Fork 722
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WorkGraph][SM6.9] Implements [MaxRecordPerNode(N)] for NodeOutpurArray #7177
Open
anupamachandra
wants to merge
7
commits into
microsoft:main
Choose a base branch
from
anupamachandra:anupamac/MaxRecordsPerNode
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[WorkGraph][SM6.9] Implements [MaxRecordPerNode(N)] for NodeOutpurArray #7177
anupamachandra
wants to merge
7
commits into
microsoft:main
from
anupamachandra:anupamac/MaxRecordsPerNode
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
You can test this locally with the following command:git-clang-format --diff 0a1143572d107c8b6980df092b84a79190ec1fbd c1788dc5bb516633d87c54e98a5c7acd66f5010f -- include/dxc/DXIL/DxilMetadataHelper.h include/dxc/DXIL/DxilNodeProps.h lib/DXIL/DxilMetadataHelper.cpp lib/DxilContainer/DxilContainerAssembler.cpp tools/clang/include/clang/AST/HlslTypes.h tools/clang/lib/AST/HlslTypes.cpp tools/clang/lib/CodeGen/CGHLSLMS.cpp tools/clang/lib/Parse/ParseDecl.cpp tools/clang/lib/Sema/SemaHLSL.cpp View the diff from clang-format here.diff --git a/lib/DXIL/DxilMetadataHelper.cpp b/lib/DXIL/DxilMetadataHelper.cpp
index 31a1b9e6..30084eb6 100644
--- a/lib/DXIL/DxilMetadataHelper.cpp
+++ b/lib/DXIL/DxilMetadataHelper.cpp
@@ -1985,7 +1985,7 @@ void DxilMDHelper::SerializeNodeProps(SmallVectorImpl<llvm::Metadata *> &MDVals,
MDVals.push_back(Uint32ToConstMD(nodeoutput.OutputArraySize));
MDVals.push_back(BoolToConstMD(nodeoutput.AllowSparseNodes));
MDVals.push_back(Uint32ToConstMD(nodeoutput.RecordType.alignment));
- MDVals.push_back(Uint32ToConstMD(nodeoutput.MaxRecordsPerNode));
+ MDVals.push_back(Uint32ToConstMD(nodeoutput.MaxRecordsPerNode));
}
}
@@ -2834,7 +2834,7 @@ DxilMDHelper::EmitDxilNodeIOState(const hlsl::NodeIOProperties &Node) {
NodeOpIDVals.emplace_back(Uint32ToConstMD(Node.OutputID.Index));
MDVals.emplace_back(MDNode::get(m_Ctx, NodeOpIDVals));
}
-
+
if (Node.MaxRecordsPerNode) {
MDVals.emplace_back(
Uint32ToConstMD(DxilMDHelper::kDxilNodeMaxRecordsPerNodeTag));
diff --git a/lib/DxilContainer/DxilContainerAssembler.cpp b/lib/DxilContainer/DxilContainerAssembler.cpp
index 9505279b..9ff31ff2 100644
--- a/lib/DxilContainer/DxilContainerAssembler.cpp
+++ b/lib/DxilContainer/DxilContainerAssembler.cpp
@@ -1169,21 +1169,21 @@ private:
(uint32_t)RDAT::NodeAttribKind::MaxRecordsSharedWith;
nAttrib.MaxRecordsSharedWith = N.MaxRecordsSharedWith;
nodeAttribs.push_back(Builder.InsertRecord(nAttrib));
- }
-
+ }
+
if (N.MaxRecordsPerNode > 0) {
- nAttrib = {};
- nAttrib.AttribKind = (uint32_t)NodeAttribKind::MaxRecordsPerNode;
- nAttrib.MaxRecordsPerNode = N.MaxRecordsPerNode;
- nodeAttribs.push_back(Builder.InsertRecord(nAttrib));
- }
+ nAttrib = {};
+ nAttrib.AttribKind = (uint32_t)NodeAttribKind::MaxRecordsPerNode;
+ nAttrib.MaxRecordsPerNode = N.MaxRecordsPerNode;
+ nodeAttribs.push_back(Builder.InsertRecord(nAttrib));
+ }
if (N.AllowSparseNodes) {
nAttrib = {};
nAttrib.AttribKind = (uint32_t)RDAT::NodeAttribKind::AllowSparseNodes;
nAttrib.AllowSparseNodes = N.AllowSparseNodes;
nodeAttribs.push_back(Builder.InsertRecord(nAttrib));
- }
+ }
} else if (N.Flags.IsInputRecord()) {
if (N.MaxRecords) {
nAttrib = {};
diff --git a/tools/clang/lib/AST/HlslTypes.cpp b/tools/clang/lib/AST/HlslTypes.cpp
index 15d07993..6cb145ae 100644
--- a/tools/clang/lib/AST/HlslTypes.cpp
+++ b/tools/clang/lib/AST/HlslTypes.cpp
@@ -705,7 +705,7 @@ bool IsHLSLNodeOutputArrayType(clang::QualType type) {
(static_cast<uint32_t>(DXIL::NodeIOFlags::Output) |
static_cast<uint32_t>(DXIL::NodeIOFlags::NodeArray) |
static_cast<uint32_t>(DXIL::NodeIOFlags::RecordGranularityMask))) ==
- (static_cast<uint32_t>(DXIL::NodeIOFlags::Output) |
+ (static_cast<uint32_t>(DXIL::NodeIOFlags::Output) |
static_cast<uint32_t>(DXIL::NodeIOFlags::NodeArray));
}
diff --git a/tools/clang/lib/CodeGen/CGHLSLMS.cpp b/tools/clang/lib/CodeGen/CGHLSLMS.cpp
index 517a8b75..bbec7e14 100644
--- a/tools/clang/lib/CodeGen/CGHLSLMS.cpp
+++ b/tools/clang/lib/CodeGen/CGHLSLMS.cpp
@@ -2435,18 +2435,19 @@ void CGMSHLSLRuntime::AddHLSLFunctionInfo(Function *F, const FunctionDecl *FD) {
}
if (const auto *Attr = parmDecl->getAttr<HLSLMaxRecordsAttr>())
node.MaxRecords = Attr->getMaxCount();
- // Check for SM6.9 Attributes
- if (SM->IsSM69Plus()) {
- // Though MaxRecordsPerNode is a required attribute, this requirement
- // can be overriden, in which case when the attribute is not present
- // set the value to MaxRecords.
- node.MaxRecordsPerNode = node.MaxRecords;
- if (const auto *Attr = parmDecl->getAttr<HLSLMaxRecordsPerNodeAttr>()) {
- node.MaxRecordsPerNode = Attr->getMaxCount();
- DXASSERT(node.MaxRecordsPerNode <= node.MaxRecords,
- "MaxRecordsPerNode value should be less than or equal to the MaxRecords value");
- }
- }
+ // Check for SM6.9 Attributes
+ if (SM->IsSM69Plus()) {
+ // Though MaxRecordsPerNode is a required attribute, this requirement
+ // can be overriden, in which case when the attribute is not present
+ // set the value to MaxRecords.
+ node.MaxRecordsPerNode = node.MaxRecords;
+ if (const auto *Attr = parmDecl->getAttr<HLSLMaxRecordsPerNodeAttr>()) {
+ node.MaxRecordsPerNode = Attr->getMaxCount();
+ DXASSERT(node.MaxRecordsPerNode <= node.MaxRecords,
+ "MaxRecordsPerNode value should be less than or equal to the "
+ "MaxRecords value");
+ }
+ }
}
if (inputPatchCount > 1) {
diff --git a/tools/clang/lib/Sema/SemaHLSL.cpp b/tools/clang/lib/Sema/SemaHLSL.cpp
index 0552e758..d1fd63aa 100644
--- a/tools/clang/lib/Sema/SemaHLSL.cpp
+++ b/tools/clang/lib/Sema/SemaHLSL.cpp
@@ -13386,7 +13386,7 @@ void hlsl::HandleDeclAttributeForHLSL(Sema &S, Decl *D, const AttributeList &A,
A.getRange(), S.Context, ValidateAttributeIntArg(S, A),
A.getAttributeSpellingListIndex());
break;
- }
+ }
case AttributeList::AT_HLSLNodeArraySize: {
declAttr = ::new (S.Context) HLSLNodeArraySizeAttr(
A.getRange(), S.Context, ValidateAttributeIntArg(S, A),
@@ -15979,12 +15979,13 @@ void DiagnoseNodeEntry(Sema &S, FunctionDecl *FD, llvm::StringRef StageName,
bool OutputFound = false;
DiagnoseDispatchGridSemantics(S, NodeStructDecl, PD->getLocation(),
OutputFound);
- }
+ }
if (hlsl::IsHLSLNodeOutputArrayType(ParamType)) {
std::string profile = S.getLangOpts().HLSLProfile;
const ShaderModel *SM = hlsl::ShaderModel::GetByName(profile.c_str());
- if (SM->IsSM69Plus() &&!PD->getAttr<HLSLMaxRecordsPerNodeAttr>()) {
- S.Diags.Report(PD->getLocation(),
+ if (SM->IsSM69Plus() && !PD->getAttr<HLSLMaxRecordsPerNodeAttr>()) {
+ S.Diags.Report(
+ PD->getLocation(),
diag::warn_hlsl_max_records_per_node_required_attribute);
}
}
@@ -16006,8 +16007,7 @@ void DiagnoseNodeEntry(Sema &S, FunctionDecl *FD, llvm::StringRef StageName,
auto *NodeArraySizeAttr = Param->getAttr<HLSLNodeArraySizeAttr>();
auto *UnboundedSparseNodesAttr =
Param->getAttr<HLSLUnboundedSparseNodesAttr>();
- auto *MaxRecordsPerNodeAttr =
- Param->getAttr<HLSLMaxRecordsPerNodeAttr>();
+ auto *MaxRecordsPerNodeAttr = Param->getAttr<HLSLMaxRecordsPerNodeAttr>();
// Check any node input is compatible with the node launch type
if (hlsl::IsHLSLNodeInputType(ParamTy)) {
InputCount++;
@@ -16038,7 +16038,8 @@ void DiagnoseNodeEntry(Sema &S, FunctionDecl *FD, llvm::StringRef StageName,
// If node output is not an array, diagnose array only attributes
if (((uint32_t)GetNodeIOType(ParamTy) &
(uint32_t)DXIL::NodeIOFlags::NodeArray) == 0) {
- Attr *ArrayAttrs[] = {NodeArraySizeAttr, UnboundedSparseNodesAttr, MaxRecordsPerNodeAttr};
+ Attr *ArrayAttrs[] = {NodeArraySizeAttr, UnboundedSparseNodesAttr,
+ MaxRecordsPerNodeAttr};
for (auto *A : ArrayAttrs) {
if (A) {
S.Diags.Report(A->getLocation(),
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implements the following spec:
https://github.com/microsoft/hlsl-specs/blob/main/proposals/0025-max-records-per-node.md
Adds some basic Filecheck tests.