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

Function ValidateCopyMemoryMemoryAccess

source/val/validate_memory.cpp:1549–1595  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1547}
1548
1549spv_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
1597spv_result_t ValidateCopyMemory(ValidationState_t& _, const Instruction* inst) {
1598 const auto target_index = 0;

Callers 1

ValidateCopyMemoryFunction · 0.85

Calls 7

CheckMemoryAccessFunction · 0.85
MemoryAccessNumWordsFunction · 0.85
spvOpcodeStringFunction · 0.85
operandsMethod · 0.80
diagMethod · 0.80
opcodeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected