MCPcopy Create free account
hub / github.com/KhronosGroup/SPIRV-Tools / ValidateScope

Function ValidateScope

source/val/validate_scopes.cpp:42–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40}
41
42spv_result_t ValidateScope(ValidationState_t& _, const Instruction* inst,
43 uint32_t scope) {
44 spv::Op opcode = inst->opcode();
45 bool is_int32 = false, is_const_int32 = false;
46 uint32_t value = 0;
47 std::tie(is_int32, is_const_int32, value) = _.EvalInt32IfConst(scope);
48
49 if (!is_int32) {
50 return _.diag(SPV_ERROR_INVALID_DATA, inst)
51 << spvOpcodeString(opcode) << ": expected scope to be a 32-bit int";
52 }
53
54 if (!is_const_int32) {
55 if (_.HasCapability(spv::Capability::Shader) &&
56 !_.HasCapability(spv::Capability::CooperativeMatrixNV)) {
57 return _.diag(SPV_ERROR_INVALID_DATA, inst)
58 << "Scope ids must be OpConstant when Shader capability is "
59 << "present";
60 }
61 if (_.HasCapability(spv::Capability::Shader) &&
62 _.HasCapability(spv::Capability::CooperativeMatrixNV) &&
63 !spvOpcodeIsConstant(_.GetIdOpcode(scope))) {
64 return _.diag(SPV_ERROR_INVALID_DATA, inst)
65 << "Scope ids must be constant or specialization constant when "
66 << "CooperativeMatrixNV capability is present";
67 }
68 }
69
70 if (is_const_int32 && !IsValidScope(value)) {
71 return _.diag(SPV_ERROR_INVALID_DATA, inst)
72 << "Invalid scope value:\n " << _.Disassemble(*_.FindDef(scope));
73 }
74
75 return SPV_SUCCESS;
76}
77
78spv_result_t ValidateExecutionScope(ValidationState_t& _,
79 const Instruction* inst, uint32_t scope) {

Callers 3

ValidateShaderClockFunction · 0.85
ValidateExecutionScopeFunction · 0.85
ValidateMemoryScopeFunction · 0.85

Calls 10

spvOpcodeStringFunction · 0.85
spvOpcodeIsConstantFunction · 0.85
IsValidScopeFunction · 0.85
EvalInt32IfConstMethod · 0.80
diagMethod · 0.80
GetIdOpcodeMethod · 0.80
FindDefMethod · 0.80
opcodeMethod · 0.45
HasCapabilityMethod · 0.45
DisassembleMethod · 0.45

Tested by

no test coverage detected