aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsfricke-samsung <46493288+sfricke-samsung@users.noreply.github.com>2020-12-17 05:37:43 -0800
committerGitHub <noreply@github.com>2020-12-17 08:37:43 -0500
commit8f4b35c332e1b8dab2b5b8c56363bb106d335998 (patch)
tree09d5628fb981a5676e58fcaccda1efcc2c87fb06
parent4e31fdd4aa1f94dbd60b1d7374089ff7258e3b39 (diff)
downloadspirv-tools-8f4b35c332e1b8dab2b5b8c56363bb106d335998.tar.gz
spirv-val: Add Subgroup VUIDs (#4074)
-rw-r--r--source/val/validate_builtins.cpp157
-rw-r--r--source/val/validation_state.cpp40
-rw-r--r--test/val/val_builtins_test.cpp50
3 files changed, 149 insertions, 98 deletions
diff --git a/source/val/validate_builtins.cpp b/source/val/validate_builtins.cpp
index d85d1f0b..4f2a3b11 100644
--- a/source/val/validate_builtins.cpp
+++ b/source/val/validate_builtins.cpp
@@ -142,15 +142,28 @@ typedef enum VUIDError_ {
VUIDErrorMax,
} VUIDError;
-const static uint32_t NumRtBuiltins = 16;
+const static uint32_t NumVUIDBuiltins = 29;
typedef struct {
SpvBuiltIn builtIn;
uint32_t vuid[VUIDErrorMax]; // execution mode, storage class, type VUIDs
-} RtBuiltinVUIDMapping;
+} BuiltinVUIDMapping;
-std::array<RtBuiltinVUIDMapping, NumRtBuiltins> rtBuiltinInfo = {{
+std::array<BuiltinVUIDMapping, NumVUIDBuiltins> builtinVUIDInfo = {{
// clang-format off
+ {SpvBuiltInSubgroupEqMask, {0, 4370, 4371}},
+ {SpvBuiltInSubgroupGeMask, {0, 4372, 4373}},
+ {SpvBuiltInSubgroupGtMask, {0, 4374, 4375}},
+ {SpvBuiltInSubgroupLeMask, {0, 4376, 4377}},
+ {SpvBuiltInSubgroupLtMask, {0, 4378, 4379}},
+ {SpvBuiltInSubgroupLocalInvocationId, {0, 4380, 4381}},
+ {SpvBuiltInSubgroupSize, {0, 4382, 4383}},
+ {SpvBuiltInGlobalInvocationId, {4236, 4237, 4238}},
+ {SpvBuiltInLocalInvocationId, {4281, 4282, 4283}},
+ {SpvBuiltInNumWorkgroups, {4296, 4297, 4298}},
+ {SpvBuiltInNumSubgroups, {4293, 4294, 4295}},
+ {SpvBuiltInSubgroupId, {4367, 4368, 4369}},
+ {SpvBuiltInWorkgroupId, {4422, 4423, 4424}},
{SpvBuiltInHitKindKHR, {4242, 4243, 4244}},
{SpvBuiltInHitTNV, {4245, 4246, 4247}},
{SpvBuiltInInstanceCustomIndexKHR, {4251, 4252, 4253}},
@@ -170,9 +183,9 @@ std::array<RtBuiltinVUIDMapping, NumRtBuiltins> rtBuiltinInfo = {{
// clang-format off
} };
-uint32_t GetVUIDForRTBuiltin(SpvBuiltIn builtIn, VUIDError type) {
+uint32_t GetVUIDForBuiltin(SpvBuiltIn builtIn, VUIDError type) {
uint32_t vuid = 0;
- for (const auto& iter: rtBuiltinInfo) {
+ for (const auto& iter: builtinVUIDInfo) {
if (iter.builtIn == builtIn) {
assert(type < VUIDErrorMax);
vuid = iter.vuid[type];
@@ -2826,32 +2839,17 @@ spv_result_t BuiltInsValidator::ValidateLayerOrViewportIndexAtReference(
spv_result_t BuiltInsValidator::ValidateComputeShaderI32Vec3InputAtDefinition(
const Decoration& decoration, const Instruction& inst) {
if (spvIsVulkanOrWebGPUEnv(_.context()->target_env)) {
+ const SpvBuiltIn builtin = SpvBuiltIn(decoration.params()[0]);
if (spv_result_t error = ValidateI32Vec(
decoration, inst, 3,
- [this, &decoration,
- &inst](const std::string& message) -> spv_result_t {
- uint32_t operand = decoration.params()[0];
- uint32_t vuid = 0;
- switch (operand) {
- case SpvBuiltInGlobalInvocationId:
- vuid = 4238;
- break;
- case SpvBuiltInLocalInvocationId:
- vuid = 4283;
- break;
- case SpvBuiltInNumWorkgroups:
- vuid = 4298;
- break;
- case SpvBuiltInWorkgroupId:
- vuid = 4424;
- break;
- };
+ [this, &inst, builtin](const std::string& message) -> spv_result_t {
+ uint32_t vuid = GetVUIDForBuiltin(builtin, VUIDErrorType);
return _.diag(SPV_ERROR_INVALID_DATA, &inst)
<< _.VkErrorID(vuid) << "According to the "
<< spvLogStringForEnv(_.context()->target_env)
<< " spec BuiltIn "
<< _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN,
- operand)
+ builtin)
<< " variable needs to be a 3-component 32-bit int "
"vector. "
<< message;
@@ -2869,31 +2867,16 @@ spv_result_t BuiltInsValidator::ValidateComputeShaderI32Vec3InputAtReference(
const Decoration& decoration, const Instruction& built_in_inst,
const Instruction& referenced_inst,
const Instruction& referenced_from_inst) {
- uint32_t operand = decoration.params()[0];
if (spvIsVulkanOrWebGPUEnv(_.context()->target_env)) {
+ const SpvBuiltIn builtin = SpvBuiltIn(decoration.params()[0]);
const SpvStorageClass storage_class = GetStorageClass(referenced_from_inst);
if (storage_class != SpvStorageClassMax &&
storage_class != SpvStorageClassInput) {
- uint32_t vuid = 0;
- switch (operand) {
- case SpvBuiltInGlobalInvocationId:
- vuid = 4237;
- break;
- case SpvBuiltInLocalInvocationId:
- vuid = 4282;
- break;
- case SpvBuiltInNumWorkgroups:
- vuid = 4297;
- break;
- case SpvBuiltInWorkgroupId:
- vuid = 4423;
- break;
- };
+ uint32_t vuid = GetVUIDForBuiltin(builtin, VUIDErrorStorageClass);
return _.diag(SPV_ERROR_INVALID_DATA, &referenced_from_inst)
<< _.VkErrorID(vuid) << spvLogStringForEnv(_.context()->target_env)
<< " spec allows BuiltIn "
- << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN,
- decoration.params()[0])
+ << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN, builtin)
<< " to be only used for variables with Input storage class. "
<< GetReferenceDesc(decoration, built_in_inst, referenced_inst,
referenced_from_inst)
@@ -2907,27 +2890,12 @@ spv_result_t BuiltInsValidator::ValidateComputeShaderI32Vec3InputAtReference(
bool has_webgpu_model = execution_model == SpvExecutionModelGLCompute;
if ((spvIsVulkanEnv(_.context()->target_env) && !has_vulkan_model) ||
(spvIsWebGPUEnv(_.context()->target_env) && !has_webgpu_model)) {
- uint32_t vuid = 0;
- switch (operand) {
- case SpvBuiltInGlobalInvocationId:
- vuid = 4236;
- break;
- case SpvBuiltInLocalInvocationId:
- vuid = 4281;
- break;
- case SpvBuiltInNumWorkgroups:
- vuid = 4296;
- break;
- case SpvBuiltInWorkgroupId:
- vuid = 4422;
- break;
- };
+ uint32_t vuid = GetVUIDForBuiltin(builtin, VUIDErrorExecutionModel);
return _.diag(SPV_ERROR_INVALID_DATA, &referenced_from_inst)
<< _.VkErrorID(vuid)
<< spvLogStringForEnv(_.context()->target_env)
<< " spec allows BuiltIn "
- << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN,
- decoration.params()[0])
+ << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN, builtin)
<< " to be used only with GLCompute execution model. "
<< GetReferenceDesc(decoration, built_in_inst, referenced_inst,
referenced_from_inst, execution_model);
@@ -2949,23 +2917,23 @@ spv_result_t BuiltInsValidator::ValidateComputeShaderI32Vec3InputAtReference(
spv_result_t BuiltInsValidator::ValidateComputeI32InputAtDefinition(
const Decoration& decoration, const Instruction& inst) {
if (spvIsVulkanEnv(_.context()->target_env)) {
+ const SpvBuiltIn builtin = SpvBuiltIn(decoration.params()[0]);
if (decoration.struct_member_index() != Decoration::kInvalidMember) {
return _.diag(SPV_ERROR_INVALID_DATA, &inst)
<< "BuiltIn "
- << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN,
- decoration.params()[0])
+ << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN, builtin)
<< " cannot be used as a member decoration ";
}
if (spv_result_t error = ValidateI32(
decoration, inst,
- [this, &decoration,
- &inst](const std::string& message) -> spv_result_t {
+ [this, &inst, builtin](const std::string& message) -> spv_result_t {
+ uint32_t vuid = GetVUIDForBuiltin(builtin, VUIDErrorType);
return _.diag(SPV_ERROR_INVALID_DATA, &inst)
+ << _.VkErrorID(vuid)
<< "According to the "
<< spvLogStringForEnv(_.context()->target_env)
<< " spec BuiltIn "
- << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN,
- decoration.params()[0])
+ << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN, builtin)
<< " variable needs to be a 32-bit int "
"vector. "
<< message;
@@ -2983,14 +2951,16 @@ spv_result_t BuiltInsValidator::ValidateComputeI32InputAtReference(
const Instruction& referenced_inst,
const Instruction& referenced_from_inst) {
if (spvIsVulkanEnv(_.context()->target_env)) {
+ const SpvBuiltIn builtin = SpvBuiltIn(decoration.params()[0]);
const SpvStorageClass storage_class = GetStorageClass(referenced_from_inst);
if (storage_class != SpvStorageClassMax &&
storage_class != SpvStorageClassInput) {
+ uint32_t vuid = GetVUIDForBuiltin(builtin, VUIDErrorStorageClass);
return _.diag(SPV_ERROR_INVALID_DATA, &referenced_from_inst)
+ << _.VkErrorID(vuid)
<< spvLogStringForEnv(_.context()->target_env)
<< " spec allows BuiltIn "
- << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN,
- decoration.params()[0])
+ << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN, builtin)
<< " to be only used for variables with Input storage class. "
<< GetReferenceDesc(decoration, built_in_inst, referenced_inst,
referenced_from_inst)
@@ -3002,11 +2972,12 @@ spv_result_t BuiltInsValidator::ValidateComputeI32InputAtReference(
execution_model == SpvExecutionModelTaskNV ||
execution_model == SpvExecutionModelMeshNV;
if (spvIsVulkanEnv(_.context()->target_env) && !has_vulkan_model) {
+ uint32_t vuid = GetVUIDForBuiltin(builtin, VUIDErrorExecutionModel);
return _.diag(SPV_ERROR_INVALID_DATA, &referenced_from_inst)
+ << _.VkErrorID(vuid)
<< spvLogStringForEnv(_.context()->target_env)
<< " spec allows BuiltIn "
- << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN,
- decoration.params()[0])
+ << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN, builtin)
<< " to be used only with GLCompute execution model. "
<< GetReferenceDesc(decoration, built_in_inst, referenced_inst,
referenced_from_inst, execution_model);
@@ -3028,23 +2999,23 @@ spv_result_t BuiltInsValidator::ValidateComputeI32InputAtReference(
spv_result_t BuiltInsValidator::ValidateI32InputAtDefinition(
const Decoration& decoration, const Instruction& inst) {
if (spvIsVulkanEnv(_.context()->target_env)) {
+ const SpvBuiltIn builtin = SpvBuiltIn(decoration.params()[0]);
if (decoration.struct_member_index() != Decoration::kInvalidMember) {
return _.diag(SPV_ERROR_INVALID_DATA, &inst)
<< "BuiltIn "
- << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN,
- decoration.params()[0])
+ << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN, builtin)
<< " cannot be used as a member decoration ";
}
if (spv_result_t error = ValidateI32(
decoration, inst,
- [this, &decoration,
- &inst](const std::string& message) -> spv_result_t {
+ [this, &inst, builtin](const std::string& message) -> spv_result_t {
+ uint32_t vuid = GetVUIDForBuiltin(builtin, VUIDErrorType);
return _.diag(SPV_ERROR_INVALID_DATA, &inst)
+ << _.VkErrorID(vuid)
<< "According to the "
<< spvLogStringForEnv(_.context()->target_env)
<< " spec BuiltIn "
- << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN,
- decoration.params()[0])
+ << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN, builtin)
<< " variable needs to be a 32-bit int. " << message;
})) {
return error;
@@ -3053,11 +3024,12 @@ spv_result_t BuiltInsValidator::ValidateI32InputAtDefinition(
const SpvStorageClass storage_class = GetStorageClass(inst);
if (storage_class != SpvStorageClassMax &&
storage_class != SpvStorageClassInput) {
+ uint32_t vuid = GetVUIDForBuiltin(builtin, VUIDErrorStorageClass);
return _.diag(SPV_ERROR_INVALID_DATA, &inst)
+ << _.VkErrorID(vuid)
<< spvLogStringForEnv(_.context()->target_env)
<< " spec allows BuiltIn "
- << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN,
- decoration.params()[0])
+ << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN, builtin)
<< " to be only used for variables with Input storage class. "
<< GetReferenceDesc(decoration, inst, inst, inst) << " "
<< GetStorageClassDesc(inst);
@@ -3070,23 +3042,23 @@ spv_result_t BuiltInsValidator::ValidateI32InputAtDefinition(
spv_result_t BuiltInsValidator::ValidateI32Vec4InputAtDefinition(
const Decoration& decoration, const Instruction& inst) {
if (spvIsVulkanEnv(_.context()->target_env)) {
+ const SpvBuiltIn builtin = SpvBuiltIn(decoration.params()[0]);
if (decoration.struct_member_index() != Decoration::kInvalidMember) {
return _.diag(SPV_ERROR_INVALID_DATA, &inst)
<< "BuiltIn "
- << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN,
- decoration.params()[0])
+ << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN, builtin)
<< " cannot be used as a member decoration ";
}
if (spv_result_t error = ValidateI32Vec(
decoration, inst, 4,
- [this, &decoration,
- &inst](const std::string& message) -> spv_result_t {
+ [this, &inst, builtin](const std::string& message) -> spv_result_t {
+ uint32_t vuid = GetVUIDForBuiltin(builtin, VUIDErrorType);
return _.diag(SPV_ERROR_INVALID_DATA, &inst)
+ << _.VkErrorID(vuid)
<< "According to the "
<< spvLogStringForEnv(_.context()->target_env)
<< " spec BuiltIn "
- << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN,
- decoration.params()[0])
+ << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN, builtin)
<< " variable needs to be a 4-component 32-bit int "
"vector. "
<< message;
@@ -3097,11 +3069,12 @@ spv_result_t BuiltInsValidator::ValidateI32Vec4InputAtDefinition(
const SpvStorageClass storage_class = GetStorageClass(inst);
if (storage_class != SpvStorageClassMax &&
storage_class != SpvStorageClassInput) {
+ uint32_t vuid = GetVUIDForBuiltin(builtin, VUIDErrorStorageClass);
return _.diag(SPV_ERROR_INVALID_DATA, &inst)
+ << _.VkErrorID(vuid)
<< spvLogStringForEnv(_.context()->target_env)
<< " spec allows BuiltIn "
- << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN,
- decoration.params()[0])
+ << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN, builtin)
<< " to be only used for variables with Input storage class. "
<< GetReferenceDesc(decoration, inst, inst, inst) << " "
<< GetStorageClassDesc(inst);
@@ -3628,7 +3601,7 @@ spv_result_t BuiltInsValidator::ValidateRayTracingBuiltinsAtDefinition(
decoration, inst,
[this, &inst,
builtin](const std::string& message) -> spv_result_t {
- uint32_t vuid = GetVUIDForRTBuiltin(builtin, VUIDErrorType);
+ uint32_t vuid = GetVUIDForBuiltin(builtin, VUIDErrorType);
return _.diag(SPV_ERROR_INVALID_DATA, &inst)
<< _.VkErrorID(vuid)
<< "According to the Vulkan spec BuiltIn "
@@ -3650,7 +3623,7 @@ spv_result_t BuiltInsValidator::ValidateRayTracingBuiltinsAtDefinition(
decoration, inst,
[this, &inst,
builtin](const std::string& message) -> spv_result_t {
- uint32_t vuid = GetVUIDForRTBuiltin(builtin, VUIDErrorType);
+ uint32_t vuid = GetVUIDForBuiltin(builtin, VUIDErrorType);
return _.diag(SPV_ERROR_INVALID_DATA, &inst)
<< _.VkErrorID(vuid)
<< "According to the Vulkan spec BuiltIn "
@@ -3671,7 +3644,7 @@ spv_result_t BuiltInsValidator::ValidateRayTracingBuiltinsAtDefinition(
decoration, inst, 3,
[this, &inst,
builtin](const std::string& message) -> spv_result_t {
- uint32_t vuid = GetVUIDForRTBuiltin(builtin, VUIDErrorType);
+ uint32_t vuid = GetVUIDForBuiltin(builtin, VUIDErrorType);
return _.diag(SPV_ERROR_INVALID_DATA, &inst)
<< _.VkErrorID(vuid)
<< "According to the Vulkan spec BuiltIn "
@@ -3691,7 +3664,7 @@ spv_result_t BuiltInsValidator::ValidateRayTracingBuiltinsAtDefinition(
decoration, inst, 3,
[this, &inst,
builtin](const std::string& message) -> spv_result_t {
- uint32_t vuid = GetVUIDForRTBuiltin(builtin, VUIDErrorType);
+ uint32_t vuid = GetVUIDForBuiltin(builtin, VUIDErrorType);
return _.diag(SPV_ERROR_INVALID_DATA, &inst)
<< _.VkErrorID(vuid)
<< "According to the Vulkan spec BuiltIn "
@@ -3711,7 +3684,7 @@ spv_result_t BuiltInsValidator::ValidateRayTracingBuiltinsAtDefinition(
decoration, inst, 3, 4,
[this, &inst,
builtin](const std::string& message) -> spv_result_t {
- uint32_t vuid = GetVUIDForRTBuiltin(builtin, VUIDErrorType);
+ uint32_t vuid = GetVUIDForBuiltin(builtin, VUIDErrorType);
return _.diag(SPV_ERROR_INVALID_DATA, &inst)
<< _.VkErrorID(vuid)
<< "According to the Vulkan spec BuiltIn "
@@ -3744,7 +3717,7 @@ spv_result_t BuiltInsValidator::ValidateRayTracingBuiltinsAtReference(
const SpvStorageClass storage_class = GetStorageClass(referenced_from_inst);
if (storage_class != SpvStorageClassMax &&
storage_class != SpvStorageClassInput) {
- uint32_t vuid = GetVUIDForRTBuiltin(builtin, VUIDErrorStorageClass);
+ uint32_t vuid = GetVUIDForBuiltin(builtin, VUIDErrorStorageClass);
return _.diag(SPV_ERROR_INVALID_DATA, &referenced_from_inst)
<< _.VkErrorID(vuid) << "Vulkan spec allows BuiltIn "
<< _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN,
@@ -3757,7 +3730,7 @@ spv_result_t BuiltInsValidator::ValidateRayTracingBuiltinsAtReference(
for (const SpvExecutionModel execution_model : execution_models_) {
if (!IsExecutionModelValidForRtBuiltIn(builtin, execution_model)) {
- uint32_t vuid = GetVUIDForRTBuiltin(builtin, VUIDErrorExecutionModel);
+ uint32_t vuid = GetVUIDForBuiltin(builtin, VUIDErrorExecutionModel);
return _.diag(SPV_ERROR_INVALID_DATA, &referenced_from_inst)
<< _.VkErrorID(vuid) << "Vulkan spec does not allow BuiltIn "
<< _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN,
diff --git a/source/val/validation_state.cpp b/source/val/validation_state.cpp
index 1d67345b..d59f3883 100644
--- a/source/val/validation_state.cpp
+++ b/source/val/validation_state.cpp
@@ -1445,6 +1445,12 @@ std::string ValidationState_t::VkErrorID(uint32_t id,
return VUID_WRAP(VUID-LocalInvocationId-LocalInvocationId-04282);
case 4283:
return VUID_WRAP(VUID-LocalInvocationId-LocalInvocationId-04283);
+ case 4293:
+ return VUID_WRAP(VUID-NumSubgroups-NumSubgroups-04293);
+ case 4294:
+ return VUID_WRAP(VUID-NumSubgroups-NumSubgroups-04294);
+ case 4295:
+ return VUID_WRAP(VUID-NumSubgroups-NumSubgroups-04295);
case 4296:
return VUID_WRAP(VUID-NumWorkgroups-NumWorkgroups-04296);
case 4297:
@@ -1539,6 +1545,40 @@ std::string ValidationState_t::VkErrorID(uint32_t id,
return VUID_WRAP(VUID-SamplePosition-SamplePosition-04361);
case 4362:
return VUID_WRAP(VUID-SamplePosition-SamplePosition-04362);
+ case 4367:
+ return VUID_WRAP(VUID-SubgroupId-SubgroupId-04367);
+ case 4368:
+ return VUID_WRAP(VUID-SubgroupId-SubgroupId-04368);
+ case 4369:
+ return VUID_WRAP(VUID-SubgroupId-SubgroupId-04369);
+ case 4370:
+ return VUID_WRAP(VUID-SubgroupEqMask-SubgroupEqMask-04370);
+ case 4371:
+ return VUID_WRAP(VUID-SubgroupEqMask-SubgroupEqMask-04371);
+ case 4372:
+ return VUID_WRAP(VUID-SubgroupGeMask-SubgroupGeMask-04372);
+ case 4373:
+ return VUID_WRAP(VUID-SubgroupGeMask-SubgroupGeMask-04373);
+ case 4374:
+ return VUID_WRAP(VUID-SubgroupGtMask-SubgroupGtMask-04374);
+ case 4375:
+ return VUID_WRAP(VUID-SubgroupGtMask-SubgroupGtMask-04375);
+ case 4376:
+ return VUID_WRAP(VUID-SubgroupLeMask-SubgroupLeMask-04376);
+ case 4377:
+ return VUID_WRAP(VUID-SubgroupLeMask-SubgroupLeMask-04377);
+ case 4378:
+ return VUID_WRAP(VUID-SubgroupLtMask-SubgroupLtMask-04378);
+ case 4379:
+ return VUID_WRAP(VUID-SubgroupLtMask-SubgroupLtMask-04379);
+ case 4380:
+ return VUID_WRAP(VUID-SubgroupLocalInvocationId-SubgroupLocalInvocationId-04380);
+ case 4381:
+ return VUID_WRAP(VUID-SubgroupLocalInvocationId-SubgroupLocalInvocationId-04381);
+ case 4382:
+ return VUID_WRAP(VUID-SubgroupSize-SubgroupSize-04382);
+ case 4383:
+ return VUID_WRAP(VUID-SubgroupSize-SubgroupSize-04383);
case 4387:
return VUID_WRAP(VUID-TessCoord-TessCoord-04387);
case 4388:
diff --git a/test/val/val_builtins_test.cpp b/test/val/val_builtins_test.cpp
index cce3cd54..eac38344 100644
--- a/test/val/val_builtins_test.cpp
+++ b/test/val/val_builtins_test.cpp
@@ -54,8 +54,9 @@ using ::testing::Values;
using ::testing::ValuesIn;
using ValidateBuiltIns = spvtest::ValidateBase<bool>;
-using ValidateVulkanSubgroupBuiltIns = spvtest::ValidateBase<
- std::tuple<const char*, const char*, const char*, const char*, TestResult>>;
+using ValidateVulkanSubgroupBuiltIns =
+ spvtest::ValidateBase<std::tuple<const char*, const char*, const char*,
+ const char*, const char*, TestResult>>;
using ValidateVulkanCombineBuiltInExecutionModelDataTypeResult =
spvtest::ValidateBase<std::tuple<const char*, const char*, const char*,
const char*, const char*, TestResult>>;
@@ -4082,7 +4083,8 @@ TEST_P(ValidateVulkanSubgroupBuiltIns, InMain) {
const char* const execution_model = std::get<1>(GetParam());
const char* const storage_class = std::get<2>(GetParam());
const char* const data_type = std::get<3>(GetParam());
- const TestResult& test_result = std::get<4>(GetParam());
+ const char* const vuid = std::get<4>(GetParam());
+ const TestResult& test_result = std::get<5>(GetParam());
CodeGenerator generator = CodeGenerator::GetDefaultShaderCodeGenerator();
generator.capabilities_ += R"(
@@ -4142,6 +4144,9 @@ OpCapability GroupNonUniformBallot
if (test_result.error_str2) {
EXPECT_THAT(getDiagnosticString(), HasSubstr(test_result.error_str2));
}
+ if (vuid) {
+ EXPECT_THAT(getDiagnosticString(), AnyVUID(vuid));
+ }
}
INSTANTIATE_TEST_SUITE_P(
@@ -4149,6 +4154,11 @@ INSTANTIATE_TEST_SUITE_P(
Combine(Values("SubgroupEqMask", "SubgroupGeMask", "SubgroupGtMask",
"SubgroupLeMask", "SubgroupLtMask"),
Values("GLCompute"), Values("Input"), Values("%u32vec3"),
+ Values("VUID-SubgroupEqMask-SubgroupEqMask-04371 "
+ "VUID-SubgroupGeMask-SubgroupGeMask-04373 "
+ "VUID-SubgroupGtMask-SubgroupGtMask-04375 "
+ "VUID-SubgroupLeMask-SubgroupLeMask-04377 "
+ "VUID-SubgroupLtMask-SubgroupLtMask-04379"),
Values(TestResult(SPV_ERROR_INVALID_DATA,
"needs to be a 4-component 32-bit int vector"))));
@@ -4157,6 +4167,11 @@ INSTANTIATE_TEST_SUITE_P(
Combine(Values("SubgroupEqMask", "SubgroupGeMask", "SubgroupGtMask",
"SubgroupLeMask", "SubgroupLtMask"),
Values("GLCompute"), Values("Input"), Values("%f32vec4"),
+ Values("VUID-SubgroupEqMask-SubgroupEqMask-04371 "
+ "VUID-SubgroupGeMask-SubgroupGeMask-04373 "
+ "VUID-SubgroupGtMask-SubgroupGtMask-04375 "
+ "VUID-SubgroupLeMask-SubgroupLeMask-04377 "
+ "VUID-SubgroupLtMask-SubgroupLtMask-04379"),
Values(TestResult(SPV_ERROR_INVALID_DATA,
"needs to be a 4-component 32-bit int vector"))));
@@ -4166,6 +4181,11 @@ INSTANTIATE_TEST_SUITE_P(
"SubgroupLeMask", "SubgroupLtMask"),
Values("GLCompute"), Values("Output", "Workgroup", "Private"),
Values("%u32vec4"),
+ Values("VUID-SubgroupEqMask-SubgroupEqMask-04370 "
+ "VUID-SubgroupGeMask-SubgroupGeMask-04372 "
+ "VUID-SubgroupGtMask-SubgroupGtMask-04374 "
+ "VUID-SubgroupLeMask-SubgroupLeMask-04376 "
+ "VUID-SubgroupLtMask-SubgroupLtMask-04378"),
Values(TestResult(
SPV_ERROR_INVALID_DATA,
"to be only used for variables with Input storage class"))));
@@ -4175,7 +4195,7 @@ INSTANTIATE_TEST_SUITE_P(SubgroupMaskOk, ValidateVulkanSubgroupBuiltIns,
"SubgroupGtMask", "SubgroupLeMask",
"SubgroupLtMask"),
Values("GLCompute"), Values("Input"),
- Values("%u32vec4"),
+ Values("%u32vec4"), Values(nullptr),
Values(TestResult(SPV_SUCCESS, ""))));
TEST_F(ValidateBuiltIns, SubgroupMaskMemberDecorate) {
@@ -4208,6 +4228,8 @@ INSTANTIATE_TEST_SUITE_P(
SubgroupInvocationIdAndSizeNotU32, ValidateVulkanSubgroupBuiltIns,
Combine(Values("SubgroupLocalInvocationId", "SubgroupSize"),
Values("GLCompute"), Values("Input"), Values("%f32"),
+ Values("VUID-SubgroupLocalInvocationId-SubgroupLocalInvocationId-"
+ "04381 VUID-SubgroupSize-SubgroupSize-04383"),
Values(TestResult(SPV_ERROR_INVALID_DATA,
"needs to be a 32-bit int"))));
@@ -4216,6 +4238,8 @@ INSTANTIATE_TEST_SUITE_P(
Combine(Values("SubgroupLocalInvocationId", "SubgroupSize"),
Values("GLCompute"), Values("Output", "Workgroup", "Private"),
Values("%u32"),
+ Values("VUID-SubgroupLocalInvocationId-SubgroupLocalInvocationId-"
+ "04380 VUID-SubgroupSize-SubgroupSize-04382"),
Values(TestResult(
SPV_ERROR_INVALID_DATA,
"to be only used for variables with Input storage class"))));
@@ -4224,7 +4248,7 @@ INSTANTIATE_TEST_SUITE_P(
SubgroupInvocationIdAndSizeOk, ValidateVulkanSubgroupBuiltIns,
Combine(Values("SubgroupLocalInvocationId", "SubgroupSize"),
Values("GLCompute"), Values("Input"), Values("%u32"),
- Values(TestResult(SPV_SUCCESS, ""))));
+ Values(nullptr), Values(TestResult(SPV_SUCCESS, ""))));
TEST_F(ValidateBuiltIns, SubgroupSizeMemberDecorate) {
const std::string text = R"(
@@ -4252,9 +4276,21 @@ OpFunctionEnd
}
INSTANTIATE_TEST_SUITE_P(
+ SubgroupNumAndIdNotCompute, ValidateVulkanSubgroupBuiltIns,
+ Combine(
+ Values("SubgroupId", "NumSubgroups"), Values("Vertex"), Values("Input"),
+ Values("%u32"),
+ Values("VUID-SubgroupId-SubgroupId-04367 "
+ "VUID-NumSubgroups-NumSubgroups-04293"),
+ Values(TestResult(SPV_ERROR_INVALID_DATA,
+ "to be used only with GLCompute execution model"))));
+
+INSTANTIATE_TEST_SUITE_P(
SubgroupNumAndIdNotU32, ValidateVulkanSubgroupBuiltIns,
Combine(Values("SubgroupId", "NumSubgroups"), Values("GLCompute"),
Values("Input"), Values("%f32"),
+ Values("VUID-SubgroupId-SubgroupId-04369 "
+ "VUID-NumSubgroups-NumSubgroups-04295"),
Values(TestResult(SPV_ERROR_INVALID_DATA,
"needs to be a 32-bit int"))));
@@ -4262,6 +4298,8 @@ INSTANTIATE_TEST_SUITE_P(
SubgroupNumAndIdNotInput, ValidateVulkanSubgroupBuiltIns,
Combine(Values("SubgroupId", "NumSubgroups"), Values("GLCompute"),
Values("Output", "Workgroup", "Private"), Values("%u32"),
+ Values("VUID-SubgroupId-SubgroupId-04368 "
+ "VUID-NumSubgroups-NumSubgroups-04294"),
Values(TestResult(
SPV_ERROR_INVALID_DATA,
"to be only used for variables with Input storage class"))));
@@ -4269,7 +4307,7 @@ INSTANTIATE_TEST_SUITE_P(
INSTANTIATE_TEST_SUITE_P(SubgroupNumAndIdOk, ValidateVulkanSubgroupBuiltIns,
Combine(Values("SubgroupId", "NumSubgroups"),
Values("GLCompute"), Values("Input"),
- Values("%u32"),
+ Values("%u32"), Values(nullptr),
Values(TestResult(SPV_SUCCESS, ""))));
TEST_F(ValidateBuiltIns, SubgroupIdMemberDecorate) {