diff options
| author | cheneym2 <acheney@nvidia.com> | 2025-01-29 14:59:42 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-29 11:59:42 -0800 |
| commit | 2ba6458eba8bd2d4f4d2ffdd452ae089e5b50907 (patch) | |
| tree | df185018f91073eff6066b2e1569557c6d2df1a0 /source | |
| parent | 605204374658fc6d7f647f9a57e9e322b8c83100 (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')
| -rw-r--r-- | source/slang/slang-diagnostic-defs.h | 7 | ||||
| -rw-r--r-- | source/slang/slang-parameter-binding.cpp | 34 |
2 files changed, 38 insertions, 3 deletions
diff --git a/source/slang/slang-diagnostic-defs.h b/source/slang/slang-diagnostic-defs.h index cf338edfa..345be7a54 100644 --- a/source/slang/slang-diagnostic-defs.h +++ b/source/slang/slang-diagnostic-defs.h @@ -2019,6 +2019,13 @@ DIAGNOSTIC( notValidVaryingParameter, "parameter '$0' is not a valid varying parameter.") +DIAGNOSTIC( + 39029, + Warning, + registerModifierButNoVkBindingNorShift, + "shader parameter '$0' has a 'register' specified for D3D, but no '[[vk::binding(...)]]` " + "specified for Vulkan, nor is `-fvk-$1-shift` used.") + // // 4xxxx - IL code generation. 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? |
