From 251f55c5ec4cb2b7432e71d6ba8adc96700d35c2 Mon Sep 17 00:00:00 2001 From: Jay Kwak <82421531+jkwak-work@users.noreply.github.com> Date: Mon, 1 Apr 2024 22:02:25 -0700 Subject: Support SM6.6 keyword "WaveSize" (#3871) Resolves an issue #3385 Shader Model 6.6 added a new keyowrd, "WaveSize". See the following link for more details: https://microsoft.github.io/DirectX-Specs/d3d/HLSL_SM_6_6_WaveSize.html Co-authored-by: Yong He --- source/slang/slang-check-modifier.cpp | 41 +++++++++++++++++++++++++++++++++++ 1 file changed, 41 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 1587fa1b0..a387e458c 100644 --- a/source/slang/slang-check-modifier.cpp +++ b/source/slang/slang-check-modifier.cpp @@ -362,6 +362,47 @@ namespace Slang numThreadsAttr->y = values[1]; numThreadsAttr->z = values[2]; } + else if (auto waveSizeAttr = as(attr)) + { + SLANG_ASSERT(attr->args.getCount() == 1); + + IntVal* value = nullptr; + + auto arg = attr->args[0]; + if (arg) + { + auto intValue = checkLinkTimeConstantIntVal(arg); + if (!intValue) + { + return false; + } + if (auto constIntVal = as(intValue)) + { + bool isValidWaveSize = false; + const IntegerLiteralValue waveSize = constIntVal->getValue(); + for (int validWaveSize : { 4, 8, 16, 32, 64, 128 }) + { + if (validWaveSize == waveSize) + { + isValidWaveSize = true; + break; + } + } + if (!isValidWaveSize) + { + getSink()->diagnose(attr, Diagnostics::invalidWaveSize, constIntVal->getValue()); + return false; + } + } + value = intValue; + } + else + { + value = m_astBuilder->getIntVal(m_astBuilder->getIntType(), 1); + } + + waveSizeAttr->numLanes = value; + } else if (auto anyValueSizeAttr = as(attr)) { // This case handles GLSL-oriented layout attributes -- cgit v1.2.3