mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-11-24 04:20:13 +00:00
Update diag() in validate_barriers (#1754)
This CL updates validate_barriers to provide an explicit instruction when calling diag().
This commit is contained in:
parent
32ccf0d04c
commit
111933537b
@ -37,7 +37,7 @@ spv_result_t ValidateExecutionScope(ValidationState_t& _,
|
|||||||
std::tie(is_int32, is_const_int32, value) = _.EvalInt32IfConst(id);
|
std::tie(is_int32, is_const_int32, value) = _.EvalInt32IfConst(id);
|
||||||
|
|
||||||
if (!is_int32) {
|
if (!is_int32) {
|
||||||
return _.diag(SPV_ERROR_INVALID_DATA)
|
return _.diag(SPV_ERROR_INVALID_DATA, inst)
|
||||||
<< spvOpcodeString(opcode)
|
<< spvOpcodeString(opcode)
|
||||||
<< ": expected Execution Scope to be a 32-bit int";
|
<< ": expected Execution Scope to be a 32-bit int";
|
||||||
}
|
}
|
||||||
@ -48,7 +48,7 @@ spv_result_t ValidateExecutionScope(ValidationState_t& _,
|
|||||||
|
|
||||||
if (spvIsVulkanEnv(_.context()->target_env)) {
|
if (spvIsVulkanEnv(_.context()->target_env)) {
|
||||||
if (value != SpvScopeWorkgroup && value != SpvScopeSubgroup) {
|
if (value != SpvScopeWorkgroup && value != SpvScopeSubgroup) {
|
||||||
return _.diag(SPV_ERROR_INVALID_DATA)
|
return _.diag(SPV_ERROR_INVALID_DATA, inst)
|
||||||
<< spvOpcodeString(opcode)
|
<< spvOpcodeString(opcode)
|
||||||
<< ": in Vulkan environment Execution Scope is limited to "
|
<< ": in Vulkan environment Execution Scope is limited to "
|
||||||
"Workgroup and Subgroup";
|
"Workgroup and Subgroup";
|
||||||
@ -89,7 +89,7 @@ spv_result_t ValidateMemoryScope(ValidationState_t& _, const Instruction* inst,
|
|||||||
std::tie(is_int32, is_const_int32, value) = _.EvalInt32IfConst(id);
|
std::tie(is_int32, is_const_int32, value) = _.EvalInt32IfConst(id);
|
||||||
|
|
||||||
if (!is_int32) {
|
if (!is_int32) {
|
||||||
return _.diag(SPV_ERROR_INVALID_DATA)
|
return _.diag(SPV_ERROR_INVALID_DATA, inst)
|
||||||
<< spvOpcodeString(opcode)
|
<< spvOpcodeString(opcode)
|
||||||
<< ": expected Memory Scope to be a 32-bit int";
|
<< ": expected Memory Scope to be a 32-bit int";
|
||||||
}
|
}
|
||||||
@ -100,14 +100,14 @@ spv_result_t ValidateMemoryScope(ValidationState_t& _, const Instruction* inst,
|
|||||||
|
|
||||||
if (spvIsVulkanEnv(_.context()->target_env)) {
|
if (spvIsVulkanEnv(_.context()->target_env)) {
|
||||||
if (value == SpvScopeCrossDevice) {
|
if (value == SpvScopeCrossDevice) {
|
||||||
return _.diag(SPV_ERROR_INVALID_DATA)
|
return _.diag(SPV_ERROR_INVALID_DATA, inst)
|
||||||
<< spvOpcodeString(opcode)
|
<< spvOpcodeString(opcode)
|
||||||
<< ": in Vulkan environment, Memory Scope cannot be CrossDevice";
|
<< ": in Vulkan environment, Memory Scope cannot be CrossDevice";
|
||||||
}
|
}
|
||||||
if (_.context()->target_env == SPV_ENV_VULKAN_1_0 &&
|
if (_.context()->target_env == SPV_ENV_VULKAN_1_0 &&
|
||||||
value != SpvScopeDevice && value != SpvScopeWorkgroup &&
|
value != SpvScopeDevice && value != SpvScopeWorkgroup &&
|
||||||
value != SpvScopeInvocation) {
|
value != SpvScopeInvocation) {
|
||||||
return _.diag(SPV_ERROR_INVALID_DATA)
|
return _.diag(SPV_ERROR_INVALID_DATA, inst)
|
||||||
<< spvOpcodeString(opcode)
|
<< spvOpcodeString(opcode)
|
||||||
<< ": in Vulkan 1.0 environment Memory Scope is limited to "
|
<< ": in Vulkan 1.0 environment Memory Scope is limited to "
|
||||||
"Device, "
|
"Device, "
|
||||||
@ -129,7 +129,7 @@ spv_result_t ValidateMemorySemantics(ValidationState_t& _,
|
|||||||
std::tie(is_int32, is_const_int32, value) = _.EvalInt32IfConst(id);
|
std::tie(is_int32, is_const_int32, value) = _.EvalInt32IfConst(id);
|
||||||
|
|
||||||
if (!is_int32) {
|
if (!is_int32) {
|
||||||
return _.diag(SPV_ERROR_INVALID_DATA)
|
return _.diag(SPV_ERROR_INVALID_DATA, inst)
|
||||||
<< spvOpcodeString(opcode)
|
<< spvOpcodeString(opcode)
|
||||||
<< ": expected Memory Semantics to be a 32-bit int";
|
<< ": expected Memory Semantics to be a 32-bit int";
|
||||||
}
|
}
|
||||||
@ -144,7 +144,7 @@ spv_result_t ValidateMemorySemantics(ValidationState_t& _,
|
|||||||
SpvMemorySemanticsSequentiallyConsistentMask));
|
SpvMemorySemanticsSequentiallyConsistentMask));
|
||||||
|
|
||||||
if (num_memory_order_set_bits > 1) {
|
if (num_memory_order_set_bits > 1) {
|
||||||
return _.diag(SPV_ERROR_INVALID_DATA)
|
return _.diag(SPV_ERROR_INVALID_DATA, inst)
|
||||||
<< spvOpcodeString(opcode)
|
<< spvOpcodeString(opcode)
|
||||||
<< ": Memory Semantics can have at most one of the following bits "
|
<< ": Memory Semantics can have at most one of the following bits "
|
||||||
"set: Acquire, Release, AcquireRelease or SequentiallyConsistent";
|
"set: Acquire, Release, AcquireRelease or SequentiallyConsistent";
|
||||||
@ -157,7 +157,7 @@ spv_result_t ValidateMemorySemantics(ValidationState_t& _,
|
|||||||
SpvMemorySemanticsImageMemoryMask);
|
SpvMemorySemanticsImageMemoryMask);
|
||||||
|
|
||||||
if (opcode == SpvOpMemoryBarrier && !num_memory_order_set_bits) {
|
if (opcode == SpvOpMemoryBarrier && !num_memory_order_set_bits) {
|
||||||
return _.diag(SPV_ERROR_INVALID_DATA)
|
return _.diag(SPV_ERROR_INVALID_DATA, inst)
|
||||||
<< spvOpcodeString(opcode)
|
<< spvOpcodeString(opcode)
|
||||||
<< ": Vulkan specification requires Memory Semantics to have one "
|
<< ": Vulkan specification requires Memory Semantics to have one "
|
||||||
"of the following bits set: Acquire, Release, AcquireRelease "
|
"of the following bits set: Acquire, Release, AcquireRelease "
|
||||||
@ -165,7 +165,7 @@ spv_result_t ValidateMemorySemantics(ValidationState_t& _,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (opcode == SpvOpMemoryBarrier && !includes_storage_class) {
|
if (opcode == SpvOpMemoryBarrier && !includes_storage_class) {
|
||||||
return _.diag(SPV_ERROR_INVALID_DATA)
|
return _.diag(SPV_ERROR_INVALID_DATA, inst)
|
||||||
<< spvOpcodeString(opcode)
|
<< spvOpcodeString(opcode)
|
||||||
<< ": expected Memory Semantics to include a Vulkan-supported "
|
<< ": expected Memory Semantics to include a Vulkan-supported "
|
||||||
"storage class";
|
"storage class";
|
||||||
@ -174,7 +174,7 @@ spv_result_t ValidateMemorySemantics(ValidationState_t& _,
|
|||||||
#if 0
|
#if 0
|
||||||
// TODO(atgoo@github.com): this check fails Vulkan CTS, reenable once fixed.
|
// TODO(atgoo@github.com): this check fails Vulkan CTS, reenable once fixed.
|
||||||
if (opcode == SpvOpControlBarrier && value && !includes_storage_class) {
|
if (opcode == SpvOpControlBarrier && value && !includes_storage_class) {
|
||||||
return _.diag(SPV_ERROR_INVALID_DATA)
|
return _.diag(SPV_ERROR_INVALID_DATA, inst)
|
||||||
<< spvOpcodeString(opcode)
|
<< spvOpcodeString(opcode)
|
||||||
<< ": expected Memory Semantics to include a Vulkan-supported "
|
<< ": expected Memory Semantics to include a Vulkan-supported "
|
||||||
"storage class if Memory Semantics is not None";
|
"storage class if Memory Semantics is not None";
|
||||||
@ -249,7 +249,7 @@ spv_result_t BarriersPass(ValidationState_t& _, const Instruction* inst) {
|
|||||||
|
|
||||||
case SpvOpNamedBarrierInitialize: {
|
case SpvOpNamedBarrierInitialize: {
|
||||||
if (_.GetIdOpcode(result_type) != SpvOpTypeNamedBarrier) {
|
if (_.GetIdOpcode(result_type) != SpvOpTypeNamedBarrier) {
|
||||||
return _.diag(SPV_ERROR_INVALID_DATA)
|
return _.diag(SPV_ERROR_INVALID_DATA, inst)
|
||||||
<< spvOpcodeString(opcode)
|
<< spvOpcodeString(opcode)
|
||||||
<< ": expected Result Type to be OpTypeNamedBarrier";
|
<< ": expected Result Type to be OpTypeNamedBarrier";
|
||||||
}
|
}
|
||||||
@ -257,7 +257,7 @@ spv_result_t BarriersPass(ValidationState_t& _, const Instruction* inst) {
|
|||||||
const uint32_t subgroup_count_type = _.GetOperandTypeId(inst, 2);
|
const uint32_t subgroup_count_type = _.GetOperandTypeId(inst, 2);
|
||||||
if (!_.IsIntScalarType(subgroup_count_type) ||
|
if (!_.IsIntScalarType(subgroup_count_type) ||
|
||||||
_.GetBitWidth(subgroup_count_type) != 32) {
|
_.GetBitWidth(subgroup_count_type) != 32) {
|
||||||
return _.diag(SPV_ERROR_INVALID_DATA)
|
return _.diag(SPV_ERROR_INVALID_DATA, inst)
|
||||||
<< spvOpcodeString(opcode)
|
<< spvOpcodeString(opcode)
|
||||||
<< ": expected Subgroup Count to be a 32-bit int";
|
<< ": expected Subgroup Count to be a 32-bit int";
|
||||||
}
|
}
|
||||||
@ -267,7 +267,7 @@ spv_result_t BarriersPass(ValidationState_t& _, const Instruction* inst) {
|
|||||||
case SpvOpMemoryNamedBarrier: {
|
case SpvOpMemoryNamedBarrier: {
|
||||||
const uint32_t named_barrier_type = _.GetOperandTypeId(inst, 0);
|
const uint32_t named_barrier_type = _.GetOperandTypeId(inst, 0);
|
||||||
if (_.GetIdOpcode(named_barrier_type) != SpvOpTypeNamedBarrier) {
|
if (_.GetIdOpcode(named_barrier_type) != SpvOpTypeNamedBarrier) {
|
||||||
return _.diag(SPV_ERROR_INVALID_DATA)
|
return _.diag(SPV_ERROR_INVALID_DATA, inst)
|
||||||
<< spvOpcodeString(opcode)
|
<< spvOpcodeString(opcode)
|
||||||
<< ": expected Named Barrier to be of type OpTypeNamedBarrier";
|
<< ": expected Named Barrier to be of type OpTypeNamedBarrier";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user