Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/gpgmm/d3d12/ResidencyManagerD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ namespace gpgmm::d3d12 {

// If the heap was never locked, nothing further should be done.
if (!heap->IsResidencyLocked()) {
return S_FALSE;
return S_OK;
}

if (heap->IsInList()) {
Expand Down
4 changes: 2 additions & 2 deletions src/gpgmm/d3d12/ResourceAllocationD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ namespace gpgmm::d3d12 {
// If the developer forgots to unlock the heap, do so now so the heap can be made eligable
// for eviction.
ResidencyHeap* residencyHeap = static_cast<ResidencyHeap*>(GetMemory());
if (residencyHeap->GetResidencyManager() != nullptr) {
residencyHeap->Unlock();
if (residencyHeap->GetResidencyManager() != nullptr &&
GPGMM_UNSUCCESSFUL(residencyHeap->Unlock())) {
WarnLog(MessageId::kPerformanceWarning, this)
<< "Destroying a locked resource allocation is allowed but discouraged. Please "
"call UnlockHeap the same number of times as LockHeap before releasing the "
Expand Down
10 changes: 10 additions & 0 deletions src/tests/end2end/D3D12ResidencyManagerTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,16 @@ TEST_F(D3D12ResidencyManagerTests, CreateResourceHeapLocked) {
ASSERT_FAILED(CreateResidencyHeap(lockedResidencyHeapDesc, nullptr,
CreateResourceHeapCallbackContext::CreateHeap,
&createHeapContext, nullptr));

ASSERT_SUCCEEDED(residencyManager->LockHeap(resourceHeap.Get()));

// Unlocking a heap with another lock must return S_FALSE.
EXPECT_EQ(residencyManager->UnlockHeap(resourceHeap.Get()), S_FALSE);
EXPECT_TRUE(resourceHeap->GetInfo().IsLocked);

// But unlocking the last lock must return S_OK.
EXPECT_EQ(residencyManager->UnlockHeap(resourceHeap.Get()), S_OK);
EXPECT_FALSE(resourceHeap->GetInfo().IsLocked);
}

TEST_F(D3D12ResidencyManagerTests, CreateResourceHeap) {
Expand Down