diff options
| author | kaizhangNV <149626564+kaizhangNV@users.noreply.github.com> | 2025-05-14 12:11:53 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-14 10:11:53 -0700 |
| commit | 375ecfe2903b09f07abeba2eafb88d9a564c1458 (patch) | |
| tree | a507ffcdbe118f5d69ffb3e6c341d8f954e0bfef /source/slang/slang.cpp | |
| parent | 39c9e25f6d728e970b68a9452330e754991b4ac5 (diff) | |
support specialization constant sized array (#6871)
Close #6859
Goal of this PR
We want to support an array whose size can be specialization constant for shared/global variable e.g.
layout (constant_id = 0) const uint BLOCK_SIZE = 64;
shared float buf_a[(BLOCK_SIZE + 5) * 4];
Overview of the solution:
During IndexExpr check, we will loose the restriction to allow SpecConst passing, but the size parameter will not be a constant value because it cannot be folded into a constant, so we will make it follow the same logic as generic parameter value, and the size will be represented by FuncCallIntVal/PolynomialIntVal/DeclRefIntVal.
During IR lowering, we will detect whether there is spec constant in the IntVal, and wrap the IRInst with a SpecConstRateType, and propagate the type though the lowering logic, such that the IntVal representing the array size will have SpecConstRateType.
During spirv emit stage, if we detect that a IRInst has SpecConstRateType, we will emit it as SpecConstantOp.
We have to implement new logic to emit OpSpecConstantOp, the existing emit logic doesn't support emitting OpSpecConstantOp, especially this op can embed arithmetic operation at global scope, where we can only emit arithmetic instruct at local. But there are only few instructs we need to support.
Overview of the solution:
This PR doesn't support generic, and we will create a separate PR to extend that, tracked in #6840.
Diffstat (limited to 'source/slang/slang.cpp')
| -rw-r--r-- | source/slang/slang.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index 602446cda..67d13c34b 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -6079,7 +6079,7 @@ struct SpecializationArgModuleCollector : ComponentTypeVisitor { collectReferencedModules(type); } - else if (auto declRefVal = as<GenericParamIntVal>(val)) + else if (auto declRefVal = as<DeclRefIntVal>(val)) { collectReferencedModules(declRefVal->getDeclRef()); } |
