mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Destroy resource handle when created
Do not create resource when cpuPtr is set Signed-off-by: Kamil Diedrich <kamil.diedrich@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
54dc2f2000
commit
011a0dd497
@ -811,6 +811,19 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenFreeAllocFromSharedHandl
|
||||
EXPECT_EQ(lastDestroyed, expectedDestroyHandle);
|
||||
}
|
||||
|
||||
TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenAllocFromHostPtrIsCalledThenResourceHandleIsNotCreated) {
|
||||
auto size = 13u;
|
||||
auto hostPtr = reinterpret_cast<const void *>(0x10001);
|
||||
|
||||
AllocationData allocationData{};
|
||||
allocationData.size = size;
|
||||
allocationData.hostPtr = hostPtr;
|
||||
auto allocation = static_cast<WddmAllocation *>(memoryManager->allocateGraphicsMemoryForNonSvmHostPtr(allocationData));
|
||||
|
||||
EXPECT_EQ(0u, allocation->resourceHandle);
|
||||
memoryManager->freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerSizeZeroWhenCreateFromSharedHandleIsCalledThenUpdateSize) {
|
||||
auto osHandle = 1u;
|
||||
auto size = 4096u;
|
||||
|
@ -606,7 +606,7 @@ NTSTATUS Wddm::createAllocation(const void *alignedCpuPtr, const Gmm *gmm, D3DKM
|
||||
createAllocation.NumAllocations = 1;
|
||||
createAllocation.Flags.CreateShared = outSharedHandle ? TRUE : FALSE;
|
||||
createAllocation.Flags.NtSecuritySharing = outSharedHandle ? TRUE : FALSE;
|
||||
createAllocation.Flags.CreateResource = outSharedHandle || alignedCpuPtr ? TRUE : FALSE;
|
||||
createAllocation.Flags.CreateResource = outSharedHandle ? TRUE : FALSE;
|
||||
createAllocation.pAllocationInfo2 = &allocationInfo;
|
||||
createAllocation.hDevice = device;
|
||||
|
||||
|
@ -565,7 +565,7 @@ void WddmMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation
|
||||
input->fragmentsStorage.fragmentCount > 0) {
|
||||
cleanGraphicsMemoryCreatedFromHostPtr(gfxAllocation);
|
||||
} else {
|
||||
if (input->peekSharedHandle() || input->peekInternalHandle(nullptr) != 0) {
|
||||
if (input->resourceHandle != 0) {
|
||||
[[maybe_unused]] auto status = tryDeferDeletions(nullptr, 0, input->resourceHandle, gfxAllocation->getRootDeviceIndex());
|
||||
DEBUG_BREAK_IF(!status);
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user