2018-05-06 03:30:37 +08:00
|
|
|
/*
|
2021-05-03 04:41:01 +08:00
|
|
|
* Copyright (C) 2018-2021 Intel Corporation
|
2018-09-18 15:11:08 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
2018-05-06 03:30:37 +08:00
|
|
|
|
2021-06-29 01:36:16 +08:00
|
|
|
#include "shared/source/gmm_helper/client_context/gmm_client_context.h"
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/gmm_helper/gmm_helper.h"
|
|
|
|
#include "shared/source/gmm_helper/resource_info.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2018-05-06 03:30:37 +08:00
|
|
|
|
2019-12-30 21:14:27 +08:00
|
|
|
GmmResourceInfo::GmmResourceInfo(GmmClientContext *clientContext, GMM_RESCREATE_PARAMS *resourceCreateParams) : clientContext(clientContext) {
|
|
|
|
auto resourceInfoPtr = clientContext->createResInfoObject(resourceCreateParams);
|
2019-09-20 21:37:58 +08:00
|
|
|
createResourceInfo(resourceInfoPtr);
|
2018-05-06 03:30:37 +08:00
|
|
|
}
|
|
|
|
|
2019-12-30 21:14:27 +08:00
|
|
|
GmmResourceInfo::GmmResourceInfo(GmmClientContext *clientContext, GMM_RESOURCE_INFO *inputGmmResourceInfo) : clientContext(clientContext) {
|
|
|
|
auto resourceInfoPtr = clientContext->copyResInfoObject(inputGmmResourceInfo);
|
2019-09-20 21:37:58 +08:00
|
|
|
createResourceInfo(resourceInfoPtr);
|
|
|
|
}
|
|
|
|
|
2021-05-03 04:41:01 +08:00
|
|
|
GmmResourceInfo::~GmmResourceInfo() {
|
|
|
|
if (this->clientContext && this->clientContext->getHandleAllocator()) {
|
|
|
|
this->clientContext->getHandleAllocator()->destroyHandle(this->handle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-20 21:37:58 +08:00
|
|
|
void GmmResourceInfo::createResourceInfo(GMM_RESOURCE_INFO *resourceInfoPtr) {
|
2019-12-30 21:14:27 +08:00
|
|
|
auto customDeleter = [this](GMM_RESOURCE_INFO *gmmResourceInfo) {
|
|
|
|
this->clientContext->destroyResInfoObject(gmmResourceInfo);
|
2019-09-20 21:37:58 +08:00
|
|
|
};
|
|
|
|
this->resourceInfo = UniquePtrType(resourceInfoPtr, customDeleter);
|
2021-05-03 04:41:01 +08:00
|
|
|
|
|
|
|
if (this->clientContext->getHandleAllocator()) {
|
|
|
|
this->handle = this->clientContext->getHandleAllocator()->createHandle(this->resourceInfo.get());
|
|
|
|
this->handleSize = this->clientContext->getHandleAllocator()->getHandleSize();
|
|
|
|
} else {
|
|
|
|
this->handle = this->resourceInfo.get();
|
|
|
|
this->handleSize = sizeof(GMM_RESOURCE_INFO);
|
|
|
|
}
|
2018-05-06 03:30:37 +08:00
|
|
|
}
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|