mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-04 07:14:10 +08:00
feature: Get Peer Allocation with specified base Pointer
Related-To: LOCI-4176 - Given a Base Pointer passed into Get Peer Allocation, then the base pointer is used in the map of the new allocation to the virtual memory. - Enables users to use the same pointer for all devices in Peer To Peer. - Currently unsupported on reserved memory due to mapped and exec resiedency of Virtual addresses. Signed-off-by: Neil R Spruit <neil.r.spruit@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
f98ac7098b
commit
ded9d7bff2
@@ -118,8 +118,8 @@ class MemoryManager {
|
||||
|
||||
virtual bool verifyHandle(osHandle handle, uint32_t rootDeviceIndex, bool) { return true; }
|
||||
virtual bool isNTHandle(osHandle handle, uint32_t rootDeviceIndex) { return false; }
|
||||
virtual GraphicsAllocation *createGraphicsAllocationFromMultipleSharedHandles(const std::vector<osHandle> &handles, AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation) = 0;
|
||||
virtual GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation) = 0;
|
||||
virtual GraphicsAllocation *createGraphicsAllocationFromMultipleSharedHandles(const std::vector<osHandle> &handles, AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) = 0;
|
||||
virtual GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) = 0;
|
||||
virtual void closeSharedHandle(GraphicsAllocation *graphicsAllocation){};
|
||||
virtual void closeInternalHandle(uint64_t &handle, uint32_t handleId, GraphicsAllocation *graphicsAllocation){};
|
||||
virtual GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex, AllocationType allocType) = 0;
|
||||
|
||||
@@ -238,12 +238,16 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocate32BitGraphicsMemoryImpl(con
|
||||
return memoryAllocation;
|
||||
}
|
||||
|
||||
GraphicsAllocation *OsAgnosticMemoryManager::createGraphicsAllocationFromMultipleSharedHandles(const std::vector<osHandle> &handles, AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation) {
|
||||
GraphicsAllocation *OsAgnosticMemoryManager::createGraphicsAllocationFromMultipleSharedHandles(const std::vector<osHandle> &handles, AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GraphicsAllocation *OsAgnosticMemoryManager::createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation) {
|
||||
auto graphicsAllocation = createMemoryAllocation(properties.allocationType, nullptr, reinterpret_cast<void *>(1), 1,
|
||||
GraphicsAllocation *OsAgnosticMemoryManager::createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) {
|
||||
void *gpuPtr = reinterpret_cast<void *>(1);
|
||||
if (mapPointer) {
|
||||
gpuPtr = mapPointer;
|
||||
}
|
||||
auto graphicsAllocation = createMemoryAllocation(properties.allocationType, nullptr, gpuPtr, 1,
|
||||
4096u, static_cast<uint64_t>(handle), MemoryPool::SystemCpuInaccessible, properties.rootDeviceIndex,
|
||||
false, false, requireSpecificBitness);
|
||||
graphicsAllocation->setSharedHandle(handle);
|
||||
|
||||
@@ -23,8 +23,8 @@ class OsAgnosticMemoryManager : public MemoryManager {
|
||||
OsAgnosticMemoryManager(bool aubUsage, ExecutionEnvironment &executionEnvironment);
|
||||
void initialize(bool aubUsage);
|
||||
~OsAgnosticMemoryManager() override;
|
||||
GraphicsAllocation *createGraphicsAllocationFromMultipleSharedHandles(const std::vector<osHandle> &handles, AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation) override;
|
||||
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation) override;
|
||||
GraphicsAllocation *createGraphicsAllocationFromMultipleSharedHandles(const std::vector<osHandle> &handles, AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) override;
|
||||
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) override;
|
||||
GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex, AllocationType allocType) override { return nullptr; }
|
||||
|
||||
void addAllocationToHostPtrManager(GraphicsAllocation *gfxAllocation) override;
|
||||
|
||||
@@ -434,7 +434,6 @@ bool SVMAllocsManager::freeSVMAlloc(void *ptr, bool blocking) {
|
||||
if (svmDeferFreeAllocs.allocations.size() > 0) {
|
||||
this->freeSVMAllocDeferImpl();
|
||||
}
|
||||
|
||||
SvmAllocationData *svmData = getSVMAlloc(ptr);
|
||||
if (svmData) {
|
||||
if (InternalMemoryType::DEVICE_UNIFIED_MEMORY == svmData->memoryType &&
|
||||
|
||||
@@ -42,6 +42,7 @@ struct SvmAllocationData {
|
||||
this->gpuAllocations.addAllocation(allocation);
|
||||
}
|
||||
}
|
||||
this->mappedAllocData = svmAllocData.mappedAllocData;
|
||||
}
|
||||
SvmAllocationData &operator=(const SvmAllocationData &) = delete;
|
||||
GraphicsAllocation *cpuAllocation = nullptr;
|
||||
@@ -55,6 +56,7 @@ struct SvmAllocationData {
|
||||
void setAllocId(uint32_t id) {
|
||||
allocId = id;
|
||||
}
|
||||
bool mappedAllocData = false;
|
||||
|
||||
uint32_t getAllocId() {
|
||||
return allocId;
|
||||
|
||||
@@ -775,10 +775,12 @@ GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromMultipleShared
|
||||
AllocationProperties &properties,
|
||||
bool requireSpecificBitness,
|
||||
bool isHostIpcAllocation,
|
||||
bool reuseSharedAllocation) {
|
||||
bool reuseSharedAllocation,
|
||||
void *mapPointer) {
|
||||
BufferObjects bos;
|
||||
std::vector<size_t> sizes;
|
||||
size_t totalSize = 0;
|
||||
uint64_t gpuRange = 0;
|
||||
|
||||
std::unique_lock<std::mutex> lock(mtx);
|
||||
|
||||
@@ -828,10 +830,14 @@ GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromMultipleShared
|
||||
sizes.push_back(bo->peekSize());
|
||||
}
|
||||
|
||||
auto gfxPartition = getGfxPartition(properties.rootDeviceIndex);
|
||||
auto prefer57bitAddressing = (gfxPartition->getHeapLimit(HeapIndex::HEAP_EXTENDED) > 0);
|
||||
auto heapIndex = prefer57bitAddressing ? HeapIndex::HEAP_EXTENDED : HeapIndex::HEAP_STANDARD2MB;
|
||||
auto gpuRange = acquireGpuRange(totalSize, properties.rootDeviceIndex, heapIndex);
|
||||
if (mapPointer) {
|
||||
gpuRange = reinterpret_cast<uint64_t>(mapPointer);
|
||||
} else {
|
||||
auto gfxPartition = getGfxPartition(properties.rootDeviceIndex);
|
||||
auto prefer57bitAddressing = (gfxPartition->getHeapLimit(HeapIndex::HEAP_EXTENDED) > 0);
|
||||
auto heapIndex = prefer57bitAddressing ? HeapIndex::HEAP_EXTENDED : HeapIndex::HEAP_STANDARD2MB;
|
||||
gpuRange = acquireGpuRange(totalSize, properties.rootDeviceIndex, heapIndex);
|
||||
}
|
||||
|
||||
if (reuseSharedAllocation) {
|
||||
lock.unlock();
|
||||
@@ -928,7 +934,8 @@ GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromSharedHandle(o
|
||||
const AllocationProperties &properties,
|
||||
bool requireSpecificBitness,
|
||||
bool isHostIpcAllocation,
|
||||
bool reuseSharedAllocation) {
|
||||
bool reuseSharedAllocation,
|
||||
void *mapPointer) {
|
||||
if (isHostIpcAllocation) {
|
||||
return createUSMHostAllocationFromSharedHandle(handle, properties, false, reuseSharedAllocation);
|
||||
}
|
||||
@@ -936,6 +943,7 @@ GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromSharedHandle(o
|
||||
std::unique_lock<std::mutex> lock(mtx);
|
||||
|
||||
PrimeHandle openFd{};
|
||||
uint64_t gpuRange = 0;
|
||||
openFd.fileDescriptor = handle;
|
||||
|
||||
auto &drm = this->getDrm(properties.rootDeviceIndex);
|
||||
@@ -986,8 +994,12 @@ GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromSharedHandle(o
|
||||
return HeapIndex::HEAP_STANDARD;
|
||||
};
|
||||
|
||||
auto heapIndex = getHeapIndex();
|
||||
auto gpuRange = acquireGpuRange(size, properties.rootDeviceIndex, heapIndex);
|
||||
if (mapPointer) {
|
||||
gpuRange = reinterpret_cast<uint64_t>(mapPointer);
|
||||
} else {
|
||||
auto heapIndex = getHeapIndex();
|
||||
gpuRange = acquireGpuRange(size, properties.rootDeviceIndex, heapIndex);
|
||||
}
|
||||
|
||||
bo->setAddress(gpuRange);
|
||||
bo->setUnmapSize(size);
|
||||
|
||||
@@ -38,8 +38,8 @@ class DrmMemoryManager : public MemoryManager {
|
||||
void freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation, bool isImportedAllocation) override;
|
||||
void handleFenceCompletion(GraphicsAllocation *allocation) override;
|
||||
GraphicsAllocation *createGraphicsAllocationFromExistingStorage(AllocationProperties &properties, void *ptr, MultiGraphicsAllocation &multiGraphicsAllocation) override;
|
||||
GraphicsAllocation *createGraphicsAllocationFromMultipleSharedHandles(const std::vector<osHandle> &handles, AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation) override;
|
||||
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation) override;
|
||||
GraphicsAllocation *createGraphicsAllocationFromMultipleSharedHandles(const std::vector<osHandle> &handles, AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) override;
|
||||
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) override;
|
||||
void closeSharedHandle(GraphicsAllocation *gfxAllocation) override;
|
||||
void closeInternalHandle(uint64_t &handle, uint32_t handleId, GraphicsAllocation *graphicsAllocation) override;
|
||||
|
||||
|
||||
@@ -504,7 +504,7 @@ bool WddmMemoryManager::isNTHandle(osHandle handle, uint32_t rootDeviceIndex) {
|
||||
return status;
|
||||
}
|
||||
|
||||
GraphicsAllocation *WddmMemoryManager::createAllocationFromHandle(osHandle handle, bool requireSpecificBitness, bool ntHandle, AllocationType allocationType, uint32_t rootDeviceIndex) {
|
||||
GraphicsAllocation *WddmMemoryManager::createAllocationFromHandle(osHandle handle, bool requireSpecificBitness, bool ntHandle, AllocationType allocationType, uint32_t rootDeviceIndex, void *mapPointer) {
|
||||
auto allocation = std::make_unique<WddmAllocation>(rootDeviceIndex, allocationType, nullptr, 0, handle, MemoryPool::SystemCpuInaccessible, maxOsContextCount, 0llu);
|
||||
|
||||
bool status = ntHandle ? getWddm(rootDeviceIndex).openNTHandle(reinterpret_cast<HANDLE>(static_cast<uintptr_t>(handle)), allocation.get())
|
||||
@@ -518,18 +518,22 @@ GraphicsAllocation *WddmMemoryManager::createAllocationFromHandle(osHandle handl
|
||||
size_t size = allocation->getDefaultGmm()->gmmResourceInfo->getSizeAllocation();
|
||||
allocation->setSize(size);
|
||||
|
||||
if (is32bit) {
|
||||
void *ptr = nullptr;
|
||||
if (!getWddm(rootDeviceIndex).reserveValidAddressRange(size, ptr)) {
|
||||
return nullptr;
|
||||
if (mapPointer == nullptr) {
|
||||
if (is32bit) {
|
||||
void *ptr = nullptr;
|
||||
if (!getWddm(rootDeviceIndex).reserveValidAddressRange(size, ptr)) {
|
||||
return nullptr;
|
||||
}
|
||||
allocation->setReservedAddressRange(ptr, size);
|
||||
} else if (requireSpecificBitness && this->force32bitAllocations) {
|
||||
allocation->set32BitAllocation(true);
|
||||
auto gmmHelper = getGmmHelper(allocation->getRootDeviceIndex());
|
||||
allocation->setGpuBaseAddress(gmmHelper->canonize(getExternalHeapBaseAddress(allocation->getRootDeviceIndex(), false)));
|
||||
}
|
||||
allocation->setReservedAddressRange(ptr, size);
|
||||
} else if (requireSpecificBitness && this->force32bitAllocations) {
|
||||
allocation->set32BitAllocation(true);
|
||||
auto gmmHelper = getGmmHelper(allocation->getRootDeviceIndex());
|
||||
allocation->setGpuBaseAddress(gmmHelper->canonize(getExternalHeapBaseAddress(allocation->getRootDeviceIndex(), false)));
|
||||
status = mapGpuVirtualAddress(allocation.get(), allocation->getReservedAddressPtr());
|
||||
} else {
|
||||
status = mapPhysicalToVirtualMemory(allocation.get(), reinterpret_cast<uint64_t>(mapPointer), size);
|
||||
}
|
||||
status = mapGpuVirtualAddress(allocation.get(), allocation->getReservedAddressPtr());
|
||||
DEBUG_BREAK_IF(!status);
|
||||
if (!status) {
|
||||
freeGraphicsMemoryImpl(allocation.release());
|
||||
@@ -540,16 +544,16 @@ GraphicsAllocation *WddmMemoryManager::createAllocationFromHandle(osHandle handl
|
||||
return allocation.release();
|
||||
}
|
||||
|
||||
GraphicsAllocation *WddmMemoryManager::createGraphicsAllocationFromMultipleSharedHandles(const std::vector<osHandle> &handles, AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation) {
|
||||
GraphicsAllocation *WddmMemoryManager::createGraphicsAllocationFromMultipleSharedHandles(const std::vector<osHandle> &handles, AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GraphicsAllocation *WddmMemoryManager::createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation) {
|
||||
return createAllocationFromHandle(handle, requireSpecificBitness, false, properties.allocationType, properties.rootDeviceIndex);
|
||||
GraphicsAllocation *WddmMemoryManager::createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) {
|
||||
return createAllocationFromHandle(handle, requireSpecificBitness, false, properties.allocationType, properties.rootDeviceIndex, mapPointer);
|
||||
}
|
||||
|
||||
GraphicsAllocation *WddmMemoryManager::createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex, AllocationType allocType) {
|
||||
return createAllocationFromHandle(toOsHandle(handle), false, true, allocType, rootDeviceIndex);
|
||||
return createAllocationFromHandle(toOsHandle(handle), false, true, allocType, rootDeviceIndex, nullptr);
|
||||
}
|
||||
|
||||
void WddmMemoryManager::addAllocationToHostPtrManager(GraphicsAllocation *gfxAllocation) {
|
||||
|
||||
@@ -40,8 +40,8 @@ class WddmMemoryManager : public MemoryManager {
|
||||
void freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation, bool isImportedAllocation) override;
|
||||
void handleFenceCompletion(GraphicsAllocation *allocation) override;
|
||||
|
||||
GraphicsAllocation *createGraphicsAllocationFromMultipleSharedHandles(const std::vector<osHandle> &handles, AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation) override;
|
||||
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation) override;
|
||||
GraphicsAllocation *createGraphicsAllocationFromMultipleSharedHandles(const std::vector<osHandle> &handles, AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) override;
|
||||
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) override;
|
||||
GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex, AllocationType allocType) override;
|
||||
|
||||
void addAllocationToHostPtrManager(GraphicsAllocation *memory) override;
|
||||
@@ -106,7 +106,7 @@ class WddmMemoryManager : public MemoryManager {
|
||||
MOCKABLE_VIRTUAL size_t getHugeGfxMemoryChunkSize(GfxMemoryAllocationMethod allocationMethod) const;
|
||||
MOCKABLE_VIRTUAL GraphicsAllocation *allocateHugeGraphicsMemory(const AllocationData &allocationData, bool sharedVirtualAddress);
|
||||
|
||||
GraphicsAllocation *createAllocationFromHandle(osHandle handle, bool requireSpecificBitness, bool ntHandle, AllocationType allocationType, uint32_t rootDeviceIndex);
|
||||
GraphicsAllocation *createAllocationFromHandle(osHandle handle, bool requireSpecificBitness, bool ntHandle, AllocationType allocationType, uint32_t rootDeviceIndex, void *mapPointer);
|
||||
static bool validateAllocation(WddmAllocation *alloc);
|
||||
MOCKABLE_VIRTUAL bool createWddmAllocation(WddmAllocation *allocation, void *requiredGpuPtr);
|
||||
MOCKABLE_VIRTUAL bool mapGpuVirtualAddress(WddmAllocation *graphicsAllocation, const void *requiredGpuPtr);
|
||||
|
||||
@@ -14,7 +14,8 @@ enum InternalMemoryType : uint32_t {
|
||||
SVM = 0b1,
|
||||
DEVICE_UNIFIED_MEMORY = 0b10,
|
||||
HOST_UNIFIED_MEMORY = 0b100,
|
||||
SHARED_UNIFIED_MEMORY = 0b1000
|
||||
SHARED_UNIFIED_MEMORY = 0b1000,
|
||||
RESERVED_DEVICE_MEMORY = 0b10000
|
||||
};
|
||||
|
||||
enum class InternalIpcMemoryType : uint32_t {
|
||||
|
||||
@@ -218,9 +218,9 @@ GraphicsAllocation *MockMemoryManager::createGraphicsAllocationFromExistingStora
|
||||
return allocation;
|
||||
}
|
||||
|
||||
GraphicsAllocation *MockMemoryManager::createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation) {
|
||||
GraphicsAllocation *MockMemoryManager::createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) {
|
||||
if (handle != invalidSharedHandle) {
|
||||
auto allocation = OsAgnosticMemoryManager::createGraphicsAllocationFromSharedHandle(handle, properties, requireSpecificBitness, isHostIpcAllocation, reuseSharedAllocation);
|
||||
auto allocation = OsAgnosticMemoryManager::createGraphicsAllocationFromSharedHandle(handle, properties, requireSpecificBitness, isHostIpcAllocation, reuseSharedAllocation, mapPointer);
|
||||
this->capturedSharedHandle = handle;
|
||||
return allocation;
|
||||
} else {
|
||||
|
||||
@@ -79,7 +79,7 @@ class MockMemoryManager : public MemoryManagerCreate<OsAgnosticMemoryManager> {
|
||||
GraphicsAllocation *allocateGraphicsMemoryWithProperties(const AllocationProperties &properties) override;
|
||||
GraphicsAllocation *allocateGraphicsMemoryWithProperties(const AllocationProperties &properties, const void *ptr) override;
|
||||
GraphicsAllocation *createGraphicsAllocationFromExistingStorage(AllocationProperties &properties, void *ptr, MultiGraphicsAllocation &multiGraphicsAllocation) override;
|
||||
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation) override;
|
||||
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) override;
|
||||
GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex, AllocationType allocType) override;
|
||||
|
||||
void *allocateSystemMemory(size_t size, size_t alignment) override;
|
||||
@@ -315,11 +315,11 @@ class FailMemoryManager : public MockMemoryManager {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GraphicsAllocation *createGraphicsAllocationFromMultipleSharedHandles(const std::vector<osHandle> &handles, AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation) override {
|
||||
GraphicsAllocation *createGraphicsAllocationFromMultipleSharedHandles(const std::vector<osHandle> &handles, AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) override {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation) override {
|
||||
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) override {
|
||||
return nullptr;
|
||||
}
|
||||
GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex, AllocationType allocType) override {
|
||||
|
||||
@@ -86,7 +86,7 @@ struct ComputeModeRequirements : public ::testing::Test {
|
||||
device->resetCommandStreamReceiver(csr);
|
||||
AllocationProperties properties(device->getRootDeviceIndex(), false, MemoryConstants::pageSize, AllocationType::SHARED_BUFFER, false, {});
|
||||
|
||||
alloc = device->getMemoryManager()->createGraphicsAllocationFromSharedHandle(static_cast<osHandle>(123), properties, false, false, true);
|
||||
alloc = device->getMemoryManager()->createGraphicsAllocationFromSharedHandle(static_cast<osHandle>(123), properties, false, false, true, nullptr);
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
|
||||
@@ -457,8 +457,8 @@ TEST_F(DeviceGetCapsTest, givenFlagEnabled64kbPagesWhenCallConstructorMemoryMana
|
||||
MockMemoryManager(ExecutionEnvironment &executionEnvironment) : MemoryManager(executionEnvironment) {}
|
||||
void addAllocationToHostPtrManager(GraphicsAllocation *memory) override{};
|
||||
void removeAllocationFromHostPtrManager(GraphicsAllocation *memory) override{};
|
||||
GraphicsAllocation *createGraphicsAllocationFromMultipleSharedHandles(const std::vector<osHandle> &handles, AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation) override { return nullptr; }
|
||||
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation) override { return nullptr; };
|
||||
GraphicsAllocation *createGraphicsAllocationFromMultipleSharedHandles(const std::vector<osHandle> &handles, AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) override { return nullptr; }
|
||||
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) override { return nullptr; };
|
||||
GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex, AllocationType allocType) override { return nullptr; };
|
||||
AllocationStatus populateOsHandles(OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override { return AllocationStatus::Success; };
|
||||
void cleanOsHandles(OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override{};
|
||||
|
||||
@@ -48,7 +48,7 @@ struct Gen12LpCoherencyRequirements : public ::testing::Test {
|
||||
device->resetCommandStreamReceiver(csr);
|
||||
AllocationProperties properties(device->getRootDeviceIndex(), false, MemoryConstants::pageSize, AllocationType::SHARED_BUFFER, false, {});
|
||||
|
||||
alloc = device->getMemoryManager()->createGraphicsAllocationFromSharedHandle(static_cast<osHandle>(123), properties, false, false, true);
|
||||
alloc = device->getMemoryManager()->createGraphicsAllocationFromSharedHandle(static_cast<osHandle>(123), properties, false, false, true, nullptr);
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2022 Intel Corporation
|
||||
* Copyright (C) 2019-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -45,12 +45,12 @@ TEST_P(MemoryManagerMultiDeviceTest, givenRootDeviceIndexSpecifiedWhenAllocateGr
|
||||
EXPECT_EQ(rootDeviceIndex, gfxAllocation->getRootDeviceIndex());
|
||||
memoryManager->freeGraphicsMemory(gfxAllocation);
|
||||
|
||||
gfxAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(static_cast<osHandle>(0u), properties, false, false, true);
|
||||
gfxAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(static_cast<osHandle>(0u), properties, false, false, true, nullptr);
|
||||
ASSERT_NE(gfxAllocation, nullptr);
|
||||
EXPECT_EQ(rootDeviceIndex, gfxAllocation->getRootDeviceIndex());
|
||||
memoryManager->freeGraphicsMemory(gfxAllocation);
|
||||
|
||||
gfxAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(static_cast<osHandle>(0u), properties, true, false, true);
|
||||
gfxAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(static_cast<osHandle>(0u), properties, true, false, true, nullptr);
|
||||
ASSERT_NE(gfxAllocation, nullptr);
|
||||
EXPECT_EQ(rootDeviceIndex, gfxAllocation->getRootDeviceIndex());
|
||||
memoryManager->freeGraphicsMemory(gfxAllocation);
|
||||
|
||||
@@ -232,3 +232,62 @@ TEST(OsAgnosticMemoryManager, givenOsAgnosticMemoryManagerWhenGpuAddressReservat
|
||||
EXPECT_NE(static_cast<int>(addressRange.address), 0x1234);
|
||||
EXPECT_NE(static_cast<int>(addressRange.size), 0);
|
||||
}
|
||||
|
||||
TEST(OsAgnosticMemoryManager, whenCallingCreateGraphicsAllocationFromMultipleSharedHandlesWithBasePointerFromOsAgnosticMemoryManagerThenNullptrIsReturned) {
|
||||
MockExecutionEnvironment executionEnvironment;
|
||||
OsAgnosticMemoryManager memoryManager(executionEnvironment);
|
||||
uint32_t mockRootDeviceIndex = 0u;
|
||||
DeviceBitfield mockDeviceBitfield(0b1);
|
||||
|
||||
std::vector<osHandle> handles{6, 7};
|
||||
AllocationProperties properties = {mockRootDeviceIndex,
|
||||
true,
|
||||
MemoryConstants::pageSize,
|
||||
AllocationType::BUFFER,
|
||||
false,
|
||||
mockDeviceBitfield};
|
||||
bool requireSpecificBitness{};
|
||||
bool isHostIpcAllocation{};
|
||||
uint64_t basePointer = 0x1234;
|
||||
auto ptr = memoryManager.createGraphicsAllocationFromMultipleSharedHandles(handles, properties, requireSpecificBitness, isHostIpcAllocation, true, reinterpret_cast<void *>(basePointer));
|
||||
EXPECT_EQ(nullptr, ptr);
|
||||
}
|
||||
|
||||
TEST(OsAgnosticMemoryManager, whenCallingCreateGraphicsAllocationFromSharedHandleWithNullBasePointerFromOsAgnosticMemoryManagerThenBasicPointerReturned) {
|
||||
uint32_t mockRootDeviceIndex = 0u;
|
||||
DeviceBitfield mockDeviceBitfield(0b1);
|
||||
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
||||
MemoryManagerCreate<OsAgnosticMemoryManager> memoryManager(false, false, executionEnvironment);
|
||||
osHandle handle = 1;
|
||||
auto size = 4096u;
|
||||
AllocationProperties properties(mockRootDeviceIndex, false, size, AllocationType::SHARED_BUFFER, false, mockDeviceBitfield);
|
||||
auto sharedAllocation = memoryManager.createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true, nullptr);
|
||||
EXPECT_NE(nullptr, sharedAllocation);
|
||||
EXPECT_EQ(reinterpret_cast<void *>(1u), sharedAllocation->getUnderlyingBuffer());
|
||||
EXPECT_FALSE(sharedAllocation->isCoherent());
|
||||
EXPECT_NE(nullptr, sharedAllocation->getUnderlyingBuffer());
|
||||
EXPECT_EQ(size, sharedAllocation->getUnderlyingBufferSize());
|
||||
EXPECT_EQ(MemoryPool::SystemCpuInaccessible, sharedAllocation->getMemoryPool());
|
||||
|
||||
memoryManager.freeGraphicsMemory(sharedAllocation);
|
||||
}
|
||||
|
||||
TEST(OsAgnosticMemoryManager, whenCallingCreateGraphicsAllocationFromSharedHandleWithBasePointerFromOsAgnosticMemoryManagerThenBasePointerReturned) {
|
||||
uint32_t mockRootDeviceIndex = 0u;
|
||||
DeviceBitfield mockDeviceBitfield(0b1);
|
||||
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
||||
MemoryManagerCreate<OsAgnosticMemoryManager> memoryManager(false, false, executionEnvironment);
|
||||
osHandle handle = 1;
|
||||
auto size = 4096u;
|
||||
uint64_t basePointer = 0x1234;
|
||||
AllocationProperties properties(mockRootDeviceIndex, false, size, AllocationType::SHARED_BUFFER, false, mockDeviceBitfield);
|
||||
auto sharedAllocation = memoryManager.createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true, reinterpret_cast<void *>(basePointer));
|
||||
EXPECT_NE(nullptr, sharedAllocation);
|
||||
EXPECT_EQ(reinterpret_cast<void *>(0x1234), sharedAllocation->getUnderlyingBuffer());
|
||||
EXPECT_FALSE(sharedAllocation->isCoherent());
|
||||
EXPECT_NE(nullptr, sharedAllocation->getUnderlyingBuffer());
|
||||
EXPECT_EQ(size, sharedAllocation->getUnderlyingBufferSize());
|
||||
EXPECT_EQ(MemoryPool::SystemCpuInaccessible, sharedAllocation->getMemoryPool());
|
||||
|
||||
memoryManager.freeGraphicsMemory(sharedAllocation);
|
||||
}
|
||||
@@ -2037,7 +2037,7 @@ TEST_F(DrmMemoryManagerTestPrelim, whenSettingNumHandlesThenTheyAreRetrievedCorr
|
||||
size_t size = 65536u * 2;
|
||||
AllocationProperties properties(rootDeviceIndex, true, size, AllocationType::BUFFER_HOST_MEMORY, false, device->getDeviceBitfield());
|
||||
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromMultipleSharedHandles(handles, properties, false, false, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromMultipleSharedHandles(handles, properties, false, false, true, nullptr);
|
||||
ASSERT_NE(nullptr, graphicsAllocation);
|
||||
|
||||
uint32_t numHandlesExpected = 8;
|
||||
@@ -2060,10 +2060,10 @@ TEST_F(DrmMemoryManagerTestPrelim, whenCreatingAllocationFromMultipleSharedHandl
|
||||
|
||||
memoryManager->failOnfindAndReferenceSharedBufferObject = false;
|
||||
|
||||
auto graphicsAllocationFromReferencedHandle = memoryManager->createGraphicsAllocationFromMultipleSharedHandles(handles, properties, false, false, true);
|
||||
auto graphicsAllocationFromReferencedHandle = memoryManager->createGraphicsAllocationFromMultipleSharedHandles(handles, properties, false, false, true, nullptr);
|
||||
ASSERT_NE(nullptr, graphicsAllocationFromReferencedHandle);
|
||||
|
||||
auto graphicsAllocationFromReferencedHandle2 = memoryManager->createGraphicsAllocationFromMultipleSharedHandles(handles, properties, false, false, true);
|
||||
auto graphicsAllocationFromReferencedHandle2 = memoryManager->createGraphicsAllocationFromMultipleSharedHandles(handles, properties, false, false, true, nullptr);
|
||||
ASSERT_NE(nullptr, graphicsAllocationFromReferencedHandle2);
|
||||
|
||||
DrmAllocation *drmAllocationFromReferencedHandle = static_cast<DrmAllocation *>(graphicsAllocationFromReferencedHandle);
|
||||
@@ -2082,6 +2082,40 @@ TEST_F(DrmMemoryManagerTestPrelim, whenCreatingAllocationFromMultipleSharedHandl
|
||||
memoryManager->freeGraphicsMemory(graphicsAllocationFromReferencedHandle);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerTestPrelim, whenCreatingAllocationFromMultipleSharedHandlesWithSharingResourcesWithBasePointerThenUnderlyingPointerIsTheSame) {
|
||||
mock->ioctlExpected.primeFdToHandle = 4;
|
||||
mock->ioctlExpected.gemWait = 2;
|
||||
mock->ioctlExpected.gemClose = 2;
|
||||
|
||||
std::vector<NEO::osHandle> handles{6, 7};
|
||||
size_t size = 65536u * 2;
|
||||
AllocationProperties properties(rootDeviceIndex, true, size, AllocationType::BUFFER_HOST_MEMORY, false, device->getDeviceBitfield());
|
||||
|
||||
memoryManager->failOnfindAndReferenceSharedBufferObject = false;
|
||||
|
||||
auto graphicsAllocationFromReferencedHandle = memoryManager->createGraphicsAllocationFromMultipleSharedHandles(handles, properties, false, false, true, nullptr);
|
||||
ASSERT_NE(nullptr, graphicsAllocationFromReferencedHandle);
|
||||
|
||||
auto graphicsAllocationFromReferencedHandle2 = memoryManager->createGraphicsAllocationFromMultipleSharedHandles(handles, properties, false, false, true, reinterpret_cast<void *>(graphicsAllocationFromReferencedHandle->getGpuAddress()));
|
||||
ASSERT_NE(nullptr, graphicsAllocationFromReferencedHandle2);
|
||||
|
||||
DrmAllocation *drmAllocationFromReferencedHandle = static_cast<DrmAllocation *>(graphicsAllocationFromReferencedHandle);
|
||||
auto boFromReferencedHandle = drmAllocationFromReferencedHandle->getBO();
|
||||
EXPECT_EQ(boFromReferencedHandle->peekHandle(), (int)this->mock->outputHandle);
|
||||
EXPECT_NE(0llu, boFromReferencedHandle->peekAddress());
|
||||
|
||||
DrmAllocation *drmAllocationFromReferencedHandle2 = static_cast<DrmAllocation *>(graphicsAllocationFromReferencedHandle2);
|
||||
auto boFromReferencedHandle2 = drmAllocationFromReferencedHandle2->getBO();
|
||||
EXPECT_EQ(boFromReferencedHandle2->peekHandle(), (int)this->mock->outputHandle);
|
||||
EXPECT_NE(0llu, boFromReferencedHandle2->peekAddress());
|
||||
|
||||
EXPECT_EQ(boFromReferencedHandle->peekAddress(), boFromReferencedHandle2->peekAddress());
|
||||
|
||||
EXPECT_EQ(graphicsAllocationFromReferencedHandle->getGpuAddress(), graphicsAllocationFromReferencedHandle2->getGpuAddress());
|
||||
memoryManager->freeGraphicsMemory(graphicsAllocationFromReferencedHandle2);
|
||||
memoryManager->freeGraphicsMemory(graphicsAllocationFromReferencedHandle);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerTestPrelim, whenCreatingAllocationFromMultipleSharedHandlesWithNoSharingResourcesThenDifferentAllocationsAreReturned) {
|
||||
mock->ioctlExpected.primeFdToHandle = 4;
|
||||
mock->ioctlExpected.gemWait = 2;
|
||||
@@ -2093,10 +2127,10 @@ TEST_F(DrmMemoryManagerTestPrelim, whenCreatingAllocationFromMultipleSharedHandl
|
||||
|
||||
memoryManager->failOnfindAndReferenceSharedBufferObject = false;
|
||||
|
||||
auto graphicsAllocationFromReferencedHandle = memoryManager->createGraphicsAllocationFromMultipleSharedHandles(handles, properties, false, false, false);
|
||||
auto graphicsAllocationFromReferencedHandle = memoryManager->createGraphicsAllocationFromMultipleSharedHandles(handles, properties, false, false, false, nullptr);
|
||||
ASSERT_NE(nullptr, graphicsAllocationFromReferencedHandle);
|
||||
|
||||
auto graphicsAllocationFromReferencedHandle2 = memoryManager->createGraphicsAllocationFromMultipleSharedHandles(handles, properties, false, false, false);
|
||||
auto graphicsAllocationFromReferencedHandle2 = memoryManager->createGraphicsAllocationFromMultipleSharedHandles(handles, properties, false, false, false, nullptr);
|
||||
ASSERT_NE(nullptr, graphicsAllocationFromReferencedHandle2);
|
||||
|
||||
DrmAllocation *drmAllocationFromReferencedHandle = static_cast<DrmAllocation *>(graphicsAllocationFromReferencedHandle);
|
||||
@@ -2125,7 +2159,7 @@ TEST_F(DrmMemoryManagerTestPrelim, whenCreatingAllocationFromMultipleSharedHandl
|
||||
AllocationProperties properties(rootDeviceIndex, true, size, AllocationType::BUFFER_HOST_MEMORY, false, device->getDeviceBitfield());
|
||||
|
||||
memoryManager->failOnfindAndReferenceSharedBufferObject = false;
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromMultipleSharedHandles(handles, properties, false, false, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromMultipleSharedHandles(handles, properties, false, false, true, nullptr);
|
||||
ASSERT_NE(nullptr, graphicsAllocation);
|
||||
|
||||
DrmAllocation *drmAllocation = static_cast<DrmAllocation *>(graphicsAllocation);
|
||||
@@ -2133,7 +2167,7 @@ TEST_F(DrmMemoryManagerTestPrelim, whenCreatingAllocationFromMultipleSharedHandl
|
||||
EXPECT_EQ(bo->peekHandle(), (int)this->mock->outputHandle);
|
||||
EXPECT_NE(0llu, bo->peekAddress());
|
||||
|
||||
auto graphicsAllocationFromReferencedHandle = memoryManager->createGraphicsAllocationFromMultipleSharedHandles(handles, properties, false, false, true);
|
||||
auto graphicsAllocationFromReferencedHandle = memoryManager->createGraphicsAllocationFromMultipleSharedHandles(handles, properties, false, false, true, nullptr);
|
||||
ASSERT_NE(nullptr, graphicsAllocationFromReferencedHandle);
|
||||
|
||||
DrmAllocation *drmAllocationFromReferencedHandle = static_cast<DrmAllocation *>(graphicsAllocationFromReferencedHandle);
|
||||
@@ -2155,7 +2189,7 @@ TEST_F(DrmMemoryManagerTestPrelim, whenCreatingAllocationFromMultipleSharedHandl
|
||||
AllocationProperties properties(rootDeviceIndex, true, size, AllocationType::BUFFER_HOST_MEMORY, false, device->getDeviceBitfield());
|
||||
|
||||
memoryManager->failOnfindAndReferenceSharedBufferObject = false;
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromMultipleSharedHandles(handles, properties, false, false, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromMultipleSharedHandles(handles, properties, false, false, true, nullptr);
|
||||
ASSERT_NE(nullptr, graphicsAllocation);
|
||||
|
||||
const bool prefer57bitAddressing = memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_EXTENDED) > 0;
|
||||
@@ -2187,7 +2221,7 @@ TEST_F(DrmMemoryManagerTestPrelim, whenCreatingAllocationFromMultipleSharedHandl
|
||||
AllocationProperties properties(rootDeviceIndex, true, size, AllocationType::BUFFER_HOST_MEMORY, false, device->getDeviceBitfield());
|
||||
|
||||
memoryManager->failOnfindAndReferenceSharedBufferObject = false;
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromMultipleSharedHandles(handles, properties, false, false, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromMultipleSharedHandles(handles, properties, false, false, true, nullptr);
|
||||
EXPECT_EQ(nullptr, graphicsAllocation);
|
||||
}
|
||||
|
||||
@@ -2200,7 +2234,7 @@ TEST_F(DrmMemoryManagerTestPrelim, whenCreatingAllocationFromMultipleSharedHandl
|
||||
size_t size = 65536u * 2;
|
||||
AllocationProperties properties(rootDeviceIndex, true, size, AllocationType::BUFFER_HOST_MEMORY, false, device->getDeviceBitfield());
|
||||
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromMultipleSharedHandles(handles, properties, false, false, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromMultipleSharedHandles(handles, properties, false, false, true, nullptr);
|
||||
ASSERT_NE(nullptr, graphicsAllocation);
|
||||
|
||||
DrmAllocation *drmAllocation = static_cast<DrmAllocation *>(graphicsAllocation);
|
||||
@@ -2253,7 +2287,7 @@ TEST_F(DrmMemoryManagerTestPrelim, givenDrmMemoryManagerAndOsHandleWhenCreateIsC
|
||||
size_t size = 4096u;
|
||||
AllocationProperties properties(rootDeviceIndex, false, size, AllocationType::BUFFER_HOST_MEMORY, false, {});
|
||||
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, true, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, true, true, nullptr);
|
||||
ASSERT_NE(nullptr, graphicsAllocation);
|
||||
|
||||
EXPECT_NE(nullptr, graphicsAllocation->getUnderlyingBuffer());
|
||||
@@ -2285,7 +2319,7 @@ TEST_F(DrmMemoryManagerTestPrelim,
|
||||
AllocationProperties properties(rootDeviceIndex, false, size, AllocationType::BUFFER_HOST_MEMORY, false, {});
|
||||
|
||||
testing::internal::CaptureStdout();
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, true, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, true, true, nullptr);
|
||||
ASSERT_NE(nullptr, graphicsAllocation);
|
||||
|
||||
EXPECT_NE(nullptr, graphicsAllocation->getUnderlyingBuffer());
|
||||
@@ -2325,7 +2359,7 @@ TEST_F(DrmMemoryManagerTestPrelim, givenDrmMemoryManagerAndOsHandleWhenCreateIsC
|
||||
size_t size = 4096u;
|
||||
AllocationProperties properties(rootDeviceIndex, false, size, AllocationType::BUFFER_HOST_MEMORY, false, {});
|
||||
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, true, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, true, true, nullptr);
|
||||
ASSERT_NE(nullptr, graphicsAllocation);
|
||||
|
||||
EXPECT_NE(nullptr, graphicsAllocation->getUnderlyingBuffer());
|
||||
@@ -2354,7 +2388,7 @@ TEST_F(DrmMemoryManagerTestPrelim, givenDrmMemoryManagerAndOsHandleWhenCreateIsC
|
||||
size_t size = 4096u;
|
||||
AllocationProperties properties(rootDeviceIndex, false, size, AllocationType::BUFFER_HOST_MEMORY, false, {});
|
||||
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, true, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, true, true, nullptr);
|
||||
ASSERT_NE(nullptr, graphicsAllocation);
|
||||
|
||||
EXPECT_NE(nullptr, graphicsAllocation->getUnderlyingBuffer());
|
||||
@@ -2369,7 +2403,7 @@ TEST_F(DrmMemoryManagerTestPrelim, givenDrmMemoryManagerAndOsHandleWhenCreateIsC
|
||||
EXPECT_EQ(1u, bo->getRefCount());
|
||||
EXPECT_EQ(size, bo->peekSize());
|
||||
|
||||
auto graphicsAllocation2 = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, true, true);
|
||||
auto graphicsAllocation2 = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, true, true, nullptr);
|
||||
ASSERT_NE(nullptr, graphicsAllocation2);
|
||||
|
||||
EXPECT_NE(nullptr, graphicsAllocation2->getUnderlyingBuffer());
|
||||
@@ -2396,7 +2430,7 @@ TEST_F(DrmMemoryManagerTestPrelim, givenDrmMemoryManagerAndOsHandleWhenCreateIsC
|
||||
|
||||
mock->returnIoctlExtraErrorValue = true;
|
||||
mock->failOnMmapOffset = true;
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, true, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, true, true, nullptr);
|
||||
EXPECT_EQ(nullptr, graphicsAllocation);
|
||||
|
||||
memoryManager->freeGraphicsMemory(graphicsAllocation);
|
||||
@@ -2414,7 +2448,7 @@ TEST_F(DrmMemoryManagerTestPrelim, givenDrmMemoryManagerAndUseMmapObjectSetToFal
|
||||
AllocationProperties properties(rootDeviceIndex, false, size, AllocationType::BUFFER_HOST_MEMORY, false, {});
|
||||
properties.useMmapObject = false;
|
||||
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, true, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, true, true, nullptr);
|
||||
EXPECT_EQ(static_cast<int>(handle), static_cast<DrmAllocation *>(graphicsAllocation)->getBO()->peekHandle());
|
||||
|
||||
memoryManager->freeGraphicsMemory(graphicsAllocation);
|
||||
@@ -2433,7 +2467,7 @@ TEST_F(DrmMemoryManagerTestPrelim, givenDrmMemoryManagerWithoutMemoryInfoThenDrm
|
||||
size_t size = 4096u;
|
||||
AllocationProperties properties(rootDeviceIndex, false, size, AllocationType::BUFFER_HOST_MEMORY, false, {});
|
||||
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, true, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, true, true, nullptr);
|
||||
EXPECT_EQ(static_cast<int>(handle), static_cast<DrmAllocation *>(graphicsAllocation)->getBO()->peekHandle());
|
||||
|
||||
memoryManager->freeGraphicsMemory(graphicsAllocation);
|
||||
@@ -2451,7 +2485,7 @@ TEST_F(DrmMemoryManagerTestPrelim, MmapFailWhenUSMHostAllocationFromSharedHandle
|
||||
return MAP_FAILED;
|
||||
};
|
||||
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, true, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, true, true, nullptr);
|
||||
|
||||
ASSERT_EQ(nullptr, graphicsAllocation);
|
||||
}
|
||||
|
||||
@@ -232,7 +232,7 @@ TEST_F(DrmMemoryManagerUsmSharedHandleTest, givenDrmMemoryManagerAndOsHandleWhen
|
||||
size_t size = 4096u;
|
||||
AllocationProperties properties(rootDeviceIndex, false, size, AllocationType::BUFFER_HOST_MEMORY, false, {});
|
||||
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, true, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, true, true, nullptr);
|
||||
ASSERT_NE(nullptr, graphicsAllocation);
|
||||
|
||||
EXPECT_EQ(this->mock->inputFd, (int)handle);
|
||||
|
||||
@@ -61,14 +61,14 @@ TEST_P(MemoryManagerMultiDeviceSharedHandleTest, whenCreatingAllocationFromShare
|
||||
uint32_t handle0 = 0;
|
||||
uint32_t rootDeviceIndex0 = 0;
|
||||
AllocationProperties properties0{rootDeviceIndex0, true, MemoryConstants::pageSize, AllocationType::BUFFER, false, false, mockDeviceBitfield};
|
||||
auto gfxAllocation0 = memoryManager->createGraphicsAllocationFromSharedHandle(handle0, properties0, false, false, true);
|
||||
auto gfxAllocation0 = memoryManager->createGraphicsAllocationFromSharedHandle(handle0, properties0, false, false, true, nullptr);
|
||||
ASSERT_NE(gfxAllocation0, nullptr);
|
||||
EXPECT_EQ(rootDeviceIndex0, gfxAllocation0->getRootDeviceIndex());
|
||||
|
||||
uint32_t handle1 = 0;
|
||||
uint32_t rootDeviceIndex1 = 0;
|
||||
AllocationProperties properties1{rootDeviceIndex1, true, MemoryConstants::pageSize, AllocationType::BUFFER, false, false, mockDeviceBitfield};
|
||||
auto gfxAllocation1 = memoryManager->createGraphicsAllocationFromSharedHandle(handle1, properties1, false, false, true);
|
||||
auto gfxAllocation1 = memoryManager->createGraphicsAllocationFromSharedHandle(handle1, properties1, false, false, true, nullptr);
|
||||
ASSERT_NE(gfxAllocation1, nullptr);
|
||||
EXPECT_EQ(rootDeviceIndex1, gfxAllocation1->getRootDeviceIndex());
|
||||
|
||||
@@ -85,14 +85,14 @@ TEST_P(MemoryManagerMultiDeviceSharedHandleTest, whenCreatingAllocationFromShare
|
||||
uint32_t handle0 = 0;
|
||||
uint32_t rootDeviceIndex0 = 0;
|
||||
AllocationProperties properties0{rootDeviceIndex0, true, MemoryConstants::pageSize, AllocationType::BUFFER, false, false, mockDeviceBitfield};
|
||||
auto gfxAllocation0 = memoryManager->createGraphicsAllocationFromSharedHandle(handle0, properties0, false, false, true);
|
||||
auto gfxAllocation0 = memoryManager->createGraphicsAllocationFromSharedHandle(handle0, properties0, false, false, true, nullptr);
|
||||
ASSERT_NE(gfxAllocation0, nullptr);
|
||||
EXPECT_EQ(rootDeviceIndex0, gfxAllocation0->getRootDeviceIndex());
|
||||
|
||||
uint32_t handle1 = 0;
|
||||
uint32_t rootDeviceIndex1 = 1;
|
||||
AllocationProperties properties1{rootDeviceIndex1, true, MemoryConstants::pageSize, AllocationType::BUFFER, false, false, mockDeviceBitfield};
|
||||
auto gfxAllocation1 = memoryManager->createGraphicsAllocationFromSharedHandle(handle1, properties1, false, false, true);
|
||||
auto gfxAllocation1 = memoryManager->createGraphicsAllocationFromSharedHandle(handle1, properties1, false, false, true, nullptr);
|
||||
ASSERT_NE(gfxAllocation1, nullptr);
|
||||
EXPECT_EQ(rootDeviceIndex1, gfxAllocation1->getRootDeviceIndex());
|
||||
|
||||
@@ -105,18 +105,43 @@ TEST_P(MemoryManagerMultiDeviceSharedHandleTest, whenCreatingAllocationFromShare
|
||||
memoryManager->freeGraphicsMemory(gfxAllocation1);
|
||||
}
|
||||
|
||||
TEST_P(MemoryManagerMultiDeviceSharedHandleTest, whenCreatingAllocationFromSharedHandleWithSameHandleAndDifferentRootDeviceWithBasePointerOnSecondDeviceThenSamePointerIsUsed) {
|
||||
uint32_t handle0 = 0;
|
||||
uint32_t rootDeviceIndex0 = 0;
|
||||
AllocationProperties properties0{rootDeviceIndex0, true, MemoryConstants::pageSize, AllocationType::BUFFER, false, false, mockDeviceBitfield};
|
||||
auto gfxAllocation0 = memoryManager->createGraphicsAllocationFromSharedHandle(handle0, properties0, false, false, true, nullptr);
|
||||
ASSERT_NE(gfxAllocation0, nullptr);
|
||||
EXPECT_EQ(rootDeviceIndex0, gfxAllocation0->getRootDeviceIndex());
|
||||
|
||||
uint32_t handle1 = 0;
|
||||
uint32_t rootDeviceIndex1 = 1;
|
||||
AllocationProperties properties1{rootDeviceIndex1, true, MemoryConstants::pageSize, AllocationType::BUFFER, false, false, mockDeviceBitfield};
|
||||
auto gfxAllocation1 = memoryManager->createGraphicsAllocationFromSharedHandle(handle1, properties1, false, false, true, reinterpret_cast<void *>(gfxAllocation0->getUnderlyingBuffer()));
|
||||
ASSERT_NE(gfxAllocation1, nullptr);
|
||||
EXPECT_EQ(rootDeviceIndex1, gfxAllocation1->getRootDeviceIndex());
|
||||
|
||||
DrmAllocation *drmAllocation0 = static_cast<DrmAllocation *>(gfxAllocation0);
|
||||
DrmAllocation *drmAllocation1 = static_cast<DrmAllocation *>(gfxAllocation1);
|
||||
|
||||
EXPECT_NE(drmAllocation0->getBO(), drmAllocation1->getBO());
|
||||
EXPECT_EQ(gfxAllocation0->getUnderlyingBuffer(), gfxAllocation1->getUnderlyingBuffer());
|
||||
|
||||
memoryManager->freeGraphicsMemory(gfxAllocation0);
|
||||
memoryManager->freeGraphicsMemory(gfxAllocation1);
|
||||
}
|
||||
|
||||
TEST_P(MemoryManagerMultiDeviceSharedHandleTest, whenCreatingAllocationFromSharedHandleWithDifferentHandleAndSameRootDeviceThenDifferentBOIsUsed) {
|
||||
uint32_t handle0 = 0;
|
||||
uint32_t rootDeviceIndex0 = 0;
|
||||
AllocationProperties properties0{rootDeviceIndex0, true, MemoryConstants::pageSize, AllocationType::BUFFER, false, false, mockDeviceBitfield};
|
||||
auto gfxAllocation0 = memoryManager->createGraphicsAllocationFromSharedHandle(handle0, properties0, false, false, true);
|
||||
auto gfxAllocation0 = memoryManager->createGraphicsAllocationFromSharedHandle(handle0, properties0, false, false, true, nullptr);
|
||||
ASSERT_NE(gfxAllocation0, nullptr);
|
||||
EXPECT_EQ(rootDeviceIndex0, gfxAllocation0->getRootDeviceIndex());
|
||||
|
||||
uint32_t handle1 = 1;
|
||||
uint32_t rootDeviceIndex1 = 0;
|
||||
AllocationProperties properties1{rootDeviceIndex1, true, MemoryConstants::pageSize, AllocationType::BUFFER, false, false, mockDeviceBitfield};
|
||||
auto gfxAllocation1 = memoryManager->createGraphicsAllocationFromSharedHandle(handle1, properties1, false, false, true);
|
||||
auto gfxAllocation1 = memoryManager->createGraphicsAllocationFromSharedHandle(handle1, properties1, false, false, true, nullptr);
|
||||
ASSERT_NE(gfxAllocation1, nullptr);
|
||||
EXPECT_EQ(rootDeviceIndex1, gfxAllocation1->getRootDeviceIndex());
|
||||
|
||||
@@ -133,14 +158,14 @@ TEST_P(MemoryManagerMultiDeviceSharedHandleTest, whenCreatingAllocationFromShare
|
||||
uint32_t handle0 = 0;
|
||||
uint32_t rootDeviceIndex0 = 0;
|
||||
AllocationProperties properties0{rootDeviceIndex0, true, MemoryConstants::pageSize, AllocationType::BUFFER, false, false, mockDeviceBitfield};
|
||||
auto gfxAllocation0 = memoryManager->createGraphicsAllocationFromSharedHandle(handle0, properties0, false, false, true);
|
||||
auto gfxAllocation0 = memoryManager->createGraphicsAllocationFromSharedHandle(handle0, properties0, false, false, true, nullptr);
|
||||
ASSERT_NE(gfxAllocation0, nullptr);
|
||||
EXPECT_EQ(rootDeviceIndex0, gfxAllocation0->getRootDeviceIndex());
|
||||
|
||||
uint32_t handle1 = 1;
|
||||
uint32_t rootDeviceIndex1 = 1;
|
||||
AllocationProperties properties1{rootDeviceIndex1, true, MemoryConstants::pageSize, AllocationType::BUFFER, false, false, mockDeviceBitfield};
|
||||
auto gfxAllocation1 = memoryManager->createGraphicsAllocationFromSharedHandle(handle1, properties1, false, false, true);
|
||||
auto gfxAllocation1 = memoryManager->createGraphicsAllocationFromSharedHandle(handle1, properties1, false, false, true, nullptr);
|
||||
ASSERT_NE(gfxAllocation1, nullptr);
|
||||
EXPECT_EQ(rootDeviceIndex1, gfxAllocation1->getRootDeviceIndex());
|
||||
|
||||
@@ -915,7 +940,7 @@ TEST_F(DrmMemoryManagerTest, GivenAllocationWhenClosingSharedHandleThenSucceeds)
|
||||
size_t size = 4096u;
|
||||
AllocationProperties properties(rootDeviceIndex, false, size, AllocationType::SHARED_BUFFER, false, {});
|
||||
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true, nullptr);
|
||||
EXPECT_EQ(handle, graphicsAllocation->peekSharedHandle());
|
||||
|
||||
memoryManager->closeSharedHandle(graphicsAllocation);
|
||||
@@ -936,7 +961,7 @@ TEST_F(DrmMemoryManagerTest, GivenAllocationWhenClosingInternalHandleThenSucceed
|
||||
size_t size = 4096u;
|
||||
AllocationProperties properties(rootDeviceIndex, false, size, AllocationType::SHARED_BUFFER, false, {});
|
||||
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true, nullptr);
|
||||
EXPECT_EQ(0, graphicsAllocation->createInternalHandle(this->memoryManager, 0u, handleVal));
|
||||
|
||||
memoryManager->closeInternalHandle(handleVal, 0u, graphicsAllocation);
|
||||
@@ -1020,7 +1045,7 @@ TEST_F(DrmMemoryManagerTest, GivenDeviceSharedAllocationWhichRequiresHostMapThen
|
||||
this->mock->queryEngineInfo();
|
||||
AllocationProperties properties(rootDeviceIndex, false, size, AllocationType::GPU_TIMESTAMP_DEVICE_BUFFER, false, {});
|
||||
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, true, false);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, true, false, nullptr);
|
||||
DrmAllocation *drmAlloc = (DrmAllocation *)graphicsAllocation;
|
||||
|
||||
EXPECT_TRUE(isAligned<MemoryConstants::pageSize64k>(drmAlloc->getMmapPtr()));
|
||||
@@ -1792,7 +1817,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerAndOsHandleWhenCreateIsCalledT
|
||||
size_t size = 4096u;
|
||||
AllocationProperties properties(rootDeviceIndex, false, size, AllocationType::SHARED_BUFFER, false, {});
|
||||
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true, nullptr);
|
||||
ASSERT_NE(nullptr, graphicsAllocation);
|
||||
|
||||
EXPECT_NE(nullptr, graphicsAllocation->getUnderlyingBuffer());
|
||||
@@ -1822,7 +1847,7 @@ TEST_F(DrmMemoryManagerWithLocalMemoryTest, givenDrmMemoryManagerWithLocalMemory
|
||||
size_t size = 4096u;
|
||||
AllocationProperties properties(rootDeviceIndex, false, size, AllocationType::SHARED_BUFFER, false, {});
|
||||
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true, nullptr);
|
||||
ASSERT_NE(nullptr, graphicsAllocation);
|
||||
|
||||
EXPECT_NE(nullptr, graphicsAllocation->getUnderlyingBuffer());
|
||||
@@ -1863,7 +1888,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerAndOsHandleWhenCreateIsCalledA
|
||||
AllocationProperties properties(rootDeviceIndex, false, size, AllocationType::SHARED_BUFFER, false, false, 0u);
|
||||
ASSERT_TRUE(properties.subDevicesBitfield.none());
|
||||
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true, nullptr);
|
||||
ASSERT_NE(nullptr, graphicsAllocation);
|
||||
|
||||
EXPECT_EQ(rootDeviceIndex, graphicsAllocation->getRootDeviceIndex());
|
||||
@@ -1890,7 +1915,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerAndOsHandleWhenAllocationFails
|
||||
InjectedFunction method = [this, &handle](size_t failureIndex) {
|
||||
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, AllocationType::SHARED_BUFFER, false, mockDeviceBitfield);
|
||||
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true, nullptr);
|
||||
if (MemoryManagement::nonfailingAllocation == failureIndex) {
|
||||
EXPECT_NE(nullptr, graphicsAllocation);
|
||||
memoryManager->freeGraphicsMemory(graphicsAllocation);
|
||||
@@ -1924,7 +1949,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerAndThreeOsHandlesWhenReuseCrea
|
||||
|
||||
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, AllocationType::SHARED_BUFFER, false, mockDeviceBitfield);
|
||||
|
||||
graphicsAllocations[i] = memoryManager->createGraphicsAllocationFromSharedHandle(handles[i], properties, false, false, true);
|
||||
graphicsAllocations[i] = memoryManager->createGraphicsAllocationFromSharedHandle(handles[i], properties, false, false, true, nullptr);
|
||||
// Clang-tidy false positive WA
|
||||
if (graphicsAllocations[i] == nullptr) {
|
||||
ASSERT_FALSE(true);
|
||||
@@ -1965,7 +1990,7 @@ TEST_F(DrmMemoryManagerTest, given32BitAddressingWhenBufferFromSharedHandleAndBi
|
||||
|
||||
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, AllocationType::SHARED_BUFFER, false, mockDeviceBitfield);
|
||||
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, true, false, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, true, false, true, nullptr);
|
||||
auto drmAllocation = static_cast<DrmAllocation *>(graphicsAllocation);
|
||||
EXPECT_TRUE(graphicsAllocation->is32BitAllocation());
|
||||
EXPECT_EQ(1, lseekCalledCount);
|
||||
@@ -1983,7 +2008,7 @@ TEST_F(DrmMemoryManagerTest, given32BitAddressingWhenBufferFromSharedHandleIsCre
|
||||
osHandle handle = 1u;
|
||||
this->mock->outputHandle = 2u;
|
||||
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, AllocationType::SHARED_BUFFER, false, mockDeviceBitfield);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true, nullptr);
|
||||
auto drmAllocation = static_cast<DrmAllocation *>(graphicsAllocation);
|
||||
|
||||
EXPECT_FALSE(graphicsAllocation->is32BitAllocation());
|
||||
@@ -2003,7 +2028,7 @@ TEST_F(DrmMemoryManagerTest, givenLimitedRangeAllocatorWhenBufferFromSharedHandl
|
||||
osHandle handle = 1u;
|
||||
this->mock->outputHandle = 2u;
|
||||
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, AllocationType::SHARED_BUFFER, false, mockDeviceBitfield);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true, nullptr);
|
||||
EXPECT_FALSE(graphicsAllocation->is32BitAllocation());
|
||||
auto drmAllocation = static_cast<DrmAllocation *>(graphicsAllocation);
|
||||
|
||||
@@ -2021,7 +2046,7 @@ TEST_F(DrmMemoryManagerTest, givenNon32BitAddressingWhenBufferFromSharedHandleIs
|
||||
osHandle handle = 1u;
|
||||
this->mock->outputHandle = 2u;
|
||||
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, AllocationType::SHARED_BUFFER, false, mockDeviceBitfield);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, true, false, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, true, false, true, nullptr);
|
||||
auto drmAllocation = static_cast<DrmAllocation *>(graphicsAllocation);
|
||||
EXPECT_FALSE(graphicsAllocation->is32BitAllocation());
|
||||
EXPECT_EQ(1, lseekCalledCount);
|
||||
@@ -2037,7 +2062,7 @@ TEST_F(DrmMemoryManagerTest, givenSharedHandleWhenAllocationIsCreatedAndIoctlPri
|
||||
osHandle handle = 1u;
|
||||
this->mock->outputHandle = 2u;
|
||||
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, AllocationType::SHARED_BUFFER, false, mockDeviceBitfield);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true, nullptr);
|
||||
EXPECT_EQ(nullptr, graphicsAllocation);
|
||||
memoryManager->freeGraphicsMemory(graphicsAllocation);
|
||||
}
|
||||
@@ -2050,8 +2075,8 @@ TEST_F(DrmMemoryManagerTest, givenTwoGraphicsAllocationsThatShareTheSameBufferOb
|
||||
|
||||
osHandle sharedHandle = 1u;
|
||||
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, AllocationType::SHARED_BUFFER, false, mockDeviceBitfield);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(sharedHandle, properties, false, false, true);
|
||||
auto graphicsAllocation2 = memoryManager->createGraphicsAllocationFromSharedHandle(sharedHandle, properties, false, false, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(sharedHandle, properties, false, false, true, nullptr);
|
||||
auto graphicsAllocation2 = memoryManager->createGraphicsAllocationFromSharedHandle(sharedHandle, properties, false, false, true, nullptr);
|
||||
|
||||
auto currentResidentSize = testedCsr->getResidencyAllocations().size();
|
||||
testedCsr->makeResident(*graphicsAllocation);
|
||||
@@ -2076,9 +2101,9 @@ TEST_F(DrmMemoryManagerTest, givenTwoGraphicsAllocationsThatDoesnShareTheSameBuf
|
||||
|
||||
osHandle sharedHandle = 1u;
|
||||
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, AllocationType::SHARED_BUFFER, false, {});
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(sharedHandle, properties, false, false, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(sharedHandle, properties, false, false, true, nullptr);
|
||||
mock->outputHandle++;
|
||||
auto graphicsAllocation2 = memoryManager->createGraphicsAllocationFromSharedHandle(sharedHandle, properties, false, false, true);
|
||||
auto graphicsAllocation2 = memoryManager->createGraphicsAllocationFromSharedHandle(sharedHandle, properties, false, false, true, nullptr);
|
||||
|
||||
auto currentResidentSize = testedCsr->getResidencyAllocations().size();
|
||||
testedCsr->makeResident(*graphicsAllocation);
|
||||
@@ -2341,7 +2366,7 @@ TEST_F(DrmMemoryManagerTest, givenSharedAllocationWithSmallerThenRealSizeWhenCre
|
||||
osHandle sharedHandle = 1u;
|
||||
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, AllocationType::SHARED_BUFFER, false, {});
|
||||
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(sharedHandle, properties, false, false, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(sharedHandle, properties, false, false, true, nullptr);
|
||||
|
||||
EXPECT_NE(nullptr, graphicsAllocation->getUnderlyingBuffer());
|
||||
EXPECT_EQ(realSize, graphicsAllocation->getUnderlyingBufferSize());
|
||||
@@ -2709,7 +2734,7 @@ TEST_F(DrmMemoryManagerBasic, givenMemoryManagerWhenCreateAllocationFromHandleIs
|
||||
executionEnvironment));
|
||||
auto osHandle = 1u;
|
||||
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, AllocationType::SHARED_BUFFER, false, {});
|
||||
auto allocation = memoryManager->createGraphicsAllocationFromSharedHandle(osHandle, properties, false, false, true);
|
||||
auto allocation = memoryManager->createGraphicsAllocationFromSharedHandle(osHandle, properties, false, false, true, nullptr);
|
||||
EXPECT_NE(nullptr, allocation);
|
||||
EXPECT_EQ(MemoryPool::SystemCpuInaccessible, allocation->getMemoryPool());
|
||||
memoryManager->freeGraphicsMemory(allocation);
|
||||
@@ -3585,10 +3610,10 @@ TEST(DrmMemoryManagerFreeGraphicsMemoryUnreferenceTest,
|
||||
|
||||
osHandle handle = 1u;
|
||||
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, AllocationType::SHARED_BUFFER, false, {});
|
||||
auto allocation = memoryManger.createGraphicsAllocationFromSharedHandle(handle, properties, false, false, false);
|
||||
auto allocation = memoryManger.createGraphicsAllocationFromSharedHandle(handle, properties, false, false, false, nullptr);
|
||||
ASSERT_NE(nullptr, allocation);
|
||||
|
||||
auto allocation2 = memoryManger.createGraphicsAllocationFromSharedHandle(handle, properties, false, false, false);
|
||||
auto allocation2 = memoryManger.createGraphicsAllocationFromSharedHandle(handle, properties, false, false, false, nullptr);
|
||||
ASSERT_NE(nullptr, allocation2);
|
||||
|
||||
EXPECT_NE(allocation->getGpuAddress(), allocation2->getGpuAddress());
|
||||
@@ -3615,7 +3640,7 @@ TEST(DrmMemoryManagerFreeGraphicsMemoryUnreferenceTest,
|
||||
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, AllocationType::SHARED_BUFFER, false, {});
|
||||
|
||||
testing::internal::CaptureStdout();
|
||||
auto allocation = memoryManger.createGraphicsAllocationFromSharedHandle(handle, properties, false, false, false);
|
||||
auto allocation = memoryManger.createGraphicsAllocationFromSharedHandle(handle, properties, false, false, false, nullptr);
|
||||
ASSERT_NE(nullptr, allocation);
|
||||
|
||||
std::stringstream expectedOutput;
|
||||
@@ -3645,10 +3670,10 @@ TEST(DrmMemoryManagerFreeGraphicsMemoryUnreferenceTest,
|
||||
|
||||
osHandle handle = 1u;
|
||||
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, AllocationType::SHARED_BUFFER, false, {});
|
||||
auto allocation = memoryManger.createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true);
|
||||
auto allocation = memoryManger.createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true, nullptr);
|
||||
ASSERT_NE(nullptr, allocation);
|
||||
|
||||
auto allocation2 = memoryManger.createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true);
|
||||
auto allocation2 = memoryManger.createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true, nullptr);
|
||||
ASSERT_NE(nullptr, allocation2);
|
||||
|
||||
EXPECT_EQ(allocation->getGpuAddress(), allocation2->getGpuAddress());
|
||||
@@ -3669,7 +3694,7 @@ TEST(DrmMemoryManagerFreeGraphicsMemoryUnreferenceTest, givenDrmMemoryManagerAnd
|
||||
|
||||
osHandle handle = 1u;
|
||||
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, AllocationType::SHARED_BUFFER, false, {});
|
||||
auto allocation = memoryManger.createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true);
|
||||
auto allocation = memoryManger.createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true, nullptr);
|
||||
ASSERT_NE(nullptr, allocation);
|
||||
|
||||
memoryManger.freeGraphicsMemory(allocation);
|
||||
|
||||
@@ -501,7 +501,7 @@ TEST_F(Wddm20WithMockGdiDllTests, givenSharedHandleWhenCreateGraphicsAllocationF
|
||||
MemoryManagerCreate<WddmMemoryManager> mm(false, false, *executionEnvironment);
|
||||
AllocationProperties properties(0, false, 4096u, AllocationType::SHARED_BUFFER, false, {});
|
||||
|
||||
auto graphicsAllocation = mm.createGraphicsAllocationFromSharedHandle(ALLOCATION_HANDLE, properties, false, false, true);
|
||||
auto graphicsAllocation = mm.createGraphicsAllocationFromSharedHandle(ALLOCATION_HANDLE, properties, false, false, true, nullptr);
|
||||
auto wddmAllocation = (WddmAllocation *)graphicsAllocation;
|
||||
ASSERT_NE(nullptr, wddmAllocation);
|
||||
|
||||
@@ -529,6 +529,48 @@ TEST_F(Wddm20WithMockGdiDllTests, givenSharedHandleWhenCreateGraphicsAllocationF
|
||||
EXPECT_EQ(1u, destroyWithResourceHandleCalled);
|
||||
}
|
||||
|
||||
TEST_F(Wddm20WithMockGdiDllTests, givenSharedHandleWhenCreateGraphicsAllocationFromSharedHandleIsCalledWithMapPointerThenGraphicsAllocationWithSharedPropertiesIsCreated) {
|
||||
void *pSysMem = (void *)0x1000;
|
||||
|
||||
size_t sizeAlignedTo64Kb = 64 * KB;
|
||||
void *reservedAddress;
|
||||
EXPECT_TRUE(wddm->reserveValidAddressRange(sizeAlignedTo64Kb, reservedAddress));
|
||||
|
||||
std::unique_ptr<Gmm> gmm(new Gmm(getGmmHelper(), pSysMem, sizeAlignedTo64Kb, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true));
|
||||
auto status = setSizesFcn(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u);
|
||||
EXPECT_EQ(0u, static_cast<uint32_t>(status));
|
||||
|
||||
MemoryManagerCreate<WddmMemoryManager> mm(false, false, *executionEnvironment);
|
||||
AllocationProperties properties(0, false, sizeAlignedTo64Kb, AllocationType::SHARED_BUFFER, false, {});
|
||||
|
||||
auto graphicsAllocation = mm.createGraphicsAllocationFromSharedHandle(ALLOCATION_HANDLE, properties, false, false, true, reservedAddress);
|
||||
auto wddmAllocation = (WddmAllocation *)graphicsAllocation;
|
||||
ASSERT_NE(nullptr, wddmAllocation);
|
||||
|
||||
EXPECT_EQ(ALLOCATION_HANDLE, wddmAllocation->peekSharedHandle());
|
||||
EXPECT_EQ(RESOURCE_HANDLE, wddmAllocation->resourceHandle);
|
||||
EXPECT_NE(0u, wddmAllocation->getDefaultHandle());
|
||||
EXPECT_EQ(ALLOCATION_HANDLE, wddmAllocation->getDefaultHandle());
|
||||
EXPECT_EQ(reservedAddress, reinterpret_cast<void *>(wddmAllocation->getGpuAddress()));
|
||||
EXPECT_EQ(sizeAlignedTo64Kb, wddmAllocation->getUnderlyingBufferSize());
|
||||
EXPECT_EQ(nullptr, wddmAllocation->getAlignedCpuPtr());
|
||||
EXPECT_NE(nullptr, wddmAllocation->getDefaultGmm());
|
||||
|
||||
EXPECT_EQ(sizeAlignedTo64Kb, wddmAllocation->getDefaultGmm()->gmmResourceInfo->getSizeAllocation());
|
||||
mm.freeGraphicsMemory(graphicsAllocation);
|
||||
wddm->releaseReservedAddress(nullptr);
|
||||
auto destroyWithResourceHandleCalled = 0u;
|
||||
D3DKMT_DESTROYALLOCATION2 *ptrToDestroyAlloc2 = nullptr;
|
||||
|
||||
status = getSizesFcn(destroyWithResourceHandleCalled, ptrToDestroyAlloc2);
|
||||
|
||||
EXPECT_EQ(0u, ptrToDestroyAlloc2->Flags.SynchronousDestroy);
|
||||
EXPECT_EQ(1u, ptrToDestroyAlloc2->Flags.AssumeNotInUse);
|
||||
|
||||
EXPECT_EQ(0u, static_cast<uint32_t>(status));
|
||||
EXPECT_EQ(1u, destroyWithResourceHandleCalled);
|
||||
}
|
||||
|
||||
TEST_F(Wddm20WithMockGdiDllTests, givenSharedHandleWhenCreateGraphicsAllocationFromMultipleSharedHandlesIsCalledThenNullptrIsReturned) {
|
||||
void *pSysMem = (void *)0x1000;
|
||||
std::unique_ptr<Gmm> gmm(new Gmm(getGmmHelper(), pSysMem, 4096u, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true));
|
||||
@@ -539,7 +581,7 @@ TEST_F(Wddm20WithMockGdiDllTests, givenSharedHandleWhenCreateGraphicsAllocationF
|
||||
AllocationProperties properties(0, false, 4096u, AllocationType::SHARED_BUFFER, false, {});
|
||||
|
||||
std::vector<osHandle> handles{ALLOCATION_HANDLE};
|
||||
auto graphicsAllocation = mm.createGraphicsAllocationFromMultipleSharedHandles(handles, properties, false, false, true);
|
||||
auto graphicsAllocation = mm.createGraphicsAllocationFromMultipleSharedHandles(handles, properties, false, false, true, nullptr);
|
||||
ASSERT_EQ(nullptr, graphicsAllocation);
|
||||
}
|
||||
|
||||
@@ -552,7 +594,7 @@ TEST_F(Wddm20WithMockGdiDllTests, givenSharedHandleWhenCreateGraphicsAllocationF
|
||||
MemoryManagerCreate<WddmMemoryManager> mm(false, false, *executionEnvironment);
|
||||
AllocationProperties properties(0, false, 4096, AllocationType::SHARED_BUFFER, false, {});
|
||||
|
||||
auto graphicsAllocation = mm.createGraphicsAllocationFromSharedHandle(ALLOCATION_HANDLE, properties, false, false, true);
|
||||
auto graphicsAllocation = mm.createGraphicsAllocationFromSharedHandle(ALLOCATION_HANDLE, properties, false, false, true, nullptr);
|
||||
auto wddmAllocation = (WddmAllocation *)graphicsAllocation;
|
||||
ASSERT_NE(nullptr, wddmAllocation);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user