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-options.cpp | |
| 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-options.cpp')
| -rw-r--r-- | source/slang/slang-options.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/source/slang/slang-options.cpp b/source/slang/slang-options.cpp index b0eb1748d..2115a096f 100644 --- a/source/slang/slang-options.cpp +++ b/source/slang/slang-options.cpp @@ -663,6 +663,12 @@ void initCommandOptions(CommandOptions& options) "-fvk-use-dx-layout", nullptr, "Pack members using FXCs member packing rules when targeting GLSL or SPIRV."}, + {OptionKind::ForceCLayout, + "-fvk-use-c-layout", + nullptr, + "Make data accessed through ConstantBuffer, ParameterBlock, StructuredBuffer, " + "ByteAddressBuffer and general pointers follow the C/C++ structure layout rules " + "when targeting SPIRV."}, {OptionKind::VulkanBindShift, vkShiftNames.getBuffer(), "-fvk-<vulkan-shift>-shift <N> <space>", @@ -2670,6 +2676,11 @@ SlangResult OptionsParser::_parse(int argc, char const* const* argv) getCurrentTarget()->optionSet.add(CompilerOptionName::ForceDXLayout, true); break; } + case OptionKind::ForceCLayout: + { + getCurrentTarget()->optionSet.add(CompilerOptionName::ForceCLayout, true); + break; + } case OptionKind::EnableEffectAnnotations: { m_compileRequest->setEnableEffectAnnotations(true); @@ -3707,6 +3718,11 @@ SlangResult OptionsParser::_parse(int argc, char const* const* argv) m_compileRequest->setTargetForceDXLayout(targetID, true); } + if (rawTarget.optionSet.shouldUseCLayout()) + { + m_compileRequest->setTargetForceCLayout(targetID, true); + } + if (rawTarget.optionSet.getBoolOption(CompilerOptionName::GenerateWholeProgram)) { m_compileRequest->setTargetGenerateWholeProgram(targetID, true); |
