2017-12-21 00:45:38 +01:00
|
|
|
/*
|
2020-02-04 08:53:51 +01:00
|
|
|
* Copyright (C) 2017-2020 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
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/memory_manager/graphics_allocation.h"
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
namespace NEO {
|
2017-12-21 00:45:38 +01:00
|
|
|
class BufferObject;
|
|
|
|
|
|
|
|
|
|
struct OsHandle {
|
|
|
|
|
BufferObject *bo = nullptr;
|
|
|
|
|
};
|
|
|
|
|
|
2019-12-17 08:11:16 +01:00
|
|
|
using BufferObjects = std::array<BufferObject *, EngineLimits::maxHandleCount>;
|
2019-09-01 21:36:15 +02:00
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
class DrmAllocation : public GraphicsAllocation {
|
|
|
|
|
public:
|
2019-11-04 16:03:30 +01:00
|
|
|
DrmAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, BufferObject *bo, void *ptrIn, size_t sizeIn, osHandle sharedHandle, MemoryPool::Type pool)
|
2020-04-21 13:16:45 +02:00
|
|
|
: DrmAllocation(rootDeviceIndex, 1, allocationType, bo, ptrIn, sizeIn, sharedHandle, pool) {}
|
|
|
|
|
|
|
|
|
|
DrmAllocation(uint32_t rootDeviceIndex, size_t numGmms, AllocationType allocationType, BufferObject *bo, void *ptrIn, size_t sizeIn, osHandle sharedHandle, MemoryPool::Type pool)
|
|
|
|
|
: GraphicsAllocation(rootDeviceIndex, numGmms, allocationType, ptrIn, sizeIn, sharedHandle, pool),
|
2019-09-09 14:14:25 +02:00
|
|
|
bufferObjects({{bo}}) {
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
2019-02-26 11:37:51 +01:00
|
|
|
|
2019-11-04 16:03:30 +01:00
|
|
|
DrmAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, BufferObject *bo, void *ptrIn, uint64_t gpuAddress, size_t sizeIn, MemoryPool::Type pool)
|
2020-04-21 13:16:45 +02:00
|
|
|
: DrmAllocation(rootDeviceIndex, 1, allocationType, bo, ptrIn, gpuAddress, sizeIn, pool) {}
|
|
|
|
|
|
|
|
|
|
DrmAllocation(uint32_t rootDeviceIndex, size_t numGmms, AllocationType allocationType, BufferObject *bo, void *ptrIn, uint64_t gpuAddress, size_t sizeIn, MemoryPool::Type pool)
|
|
|
|
|
: GraphicsAllocation(rootDeviceIndex, numGmms, allocationType, ptrIn, gpuAddress, 0, sizeIn, pool),
|
2019-09-09 14:14:25 +02:00
|
|
|
bufferObjects({{bo}}) {
|
2019-09-01 21:36:15 +02:00
|
|
|
}
|
|
|
|
|
|
2019-11-04 16:03:30 +01:00
|
|
|
DrmAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, BufferObjects &bos, void *ptrIn, uint64_t gpuAddress, size_t sizeIn, MemoryPool::Type pool)
|
2020-04-21 13:16:45 +02:00
|
|
|
: DrmAllocation(rootDeviceIndex, 1, allocationType, bos, ptrIn, gpuAddress, sizeIn, pool) {}
|
|
|
|
|
|
|
|
|
|
DrmAllocation(uint32_t rootDeviceIndex, size_t numGmms, AllocationType allocationType, BufferObjects &bos, void *ptrIn, uint64_t gpuAddress, size_t sizeIn, MemoryPool::Type pool)
|
|
|
|
|
: GraphicsAllocation(rootDeviceIndex, numGmms, allocationType, ptrIn, gpuAddress, 0, sizeIn, pool),
|
2019-09-01 21:36:15 +02:00
|
|
|
bufferObjects(bos) {
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
|
|
|
|
|
2019-02-14 11:38:04 +01:00
|
|
|
std::string getAllocationInfoString() const override;
|
|
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
BufferObject *getBO() const {
|
|
|
|
|
if (fragmentsStorage.fragmentCount) {
|
|
|
|
|
return fragmentsStorage.fragmentStorageData[0].osHandleStorage->bo;
|
|
|
|
|
}
|
2019-09-01 21:36:15 +02:00
|
|
|
return this->bufferObjects[0];
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
2019-09-01 21:36:15 +02:00
|
|
|
const BufferObjects &getBOs() const {
|
|
|
|
|
return this->bufferObjects;
|
|
|
|
|
}
|
|
|
|
|
BufferObject *&getBufferObjectToModify(uint32_t handleIndex) {
|
|
|
|
|
return bufferObjects[handleIndex];
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-06 16:26:47 +02:00
|
|
|
uint64_t peekInternalHandle(MemoryManager *memoryManager) override;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2020-07-28 07:48:41 +02:00
|
|
|
void makeBOsResident(uint32_t osContextId, uint32_t vmHandleId, std::vector<BufferObject *> *bufferObjects, bool bind);
|
|
|
|
|
void bindBO(BufferObject *bo, uint32_t vmHandleId, std::vector<BufferObject *> *bufferObjects, bool bind);
|
|
|
|
|
void bindBOs(uint32_t vmHandleId, std::vector<BufferObject *> *bufferObjects, bool bind);
|
2020-06-26 09:14:36 +02:00
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
protected:
|
2019-09-01 21:36:15 +02:00
|
|
|
BufferObjects bufferObjects{};
|
2017-12-21 00:45:38 +01:00
|
|
|
};
|
2019-03-26 11:59:46 +01:00
|
|
|
} // namespace NEO
|