diff options
| author | Julius Ikkala <julius.ikkala@gmail.com> | 2025-08-21 08:47:18 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-21 05:47:18 +0000 |
| commit | 35f8e092f2aa3ed5e3cf03387e712f798ff4850e (patch) | |
| tree | bdafc75e4df90157568758ebf7b8128ecd066f0c /source/slang/slang-ir-layout.h | |
| parent | 05f0f5603561daed2c134e13bc64649362759968 (diff) | |
Introduce CDataLayout & -fvk-use-c-layout (#8136)
Closes #8112. ~~The issue asks for a "C layout", but in this PR I use
the term "CPU layout" because this naming was pre-existing in the
codebase as `kCPULayoutRulesImpl_`. The primary purpose of this layout
is to match CPU-side struct definitions with the shader side. I'm open
to better naming suggestions, though.~~
Edit: switched back to using `CDataLayout` & `-fvk-use-c-layout`, as the
CPU target depends on the object layout rules of existing CPU layout
rules, but they're incompatible with actual shaders. So a new
`kCLayoutRulesImpl_` was needed anyway.
---------
Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
Diffstat (limited to 'source/slang/slang-ir-layout.h')
| -rw-r--r-- | source/slang/slang-ir-layout.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/source/slang/slang-ir-layout.h b/source/slang/slang-ir-layout.h index 1918f31b6..a0f144c86 100644 --- a/source/slang/slang-ir-layout.h +++ b/source/slang/slang-ir-layout.h @@ -56,6 +56,12 @@ struct IRTypeLayoutRules public: IRTypeLayoutRuleName ruleName; + /// This function calculates the size and alignment of the given type. + virtual Result calcSizeAndAlignment( + CompilerOptionSet& optionSet, + IRType* type, + IRSizeAndAlignment* outSizeAndAlignment); + /// Align composite based on rule. Type is aligned assuming /// it is apart of a composite (array, struct, matrix, etc...) virtual IRSizeAndAlignment alignCompositeElement(IRSizeAndAlignment elementSize) = 0; @@ -79,6 +85,7 @@ public: static IRTypeLayoutRules* getStd430(); static IRTypeLayoutRules* getStd140(); static IRTypeLayoutRules* getNatural(); + static IRTypeLayoutRules* getC(); static IRTypeLayoutRules* getConstantBuffer(); static IRTypeLayoutRules* get(IRTypeLayoutRuleName name); }; |
