[spirv] Clarify error when Globals binding missing (#4519)

When -fvk-bind-register is used, all resource must have corresponding
register bindings set, including the Globals cbuffer. This change
clarifies the error message when the latter is the cause of failure and
directs the user to specify -fvk-bind-globals.

Fixes #3781
This commit is contained in:
Natalie Chouinard 2022-06-20 07:26:29 -07:00 коммит произвёл GitHub
Родитель e80724a7a0
Коммит 72f76439e0
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 27 добавлений и 2 удалений

Просмотреть файл

@ -3937,7 +3937,8 @@ codegen for Vulkan:
option cannot be used together with other binding assignment options.
It requires all source code resources have ``:register()`` attribute and
all registers have corresponding Vulkan descriptors specified using this
option.
option. If the ``$Globals`` cbuffer resource is used, it must also be bound
with ``-fvk-bind-globals``.
- ``-fvk-bind-globals N M``: Places the ``$Globals`` cbuffer at
descriptor set #M and binding #N. See `HLSL global variables and Vulkan binding`_
for explanation and examples.

Просмотреть файл

@ -2222,7 +2222,14 @@ bool DeclResultIdMapper::decorateResourceBindings() {
}
spvBuilder.decorateDSetBinding(var.getSpirvInstr(), setNo, bindNo);
}
} else if (bindGlobals && var.isGlobalsBuffer()) {
} else if (var.isGlobalsBuffer()) {
if (!bindGlobals) {
emitError("-fvk-bind-register requires Globals buffer to be bound "
"with -fvk-bind-globals",
var.getSourceLocation());
return false;
}
spvBuilder.decorateDSetBinding(var.getSpirvInstr(), globalsSetNo,
globalsBindNo);
} else {

Просмотреть файл

@ -0,0 +1,13 @@
// RUN: %dxc -T ps_6_0 -E main -fvk-bind-register t5 0 1 2 -vkbr s3 1 3 4
Texture2D MyTexture : register(t5);
SamplerState MySampler : register(s3, space1);
int globalInteger;
float4 globalFloat4;
float4 main() : SV_Target {
return MyTexture.Sample(MySampler, float2(0.1, 0.2));
}
// CHECK: error: -fvk-bind-register requires Globals buffer to be bound with -fvk-bind-globals

Просмотреть файл

@ -2015,6 +2015,10 @@ TEST_F(FileTest, VulkanRegisterBinding1to1MappingInvalidBindNo) {
TEST_F(FileTest, VulkanRegisterBinding1to1MappingMissingAttr) {
runFileTest("vk.binding.cl.register.missing-attr.hlsl", Expect::Failure);
}
TEST_F(FileTest, VulkanRegisterBinding1to1MappingMissingBindGlobals) {
runFileTest("vk.binding.cl.register.missing-bind-globals.hlsl",
Expect::Failure);
}
TEST_F(FileTest, VulkanRegisterBinding1to1MappingMissingCLOption) {
runFileTest("vk.binding.cl.register.missing-cl.hlsl", Expect::Failure);
}