2017-12-21 00:45:38 +01:00
|
|
|
/*
|
2019-01-07 09:29:49 +01:00
|
|
|
* Copyright (C) 2017-2019 Intel Corporation
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
2018-09-18 09:11:08 +02:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2018-11-02 10:01:56 +01:00
|
|
|
#include "runtime/memory_manager/graphics_allocation.h"
|
2019-02-27 11:39:32 +01:00
|
|
|
|
2019-08-02 13:25:45 -07:00
|
|
|
#include "core/helpers/aligned_memory.h"
|
2018-12-20 17:38:38 +01:00
|
|
|
#include "runtime/os_interface/debug_settings_manager.h"
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
namespace NEO {
|
2018-12-20 17:38:38 +01:00
|
|
|
|
|
|
|
void GraphicsAllocation::setAllocationType(AllocationType allocationType) {
|
|
|
|
this->allocationType = allocationType;
|
2019-04-16 08:15:06 +02:00
|
|
|
DebugManager.logAllocation(this);
|
2018-12-20 17:38:38 +01:00
|
|
|
}
|
|
|
|
|
2019-02-26 11:37:51 +01:00
|
|
|
GraphicsAllocation::GraphicsAllocation(AllocationType allocationType, void *cpuPtrIn, uint64_t gpuAddress, uint64_t baseAddress,
|
2019-09-12 14:38:46 +02:00
|
|
|
size_t sizeIn, MemoryPool::Type pool)
|
2019-03-13 15:31:46 +01:00
|
|
|
: gpuBaseAddress(baseAddress),
|
2019-02-11 10:02:27 +01:00
|
|
|
gpuAddress(gpuAddress),
|
2019-03-13 15:31:46 +01:00
|
|
|
size(sizeIn),
|
|
|
|
cpuPtr(cpuPtrIn),
|
2019-02-26 11:37:51 +01:00
|
|
|
memoryPool(pool),
|
2019-02-27 14:59:46 +01:00
|
|
|
allocationType(allocationType) {
|
|
|
|
}
|
2019-02-11 10:02:27 +01:00
|
|
|
|
2019-02-26 11:37:51 +01:00
|
|
|
GraphicsAllocation::GraphicsAllocation(AllocationType allocationType, void *cpuPtrIn, size_t sizeIn, osHandle sharedHandleIn,
|
2019-09-12 14:38:46 +02:00
|
|
|
MemoryPool::Type pool)
|
2019-03-13 15:31:46 +01:00
|
|
|
: gpuAddress(castToUint64(cpuPtrIn)),
|
|
|
|
size(sizeIn),
|
2019-02-11 10:02:27 +01:00
|
|
|
cpuPtr(cpuPtrIn),
|
2019-02-26 11:37:51 +01:00
|
|
|
memoryPool(pool),
|
2019-02-27 14:59:46 +01:00
|
|
|
allocationType(allocationType) {
|
|
|
|
sharingInfo.sharedHandle = sharedHandleIn;
|
|
|
|
}
|
2018-11-02 10:01:56 +01:00
|
|
|
|
|
|
|
GraphicsAllocation::~GraphicsAllocation() = default;
|
|
|
|
|
|
|
|
void GraphicsAllocation::updateTaskCount(uint32_t newTaskCount, uint32_t contextId) {
|
2018-11-07 08:33:55 +00:00
|
|
|
if (usageInfos[contextId].taskCount == objectNotUsed) {
|
2018-11-02 10:01:56 +01:00
|
|
|
registeredContextsNum++;
|
|
|
|
}
|
2018-11-07 08:33:55 +00:00
|
|
|
if (newTaskCount == objectNotUsed) {
|
2018-11-02 10:01:56 +01:00
|
|
|
registeredContextsNum--;
|
|
|
|
}
|
2018-11-06 11:38:49 +01:00
|
|
|
usageInfos[contextId].taskCount = newTaskCount;
|
2018-11-02 10:01:56 +01:00
|
|
|
}
|
2018-12-20 17:38:38 +01:00
|
|
|
|
|
|
|
std::string GraphicsAllocation::getAllocationInfoString() const {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2019-06-13 12:29:21 +02:00
|
|
|
uint32_t GraphicsAllocation::getUsedPageSize() const {
|
|
|
|
switch (this->memoryPool) {
|
|
|
|
case MemoryPool::System64KBPages:
|
|
|
|
case MemoryPool::System64KBPagesWith32BitGpuAddressing:
|
|
|
|
case MemoryPool::LocalMemory:
|
|
|
|
return MemoryConstants::pageSize64k;
|
|
|
|
default:
|
|
|
|
return MemoryConstants::pageSize;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-07 08:33:55 +00:00
|
|
|
constexpr uint32_t GraphicsAllocation::objectNotUsed;
|
|
|
|
constexpr uint32_t GraphicsAllocation::objectNotResident;
|
2019-03-26 11:59:46 +01:00
|
|
|
} // namespace NEO
|