summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-type-layout.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2021-06-09 07:34:52 -0700
committerGitHub <noreply@github.com>2021-06-09 10:34:52 -0400
commit430b832a292785a79ca4c25f037c658db8bdc2d2 (patch)
tree4e717be173f2f43cff14a695a425f39fd00b0079 /source/slang/slang-type-layout.cpp
parent6cee1eeda28c1ce1e5d326a0c43427b4776a1d09 (diff)
Fix CUDA vector layout logic. (#1879)
And rename debug symbols for navis. Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-type-layout.cpp')
-rw-r--r--source/slang/slang-type-layout.cpp15
1 files changed, 4 insertions, 11 deletions
diff --git a/source/slang/slang-type-layout.cpp b/source/slang/slang-type-layout.cpp
index 02b5b5bdc..ad38e11cb 100644
--- a/source/slang/slang-type-layout.cpp
+++ b/source/slang/slang-type-layout.cpp
@@ -465,16 +465,10 @@ struct CUDALayoutRulesImpl : DefaultLayoutRulesImpl
return arrayInfo;
}
- // Given `size` between [0, 16] return the smallest power-of-2 that is greater than or equal to `size`.
- uint32_t getVectorAlignment(uint32_t size)
+ // Computes the alignment of a vector type given element size and element count.
+ uint32_t getVectorAlignment(uint32_t elementSize, uint32_t elementCount)
{
- SLANG_ASSERT(size <= 16);
- --size;
- // Set every bit after the highest bit.
- size |= (size >> 1);
- size |= (size >> 2);
- ++size;
- return size;
+ return elementCount == 3 ? elementSize : elementSize * elementCount;
}
SimpleLayoutInfo GetVectorLayout(BaseType elementType, SimpleLayoutInfo elementInfo, size_t elementCount) override
@@ -491,8 +485,7 @@ struct CUDALayoutRulesImpl : DefaultLayoutRulesImpl
SimpleLayoutInfo vectorInfo;
vectorInfo.kind = elementInfo.kind;
vectorInfo.size = elementInfo.size * elementCount;
- vectorInfo.alignment = getVectorAlignment(
- (uint32_t)(elementInfo.size.getFiniteValue() * elementCount));
+ vectorInfo.alignment = getVectorAlignment((uint32_t)elementInfo.size.getFiniteValue(), (uint32_t)elementCount);
return vectorInfo;
}