diff --git a/tools/clang/lib/Sema/SemaHLSL.cpp b/tools/clang/lib/Sema/SemaHLSL.cpp index 70a9b4c453..4abb93946b 100644 --- a/tools/clang/lib/Sema/SemaHLSL.cpp +++ b/tools/clang/lib/Sema/SemaHLSL.cpp @@ -12336,7 +12336,11 @@ static int ValidateAttributeIntArg(Sema &S, const AttributeList &Attr, } else { if (ArgNum.isInt()) { value = ArgNum.getInt().getSExtValue(); - if (!(E->getType()->isIntegralType(S.Context)) || value < 0) { + if (E->getType()->isBooleanType()) { + // Bool should map to 0 or 1. Otherwise, we would see -1 and emit a + // warning. + value = value ? 1 : 0; + } else if (!(E->getType()->isIntegralType(S.Context)) || value < 0) { S.Diag(Attr.getLoc(), diag::warn_hlsl_attribute_expects_uint_literal) << Attr.getName(); } diff --git a/tools/clang/test/CodeGenDXIL/hlsl/objects/NodeObjects/mesh-node-invalid-attribs.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/objects/NodeObjects/mesh-node-invalid-attribs.hlsl index dcaf7dd69a..02f7db9b02 100644 --- a/tools/clang/test/CodeGenDXIL/hlsl/objects/NodeObjects/mesh-node-invalid-attribs.hlsl +++ b/tools/clang/test/CodeGenDXIL/hlsl/objects/NodeObjects/mesh-node-invalid-attribs.hlsl @@ -78,3 +78,21 @@ void compute_node_topology() {} [OutputTopology("triangle")] [NodeMaxInputRecordsPerGraphEntryRecord(7, false)] // expected-error {{attribute nodemaxinputrecordspergraphentryrecord only allowed on node shaders}} void compute_node_maxrecs() {} + +// Check a few valid cases as well. + +[Shader("node")] +[NodeLaunch("mesh")] +[OutputTopology("triangle")] +[NumThreads(42,1,1)] +[NodeDispatchGrid(19,84,1)] +[NodeMaxInputRecordsPerGraphEntryRecord(11, false)] +void valid_mesh_max_input_records() {} + +[Shader("node")] +[NodeLaunch("mesh")] +[NumThreads(122,1,1)] +[NodeDispatchGrid(17,76,1)] +[OutputTopology("line")] +[NodeMaxInputRecordsPerGraphEntryRecord(13, true)] +void valid_mesh_max_input_records_shared() {}