Skip to content

Commit 3424125

Browse files
committed
Fix warning about push constants, shaderRecordEXT
These resources should not warn about missing vk::binding.
1 parent 0a68285 commit 3424125

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

source/slang/slang-parameter-binding.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -1073,6 +1073,13 @@ static void _maybeDiagnoseMissingVulkanLayoutModifier(
10731073
ParameterBindingContext* context,
10741074
DeclRef<VarDeclBase> const& varDecl)
10751075
{
1076+
// Don't warn if the declaration is a vk::push_constant or shaderRecordEXT
1077+
if (varDecl.getDecl()->hasModifier<PushConstantAttribute>()
1078+
|| varDecl.getDecl()->hasModifier<ShaderRecordAttribute>())
1079+
{
1080+
return;
1081+
}
1082+
10761083
// If the user didn't specify a `binding` (and optional `set`) for Vulkan,
10771084
// but they *did* specify a `register` for D3D, then that is probably an
10781085
// oversight on their part.

tests/diagnostics/vk-bindings.slang

+6-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ struct S { float4 a; };
1414
[[vk::binding(2,1)]]
1515
ParameterBlock<S> b;
1616

17+
[[vk::push_constant]] \
18+
ConstantBuffer<int> gint : register(b0, space0);
19+
20+
layout(shaderRecordEXT) ConstantBuffer<int> GeometrySBT : register(b0, space99999);
21+
1722
[shader("compute")]
1823
void main()
19-
{}
24+
{}

tests/diagnostics/vk-bindings.slang.expected

+6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ Texture2D t : register(t0);
66
tests/diagnostics/vk-bindings.slang(14): error 39015: shader parameter 'b' consumes whole descriptor sets, so the binding must be in the form '[[vk::binding(0, ...)]]'; the non-zero binding '2' is not allowed
77
[[vk::binding(2,1)]]
88
^~~~~~~
9+
tests/diagnostics/vk-bindings.slang(18): warning 39001: explicit binding for parameter 'gint' overlaps with parameter 't'
10+
ConstantBuffer<int> gint : register(b0, space0);
11+
^~~~
12+
tests/diagnostics/vk-bindings.slang(6): note: see declaration of 't'
13+
Texture2D t : register(t0);
14+
^
915
}
1016
standard output = {
1117
}

0 commit comments

Comments
 (0)