diff --git a/tools/clang/lib/Sema/SemaHLSL.cpp b/tools/clang/lib/Sema/SemaHLSL.cpp index d831f51f09..d322c7c854 100644 --- a/tools/clang/lib/Sema/SemaHLSL.cpp +++ b/tools/clang/lib/Sema/SemaHLSL.cpp @@ -13170,7 +13170,8 @@ void ValidateDispatchGridValues(DiagnosticsEngine &Diags, << A.getName() << "Z" << A.getRange(); z = 0; } - if (x * y * z > MaxProductValue) + uint64_t product = (uint64_t)x * (uint64_t)y * (uint64_t)z; + if (product > MaxProductValue) Diags.Report(A.getLoc(), diag::err_hlsl_dispatchgrid_product) << A.getName() << A.getRange(); } diff --git a/tools/clang/test/SemaHLSL/attributes/overflow_node_dispatch_grid.hlsl b/tools/clang/test/SemaHLSL/attributes/overflow_node_dispatch_grid.hlsl new file mode 100644 index 0000000000..074d70e269 --- /dev/null +++ b/tools/clang/test/SemaHLSL/attributes/overflow_node_dispatch_grid.hlsl @@ -0,0 +1,7 @@ +// RUN: %dxc -T lib_6_8 -verify %s + +[Shader("node")] +[NodeLaunch("broadcasting")] +[NodeDispatchGrid(65535, 65535, 65535)] // expected-error {{'NodeDispatchGrid' X * Y * Z product may not exceed 16,777,215 (2^24-1)}} +[NumThreads(1, 1, 1)] +void myNode() { }