2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2024-01-15 21:57:17 +08:00
|
|
|
* Copyright (C) 2018-2024 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-20 11:54:29 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2022-11-22 21:53:59 +08:00
|
|
|
#include "shared/source/command_stream/task_count_helper.h"
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/helpers/debug_helpers.h"
|
|
|
|
#include "shared/source/helpers/ptr_math.h"
|
2022-02-04 21:59:01 +08:00
|
|
|
#include "shared/source/memory_manager/allocation_type.h"
|
2021-06-30 00:23:56 +08:00
|
|
|
#include "shared/source/memory_manager/definitions/engine_limits.h"
|
2021-04-24 00:43:48 +08:00
|
|
|
#include "shared/source/memory_manager/definitions/storage_info.h"
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/memory_manager/host_ptr_defines.h"
|
|
|
|
#include "shared/source/memory_manager/memory_pool.h"
|
2022-05-10 18:46:08 +08:00
|
|
|
#include "shared/source/memory_manager/residency.h"
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/utilities/idlist.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-09-21 12:07:50 +08:00
|
|
|
using osHandle = unsigned int;
|
2020-01-20 22:00:07 +08:00
|
|
|
inline osHandle toOsHandle(const void *handle) {
|
2021-08-30 22:57:25 +08:00
|
|
|
|
2020-01-20 22:00:07 +08:00
|
|
|
return static_cast<osHandle>(castToUint64(handle));
|
|
|
|
}
|
|
|
|
|
2019-03-01 23:14:28 +08:00
|
|
|
enum class HeapIndex : uint32_t;
|
2019-02-15 22:33:40 +08:00
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
namespace Sharing {
|
|
|
|
constexpr auto nonSharedResource = 0u;
|
|
|
|
}
|
|
|
|
|
|
|
|
class Gmm;
|
2019-06-06 22:26:47 +08:00
|
|
|
class MemoryManager;
|
2022-05-05 20:01:59 +08:00
|
|
|
class CommandStreamReceiver;
|
2023-07-21 19:55:22 +08:00
|
|
|
class GraphicsAllocation;
|
2024-08-23 08:02:44 +08:00
|
|
|
class ProductHelper;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2024-03-29 18:17:04 +08:00
|
|
|
struct AllocationProperties;
|
|
|
|
|
2020-07-10 22:04:01 +08:00
|
|
|
struct AubInfo {
|
|
|
|
uint32_t aubWritable = std::numeric_limits<uint32_t>::max();
|
|
|
|
uint32_t tbxWritable = std::numeric_limits<uint32_t>::max();
|
|
|
|
bool allocDumpable = false;
|
|
|
|
bool bcsDumpOnly = false;
|
|
|
|
bool memObjectsAllocationWithWritableFlags = false;
|
2023-02-20 20:51:01 +08:00
|
|
|
bool writeMemoryOnly = false;
|
2020-07-10 22:04:01 +08:00
|
|
|
};
|
|
|
|
|
2023-07-21 19:55:22 +08:00
|
|
|
struct SurfaceStateInHeapInfo {
|
|
|
|
GraphicsAllocation *heapAllocation;
|
|
|
|
uint64_t surfaceStateOffset;
|
|
|
|
void *ssPtr;
|
2023-08-17 16:17:57 +08:00
|
|
|
size_t ssSize;
|
2023-07-21 19:55:22 +08:00
|
|
|
};
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
class GraphicsAllocation : public IDNode<GraphicsAllocation> {
|
|
|
|
public:
|
2022-01-31 18:12:51 +08:00
|
|
|
enum UsmInitialPlacement {
|
|
|
|
DEFAULT,
|
|
|
|
CPU,
|
|
|
|
GPU
|
|
|
|
};
|
|
|
|
|
2019-11-20 19:23:06 +08:00
|
|
|
~GraphicsAllocation() override;
|
2018-03-01 17:08:20 +08:00
|
|
|
GraphicsAllocation &operator=(const GraphicsAllocation &) = delete;
|
|
|
|
GraphicsAllocation(const GraphicsAllocation &) = delete;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2020-04-21 19:16:45 +08:00
|
|
|
GraphicsAllocation(uint32_t rootDeviceIndex, size_t numGmms, AllocationType allocationType, void *cpuPtrIn,
|
2022-06-02 05:13:52 +08:00
|
|
|
uint64_t canonizedGpuAddress, uint64_t baseAddress, size_t sizeIn, MemoryPool pool, size_t maxOsContextCount);
|
2020-04-21 19:16:45 +08:00
|
|
|
|
|
|
|
GraphicsAllocation(uint32_t rootDeviceIndex, size_t numGmms, AllocationType allocationType, void *cpuPtrIn,
|
2022-06-03 19:48:45 +08:00
|
|
|
size_t sizeIn, osHandle sharedHandleIn, MemoryPool pool, size_t maxOsContextCount, uint64_t canonizedGpuAddress);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-11-15 16:59:48 +08:00
|
|
|
uint32_t getRootDeviceIndex() const { return rootDeviceIndex; }
|
2017-12-21 07:45:38 +08:00
|
|
|
void *getUnderlyingBuffer() const { return cpuPtr; }
|
2019-02-27 21:59:46 +08:00
|
|
|
void *getDriverAllocatedCpuPtr() const { return driverAllocatedCpuPointer; }
|
|
|
|
void setDriverAllocatedCpuPtr(void *allocatedCpuPtr) { driverAllocatedCpuPointer = allocatedCpuPtr; }
|
|
|
|
|
2022-06-07 04:34:20 +08:00
|
|
|
void setCpuPtrAndGpuAddress(void *cpuPtr, uint64_t canonizedGpuAddress) {
|
2017-12-21 07:45:38 +08:00
|
|
|
this->cpuPtr = cpuPtr;
|
2022-06-07 04:34:20 +08:00
|
|
|
this->gpuAddress = canonizedGpuAddress;
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
2024-07-23 22:22:45 +08:00
|
|
|
void setGpuPtr(uint64_t canonizedGpuAddress) {
|
|
|
|
this->gpuAddress = canonizedGpuAddress;
|
|
|
|
}
|
2017-12-21 07:45:38 +08:00
|
|
|
size_t getUnderlyingBufferSize() const { return size; }
|
2019-02-27 21:59:46 +08:00
|
|
|
void setSize(size_t size) { this->size = size; }
|
|
|
|
|
|
|
|
uint64_t getAllocationOffset() const {
|
|
|
|
return allocationOffset;
|
|
|
|
}
|
|
|
|
void setAllocationOffset(uint64_t offset) {
|
|
|
|
allocationOffset = offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t getGpuBaseAddress() const {
|
|
|
|
return gpuBaseAddress;
|
|
|
|
}
|
|
|
|
void setGpuBaseAddress(uint64_t baseAddress) {
|
|
|
|
gpuBaseAddress = baseAddress;
|
|
|
|
}
|
|
|
|
uint64_t getGpuAddress() const {
|
2017-12-21 07:45:38 +08:00
|
|
|
DEBUG_BREAK_IF(gpuAddress < gpuBaseAddress);
|
|
|
|
return gpuAddress + allocationOffset;
|
|
|
|
}
|
2018-01-08 10:25:27 +08:00
|
|
|
uint64_t getGpuAddressToPatch() const {
|
2017-12-21 07:45:38 +08:00
|
|
|
DEBUG_BREAK_IF(gpuAddress < gpuBaseAddress);
|
|
|
|
return gpuAddress + allocationOffset - gpuBaseAddress;
|
|
|
|
}
|
|
|
|
|
2019-02-28 23:12:23 +08:00
|
|
|
void lock(void *ptr) { lockedPtr = ptr; }
|
|
|
|
void unlock() { lockedPtr = nullptr; }
|
2019-01-24 22:16:12 +08:00
|
|
|
bool isLocked() const { return lockedPtr != nullptr; }
|
|
|
|
void *getLockedPtr() const { return lockedPtr; }
|
2018-03-05 17:56:34 +08:00
|
|
|
|
2019-02-27 21:59:46 +08:00
|
|
|
bool isCoherent() const { return allocationInfo.flags.coherent; }
|
2019-02-28 23:12:23 +08:00
|
|
|
void setCoherent(bool coherentIn) { allocationInfo.flags.coherent = coherentIn; }
|
2019-02-27 21:59:46 +08:00
|
|
|
void setEvictable(bool evictable) { allocationInfo.flags.evictable = evictable; }
|
|
|
|
bool peekEvictable() const { return allocationInfo.flags.evictable; }
|
|
|
|
bool isFlushL3Required() const { return allocationInfo.flags.flushL3Required; }
|
2019-02-28 23:12:23 +08:00
|
|
|
void setFlushL3Required(bool flushL3Required) { allocationInfo.flags.flushL3Required = flushL3Required; }
|
2024-03-28 16:06:58 +08:00
|
|
|
bool isLockedMemory() const { return allocationInfo.flags.lockedMemory; }
|
|
|
|
void setLockedMemory(bool locked) { allocationInfo.flags.lockedMemory = locked; }
|
2021-02-01 18:04:49 +08:00
|
|
|
|
2021-04-28 19:51:38 +08:00
|
|
|
bool isUncacheable() const { return allocationInfo.flags.uncacheable; }
|
2021-02-01 18:04:49 +08:00
|
|
|
void setUncacheable(bool uncacheable) { allocationInfo.flags.uncacheable = uncacheable; }
|
2019-02-27 21:59:46 +08:00
|
|
|
bool is32BitAllocation() const { return allocationInfo.flags.is32BitAllocation; }
|
|
|
|
void set32BitAllocation(bool is32BitAllocation) { allocationInfo.flags.is32BitAllocation = is32BitAllocation; }
|
|
|
|
|
2019-08-07 00:01:26 +08:00
|
|
|
void setAubWritable(bool writable, uint32_t banks);
|
|
|
|
bool isAubWritable(uint32_t banks) const;
|
|
|
|
void setTbxWritable(bool writable, uint32_t banks);
|
|
|
|
bool isTbxWritable(uint32_t banks) const;
|
2020-07-10 22:04:01 +08:00
|
|
|
void setAllocDumpable(bool dumpable, bool bcsDumpOnly) {
|
|
|
|
aubInfo.allocDumpable = dumpable;
|
|
|
|
aubInfo.bcsDumpOnly = bcsDumpOnly;
|
|
|
|
}
|
2023-02-20 20:51:01 +08:00
|
|
|
void setWriteMemoryOnly(bool writeMemoryOnly) {
|
|
|
|
aubInfo.writeMemoryOnly = writeMemoryOnly;
|
|
|
|
}
|
2019-02-27 21:59:46 +08:00
|
|
|
bool isAllocDumpable() const { return aubInfo.allocDumpable; }
|
|
|
|
bool isMemObjectsAllocationWithWritableFlags() const { return aubInfo.memObjectsAllocationWithWritableFlags; }
|
|
|
|
void setMemObjectsAllocationWithWritableFlags(bool newValue) { aubInfo.memObjectsAllocationWithWritableFlags = newValue; }
|
|
|
|
|
|
|
|
void incReuseCount() { sharingInfo.reuseCount++; }
|
|
|
|
void decReuseCount() { sharingInfo.reuseCount--; }
|
|
|
|
uint32_t peekReuseCount() const { return sharingInfo.reuseCount; }
|
|
|
|
osHandle peekSharedHandle() const { return sharingInfo.sharedHandle; }
|
2021-03-18 23:16:58 +08:00
|
|
|
void setSharedHandle(osHandle handle) { sharingInfo.sharedHandle = handle; }
|
2019-02-27 21:59:46 +08:00
|
|
|
|
2024-08-23 08:02:44 +08:00
|
|
|
void setAllocationType(AllocationType allocationType, const ProductHelper &productHelper);
|
2019-02-27 21:59:46 +08:00
|
|
|
AllocationType getAllocationType() const { return allocationType; }
|
|
|
|
|
2022-06-02 05:13:52 +08:00
|
|
|
MemoryPool getMemoryPool() const { return memoryPool; }
|
2024-03-27 20:52:30 +08:00
|
|
|
virtual void setAsReadOnly(){};
|
2019-02-27 21:59:46 +08:00
|
|
|
|
2018-11-07 16:33:55 +08:00
|
|
|
bool isUsed() const { return registeredContextsNum > 0; }
|
2019-02-27 21:59:46 +08:00
|
|
|
bool isUsedByManyOsContexts() const { return registeredContextsNum > 1u; }
|
2019-01-07 16:29:49 +08:00
|
|
|
bool isUsedByOsContext(uint32_t contextId) const { return objectNotUsed != getTaskCount(contextId); }
|
2022-11-22 21:53:59 +08:00
|
|
|
MOCKABLE_VIRTUAL void updateTaskCount(TaskCountType newTaskCount, uint32_t contextId);
|
2024-01-15 21:57:17 +08:00
|
|
|
MOCKABLE_VIRTUAL TaskCountType getTaskCount(uint32_t contextId) const {
|
|
|
|
if (contextId >= usageInfos.size()) {
|
|
|
|
return objectNotUsed;
|
|
|
|
}
|
|
|
|
|
|
|
|
return usageInfos[contextId].taskCount;
|
|
|
|
}
|
2019-01-07 16:29:49 +08:00
|
|
|
void releaseUsageInOsContext(uint32_t contextId) { updateTaskCount(objectNotUsed, contextId); }
|
2019-02-26 18:37:51 +08:00
|
|
|
uint32_t getInspectionId(uint32_t contextId) const { return usageInfos[contextId].inspectionId; }
|
2018-12-04 22:11:29 +08:00
|
|
|
void setInspectionId(uint32_t newInspectionId, uint32_t contextId) { usageInfos[contextId].inspectionId = newInspectionId; }
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2022-05-23 07:04:12 +08:00
|
|
|
MOCKABLE_VIRTUAL bool isResident(uint32_t contextId) const { return GraphicsAllocation::objectNotResident != getResidencyTaskCount(contextId); }
|
2020-07-02 17:49:46 +08:00
|
|
|
bool isAlwaysResident(uint32_t contextId) const { return GraphicsAllocation::objectAlwaysResident == getResidencyTaskCount(contextId); }
|
2022-11-22 21:53:59 +08:00
|
|
|
void updateResidencyTaskCount(TaskCountType newTaskCount, uint32_t contextId) {
|
2020-07-02 17:49:46 +08:00
|
|
|
if (usageInfos[contextId].residencyTaskCount != GraphicsAllocation::objectAlwaysResident || newTaskCount == GraphicsAllocation::objectNotResident) {
|
|
|
|
usageInfos[contextId].residencyTaskCount = newTaskCount;
|
|
|
|
}
|
|
|
|
}
|
2022-11-22 21:53:59 +08:00
|
|
|
TaskCountType getResidencyTaskCount(uint32_t contextId) const { return usageInfos[contextId].residencyTaskCount; }
|
2019-01-07 16:29:49 +08:00
|
|
|
void releaseResidencyInOsContext(uint32_t contextId) { updateResidencyTaskCount(objectNotResident, contextId); }
|
2022-11-22 21:53:59 +08:00
|
|
|
bool isResidencyTaskCountBelow(TaskCountType taskCount, uint32_t contextId) const { return !isResident(contextId) || getResidencyTaskCount(contextId) < taskCount; }
|
2018-12-20 15:43:57 +08:00
|
|
|
|
2018-12-21 00:38:38 +08:00
|
|
|
virtual std::string getAllocationInfoString() const;
|
2024-01-23 19:23:06 +08:00
|
|
|
virtual std::string getPatIndexInfoString() const;
|
2023-04-07 10:57:37 +08:00
|
|
|
virtual int createInternalHandle(MemoryManager *memoryManager, uint32_t handleId, uint64_t &handle) { return 0; }
|
2022-11-10 10:57:51 +08:00
|
|
|
virtual int peekInternalHandle(MemoryManager *memoryManager, uint64_t &handle) { return 0; }
|
2023-04-07 10:57:37 +08:00
|
|
|
virtual void clearInternalHandle(uint32_t handleId) { return; }
|
2018-12-21 00:38:38 +08:00
|
|
|
|
2022-11-10 10:57:51 +08:00
|
|
|
virtual int peekInternalHandle(MemoryManager *memoryManager, uint32_t handleId, uint64_t &handle) {
|
|
|
|
return 0;
|
2022-02-01 07:29:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual uint32_t getNumHandles() {
|
|
|
|
return 0u;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void setNumHandles(uint32_t numHandles) {
|
|
|
|
}
|
|
|
|
|
2023-04-07 06:35:11 +08:00
|
|
|
virtual uint64_t getHandleAddressBase(uint32_t handleIndex) {
|
|
|
|
return 0lu;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual size_t getHandleSize(uint32_t handleIndex) {
|
|
|
|
return 0lu;
|
|
|
|
}
|
|
|
|
|
2019-02-18 17:49:21 +08:00
|
|
|
static bool isCpuAccessRequired(AllocationType allocationType) {
|
2023-12-11 22:24:36 +08:00
|
|
|
return allocationType == AllocationType::commandBuffer ||
|
|
|
|
allocationType == AllocationType::constantSurface ||
|
|
|
|
allocationType == AllocationType::globalSurface ||
|
|
|
|
allocationType == AllocationType::internalHeap ||
|
|
|
|
allocationType == AllocationType::linearStream ||
|
|
|
|
allocationType == AllocationType::pipe ||
|
|
|
|
allocationType == AllocationType::printfSurface ||
|
|
|
|
allocationType == AllocationType::timestampPacketTagBuffer ||
|
|
|
|
allocationType == AllocationType::ringBuffer ||
|
|
|
|
allocationType == AllocationType::semaphoreBuffer ||
|
|
|
|
allocationType == AllocationType::debugContextSaveArea ||
|
|
|
|
allocationType == AllocationType::debugSbaTrackingBuffer ||
|
|
|
|
allocationType == AllocationType::gpuTimestampDeviceBuffer ||
|
|
|
|
allocationType == AllocationType::debugModuleArea ||
|
2024-06-05 21:56:55 +08:00
|
|
|
allocationType == AllocationType::assertBuffer ||
|
|
|
|
allocationType == AllocationType::syncDispatchToken;
|
2019-02-18 17:49:21 +08:00
|
|
|
}
|
2021-04-14 01:23:36 +08:00
|
|
|
static bool isLockable(AllocationType allocationType) {
|
|
|
|
return isCpuAccessRequired(allocationType) ||
|
|
|
|
isIsaAllocationType(allocationType) ||
|
2023-12-11 22:24:36 +08:00
|
|
|
allocationType == AllocationType::bufferHostMemory ||
|
|
|
|
allocationType == AllocationType::sharedResourceCopy;
|
2021-04-14 01:23:36 +08:00
|
|
|
}
|
2020-11-13 02:53:30 +08:00
|
|
|
|
2023-04-24 19:58:49 +08:00
|
|
|
static bool isKernelIsaAllocationType(AllocationType type) {
|
2023-12-11 22:24:36 +08:00
|
|
|
return type == AllocationType::kernelIsa ||
|
|
|
|
type == AllocationType::kernelIsaInternal;
|
2023-04-24 19:58:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool isIsaAllocationType(AllocationType type) {
|
|
|
|
return isKernelIsaAllocationType(type) ||
|
2023-12-11 22:24:36 +08:00
|
|
|
type == AllocationType::debugModuleArea;
|
2020-11-13 02:53:30 +08:00
|
|
|
}
|
|
|
|
|
2022-11-14 20:06:54 +08:00
|
|
|
static bool isDebugSurfaceAllocationType(AllocationType type) {
|
2023-12-11 22:24:36 +08:00
|
|
|
return type == AllocationType::debugContextSaveArea ||
|
|
|
|
type == AllocationType::debugSbaTrackingBuffer;
|
2022-11-14 20:06:54 +08:00
|
|
|
}
|
|
|
|
|
2023-02-09 01:05:30 +08:00
|
|
|
static bool isConstantOrGlobalSurfaceAllocationType(AllocationType type) {
|
2023-12-11 22:24:36 +08:00
|
|
|
return type == AllocationType::constantSurface ||
|
|
|
|
type == AllocationType::globalSurface;
|
2023-02-09 01:05:30 +08:00
|
|
|
}
|
|
|
|
|
2022-11-17 07:43:35 +08:00
|
|
|
static uint32_t getNumHandlesForKmdSharedAllocation(uint32_t numBanks);
|
|
|
|
|
2019-03-13 22:31:46 +08:00
|
|
|
void *getReservedAddressPtr() const {
|
|
|
|
return this->reservedAddressRangeInfo.addressPtr;
|
|
|
|
}
|
|
|
|
size_t getReservedAddressSize() const {
|
|
|
|
return this->reservedAddressRangeInfo.rangeSize;
|
|
|
|
}
|
|
|
|
void setReservedAddressRange(void *reserveAddress, size_t size) {
|
|
|
|
this->reservedAddressRangeInfo.addressPtr = reserveAddress;
|
|
|
|
this->reservedAddressRangeInfo.rangeSize = size;
|
|
|
|
}
|
2019-02-18 17:49:21 +08:00
|
|
|
|
2022-05-05 20:01:59 +08:00
|
|
|
void prepareHostPtrForResidency(CommandStreamReceiver *csr);
|
|
|
|
|
2019-03-12 20:24:58 +08:00
|
|
|
Gmm *getDefaultGmm() const {
|
|
|
|
return getGmm(0u);
|
|
|
|
}
|
|
|
|
Gmm *getGmm(uint32_t handleId) const {
|
|
|
|
return gmms[handleId];
|
|
|
|
}
|
|
|
|
void setDefaultGmm(Gmm *gmm) {
|
2019-04-11 07:14:19 +08:00
|
|
|
setGmm(gmm, 0u);
|
2019-03-12 20:24:58 +08:00
|
|
|
}
|
|
|
|
void setGmm(Gmm *gmm, uint32_t handleId) {
|
|
|
|
gmms[handleId] = gmm;
|
|
|
|
}
|
2021-10-04 23:23:42 +08:00
|
|
|
void resizeGmms(uint32_t size) {
|
|
|
|
gmms.resize(size);
|
|
|
|
}
|
2019-10-07 15:22:25 +08:00
|
|
|
|
2020-04-21 19:16:45 +08:00
|
|
|
uint32_t getNumGmms() const {
|
|
|
|
return static_cast<uint32_t>(gmms.size());
|
|
|
|
}
|
|
|
|
|
2019-06-13 18:29:21 +08:00
|
|
|
uint32_t getUsedPageSize() const;
|
2019-03-12 20:24:58 +08:00
|
|
|
|
2023-12-12 17:11:27 +08:00
|
|
|
bool isAllocatedInLocalMemoryPool() const { return (this->memoryPool == MemoryPool::localMemory); }
|
2021-05-19 19:20:56 +08:00
|
|
|
bool isAllocationLockable() const;
|
2020-07-01 20:03:46 +08:00
|
|
|
|
2020-07-10 22:04:01 +08:00
|
|
|
const AubInfo &getAubInfo() const { return aubInfo; }
|
|
|
|
|
2021-12-02 02:11:27 +08:00
|
|
|
bool isCompressionEnabled() const;
|
|
|
|
|
2022-05-10 18:46:08 +08:00
|
|
|
ResidencyData &getResidencyData() {
|
|
|
|
return residency;
|
|
|
|
}
|
|
|
|
|
2023-07-21 19:55:22 +08:00
|
|
|
uint64_t getBindlessOffset() {
|
|
|
|
if (bindlessInfo.heapAllocation == nullptr) {
|
|
|
|
return std::numeric_limits<uint64_t>::max();
|
|
|
|
}
|
|
|
|
return bindlessInfo.surfaceStateOffset;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setBindlessInfo(const SurfaceStateInHeapInfo &info) {
|
|
|
|
bindlessInfo = info;
|
|
|
|
}
|
|
|
|
|
|
|
|
SurfaceStateInHeapInfo getBindlessInfo() {
|
|
|
|
return bindlessInfo;
|
|
|
|
}
|
2024-03-29 18:17:04 +08:00
|
|
|
bool canBeReadOnly() {
|
|
|
|
return !cantBeReadOnly;
|
|
|
|
}
|
|
|
|
void setAsCantBeReadOnly(bool cantBeReadOnly) {
|
|
|
|
this->cantBeReadOnly = cantBeReadOnly;
|
|
|
|
}
|
2023-11-17 21:14:41 +08:00
|
|
|
MOCKABLE_VIRTUAL void updateCompletionDataForAllocationAndFragments(uint64_t newFenceValue, uint32_t contextId);
|
2024-03-25 22:44:36 +08:00
|
|
|
void setShareableHostMemory(bool shareableHostMemory) { this->shareableHostMemory = shareableHostMemory; }
|
|
|
|
bool isShareableHostMemory() const { return shareableHostMemory; }
|
2024-03-27 20:52:30 +08:00
|
|
|
MOCKABLE_VIRTUAL bool hasAllocationReadOnlyType();
|
2024-03-29 18:17:04 +08:00
|
|
|
MOCKABLE_VIRTUAL void checkAllocationTypeReadOnlyRestrictions(const AllocationProperties &properties);
|
2023-07-21 19:55:22 +08:00
|
|
|
|
2019-02-27 21:59:46 +08:00
|
|
|
OsHandleStorage fragmentsStorage;
|
2019-02-28 23:12:23 +08:00
|
|
|
StorageInfo storageInfo = {};
|
2019-02-27 21:59:46 +08:00
|
|
|
|
2019-08-07 00:01:26 +08:00
|
|
|
static constexpr uint32_t defaultBank = 0b1u;
|
2019-11-13 21:19:55 +08:00
|
|
|
static constexpr uint32_t allBanks = 0xffffffff;
|
2022-11-22 21:53:59 +08:00
|
|
|
constexpr static TaskCountType objectNotResident = std::numeric_limits<TaskCountType>::max();
|
|
|
|
constexpr static TaskCountType objectNotUsed = std::numeric_limits<TaskCountType>::max();
|
|
|
|
constexpr static TaskCountType objectAlwaysResident = std::numeric_limits<TaskCountType>::max() - 1;
|
2024-03-25 22:44:36 +08:00
|
|
|
|
2022-05-05 20:01:59 +08:00
|
|
|
std::atomic<uint32_t> hostPtrTaskCountAssignment{0};
|
2018-11-07 16:33:55 +08:00
|
|
|
|
2020-01-24 18:47:19 +08:00
|
|
|
protected:
|
2018-11-07 16:33:55 +08:00
|
|
|
struct UsageInfo {
|
2022-11-22 21:53:59 +08:00
|
|
|
TaskCountType taskCount = objectNotUsed;
|
|
|
|
TaskCountType residencyTaskCount = objectNotResident;
|
2018-12-04 22:11:29 +08:00
|
|
|
uint32_t inspectionId = 0u;
|
2018-11-07 16:33:55 +08:00
|
|
|
};
|
2020-07-10 22:04:01 +08:00
|
|
|
|
2019-02-27 21:59:46 +08:00
|
|
|
struct SharingInfo {
|
|
|
|
uint32_t reuseCount = 0;
|
|
|
|
osHandle sharedHandle = Sharing::nonSharedResource;
|
|
|
|
};
|
|
|
|
struct AllocationInfo {
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
uint32_t coherent : 1;
|
|
|
|
uint32_t evictable : 1;
|
|
|
|
uint32_t flushL3Required : 1;
|
2021-02-01 18:04:49 +08:00
|
|
|
uint32_t uncacheable : 1;
|
2019-02-27 21:59:46 +08:00
|
|
|
uint32_t is32BitAllocation : 1;
|
2024-03-28 16:06:58 +08:00
|
|
|
uint32_t lockedMemory : 1;
|
|
|
|
uint32_t reserved : 26;
|
2019-02-27 21:59:46 +08:00
|
|
|
} flags;
|
|
|
|
uint32_t allFlags = 0u;
|
|
|
|
};
|
|
|
|
static_assert(sizeof(AllocationInfo::flags) == sizeof(AllocationInfo::allFlags), "");
|
|
|
|
AllocationInfo() {
|
|
|
|
flags.coherent = false;
|
|
|
|
flags.evictable = true;
|
2019-08-30 19:27:56 +08:00
|
|
|
flags.flushL3Required = true;
|
2019-02-27 21:59:46 +08:00
|
|
|
flags.is32BitAllocation = false;
|
2024-03-28 16:06:58 +08:00
|
|
|
flags.lockedMemory = false;
|
2019-02-27 21:59:46 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-03-13 22:31:46 +08:00
|
|
|
struct ReservedAddressRange {
|
|
|
|
void *addressPtr = nullptr;
|
|
|
|
size_t rangeSize = 0;
|
|
|
|
};
|
2018-11-07 16:33:55 +08:00
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
friend class SubmissionAggregator;
|
2019-03-13 22:31:46 +08:00
|
|
|
|
2019-11-04 23:03:30 +08:00
|
|
|
const uint32_t rootDeviceIndex;
|
2019-03-13 22:31:46 +08:00
|
|
|
AllocationInfo allocationInfo;
|
|
|
|
AubInfo aubInfo;
|
|
|
|
SharingInfo sharingInfo;
|
|
|
|
ReservedAddressRange reservedAddressRangeInfo;
|
2023-07-21 19:55:22 +08:00
|
|
|
SurfaceStateInHeapInfo bindlessInfo = {nullptr, 0, nullptr};
|
2019-03-13 22:31:46 +08:00
|
|
|
|
|
|
|
uint64_t allocationOffset = 0u;
|
2019-02-27 21:59:46 +08:00
|
|
|
uint64_t gpuBaseAddress = 0;
|
2018-11-02 17:01:56 +08:00
|
|
|
uint64_t gpuAddress = 0;
|
2019-03-13 22:31:46 +08:00
|
|
|
void *driverAllocatedCpuPointer = nullptr;
|
|
|
|
size_t size = 0;
|
|
|
|
void *cpuPtr = nullptr;
|
2019-01-24 22:16:12 +08:00
|
|
|
void *lockedPtr = nullptr;
|
2019-02-27 21:59:46 +08:00
|
|
|
|
2023-12-12 17:11:27 +08:00
|
|
|
MemoryPool memoryPool = MemoryPool::memoryNull;
|
2023-12-11 22:24:36 +08:00
|
|
|
AllocationType allocationType = AllocationType::unknown;
|
2019-02-27 21:59:46 +08:00
|
|
|
|
2020-01-30 16:24:03 +08:00
|
|
|
StackVec<UsageInfo, 32> usageInfos;
|
2020-04-21 19:16:45 +08:00
|
|
|
StackVec<Gmm *, EngineLimits::maxHandleCount> gmms;
|
2022-05-10 18:46:08 +08:00
|
|
|
ResidencyData residency;
|
2024-03-25 22:44:36 +08:00
|
|
|
std::atomic<uint32_t> registeredContextsNum{0};
|
|
|
|
bool shareableHostMemory = false;
|
2024-03-29 18:17:04 +08:00
|
|
|
bool cantBeReadOnly = false;
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|