diff options
| author | Yong He <yonghe@outlook.com> | 2024-11-21 14:07:23 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-21 14:07:23 -0800 |
| commit | fdf061e278720ec066a1fac8f1f35a22e817bf2d (patch) | |
| tree | db6cc05613afacdb9c67a26695355ff1b0086d79 /source/slang/slang-ir-lower-buffer-element-type.cpp | |
| parent | dcc7c6f009afc0f55e79ced050b772ea9d3b25ae (diff) | |
Add datalayout for constant buffers. (#5608)
* Add datalayout for constant buffers.
* Fixes.
* Fix test.
* Fix glsl codegen.
* Update spirv-specific doc.
* Fix test.
* Fix binding in the presense of specialization constants.
* address comments.
* Add a test for constant buffer layout.
Diffstat (limited to 'source/slang/slang-ir-lower-buffer-element-type.cpp')
| -rw-r--r-- | source/slang/slang-ir-lower-buffer-element-type.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/source/slang/slang-ir-lower-buffer-element-type.cpp b/source/slang/slang-ir-lower-buffer-element-type.cpp index 2f8631e18..bd3e350bc 100644 --- a/source/slang/slang-ir-lower-buffer-element-type.cpp +++ b/source/slang/slang-ir-lower-buffer-element-type.cpp @@ -1376,7 +1376,25 @@ IRTypeLayoutRules* getTypeLayoutRuleForBuffer(TargetProgram* target, IRType* buf } case kIROp_ConstantBufferType: case kIROp_ParameterBlockType: - return IRTypeLayoutRules::getStd140(); + { + auto parameterGroupType = as<IRUniformParameterGroupType>(bufferType); + + auto layoutTypeOp = parameterGroupType->getDataLayout() + ? parameterGroupType->getDataLayout()->getOp() + : kIROp_DefaultBufferLayoutType; + switch (layoutTypeOp) + { + case kIROp_DefaultBufferLayoutType: + return IRTypeLayoutRules::getStd140(); + case kIROp_Std140BufferLayoutType: + return IRTypeLayoutRules::getStd140(); + case kIROp_Std430BufferLayoutType: + return IRTypeLayoutRules::getStd430(); + case kIROp_ScalarBufferLayoutType: + return IRTypeLayoutRules::getNatural(); + } + return IRTypeLayoutRules::getStd140(); + } case kIROp_PtrType: return IRTypeLayoutRules::getNatural(); } |
