From 2d0912bfe2de7799b32e80722fa5c8dc279a339b Mon Sep 17 00:00:00 2001 From: Ellie Hermaszewska Date: Wed, 31 Jan 2024 03:28:04 +0800 Subject: Correctly apply glsl local size layout to entry points during lowering (#3528) * Correctly apply glsl local size layout to entry points during lowering * Test for glsl layout correctness --- source/slang/slang-check-modifier.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'source/slang/slang-check-modifier.cpp') diff --git a/source/slang/slang-check-modifier.cpp b/source/slang/slang-check-modifier.cpp index 413e1c157..96ec0acc8 100644 --- a/source/slang/slang-check-modifier.cpp +++ b/source/slang/slang-check-modifier.cpp @@ -1272,6 +1272,39 @@ namespace Slang } } + if (auto attr = as(m)) + { + SLANG_ASSERT(attr->args.getCount() == 3); + + int32_t values[3]; + + for (int i = 0; i < 3; ++i) + { + int32_t value = 1; + + auto arg = attr->args[i]; + if (arg) + { + auto intValue = checkConstantIntVal(arg); + if (!intValue) + { + return nullptr; + } + if (intValue->getValue() < 1) + { + getSink()->diagnose(attr, Diagnostics::nonPositiveNumThreads, intValue->getValue()); + return nullptr; + } + value = int32_t(intValue->getValue()); + } + values[i] = value; + } + + attr->x = values[0]; + attr->y = values[1]; + attr->z = values[2]; + } + // Default behavior is to leave things as they are, // and assume that modifiers are mostly already checked. // -- cgit v1.2.3