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 | |
| 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')
| -rw-r--r-- | source/slang/slang-emit-glsl.cpp | 5 | ||||
| -rw-r--r-- | source/slang/slang-parameter-binding.cpp | 16 |
2 files changed, 18 insertions, 3 deletions
diff --git a/source/slang/slang-emit-glsl.cpp b/source/slang/slang-emit-glsl.cpp index 37c38dd95..321f41d54 100644 --- a/source/slang/slang-emit-glsl.cpp +++ b/source/slang/slang-emit-glsl.cpp @@ -241,7 +241,10 @@ void GLSLSourceEmitter::_emitGLSLByteAddressBuffer(IRGlobalParam* varDecl, IRByt { // We can use ShaderResource/DescriptorSlot interchangably here. // This is possible because vk-shift-* - const LayoutResourceKindFlags kinds = LayoutResourceKindFlag::ShaderResource | LayoutResourceKindFlag::DescriptorTableSlot; + bool isReadOnly = (as<IRHLSLByteAddressBufferType>(byteAddressBufferType) != nullptr); + + const LayoutResourceKindFlags kinds = (isReadOnly ? LayoutResourceKindFlag::ShaderResource : LayoutResourceKindFlag::UnorderedAccess) + | LayoutResourceKindFlag::DescriptorTableSlot; EmitVarChain chain(layout); 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` |
