| 2129 | } |
| 2130 | |
| 2131 | hipError_t validateMemoryObject(const void* ptr, bool isDeviceMemory, amd::Coord3D& origin, |
| 2132 | amd::Coord3D& copyRegion, size_t rowPitch, size_t slicePitch, |
| 2133 | amd::BufferRect& rect) { |
| 2134 | if (ptr == nullptr) { |
| 2135 | return hipErrorInvalidValue; |
| 2136 | } |
| 2137 | |
| 2138 | if (!rect.create(static_cast<size_t*>(origin), static_cast<size_t*>(copyRegion), rowPitch, |
| 2139 | slicePitch)) { |
| 2140 | return hipErrorInvalidValue; |
| 2141 | } |
| 2142 | |
| 2143 | size_t offset = 0; |
| 2144 | amd::Memory* memory = nullptr; |
| 2145 | memory = getMemoryObject(ptr, offset); |
| 2146 | if (memory == nullptr && isDeviceMemory) { |
| 2147 | return hipErrorInvalidValue; |
| 2148 | } |
| 2149 | |
| 2150 | amd::Coord3D start(rect.start_, 0, 0); |
| 2151 | amd::Coord3D size(rect.end_, 1, 1); |
| 2152 | if (memory && !memory->validateRegion(start, size)) { |
| 2153 | return hipErrorInvalidValue; |
| 2154 | } |
| 2155 | |
| 2156 | rect.start_ += offset; |
| 2157 | |
| 2158 | origin.c[0] = rect.offset(0, 0, 0); // Get the physical offset of the logic origin |
| 2159 | origin.c[1] = origin.c[2] = 0; |
| 2160 | |
| 2161 | return hipSuccess; |
| 2162 | } |
| 2163 | |
| 2164 | hipError_t ihipDrvMemcpy3D_validate(const HIP_MEMCPY3D* pCopy, amd::Coord3D& srcOrigin, |
| 2165 | amd::Coord3D& dstOrigin, amd::Coord3D& copyRegion, |
no test coverage detected