Skip to content

Commit 01c8438

Browse files
authored
[SPV_KHR_untyped_pointers] Fix verification for OpenCL.std instructions (#5810)
Allow `p` to be untyped pointer for `fract`, `frexp`, `lgamma_r`, `modf`, `remquo`, and `sincos`. ``` operand must be a pointer(p1, ...).If it is a typed pointer, it must point to data types. ``` https://htmlpreview.github.io/?https://github.com/KhronosGroup/SPIRV-Registry/blob/main/extensions/KHR/SPV_KHR_untyped_pointers.html#_modifications_to_the_opencl_std_extended_instruction_set
1 parent 6dcc7e3 commit 01c8438

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

source/val/validate_extensions.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1980,7 +1980,7 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) {
19801980
"CrossWorkgroup, Workgroup or Function";
19811981
}
19821982

1983-
if (result_type != p_data_type) {
1983+
if (!_.ContainsUntypedPointer(p_type) && result_type != p_data_type) {
19841984
return _.diag(SPV_ERROR_INVALID_DATA, inst)
19851985
<< ext_inst_name() << ": "
19861986
<< "expected data type of the pointer to be equal to Result "
@@ -2042,15 +2042,17 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) {
20422042
"CrossWorkgroup, Workgroup or Function";
20432043
}
20442044

2045-
if (!_.IsIntScalarOrVectorType(p_data_type) ||
2046-
_.GetBitWidth(p_data_type) != 32) {
2045+
if ((!_.IsIntScalarOrVectorType(p_data_type) ||
2046+
_.GetBitWidth(p_data_type) != 32) &&
2047+
!_.ContainsUntypedPointer(p_type)) {
20472048
return _.diag(SPV_ERROR_INVALID_DATA, inst)
20482049
<< ext_inst_name() << ": "
20492050
<< "expected data type of the pointer to be a 32-bit int "
20502051
"scalar or vector type";
20512052
}
20522053

2053-
if (_.GetDimension(p_data_type) != num_components) {
2054+
if (!_.ContainsUntypedPointer(p_type) &&
2055+
_.GetDimension(p_data_type) != num_components) {
20542056
return _.diag(SPV_ERROR_INVALID_DATA, inst)
20552057
<< ext_inst_name() << ": "
20562058
<< "expected data type of the pointer to have the same number "

source/val/validate_memory.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,9 @@ spv_result_t ValidateVariable(ValidationState_t& _, const Instruction* inst) {
463463
const auto initializer_id = inst->GetOperandAs<uint32_t>(initializer_index);
464464
const auto initializer = _.FindDef(initializer_id);
465465
const auto is_module_scope_var =
466-
initializer && (initializer->opcode() == spv::Op::OpVariable) &&
466+
initializer &&
467+
(initializer->opcode() == spv::Op::OpVariable ||
468+
initializer->opcode() == spv::Op::OpUntypedVariableKHR) &&
467469
(initializer->GetOperandAs<spv::StorageClass>(storage_class_index) !=
468470
spv::StorageClass::Function);
469471
const auto is_constant =

0 commit comments

Comments
 (0)