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

Function ValidateCompositeInsert

source/val/validate_composites.cpp:501–536  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

499}
500
501spv_result_t ValidateCompositeInsert(ValidationState_t& _,
502 const Instruction* inst,
503 uint32_t operand_index = 2) {
504 const uint32_t object_type = _.GetOperandTypeId(inst, operand_index);
505 const uint32_t composite_type = _.GetOperandTypeId(inst, operand_index + 1);
506 const uint32_t result_type = inst->type_id();
507 if (result_type != composite_type) {
508 return _.diag(SPV_ERROR_INVALID_DATA, inst)
509 << "The Result Type must be the same as Composite type in Op"
510 << spvOpcodeString(inst->opcode()) << " yielding Result Id "
511 << result_type << ".";
512 }
513
514 uint32_t member_type = 0;
515 if (spv_result_t error =
516 GetExtractInsertValueType(_, inst, &member_type, operand_index + 1)) {
517 return error;
518 }
519
520 if (object_type != member_type) {
521 return _.diag(SPV_ERROR_INVALID_DATA, inst)
522 << "The Object type (Op"
523 << spvOpcodeString(_.GetIdOpcode(object_type))
524 << ") does not match the type that results from indexing into the "
525 "Composite (Op"
526 << spvOpcodeString(_.GetIdOpcode(member_type)) << ").";
527 }
528
529 if (_.HasCapability(spv::Capability::Shader) &&
530 _.ContainsLimitedUseIntOrFloatType(inst->type_id())) {
531 return _.diag(SPV_ERROR_INVALID_DATA, inst)
532 << "Cannot insert into a composite of 8- or 16-bit types";
533 }
534
535 return SPV_SUCCESS;
536}
537
538spv_result_t ValidateCopyObject(ValidationState_t& _, const Instruction* inst) {
539 const uint32_t result_type = inst->type_id();

Callers 1

CompositesPassFunction · 0.85

Calls 9

spvOpcodeStringFunction · 0.85
GetOperandTypeIdMethod · 0.80
diagMethod · 0.80
GetIdOpcodeMethod · 0.80
type_idMethod · 0.45
opcodeMethod · 0.45
HasCapabilityMethod · 0.45

Tested by

no test coverage detected