Skip to content

Commit f3bcb5c

Browse files
Make sure that residency is properly initialized.
- all members needs proper init. Change-Id: I578eee8178ae375cc4861872c84ced1729fb689b
1 parent e06b370 commit f3bcb5c

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

runtime/memory_manager/graphics_allocation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
4949
uint64_t gpuBaseAddress = 0;
5050
Gmm *gmm = nullptr;
5151
uint64_t allocationOffset = 0u;
52-
int residencyTaskCount[maxOsContextCount] = {ObjectNotResident};
52+
int residencyTaskCount[maxOsContextCount] = {ObjectNotResident, ObjectNotResident, ObjectNotResident, ObjectNotResident};
5353
bool cpuPtrAllocated = false; // flag indicating if cpuPtr is driver-allocated
5454

5555
enum class AllocationType {

unit_tests/memory_manager/memory_manager_tests.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1759,6 +1759,13 @@ TEST(GraphicsAllocation, givenSharedHandleBasedConstructorWhenGraphicsAllocation
17591759
EXPECT_EQ(expectedGpuAddress, graphicsAllocation.getGpuAddress());
17601760
}
17611761

1762+
TEST(GraphicsAllocation, givenGraphicsAllocationCreatedWithDefaultConstructorThenItIsNotResidentInAllContexts) {
1763+
GraphicsAllocation graphicsAllocation(nullptr, 1u);
1764+
for (uint32_t index = 0u; index < maxOsContextCount; index++) {
1765+
EXPECT_EQ(ObjectNotResident, graphicsAllocation.residencyTaskCount[index]);
1766+
}
1767+
}
1768+
17621769
TEST(ResidencyDataTest, givenOsContextWhenItIsRegisteredToMemoryManagerThenRefCountIncreases) {
17631770
auto osContext = new OsContext(nullptr, 0u);
17641771
OsAgnosticMemoryManager memoryManager;

0 commit comments

Comments
 (0)