| 1547 | } |
| 1548 | |
| 1549 | spv_result_t ValidateCopyMemoryMemoryAccess(ValidationState_t& _, |
| 1550 | const Instruction* inst) { |
| 1551 | assert(inst->opcode() == spv::Op::OpCopyMemory || |
| 1552 | inst->opcode() == spv::Op::OpCopyMemorySized); |
| 1553 | const uint32_t first_access_index = |
| 1554 | inst->opcode() == spv::Op::OpCopyMemory ? 2 : 3; |
| 1555 | if (inst->operands().size() > first_access_index) { |
| 1556 | if (auto error = CheckMemoryAccess(_, inst, first_access_index)) |
| 1557 | return error; |
| 1558 | |
| 1559 | const auto first_access = inst->GetOperandAs<uint32_t>(first_access_index); |
| 1560 | const uint32_t second_access_index = |
| 1561 | first_access_index + MemoryAccessNumWords(first_access); |
| 1562 | if (inst->operands().size() > second_access_index) { |
| 1563 | if (_.features().copy_memory_permits_two_memory_accesses) { |
| 1564 | if (auto error = CheckMemoryAccess(_, inst, second_access_index)) |
| 1565 | return error; |
| 1566 | |
| 1567 | // In the two-access form in SPIR-V 1.4 and later: |
| 1568 | // - the first is the target (write) access and it can't have |
| 1569 | // make-visible. |
| 1570 | // - the second is the source (read) access and it can't have |
| 1571 | // make-available. |
| 1572 | if (first_access & |
| 1573 | uint32_t(spv::MemoryAccessMask::MakePointerVisibleKHR)) { |
| 1574 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 1575 | << "Target memory access must not include " |
| 1576 | "MakePointerVisibleKHR"; |
| 1577 | } |
| 1578 | const auto second_access = |
| 1579 | inst->GetOperandAs<uint32_t>(second_access_index); |
| 1580 | if (second_access & |
| 1581 | uint32_t(spv::MemoryAccessMask::MakePointerAvailableKHR)) { |
| 1582 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 1583 | << "Source memory access must not include " |
| 1584 | "MakePointerAvailableKHR"; |
| 1585 | } |
| 1586 | } else { |
| 1587 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 1588 | << spvOpcodeString(inst->opcode()) |
| 1589 | << " with two memory access operands requires SPIR-V 1.4 or " |
| 1590 | "later"; |
| 1591 | } |
| 1592 | } |
| 1593 | } |
| 1594 | return SPV_SUCCESS; |
| 1595 | } |
| 1596 | |
| 1597 | spv_result_t ValidateCopyMemory(ValidationState_t& _, const Instruction* inst) { |
| 1598 | const auto target_index = 0; |
no test coverage detected