summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-parameter-binding.cpp
diff options
context:
space:
mode:
authorcheneym2 <acheney@nvidia.com>2025-01-29 14:59:42 -0500
committerGitHub <noreply@github.com>2025-01-29 11:59:42 -0800
commit2ba6458eba8bd2d4f4d2ffdd452ae089e5b50907 (patch)
treedf185018f91073eff6066b2e1569557c6d2df1a0 /source/slang/slang-parameter-binding.cpp
parent605204374658fc6d7f647f9a57e9e322b8c83100 (diff)
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>
Diffstat (limited to 'source/slang/slang-parameter-binding.cpp')
-rw-r--r--source/slang/slang-parameter-binding.cpp34
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?