From 45f737dfde81d31b44afb6e5d7e89de88ee51160 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Mon, 14 Jun 2021 10:36:42 -0400 Subject: Improve comments around -Xarg and C++/CUDA layout (#1884) * #include an absolute path didn't work - because paths were taken to always be relative. * Alter comments around layout size/alignment to reflect nuance on C++/CUDA. * Fix some errors in -X documentation, and clarify some of the behavior. * Small doc improvements. --- source/slang/slang-type-layout.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'source/slang/slang-type-layout.cpp') diff --git a/source/slang/slang-type-layout.cpp b/source/slang/slang-type-layout.cpp index 0fc7958d0..fe32c93b1 100644 --- a/source/slang/slang-type-layout.cpp +++ b/source/slang/slang-type-layout.cpp @@ -369,6 +369,8 @@ struct HLSLConstantBufferLayoutRulesImpl : DefaultLayoutRulesImpl } }; +/* CPU layout requires that all sizes are a multiple of alignment. +*/ struct CPULayoutRulesImpl : DefaultLayoutRulesImpl { typedef DefaultLayoutRulesImpl Super; @@ -385,6 +387,7 @@ struct CPULayoutRulesImpl : DefaultLayoutRulesImpl return SimpleLayoutInfo( LayoutResourceKind::Uniform, 1, 1 ); } + // This always returns a layout where the size is the same as the alignment. default: return Super::GetScalarLayout(baseType); } } @@ -519,14 +522,7 @@ struct CUDALayoutRulesImpl : DefaultLayoutRulesImpl // Nothing is aligned more than 16 alignment = std::min(alignment, size_t(16)); - // TODO(JS): It's not 100% clear what is right in terms of size in respect of *alignment*. If the size is the 'used' bytes, then - // it can be less that the aligned size. If that's the case the GetArrayLayout (and MatrixLayout) is *wrong* in that on the last element - // it uses the size (not the aligned size/stride). - // - // Here I am assuming it's reasonable for the size to be the aligned size. That being the case the GetArrayLayout/GetMatrixLayout will be - // correct without special handling. - // - // The assert below checks that is indeed the case. + // For CUDA the size must be a multiple of alignment, as this is the amount of bytes used 'exclusively' by the type. // The size must be a multiple of the alignment SLANG_ASSERT(_isAligned(size, alignment)); -- cgit v1.2.3