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