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

Function ValidateShaderClock

source/val/validate_misc.cpp:42–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40}
41
42spv_result_t ValidateShaderClock(ValidationState_t& _,
43 const Instruction* inst) {
44 const uint32_t scope = inst->GetOperandAs<uint32_t>(2);
45 if (auto error = ValidateScope(_, inst, scope)) {
46 return error;
47 }
48
49 bool is_int32 = false, is_const_int32 = false;
50 uint32_t value = 0;
51 std::tie(is_int32, is_const_int32, value) = _.EvalInt32IfConst(scope);
52 if (is_const_int32) {
53 spv::Scope scope_val{value};
54 if (spvIsVulkanEnv(_.context()->target_env)) {
55 if (scope_val != spv::Scope::Subgroup &&
56 scope_val != spv::Scope::Device) {
57 return _.diag(SPV_ERROR_INVALID_DATA, inst)
58 << _.VkErrorID(4652) << "Scope must be Subgroup or Device";
59 }
60 } else if (spvIsOpenCLEnv(_.context()->target_env)) {
61 if (scope_val != spv::Scope::Workgroup &&
62 scope_val != spv::Scope::Subgroup &&
63 scope_val != spv::Scope::Device) {
64 return _.diag(SPV_ERROR_INVALID_DATA, inst)
65 << "Scope must be Subgroup, Workgroup, or Device";
66 }
67 }
68 }
69
70 // Result Type must be a 64 - bit unsigned integer type or
71 // a vector of two - components of 32 -
72 // bit unsigned integer type
73 const uint32_t result_type = inst->type_id();
74 if (!_.IsUnsigned64BitHandle(result_type)) {
75 return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Expected Value to be a "
76 "vector of two components"
77 " of unsigned integer"
78 " or 64bit unsigned integer";
79 }
80
81 return SPV_SUCCESS;
82}
83
84spv_result_t ValidateAssumeTrue(ValidationState_t& _, const Instruction* inst) {
85 const auto operand_type_id = _.GetOperandTypeId(inst, 0);

Callers 1

MiscPassFunction · 0.85

Calls 9

ValidateScopeFunction · 0.85
spvIsVulkanEnvFunction · 0.85
spvIsOpenCLEnvFunction · 0.85
EvalInt32IfConstMethod · 0.80
diagMethod · 0.80
VkErrorIDMethod · 0.80
IsUnsigned64BitHandleMethod · 0.80
contextMethod · 0.45
type_idMethod · 0.45

Tested by

no test coverage detected