| 2527 | } |
| 2528 | |
| 2529 | spv_result_t ValidateTileImageEXT(ValidationState_t& _, |
| 2530 | const Instruction* inst) { |
| 2531 | const spv::Op opcode = inst->opcode(); |
| 2532 | |
| 2533 | const uint32_t result_type = inst->type_id(); |
| 2534 | const char* result_type_str = GetActualResultTypeStr(opcode); |
| 2535 | if (opcode == spv::Op::OpColorAttachmentReadEXT) { |
| 2536 | if (!_.IsFloatScalarOrVectorType(result_type) && |
| 2537 | !_.IsIntScalarOrVectorType(result_type)) { |
| 2538 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 2539 | << "Expected " << result_type_str |
| 2540 | << " to be int or float scalar or vector type"; |
| 2541 | } |
| 2542 | |
| 2543 | const uint32_t attachment_type = _.GetOperandTypeId(inst, 2); |
| 2544 | if (_.GetIdOpcode(attachment_type) != spv::Op::OpTypeImage) { |
| 2545 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 2546 | << "Expected Image to be of type OpTypeImage"; |
| 2547 | } |
| 2548 | |
| 2549 | ImageTypeInfo info; |
| 2550 | if (!GetImageTypeInfo(_, attachment_type, &info)) { |
| 2551 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 2552 | << "Corrupt image type definition"; |
| 2553 | } |
| 2554 | |
| 2555 | if (_.GetIdOpcode(info.sampled_type) != spv::Op::OpTypeVoid) { |
| 2556 | const uint32_t result_component_type = _.GetComponentType(result_type); |
| 2557 | if (result_component_type != info.sampled_type) { |
| 2558 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 2559 | << "Expected Image 'Sampled Type' to be the same as " |
| 2560 | << GetActualResultTypeStr(opcode) << " components"; |
| 2561 | } |
| 2562 | } |
| 2563 | |
| 2564 | if (info.dim != spv::Dim::TileImageDataEXT) { |
| 2565 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 2566 | << "Image 'Dim' must be TileImageDataEXT"; |
| 2567 | } |
| 2568 | } else if (opcode == spv::Op::OpDepthAttachmentReadEXT) { |
| 2569 | if (!_.IsFloatScalarType(result_type, 32)) { |
| 2570 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 2571 | << "Expected " << result_type_str |
| 2572 | << " to be a 32-bit floating-point type scalar"; |
| 2573 | } |
| 2574 | } else { |
| 2575 | if (!_.IsIntScalarType(result_type, 32)) { |
| 2576 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 2577 | << "Expected " << result_type_str |
| 2578 | << " to be a 32-bit integer type scalar"; |
| 2579 | } |
| 2580 | } |
| 2581 | |
| 2582 | size_t sample_word_index = |
| 2583 | opcode == spv::Op::OpColorAttachmentReadEXT ? 4 : 3; |
| 2584 | |
| 2585 | if (inst->words().size() == sample_word_index + 1) { |
| 2586 | const uint32_t sample_id = inst->word(sample_word_index); |
no test coverage detected