diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2021-06-14 10:36:42 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-14 10:36:42 -0400 |
| commit | 45f737dfde81d31b44afb6e5d7e89de88ee51160 (patch) | |
| tree | 37d48cf9700406f4249e53dba5d905ee48a3b03a /source | |
| parent | 746ee0dc5bddeea177aaf609bcc5085b46c4057c (diff) | |
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.
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/slang-type-layout.cpp | 12 | ||||
| -rw-r--r-- | source/slang/slang-type-layout.h | 4 |
2 files changed, 8 insertions, 8 deletions
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)); diff --git a/source/slang/slang-type-layout.h b/source/slang/slang-type-layout.h index be7ccdf8f..8c50b4eb3 100644 --- a/source/slang/slang-type-layout.h +++ b/source/slang/slang-type-layout.h @@ -251,6 +251,10 @@ struct SimpleLayoutInfo LayoutResourceKind kind; // How many resources of that kind? + // + // For uniform, the size is the number of bytes "reserved" exclusively for an instance of that type. + // In *general* it is not necessary for a size to be rounded up to the alignment. Some targets do + // though - for example C++ and CUDA targets always have size as a multiple of alignment. LayoutSize size; // only useful in the uniform case |
