From 2ba6458eba8bd2d4f4d2ffdd452ae089e5b50907 Mon Sep 17 00:00:00 2001 From: cheneym2 Date: Wed, 29 Jan 2025 14:59:42 -0500 Subject: Fix combined sampler documentation and warning (#6207) * Fix combined sampler documentation and warning * Update comment, show detailed '-fvk-t-shift' message in warning instead of generic '-fvk-xxx-shift' * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> --- source/slang/slang-parameter-binding.cpp | 34 +++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) (limited to 'source/slang/slang-parameter-binding.cpp') diff --git a/source/slang/slang-parameter-binding.cpp b/source/slang/slang-parameter-binding.cpp index 55c487e4e..61226f898 100644 --- a/source/slang/slang-parameter-binding.cpp +++ b/source/slang/slang-parameter-binding.cpp @@ -1078,10 +1078,32 @@ static void _maybeDiagnoseMissingVulkanLayoutModifier( // oversight on their part. if (auto registerModifier = varDecl.getDecl()->findModifier()) { + auto varType = getType(context->getASTBuilder(), varDecl.as()); + if (auto textureType = as(varType)) + { + if (textureType->isCombined()) + { + // Recommend [[vk::binding]] but not '-fvk-xxx-shift` for combined texture samplers + getSink(context)->diagnose( + registerModifier, + Diagnostics::registerModifierButNoVulkanLayout, + varDecl.getName()); + return; + } + } + + UnownedStringSlice registerClassName; + UnownedStringSlice registerIndexDigits; + splitNameAndIndex( + registerModifier->registerName.getContent(), + registerClassName, + registerIndexDigits); + getSink(context)->diagnose( registerModifier, - Diagnostics::registerModifierButNoVulkanLayout, - varDecl.getName()); + Diagnostics::registerModifierButNoVkBindingNorShift, + varDecl.getName(), + registerClassName); } } @@ -1256,7 +1278,6 @@ static void addExplicitParameterBindings_GLSL( return; } - const auto hlslInfo = _extractLayoutSemanticInfo(context, hlslRegSemantic); if (hlslInfo.kind == LayoutResourceKind::None) { @@ -1270,7 +1291,14 @@ static void addExplicitParameterBindings_GLSL( if (auto textureType = as(varType)) { if (textureType->isCombined()) + { + if (!warnedMissingVulkanLayoutModifier) + { + _maybeDiagnoseMissingVulkanLayoutModifier(context, varDecl.as()); + warnedMissingVulkanLayoutModifier = true; + } return; + } } // Can we map to a Vulkan kind in principal? -- cgit v1.2.3