diff options
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/slang-hlsl-to-vulkan-layout-options.h | 1 | ||||
| -rw-r--r-- | source/slang/slang-parameter-binding.cpp | 38 |
2 files changed, 28 insertions, 11 deletions
diff --git a/source/slang/slang-hlsl-to-vulkan-layout-options.h b/source/slang/slang-hlsl-to-vulkan-layout-options.h index 1b7daf330..b8ae40da0 100644 --- a/source/slang/slang-hlsl-to-vulkan-layout-options.h +++ b/source/slang/slang-hlsl-to-vulkan-layout-options.h @@ -75,6 +75,7 @@ public: { enum Enum : KindFlags { + None = 0, UnorderedAccess = KindFlags(1) << Index(Kind::UnorderedAccess), Sampler = KindFlags(1) << Index(Kind::Sampler), ShaderResource = KindFlags(1) << Index(Kind::ShaderResource), diff --git a/source/slang/slang-parameter-binding.cpp b/source/slang/slang-parameter-binding.cpp index cfbd7f2c5..523ba9287 100644 --- a/source/slang/slang-parameter-binding.cpp +++ b/source/slang/slang-parameter-binding.cpp @@ -1048,7 +1048,7 @@ static void addExplicitParameterBindings_GLSL( RefPtr<VarLayout> varLayout) { // We only want to apply GLSL-style layout modifers - // when compiling for a Khronos-related target. + // when compiling for a Khronos-related target. // // TODO: This should have some finer granularity // so that we are able to distinguish between @@ -1143,15 +1143,13 @@ static void addExplicitParameterBindings_GLSL( return; } - // See if we can infer vulkan binding from HLSL if we have such options set, we know - // we can't map auto hlslToVulkanLayoutOptions = context->getTargetProgram()->getHLSLToVulkanLayoutOptions(); - - // If we have the options, but cannot infer bindings, we don't need to go further + bool warnedMissingVulkanLayoutModifier = false; + // If we are not told how to infer bindings with a compile option, we warn if (hlslToVulkanLayoutOptions == nullptr || !hlslToVulkanLayoutOptions->canInferBindings()) { + warnedMissingVulkanLayoutModifier = true; _maybeDiagnoseMissingVulkanLayoutModifier(context, varDecl.as<VarDeclBase>()); - return; } // We need an HLSL register semantic to to infer from @@ -1188,20 +1186,38 @@ static void addExplicitParameterBindings_GLSL( } // If inference is not enabled for this kind, we can issue a warning - if (!hlslToVulkanLayoutOptions->canInfer(vulkanKind, hlslInfo.space)) + if (hlslToVulkanLayoutOptions && !hlslToVulkanLayoutOptions->canInfer(vulkanKind, hlslInfo.space)) { - _maybeDiagnoseMissingVulkanLayoutModifier(context, varDecl.as<VarDeclBase>()); - return; + if(!warnedMissingVulkanLayoutModifier) + { + _maybeDiagnoseMissingVulkanLayoutModifier(context, varDecl.as<VarDeclBase>()); + warnedMissingVulkanLayoutModifier = true; + } } // We use the HLSL binding directly (even though this notionally for GLSL/Vulkan) // We'll do the shifting at later later point in _maybeApplyHLSLToVulkanShifts resInfo = typeLayout->findOrAddResourceInfo(hlslInfo.kind); - + + if (warnedMissingVulkanLayoutModifier) + { + // If we warn due to invalid bindings and user did not set how to interpret 'hlsl style bindings', we should map + // `register` 1:1 with equivlent vulkan bindings. + if(!hlslToVulkanLayoutOptions + || hlslToVulkanLayoutOptions->getKindShiftEnabledFlags() == HLSLToVulkanLayoutOptions::KindFlag::None) + { + resInfo->kind = LayoutResourceKind::DescriptorTableSlot; + resInfo->count = 1; + } + else + { + return; + } + } + semanticInfo.kind = resInfo->kind; semanticInfo.index = UInt(hlslInfo.index); semanticInfo.space = UInt(hlslInfo.space); - const LayoutSize count = resInfo->count; addExplicitParameterBinding(context, parameterInfo, as<VarDeclBase>(varDecl.getDecl()), semanticInfo, count); |
