diff options
Diffstat (limited to 'source/slang/slang-parameter-binding.cpp')
| -rw-r--r-- | source/slang/slang-parameter-binding.cpp | 34 |
1 files changed, 31 insertions, 3 deletions
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<HLSLRegisterSemantic>()) { + auto varType = getType(context->getASTBuilder(), varDecl.as<VarDeclBase>()); + if (auto textureType = as<TextureType>(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<TextureType>(varType)) { if (textureType->isCombined()) + { + if (!warnedMissingVulkanLayoutModifier) + { + _maybeDiagnoseMissingVulkanLayoutModifier(context, varDecl.as<VarDeclBase>()); + warnedMissingVulkanLayoutModifier = true; + } return; + } } // Can we map to a Vulkan kind in principal? |
