diff options
| author | Yong He <yonghe@outlook.com> | 2023-07-27 14:15:16 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-27 14:15:16 -0700 |
| commit | 04f72443d717ca7b8304f893452c471fc6b6dc8f (patch) | |
| tree | c70498d149eeed09cc0f438e68ca5da212f203df /source/slang/slang-parameter-binding.cpp | |
| parent | c1216cae34a5e8ef912091fcaaf25b6633ac1db6 (diff) | |
Fix -fvk-u-shift not applying to global constant buffer. (#3033)
* Fix -fvk-u-shift not applying to global constant buffer.
* Fix test.
* Fix.
* Fix.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-parameter-binding.cpp')
| -rw-r--r-- | source/slang/slang-parameter-binding.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/source/slang/slang-parameter-binding.cpp b/source/slang/slang-parameter-binding.cpp index 51279b605..47f370854 100644 --- a/source/slang/slang-parameter-binding.cpp +++ b/source/slang/slang-parameter-binding.cpp @@ -3634,7 +3634,8 @@ static void _appendRange(Index start, LayoutSize size, StringBuilder& ioBuf) } static void _maybeApplyHLSLToVulkanShifts( - ParameterBindingContext* paramContext, + ParameterBindingContext* paramContext, + ParameterBindingAndKindInfo& globalConstantBinding, TargetRequest* targetReq, DiagnosticSink* sink) { @@ -3655,6 +3656,17 @@ static void _maybeApplyHLSLToVulkanShifts( return; } + // If the user specified -fvk-b-shift for the default space but not -fvk-bind-global, we want to apply the shift + // to the global constant buffer. + if (!vulkanOptions->hasGlobalsBinding()) + { + auto globalCBufferShift = vulkanOptions->getShift(HLSLToVulkanLayoutOptions::Kind::ConstantBuffer, globalConstantBinding.space); + if (globalCBufferShift != HLSLToVulkanLayoutOptions::kInvalidShift) + { + globalConstantBinding.index += globalCBufferShift; + } + } + for (ParameterInfo* parameterInfo : sharedContext.parameters) { auto varLayout = parameterInfo->varLayout; @@ -4035,7 +4047,7 @@ RefPtr<ProgramLayout> generateParameterBindings( _completeBindings(&context, program); // We may need to finally do any shifting if we have HLSLToVulkanLayoutOptions - _maybeApplyHLSLToVulkanShifts(&context, targetReq, sink); + _maybeApplyHLSLToVulkanShifts(&context, globalConstantBufferBinding, targetReq, sink); // Next we need to create a type layout to reflect the information // we have collected, and we will use the `ScopeLayoutBuilder` |
