Skip to content

Commit 02611dc

Browse files
Retrun valid status on createAllocation64k fail
Change-Id: Iaaed107c995a79125236196b6a956696dfe20875
1 parent 0c01653 commit 02611dc

File tree

2 files changed

+23
-12
lines changed

2 files changed

+23
-12
lines changed

runtime/os_interface/windows/wddm/wddm.cpp

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,6 @@ bool Wddm::createAllocation64k(WddmAllocation *alloc) {
443443
NTSTATUS status = STATUS_SUCCESS;
444444
D3DDDI_ALLOCATIONINFO AllocationInfo = {0};
445445
D3DKMT_CREATEALLOCATION CreateAllocation = {0};
446-
bool success = false;
447446

448447
AllocationInfo.pSystemMem = 0;
449448
AllocationInfo.pPrivateDriverData = alloc->gmm->gmmResourceInfo->peekHandle();
@@ -457,20 +456,16 @@ bool Wddm::createAllocation64k(WddmAllocation *alloc) {
457456
CreateAllocation.pAllocationInfo = &AllocationInfo;
458457
CreateAllocation.hDevice = device;
459458

460-
while (!success) {
461-
status = gdi->createAllocation(&CreateAllocation);
462-
463-
if (status != STATUS_SUCCESS) {
464-
DEBUG_BREAK_IF(true);
465-
break;
466-
}
459+
status = gdi->createAllocation(&CreateAllocation);
467460

468-
alloc->handle = AllocationInfo.hAllocation;
461+
if (status != STATUS_SUCCESS) {
462+
DEBUG_BREAK_IF(true);
463+
return false;
464+
}
469465

470-
kmDafListener->notifyWriteTarget(featureTable->ftrKmdDaf, adapter, device, alloc->handle, gdi->escape);
466+
alloc->handle = AllocationInfo.hAllocation;
471467

472-
success = true;
473-
}
468+
kmDafListener->notifyWriteTarget(featureTable->ftrKmdDaf, adapter, device, alloc->handle, gdi->escape);
474469
return true;
475470
}
476471

unit_tests/os_interface/windows/wddm20_tests.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,22 @@ TEST_F(Wddm20Tests, givenOpenSharedHandleWhenZeroAllocationsThenReturnNull) {
789789
EXPECT_EQ(false, ret);
790790
}
791791

792+
TEST_F(Wddm20Tests, whenCreateAllocation64kFailsThenReturnFalse) {
793+
struct FailingCreateAllocation {
794+
static NTSTATUS APIENTRY mockCreateAllocation(D3DKMT_CREATEALLOCATION *param) {
795+
return STATUS_GRAPHICS_NO_VIDEO_MEMORY;
796+
};
797+
};
798+
gdi->createAllocation = FailingCreateAllocation::mockCreateAllocation;
799+
800+
void *fakePtr = reinterpret_cast<void *>(0x123);
801+
auto gmm = std::make_unique<Gmm>(fakePtr, 100, false);
802+
WddmAllocation allocation(fakePtr, 100, fakePtr, 200, nullptr, MemoryPool::MemoryNull);
803+
allocation.gmm = gmm.get();
804+
805+
EXPECT_FALSE(wddm->createAllocation64k(&allocation));
806+
}
807+
792808
TEST_F(Wddm20Tests, givenReadOnlyMemoryWhenCreateAllocationFailsWithNoVideoMemoryThenCorrectStatusIsReturned) {
793809
class MockCreateAllocation {
794810
public:

0 commit comments

Comments
 (0)