Change return type of Wddm::createContext to make init more consistent

Change-Id: I113dbd636c2ed11ba76333021535160e46cb7116
This commit is contained in:
Dunajski, Bartosz
2018-05-02 12:00:28 +02:00
committed by sys_ocldev
parent 1ea44b631a
commit 224676bc2d
5 changed files with 40 additions and 45 deletions

View File

@@ -720,7 +720,7 @@ void Wddm::kmDafLock(WddmAllocation *wddmAllocation) {
kmDafListener->notifyLock(featureTable->ftrKmdDaf, adapter, device, wddmAllocation->handle, 0, gdi->escape);
}
D3DKMT_HANDLE Wddm::createContext() {
bool Wddm::createContext() {
NTSTATUS status = STATUS_UNSUCCESSFUL;
D3DKMT_CREATECONTEXTVIRTUAL CreateContext = {0};
CREATECONTEXT_PVTDATA PrivateData = {{0}};
@@ -747,10 +747,9 @@ D3DKMT_HANDLE Wddm::createContext() {
CreateContext.hDevice = device;
status = gdi->createContext(&CreateContext);
if (status == STATUS_SUCCESS) {
return CreateContext.hContext;
}
return static_cast<D3DKMT_HANDLE>(0);
context = CreateContext.hContext;
return status == STATUS_SUCCESS;
}
bool Wddm::destroyContext(D3DKMT_HANDLE context) {
@@ -761,7 +760,7 @@ bool Wddm::destroyContext(D3DKMT_HANDLE context) {
DestroyContext.hContext = context;
status = gdi->destroyContext(&DestroyContext);
}
return status == STATUS_SUCCESS ? true : false;
return status == STATUS_SUCCESS;
}
bool Wddm::submit(uint64_t commandBuffer, size_t size, void *commandHeader) {

View File

@@ -79,7 +79,7 @@ class Wddm {
MOCKABLE_VIRTUAL bool makeResident(D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim);
bool mapGpuVirtualAddress(WddmAllocation *allocation, void *cpuPtr, uint64_t size, bool allocation32bit, bool use64kbPages, bool useHeap1);
bool mapGpuVirtualAddress(AllocationStorageData *allocationStorageData, bool allocation32bit, bool use64kbPages);
MOCKABLE_VIRTUAL D3DKMT_HANDLE createContext();
MOCKABLE_VIRTUAL bool createContext();
MOCKABLE_VIRTUAL bool freeGpuVirtualAddres(D3DGPU_VIRTUAL_ADDRESS &gpuPtr, uint64_t size);
MOCKABLE_VIRTUAL NTSTATUS createAllocation(WddmAllocation *alloc);
MOCKABLE_VIRTUAL bool createAllocation64k(WddmAllocation *alloc);

View File

@@ -39,38 +39,32 @@ bool Wddm::configureDeviceAddressSpace() {
template <typename GfxFamily>
bool Wddm::init() {
bool success = false;
if (gdi != nullptr && gdi->isInitialized() && !initialized) {
do {
success = openAdapter();
if (!success)
break;
success = queryAdapterInfo();
if (!success)
break;
success = createDevice();
if (!success)
break;
success = createPagingQueue();
if (!success)
break;
success = Gmm::initContext(gfxPlatform.get(),
featureTable.get(),
waTable.get(),
gtSystemInfo.get());
if (!success)
break;
success = configureDeviceAddressSpace<GfxFamily>();
if (!success)
break;
context = createContext();
if (context == static_cast<D3DKMT_HANDLE>(0))
break;
success = createMonitoredFence();
if (!success)
break;
initialized = true;
} while (!success);
if (!openAdapter()) {
return false;
}
if (!queryAdapterInfo()) {
return false;
}
if (!createDevice()) {
return false;
}
if (!createPagingQueue()) {
return false;
}
if (!Gmm::initContext(gfxPlatform.get(), featureTable.get(), waTable.get(), gtSystemInfo.get())) {
return false;
}
if (!configureDeviceAddressSpace<GfxFamily>()) {
return false;
}
if (!createContext()) {
return false;
}
if (!createMonitoredFence()) {
return false;
}
initialized = true;
}
return initialized;
}