Skip to content

Commit

Permalink
Warning about push constants
Browse files Browse the repository at this point in the history
  • Loading branch information
cheneym2 committed Feb 4, 2025
1 parent 0a68285 commit 160f81a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions source/slang/slang-parameter-binding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,12 @@ static void _maybeDiagnoseMissingVulkanLayoutModifier(
ParameterBindingContext* context,
DeclRef<VarDeclBase> const& varDecl)
{
// Don't warn if the declaration is a vk::push_constant
if (varDecl.getDecl()->hasModifier<PushConstantAttribute>())
{
return;
}

// If the user didn't specify a `binding` (and optional `set`) for Vulkan,
// but they *did* specify a `register` for D3D, then that is probably an
// oversight on their part.
Expand Down
5 changes: 4 additions & 1 deletion tests/diagnostics/vk-bindings.slang
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ struct S { float4 a; };
[[vk::binding(2,1)]]
ParameterBlock<S> b;

[[vk::push_constant]] \
ConstantBuffer<int> gint : register(b0, space0);

[shader("compute")]
void main()
{}
{}

0 comments on commit 160f81a

Please sign in to comment.