Refactor GraphicsAllocation::AllocationType and allocationType enums

- change GraphicsAllocatoin::AllocationType to scoped enumeration
so that ALLOCATION_TYPE_ prefix in every enum value can be removed
- all accesses are typed (example AllocationType::IMAGE)
- Rename allocationType to AllocationUsage to eliminate confusion
with multiple AllocationType enums / types

Change-Id: I16003297ecfcb0aaa5779ad00706c5d983914bbe
This commit is contained in:
Hoppe, Mateusz
2018-07-05 16:31:57 +02:00
committed by sys_ocldev
parent 1c88165f6f
commit 684b1d75ba
23 changed files with 70 additions and 70 deletions

View File

@@ -234,7 +234,7 @@ LinearStream &CommandQueue::getCS(size_t minRequiredSize) {
allocation = memoryManager->allocateGraphicsMemory(requiredSize, MemoryConstants::pageSize);
}
allocation->setAllocationType(GraphicsAllocation::ALLOCATION_TYPE_LINEAR_STREAM);
allocation->setAllocationType(GraphicsAllocation::AllocationType::LINEAR_STREAM);
// Deallocate the old block, if not null
auto oldAllocation = commandStream->getGraphicsAllocation();

View File

@@ -47,7 +47,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueFillBuffer(
DEBUG_BREAK_IF(nullptr == memoryManager);
auto patternAllocation = memoryManager->allocateGraphicsMemory(alignUp(patternSize, MemoryConstants::cacheLineSize), MemoryConstants::preferredAlignment);
patternAllocation->setAllocationType(GraphicsAllocation::ALLOCATION_TYPE_FILL_PATTERN);
patternAllocation->setAllocationType(GraphicsAllocation::AllocationType::FILL_PATTERN);
if (patternSize == 1) {
int patternInt = (uint32_t)((*(uint8_t *)pattern << 24) | (*(uint8_t *)pattern << 16) | (*(uint8_t *)pattern << 8) | *(uint8_t *)pattern);

View File

@@ -247,7 +247,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueSVMMemFill(void *svmPtr,
patternAllocation = memoryManager->allocateGraphicsMemory(patternSize, MemoryConstants::preferredAlignment);
}
patternAllocation->setAllocationType(GraphicsAllocation::ALLOCATION_TYPE_FILL_PATTERN);
patternAllocation->setAllocationType(GraphicsAllocation::AllocationType::FILL_PATTERN);
if (patternSize == 1) {
int patternInt = (uint32_t)((*(uint8_t *)pattern << 24) | (*(uint8_t *)pattern << 16) | (*(uint8_t *)pattern << 8) | *(uint8_t *)pattern);

View File

@@ -531,8 +531,8 @@ bool AUBCommandStreamReceiverHw<GfxFamily>::writeMemory(GraphicsAllocation &gfxA
gfxAllocation.setLocked(false);
}
if (!!(allocType & GraphicsAllocation::ALLOCATION_TYPE_BUFFER) ||
!!(allocType & GraphicsAllocation::ALLOCATION_TYPE_IMAGE))
if (!!(allocType & GraphicsAllocation::AllocationType::BUFFER) ||
!!(allocType & GraphicsAllocation::AllocationType::IMAGE))
gfxAllocation.setTypeAubNonWritable();
return true;

View File

@@ -166,7 +166,7 @@ LinearStream &CommandStreamReceiver::getCS(size_t minRequiredSize) {
allocation = memoryManager->allocateGraphicsMemory(requiredSize, MemoryConstants::pageSize);
}
allocation->setAllocationType(GraphicsAllocation::ALLOCATION_TYPE_LINEAR_STREAM);
allocation->setAllocationType(GraphicsAllocation::AllocationType::LINEAR_STREAM);
//pass current allocation to reusable list
if (commandStream.getCpuBase()) {
@@ -309,7 +309,7 @@ void CommandStreamReceiver::allocateHeapMemory(IndirectHeap::Type heapType,
finalHeapSize = std::max(heapMemory->getUnderlyingBufferSize(), finalHeapSize);
}
heapMemory->setAllocationType(GraphicsAllocation::ALLOCATION_TYPE_LINEAR_STREAM);
heapMemory->setAllocationType(GraphicsAllocation::AllocationType::LINEAR_STREAM);
if (IndirectHeap::SURFACE_STATE == heapType) {
DEBUG_BREAK_IF(minRequiredSize > maxSshSize);

View File

@@ -41,7 +41,7 @@ void *FlatBatchBufferHelperHw<GfxFamily>::flattenBatchBuffer(BatchBuffer &batchB
if (dispatchMode == DispatchMode::ImmediateDispatch) {
if (batchBuffer.chainedBatchBuffer) {
batchBuffer.chainedBatchBuffer->setAllocationType(batchBuffer.chainedBatchBuffer->getAllocationType() | GraphicsAllocation::ALLOCATION_TYPE_NON_AUB_WRITABLE);
batchBuffer.chainedBatchBuffer->setAllocationType(batchBuffer.chainedBatchBuffer->getAllocationType() | GraphicsAllocation::AllocationType::NON_AUB_WRITABLE);
auto sizeMainBatchBuffer = batchBuffer.chainedBatchBufferStartOffset - batchBuffer.startOffset;
auto flatBatchBufferSize = alignUp(sizeMainBatchBuffer + indirectPatchCommandsSize + batchBuffer.chainedBatchBuffer->getUnderlyingBufferSize(), MemoryConstants::pageSize);

View File

@@ -149,8 +149,8 @@ Buffer *Buffer::create(Context *context,
}
auto allocationType = (flags & (CL_MEM_READ_ONLY | CL_MEM_HOST_READ_ONLY | CL_MEM_HOST_NO_ACCESS))
? GraphicsAllocation::ALLOCATION_TYPE_BUFFER
: GraphicsAllocation::ALLOCATION_TYPE_BUFFER | GraphicsAllocation::ALLOCATION_TYPE_WRITABLE;
? GraphicsAllocation::AllocationType::BUFFER
: GraphicsAllocation::AllocationType::BUFFER | GraphicsAllocation::AllocationType::WRITABLE;
memory->setAllocationType(allocationType);
DBG_LOG(LogMemoryObject, __FUNCTION__, "hostPtr:", hostPtr, "size:", size, "memoryStorage:", memory->getUnderlyingBuffer(), "GPU address:", std::hex, memory->getGpuAddress());

View File

@@ -289,8 +289,8 @@ Image *Image::create(Context *context,
}
auto allocationType = (flags & (CL_MEM_READ_ONLY | CL_MEM_HOST_READ_ONLY | CL_MEM_HOST_NO_ACCESS))
? GraphicsAllocation::ALLOCATION_TYPE_IMAGE
: GraphicsAllocation::ALLOCATION_TYPE_IMAGE | GraphicsAllocation::ALLOCATION_TYPE_WRITABLE;
? GraphicsAllocation::AllocationType::IMAGE
: GraphicsAllocation::AllocationType::IMAGE | GraphicsAllocation::AllocationType::WRITABLE;
memory->setAllocationType(allocationType);
DBG_LOG(LogMemoryObject, __FUNCTION__, "hostPtr:", hostPtr, "size:", memory->getUnderlyingBufferSize(), "memoryStorage:", memory->getUnderlyingBuffer(), "GPU address:", std::hex, memory->getGpuAddress());

View File

@@ -55,14 +55,14 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
public:
enum AllocationType {
ALLOCATION_TYPE_UNKNOWN = 0,
ALLOCATION_TYPE_BUFFER,
ALLOCATION_TYPE_IMAGE,
ALLOCATION_TYPE_TAG_BUFFER,
ALLOCATION_TYPE_LINEAR_STREAM,
ALLOCATION_TYPE_FILL_PATTERN,
ALLOCATION_TYPE_NON_AUB_WRITABLE = 0x40000000,
ALLOCATION_TYPE_WRITABLE = 0x80000000
UNKNOWN = 0,
BUFFER,
IMAGE,
TAG_BUFFER,
LINEAR_STREAM,
FILL_PATTERN,
NON_AUB_WRITABLE = 0x40000000,
WRITABLE = 0x80000000
};
virtual ~GraphicsAllocation() = default;
@@ -73,21 +73,21 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
gpuAddress(castToUint64(cpuPtrIn)),
sharedHandle(Sharing::nonSharedResource),
allocationType(ALLOCATION_TYPE_UNKNOWN) {}
allocationType(AllocationType::UNKNOWN) {}
GraphicsAllocation(void *cpuPtrIn, uint64_t gpuAddress, uint64_t baseAddress, size_t sizeIn) : size(sizeIn),
cpuPtr(cpuPtrIn),
gpuAddress(gpuAddress),
sharedHandle(Sharing::nonSharedResource),
gpuBaseAddress(baseAddress),
allocationType(ALLOCATION_TYPE_UNKNOWN) {}
allocationType(AllocationType::UNKNOWN) {}
GraphicsAllocation(void *cpuPtrIn, size_t sizeIn, osHandle sharedHandleIn) : size(sizeIn),
cpuPtr(cpuPtrIn),
gpuAddress(castToUint64(cpuPtrIn)),
sharedHandle(sharedHandleIn),
allocationType(ALLOCATION_TYPE_UNKNOWN) {}
allocationType(AllocationType::UNKNOWN) {}
void *getUnderlyingBuffer() const { return cpuPtr; }
void setCpuPtrAndGpuAddress(void *cpuPtr, uint64_t gpuAddress) {
@@ -114,9 +114,9 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
void setAllocationType(uint32_t allocationType) { this->allocationType = allocationType; }
uint32_t getAllocationType() const { return allocationType; }
void setTypeAubNonWritable() { this->allocationType |= GraphicsAllocation::ALLOCATION_TYPE_NON_AUB_WRITABLE; }
void clearTypeAubNonWritable() { this->allocationType &= ~GraphicsAllocation::ALLOCATION_TYPE_NON_AUB_WRITABLE; }
bool isTypeAubNonWritable() const { return !!(this->allocationType & GraphicsAllocation::ALLOCATION_TYPE_NON_AUB_WRITABLE); }
void setTypeAubNonWritable() { this->allocationType |= GraphicsAllocation::AllocationType::NON_AUB_WRITABLE; }
void clearTypeAubNonWritable() { this->allocationType &= ~GraphicsAllocation::AllocationType::NON_AUB_WRITABLE; }
bool isTypeAubNonWritable() const { return !!(this->allocationType & GraphicsAllocation::AllocationType::NON_AUB_WRITABLE); }
uint32_t taskCount = ObjectNotUsed;
OsHandleStorage fragmentsStorage;

View File

@@ -178,12 +178,12 @@ void MemoryManager::freeSystemMemory(void *ptr) {
::alignedFree(ptr);
}
void MemoryManager::storeAllocation(std::unique_ptr<GraphicsAllocation> gfxAllocation, uint32_t allocationType) {
void MemoryManager::storeAllocation(std::unique_ptr<GraphicsAllocation> gfxAllocation, uint32_t allocationUsage) {
std::lock_guard<decltype(mtx)> lock(mtx);
uint32_t taskCount = gfxAllocation->taskCount;
if (allocationType == REUSABLE_ALLOCATION) {
if (allocationUsage == REUSABLE_ALLOCATION) {
if (csr) {
taskCount = csr->peekTaskCount();
} else {
@@ -191,20 +191,20 @@ void MemoryManager::storeAllocation(std::unique_ptr<GraphicsAllocation> gfxAlloc
}
}
storeAllocation(std::move(gfxAllocation), allocationType, taskCount);
storeAllocation(std::move(gfxAllocation), allocationUsage, taskCount);
}
void MemoryManager::storeAllocation(std::unique_ptr<GraphicsAllocation> gfxAllocation, uint32_t allocationType, uint32_t taskCount) {
void MemoryManager::storeAllocation(std::unique_ptr<GraphicsAllocation> gfxAllocation, uint32_t allocationUsage, uint32_t taskCount) {
std::lock_guard<decltype(mtx)> lock(mtx);
if (DebugManager.flags.DisableResourceRecycling.get()) {
if (allocationType == REUSABLE_ALLOCATION) {
if (allocationUsage == REUSABLE_ALLOCATION) {
freeGraphicsMemory(gfxAllocation.release());
return;
}
}
auto &allocationsList = (allocationType == TEMPORARY_ALLOCATION) ? graphicsAllocations : allocationsForReuse;
auto &allocationsList = (allocationUsage == TEMPORARY_ALLOCATION) ? graphicsAllocations : allocationsForReuse;
gfxAllocation->taskCount = taskCount;
allocationsList.pushTailOne(*gfxAllocation.release());
}
@@ -236,9 +236,9 @@ void MemoryManager::applyCommonCleanup() {
cleanAllocationList(-1, REUSABLE_ALLOCATION);
}
bool MemoryManager::cleanAllocationList(uint32_t waitTaskCount, uint32_t allocationType) {
bool MemoryManager::cleanAllocationList(uint32_t waitTaskCount, uint32_t allocationUsage) {
std::lock_guard<decltype(mtx)> lock(mtx);
freeAllocationsList(waitTaskCount, (allocationType == TEMPORARY_ALLOCATION) ? graphicsAllocations : allocationsForReuse);
freeAllocationsList(waitTaskCount, (allocationUsage == TEMPORARY_ALLOCATION) ? graphicsAllocations : allocationsForReuse);
return false;
}

View File

@@ -50,7 +50,7 @@ class AllocsTracker;
class MapBaseAllocationTracker;
class SVMAllocsManager;
enum allocationType {
enum AllocationUsage {
TEMPORARY_ALLOCATION,
REUSABLE_ALLOCATION
};
@@ -148,12 +148,12 @@ class MemoryManager {
virtual uint64_t getInternalHeapBaseAddress() = 0;
virtual bool cleanAllocationList(uint32_t waitTaskCount, uint32_t allocationType);
virtual bool cleanAllocationList(uint32_t waitTaskCount, uint32_t allocationUsage);
void freeAllocationsList(uint32_t waitTaskCount, AllocationsList &allocationsList);
void storeAllocation(std::unique_ptr<GraphicsAllocation> gfxAllocation, uint32_t allocationType);
void storeAllocation(std::unique_ptr<GraphicsAllocation> gfxAllocation, uint32_t allocationType, uint32_t taskCount);
void storeAllocation(std::unique_ptr<GraphicsAllocation> gfxAllocation, uint32_t allocationUsage);
void storeAllocation(std::unique_ptr<GraphicsAllocation> gfxAllocation, uint32_t allocationUsage, uint32_t taskCount);
RequirementsStatus checkAllocationsForOverlapping(AllocationRequirements *requirements, CheckedFragments *checkedFragments);

View File

@@ -250,7 +250,7 @@ GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryForImage(ImageInfo &
DrmAllocation *DrmMemoryManager::allocate32BitGraphicsMemory(size_t size, void *ptr, AllocationOrigin allocationOrigin) {
auto allocatorToUse = allocationOrigin == AllocationOrigin::EXTERNAL_ALLOCATION ? allocator32Bit.get() : internal32bitAllocator.get();
auto allocationType = allocationOrigin == AllocationOrigin::EXTERNAL_ALLOCATION ? BIT32_ALLOCATOR_EXTERNAL : BIT32_ALLOCATOR_INTERNAL;
auto allocatorType = allocationOrigin == AllocationOrigin::EXTERNAL_ALLOCATION ? BIT32_ALLOCATOR_EXTERNAL : BIT32_ALLOCATOR_INTERNAL;
if (ptr) {
uintptr_t inputPtr = (uintptr_t)ptr;
@@ -274,7 +274,7 @@ DrmAllocation *DrmMemoryManager::allocate32BitGraphicsMemory(size_t size, void *
bo->address = reinterpret_cast<void *>(gpuVirtualAddress);
uintptr_t offset = (uintptr_t)bo->address;
bo->softPin((uint64_t)offset);
bo->setAllocationType(allocationType);
bo->setAllocationType(allocatorType);
auto drmAllocation = new DrmAllocation(bo, (void *)ptr, (uint64_t)ptrOffset(gpuVirtualAddress, inputPointerOffset), allocationSize);
drmAllocation->is32BitAllocation = true;
drmAllocation->gpuBaseAddress = allocatorToUse->getBase();
@@ -305,7 +305,7 @@ DrmAllocation *DrmMemoryManager::allocate32BitGraphicsMemory(size_t size, void *
bo->isAllocated = true;
bo->setUnmapSize(allocationSize);
bo->setAllocationType(allocationType);
bo->setAllocationType(allocatorType);
auto drmAllocation = new DrmAllocation(bo, reinterpret_cast<void *>(res), alignedAllocationSize);
drmAllocation->is32BitAllocation = true;

View File

@@ -220,8 +220,8 @@ void WddmCommandStreamReceiver<GfxFamily>::kmDafLockAllocations(ResidencyContain
for (uint32_t i = 0; i < residencyAllocations.size(); i++) {
auto graphicsAllocation = residencyAllocations[i];
if ((GraphicsAllocation::ALLOCATION_TYPE_LINEAR_STREAM == graphicsAllocation->getAllocationType()) ||
(GraphicsAllocation::ALLOCATION_TYPE_FILL_PATTERN == graphicsAllocation->getAllocationType())) {
if ((GraphicsAllocation::AllocationType::LINEAR_STREAM == graphicsAllocation->getAllocationType()) ||
(GraphicsAllocation::AllocationType::FILL_PATTERN == graphicsAllocation->getAllocationType())) {
wddm->kmDafLock(static_cast<WddmAllocation *>(graphicsAllocation));
}
}

View File

@@ -394,7 +394,7 @@ TEST_F(CommandQueueCommandStreamTest, givenCommandQueueWhenGetCSIsCalledThenComm
auto commandStreamAllocation = commandStream.getGraphicsAllocation();
ASSERT_NE(nullptr, commandStreamAllocation);
EXPECT_EQ(GraphicsAllocation::ALLOCATION_TYPE_LINEAR_STREAM, commandStreamAllocation->getAllocationType());
EXPECT_EQ(GraphicsAllocation::AllocationType::LINEAR_STREAM, commandStreamAllocation->getAllocationType());
}
struct CommandQueueIndirectHeapTest : public CommandQueueMemoryDevice,
@@ -638,7 +638,7 @@ TEST_P(CommandQueueIndirectHeapTest, givenCommandQueueWhenGetIndirectHeapIsCalle
auto indirectHeapAllocation = indirectHeap.getGraphicsAllocation();
ASSERT_NE(nullptr, indirectHeapAllocation);
EXPECT_EQ(GraphicsAllocation::ALLOCATION_TYPE_LINEAR_STREAM, indirectHeapAllocation->getAllocationType());
EXPECT_EQ(GraphicsAllocation::AllocationType::LINEAR_STREAM, indirectHeapAllocation->getAllocationType());
}
TEST_P(CommandQueueIndirectHeapTest, givenCommandQueueWhenGetHeapMemoryIsCalledThenHeapIsCreated) {

View File

@@ -528,5 +528,5 @@ HWTEST_F(EnqueueFillBufferCmdTests, givenEnqueueFillBufferWhenPatternAllocationI
GraphicsAllocation *patternAllocation = mmgr->graphicsAllocations.peekHead();
ASSERT_NE(nullptr, patternAllocation);
EXPECT_EQ(GraphicsAllocation::ALLOCATION_TYPE_FILL_PATTERN, patternAllocation->getAllocationType());
EXPECT_EQ(GraphicsAllocation::AllocationType::FILL_PATTERN, patternAllocation->getAllocationType());
}

View File

@@ -463,7 +463,7 @@ TEST_F(EnqueueSvmTest, givenEnqueueSVMMemFillWhenPatternAllocationIsObtainedThen
GraphicsAllocation *patternAllocation = mmgr->allocationsForReuse.peekHead();
ASSERT_NE(nullptr, patternAllocation);
EXPECT_EQ(GraphicsAllocation::ALLOCATION_TYPE_FILL_PATTERN, patternAllocation->getAllocationType());
EXPECT_EQ(GraphicsAllocation::AllocationType::FILL_PATTERN, patternAllocation->getAllocationType());
}
TEST_F(EnqueueSvmTest, enqueueTaskWithKernelExecInfo_success) {

View File

@@ -590,10 +590,10 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenProcess
memoryManager.reset(aubCsr->createMemoryManager(false));
auto gfxBufferAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
gfxBufferAllocation->setAllocationType(GraphicsAllocation::ALLOCATION_TYPE_BUFFER);
gfxBufferAllocation->setAllocationType(GraphicsAllocation::AllocationType::BUFFER);
auto gfxImageAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
gfxImageAllocation->setAllocationType(GraphicsAllocation::ALLOCATION_TYPE_IMAGE);
gfxImageAllocation->setAllocationType(GraphicsAllocation::AllocationType::IMAGE);
ResidencyContainer allocationsForResidency = {gfxBufferAllocation, gfxImageAllocation};
aubCsr->processResidency(&allocationsForResidency);
@@ -612,10 +612,10 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInSubCaptur
memoryManager.reset(aubCsr->createMemoryManager(false));
auto gfxBufferAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
gfxBufferAllocation->setAllocationType(GraphicsAllocation::ALLOCATION_TYPE_BUFFER);
gfxBufferAllocation->setAllocationType(GraphicsAllocation::AllocationType::BUFFER);
auto gfxImageAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
gfxImageAllocation->setAllocationType(GraphicsAllocation::ALLOCATION_TYPE_IMAGE);
gfxImageAllocation->setAllocationType(GraphicsAllocation::AllocationType::IMAGE);
const DispatchInfo dispatchInfo;
auto aubSubCaptureManagerMock = new AubSubCaptureManagerMock();
@@ -642,10 +642,10 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInSubCaptur
memoryManager.reset(aubCsr->createMemoryManager(false));
auto gfxBufferAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
gfxBufferAllocation->setAllocationType(GraphicsAllocation::ALLOCATION_TYPE_BUFFER | GraphicsAllocation::ALLOCATION_TYPE_NON_AUB_WRITABLE);
gfxBufferAllocation->setAllocationType(GraphicsAllocation::AllocationType::BUFFER | GraphicsAllocation::AllocationType::NON_AUB_WRITABLE);
auto gfxImageAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
gfxImageAllocation->setAllocationType(GraphicsAllocation::ALLOCATION_TYPE_IMAGE | GraphicsAllocation::ALLOCATION_TYPE_NON_AUB_WRITABLE);
gfxImageAllocation->setAllocationType(GraphicsAllocation::AllocationType::IMAGE | GraphicsAllocation::AllocationType::NON_AUB_WRITABLE);
auto aubSubCaptureManagerMock = new AubSubCaptureManagerMock();
aubSubCaptureManagerMock->subCaptureMode = AubSubCaptureManager::SubCaptureMode::Toggle;

View File

@@ -142,7 +142,7 @@ TEST_F(CommandStreamReceiverTest, givenCommandStreamReceiverWhenGetCSIsCalledThe
auto commandStreamAllocation = commandStream.getGraphicsAllocation();
ASSERT_NE(nullptr, commandStreamAllocation);
EXPECT_EQ(GraphicsAllocation::ALLOCATION_TYPE_LINEAR_STREAM, commandStreamAllocation->getAllocationType());
EXPECT_EQ(GraphicsAllocation::AllocationType::LINEAR_STREAM, commandStreamAllocation->getAllocationType());
}
TEST_F(CommandStreamReceiverTest, createAllocationAndHandleResidency) {

View File

@@ -363,10 +363,10 @@ TEST_P(NoHostPtr, withBufferGraphicsAllocationReportsBufferType) {
auto &allocation = *buffer->getGraphicsAllocation();
auto type = allocation.getAllocationType();
auto isTypeBuffer = !!(type & GraphicsAllocation::ALLOCATION_TYPE_BUFFER);
auto isTypeBuffer = !!(type & GraphicsAllocation::AllocationType::BUFFER);
EXPECT_TRUE(isTypeBuffer);
auto isTypeWritable = !!(type & GraphicsAllocation::ALLOCATION_TYPE_WRITABLE);
auto isTypeWritable = !!(type & GraphicsAllocation::AllocationType::WRITABLE);
auto isBufferWritable = !(flags & (CL_MEM_READ_ONLY | CL_MEM_HOST_READ_ONLY | CL_MEM_HOST_NO_ACCESS));
EXPECT_EQ(isBufferWritable, isTypeWritable);

View File

@@ -481,10 +481,10 @@ TEST_P(CreateImageNoHostPtr, withImageGraphicsAllocationReportsImageType) {
auto &allocation = *image->getGraphicsAllocation();
auto type = allocation.getAllocationType();
auto isTypeImage = !!(type & GraphicsAllocation::ALLOCATION_TYPE_IMAGE);
auto isTypeImage = !!(type & GraphicsAllocation::AllocationType::IMAGE);
EXPECT_TRUE(isTypeImage);
auto isTypeWritable = !!(type & GraphicsAllocation::ALLOCATION_TYPE_WRITABLE);
auto isTypeWritable = !!(type & GraphicsAllocation::AllocationType::WRITABLE);
auto isImageWritable = !(flags & (CL_MEM_READ_ONLY | CL_MEM_HOST_READ_ONLY | CL_MEM_HOST_NO_ACCESS));
EXPECT_EQ(isImageWritable, isTypeWritable);

View File

@@ -1438,12 +1438,12 @@ TEST_F(MemoryManagerWithCsrTest, checkAllocationsForOverlappingWithBiggerOverlap
GMockMemoryManager *memMngr = gmockMemoryManager;
auto cleanAllocations = [memMngr](uint32_t waitTaskCount, uint32_t allocationType) -> bool {
return memMngr->MemoryManagerCleanAllocationList(waitTaskCount, allocationType);
auto cleanAllocations = [memMngr](uint32_t waitTaskCount, uint32_t allocationUsage) -> bool {
return memMngr->MemoryManagerCleanAllocationList(waitTaskCount, allocationUsage);
};
auto cleanAllocationsWithTaskCount = [taskCountReady, memMngr](uint32_t waitTaskCount, uint32_t allocationType) -> bool {
return memMngr->MemoryManagerCleanAllocationList(taskCountReady, allocationType);
auto cleanAllocationsWithTaskCount = [taskCountReady, memMngr](uint32_t waitTaskCount, uint32_t allocationUsage) -> bool {
return memMngr->MemoryManagerCleanAllocationList(taskCountReady, allocationUsage);
};
EXPECT_CALL(*gmockMemoryManager, cleanAllocationList(::testing::_, ::testing::_)).Times(2).WillOnce(::testing::Invoke(cleanAllocations)).WillOnce(::testing::Invoke(cleanAllocationsWithTaskCount));
@@ -1494,8 +1494,8 @@ TEST_F(MemoryManagerWithCsrTest, checkAllocationsForOverlappingWithBiggerOverlap
GMockMemoryManager *memMngr = gmockMemoryManager;
auto cleanAllocations = [memMngr](uint32_t waitTaskCount, uint32_t allocationType) -> bool {
return memMngr->MemoryManagerCleanAllocationList(waitTaskCount, allocationType);
auto cleanAllocations = [memMngr](uint32_t waitTaskCount, uint32_t allocationUsage) -> bool {
return memMngr->MemoryManagerCleanAllocationList(waitTaskCount, allocationUsage);
};
EXPECT_CALL(*gmockMemoryManager, cleanAllocationList(::testing::_, ::testing::_)).Times(2).WillRepeatedly(::testing::Invoke(cleanAllocations));

View File

@@ -41,11 +41,11 @@ class MockMemoryManager : public OsAgnosticMemoryManager {
class GMockMemoryManager : public MockMemoryManager {
public:
MOCK_METHOD2(cleanAllocationList, bool(uint32_t waitTaskCount, uint32_t allocationType));
MOCK_METHOD2(cleanAllocationList, bool(uint32_t waitTaskCount, uint32_t allocationUsage));
// cleanAllocationList call defined in MemoryManager.
MOCK_METHOD1(populateOsHandles, MemoryManager::AllocationStatus(OsHandleStorage &handleStorage));
bool MemoryManagerCleanAllocationList(uint32_t waitTaskCount, uint32_t allocationType) { return MemoryManager::cleanAllocationList(waitTaskCount, allocationType); }
bool MemoryManagerCleanAllocationList(uint32_t waitTaskCount, uint32_t allocationUsage) { return MemoryManager::cleanAllocationList(waitTaskCount, allocationUsage); }
MemoryManager::AllocationStatus MemoryManagerPopulateOsHandles(OsHandleStorage &handleStorage) { return OsAgnosticMemoryManager::populateOsHandles(handleStorage); }
};

View File

@@ -322,7 +322,7 @@ TEST_F(WddmCommandStreamTest, givenWddmWithKmDafDisabledWhenFlushIsCalledWithAll
auto linearStreamAllocation = memManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
ASSERT_NE(nullptr, linearStreamAllocation);
linearStreamAllocation->setAllocationType(GraphicsAllocation::ALLOCATION_TYPE_LINEAR_STREAM);
linearStreamAllocation->setAllocationType(GraphicsAllocation::AllocationType::LINEAR_STREAM);
ResidencyContainer allocationsForResidency = {linearStreamAllocation};
EXPECT_FALSE(wddm->isKmDafEnabled());
@@ -358,7 +358,7 @@ TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithResi
auto linearStreamAllocation = memManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
ASSERT_NE(nullptr, linearStreamAllocation);
linearStreamAllocation->setAllocationType(GraphicsAllocation::ALLOCATION_TYPE_LINEAR_STREAM);
linearStreamAllocation->setAllocationType(GraphicsAllocation::AllocationType::LINEAR_STREAM);
csr->makeResident(*linearStreamAllocation);
EXPECT_EQ(1u, memManager->getResidencyAllocations().size());
@@ -383,7 +383,7 @@ TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithAllo
auto linearStreamAllocation = memManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
ASSERT_NE(nullptr, linearStreamAllocation);
linearStreamAllocation->setAllocationType(GraphicsAllocation::ALLOCATION_TYPE_LINEAR_STREAM);
linearStreamAllocation->setAllocationType(GraphicsAllocation::AllocationType::LINEAR_STREAM);
ResidencyContainer allocationsForResidency = {linearStreamAllocation};
wddm->setKmDafEnabled(true);
@@ -405,7 +405,7 @@ TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithAllo
auto fillPatternAllocation = memManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
ASSERT_NE(nullptr, fillPatternAllocation);
fillPatternAllocation->setAllocationType(GraphicsAllocation::ALLOCATION_TYPE_FILL_PATTERN);
fillPatternAllocation->setAllocationType(GraphicsAllocation::AllocationType::FILL_PATTERN);
ResidencyContainer allocationsForResidency = {fillPatternAllocation};
wddm->setKmDafEnabled(true);