layers: Add check and test for relax block layout
Tell the SPIR-V validator to skip block layout checking if the
VK_KHR_relaxed_block_layout extension is enabled.
This prevents validation error messages for shaders with
non-compliant layouts when the extension is enabled.
The VK_KHR_relaxed_block_layout extension was promoted to core
in 1.1, so it is "enabled" for 1.1 and later apps all the time.
Since block layout checking is always relaxed in 1.1 or later,
there is really no way to write a negative test for 1.1 or later.
Therefore there is just a positive test that checks that no error
is generated for a shader with a non-compiliant layout.
Fixes #275
diff --git a/layers/shader_validation.cpp b/layers/shader_validation.cpp
index 86a25ce..2b26f4d 100644
--- a/layers/shader_validation.cpp
+++ b/layers/shader_validation.cpp
@@ -1810,8 +1810,11 @@
spv_context ctx = spvContextCreate(spirv_environment);
spv_const_binary_t binary{pCreateInfo->pCode, pCreateInfo->codeSize / sizeof(uint32_t)};
spv_diagnostic diag = nullptr;
-
- spv_valid = spvValidate(ctx, &binary, &diag);
+ spv_validator_options options = spvValidatorOptionsCreate();
+ if (GetDeviceExtensions(dev_data)->vk_khr_relaxed_block_layout) {
+ spvValidatorOptionsSetRelaxBlockLayout(options, true);
+ }
+ spv_valid = spvValidateWithOptions(ctx, options, &binary, &diag);
if (spv_valid != SPV_SUCCESS) {
if (!have_glsl_shader || (pCreateInfo->pCode[0] == spv::MagicNumber)) {
skip |=
@@ -1825,6 +1828,7 @@
}
}
+ spvValidatorOptionsDestroy(options);
spvDiagnosticDestroy(diag);
spvContextDestroy(ctx);
}