Improve error handling for shared handles in wddm.

Change-Id: I93d33d89cb4b6333924c362b54e0638174e44091
This commit is contained in:
Zdunowski, Piotr
2017-12-21 17:28:17 +01:00
committed by sys_ocldev
parent aba7dc637d
commit b006972d07
6 changed files with 57 additions and 6 deletions

View File

@ -695,6 +695,10 @@ bool Wddm::openSharedHandle(D3DKMT_HANDLE handle, WddmAllocation *alloc) {
auto status = gdi->queryResourceInfo(&QueryResourceInfo);
DEBUG_BREAK_IF(status != STATUS_SUCCESS);
if (QueryResourceInfo.NumAllocations == 0) {
return false;
}
std::unique_ptr<char[]> allocPrivateData(new char[QueryResourceInfo.TotalPrivateDriverDataSize]);
std::unique_ptr<char[]> resPrivateData(new char[QueryResourceInfo.ResourcePrivateDriverDataSize]);
std::unique_ptr<char[]> resPrivateRuntimeData(new char[QueryResourceInfo.PrivateRuntimeDataSize]);
@ -721,7 +725,7 @@ bool Wddm::openSharedHandle(D3DKMT_HANDLE handle, WddmAllocation *alloc) {
alloc->gmm = Gmm::create((PGMM_RESOURCE_INFO)(allocationInfo[0].pPrivateDriverData));
return STATUS_SUCCESS;
return true;
}
bool Wddm::openNTHandle(HANDLE handle, WddmAllocation *alloc) {
@ -757,7 +761,7 @@ bool Wddm::openNTHandle(HANDLE handle, WddmAllocation *alloc) {
alloc->gmm = Gmm::create((PGMM_RESOURCE_INFO)(allocationInfo2[0].pPrivateDriverData));
return STATUS_SUCCESS;
return true;
}
void *Wddm::lockResource(WddmAllocation *wddmAllocation) {

View File

@ -83,7 +83,7 @@ class Wddm {
MOCKABLE_VIRTUAL bool createAllocation64k(WddmAllocation *alloc);
bool createAllocationsAndMapGpuVa(OsHandleStorage &osHandles);
MOCKABLE_VIRTUAL bool destroyAllocations(D3DKMT_HANDLE *handles, uint32_t allocationCount, uint64_t lastFenceValue, D3DKMT_HANDLE resourceHandle);
bool openSharedHandle(D3DKMT_HANDLE handle, WddmAllocation *alloc);
MOCKABLE_VIRTUAL bool openSharedHandle(D3DKMT_HANDLE handle, WddmAllocation *alloc);
bool openNTHandle(HANDLE handle, WddmAllocation *alloc);
MOCKABLE_VIRTUAL void *lockResource(WddmAllocation *wddmAllocation);
MOCKABLE_VIRTUAL void unlockResource(WddmAllocation *wddmAllocation);

View File

@ -211,7 +211,9 @@ GraphicsAllocation *WddmMemoryManager::createAllocationFromHandle(osHandle handl
if (ntHandle) {
wddm->openNTHandle((HANDLE)((UINT_PTR)handle), &allocation);
} else {
wddm->openSharedHandle(handle, &allocation);
if (wddm->openSharedHandle(handle, &allocation) == false) {
return nullptr;
}
}
// Shared objects are passed without size
@ -230,8 +232,7 @@ GraphicsAllocation *WddmMemoryManager::createAllocationFromHandle(osHandle handl
allocation.setGpuAddress(allocation.gpuPtr);
auto *wddmAllocation = new WddmAllocation(allocation);
return wddmAllocation;
return new WddmAllocation(allocation);
}
GraphicsAllocation *WddmMemoryManager::createGraphicsAllocationFromSharedHandle(osHandle handle, bool requireSpecificBitness, bool /*isReused*/) {