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

Function ValidateTranspose

source/val/validate_composites.cpp:552–594  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

550}
551
552spv_result_t ValidateTranspose(ValidationState_t& _, const Instruction* inst) {
553 uint32_t result_num_rows = 0;
554 uint32_t result_num_cols = 0;
555 uint32_t result_col_type = 0;
556 uint32_t result_component_type = 0;
557 const uint32_t result_type = inst->type_id();
558 if (!_.GetMatrixTypeInfo(result_type, &result_num_rows, &result_num_cols,
559 &result_col_type, &result_component_type)) {
560 return _.diag(SPV_ERROR_INVALID_DATA, inst)
561 << "Expected Result Type to be a matrix type";
562 }
563
564 const uint32_t matrix_type = _.GetOperandTypeId(inst, 2);
565 uint32_t matrix_num_rows = 0;
566 uint32_t matrix_num_cols = 0;
567 uint32_t matrix_col_type = 0;
568 uint32_t matrix_component_type = 0;
569 if (!_.GetMatrixTypeInfo(matrix_type, &matrix_num_rows, &matrix_num_cols,
570 &matrix_col_type, &matrix_component_type)) {
571 return _.diag(SPV_ERROR_INVALID_DATA, inst)
572 << "Expected Matrix to be of type OpTypeMatrix";
573 }
574
575 if (result_component_type != matrix_component_type) {
576 return _.diag(SPV_ERROR_INVALID_DATA, inst)
577 << "Expected component types of Matrix and Result Type to be "
578 << "identical";
579 }
580
581 if (result_num_rows != matrix_num_cols ||
582 result_num_cols != matrix_num_rows) {
583 return _.diag(SPV_ERROR_INVALID_DATA, inst)
584 << "Expected number of columns and the column size of Matrix "
585 << "to be the reverse of those of Result Type";
586 }
587
588 if (_.HasCapability(spv::Capability::Shader) &&
589 _.ContainsLimitedUseIntOrFloatType(inst->type_id())) {
590 return _.diag(SPV_ERROR_INVALID_DATA, inst)
591 << "Cannot transpose matrices of 16-bit floats";
592 }
593 return SPV_SUCCESS;
594}
595
596spv_result_t ValidateVectorShuffle(ValidationState_t& _,
597 const Instruction* inst,

Callers 1

CompositesPassFunction · 0.85

Calls 6

GetMatrixTypeInfoMethod · 0.80
diagMethod · 0.80
GetOperandTypeIdMethod · 0.80
type_idMethod · 0.45
HasCapabilityMethod · 0.45

Tested by

no test coverage detected