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

Function ValidateImageTexelPointer

source/val/validate_image.cpp:1442–1573  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1440}
1441
1442spv_result_t ValidateImageTexelPointer(ValidationState_t& _,
1443 const Instruction* inst) {
1444 bool isUntyped = (inst->opcode() == spv::Op::OpUntypedImageTexelPointerEXT);
1445
1446 const auto result_type = _.FindDef(inst->type_id());
1447 if (result_type->opcode() != spv::Op::OpTypePointer &&
1448 result_type->opcode() != spv::Op::OpTypeUntypedPointerKHR) {
1449 return _.diag(SPV_ERROR_INVALID_DATA, inst)
1450 << "Expected Result Type to be a pointer";
1451 }
1452
1453 const auto storage_class = result_type->GetOperandAs<spv::StorageClass>(1);
1454 if (storage_class != spv::StorageClass::Image) {
1455 return _.diag(SPV_ERROR_INVALID_DATA, inst)
1456 << "Expected Result Type to be a pointer whose Storage Class "
1457 "operand is Image";
1458 }
1459
1460 uint32_t ptr_type = 0;
1461 if (result_type->opcode() == spv::Op::OpTypePointer) {
1462 ptr_type = result_type->GetOperandAs<uint32_t>(2);
1463 const auto ptr_opcode = _.GetIdOpcode(ptr_type);
1464 if (ptr_opcode != spv::Op::OpTypeInt &&
1465 ptr_opcode != spv::Op::OpTypeFloat &&
1466 ptr_opcode != spv::Op::OpTypeVoid &&
1467 !(ptr_opcode == spv::Op::OpTypeVector &&
1468 _.HasCapability(spv::Capability::AtomicFloat16VectorNV) &&
1469 _.IsFloat16Vector2Or4Type(ptr_type))) {
1470 return _.diag(SPV_ERROR_INVALID_DATA, inst)
1471 << "Expected Result Type to be a pointer whose Type operand "
1472 "must be a scalar numerical type or OpTypeVoid";
1473 }
1474 }
1475
1476 const auto image_ptr =
1477 _.FindDef(_.GetOperandTypeId(inst, (isUntyped ? 3 : 2)));
1478 if (!image_ptr ||
1479 (isUntyped && image_ptr->opcode() != spv::Op::OpTypeUntypedPointerKHR) ||
1480 (!isUntyped && image_ptr->opcode() != spv::Op::OpTypePointer)) {
1481 return _.diag(SPV_ERROR_INVALID_DATA, inst)
1482 << "Expected Image to be "
1483 << (isUntyped ? "OpTypeUntypedPointerKHR" : "OpTypePointer");
1484 }
1485
1486 const auto image_type = isUntyped ? inst->GetOperandAs<uint32_t>(2)
1487 : image_ptr->GetOperandAs<uint32_t>(2);
1488 if (_.GetIdOpcode(image_type) != spv::Op::OpTypeImage) {
1489 return _.diag(SPV_ERROR_INVALID_DATA, inst)
1490 << "Expected Image to be "
1491 << (isUntyped ? "OpTypeUntypedPointerKHR" : "OpTypePointer ")
1492 << "with Type OpTypeImage";
1493 }
1494
1495 ImageTypeInfo info;
1496 if (!GetImageTypeInfo(_, image_type, &info)) {
1497 return _.diag(SPV_ERROR_INVALID_DATA, inst)
1498 << "Corrupt image type definition";
1499 }

Callers 1

ImagePassFunction · 0.85

Calls 15

GetImageTypeInfoFunction · 0.85
ValidateImageCoordinateFunction · 0.85
spvIsVulkanEnvFunction · 0.85
spvOpcodeStringFunction · 0.85
FindDefMethod · 0.80
diagMethod · 0.80
GetIdOpcodeMethod · 0.80
GetOperandTypeIdMethod · 0.80
GetDimensionMethod · 0.80
IsIntScalarTypeMethod · 0.80
EvalConstantValUint64Method · 0.80

Tested by

no test coverage detected