diff options
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` |
