mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-04 15:53:45 +08:00
Add proper handling decoding resource while import on WSL
- create resource info and handle when needed Signed-off-by: Kamil Diedrich <kamil.diedrich@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
7829364e67
commit
4d35a76931
@@ -97,7 +97,7 @@ class GmmResourceInfo {
|
||||
GmmResourceInfo(GmmClientContext *clientContext, GMM_RESOURCE_INFO *inputGmmResourceInfo, bool openingHandle);
|
||||
|
||||
void createResourceInfo(GMM_RESOURCE_INFO *resourceInfoPtr);
|
||||
void decodeResourceInfo(GMM_RESOURCE_INFO *resourceInfoPtr, GMM_RESOURCE_INFO *inputGmmResourceInfo);
|
||||
void decodeResourceInfo(GMM_RESOURCE_INFO *inputGmmResourceInfo);
|
||||
|
||||
UniquePtrType resourceInfo;
|
||||
|
||||
|
||||
@@ -19,26 +19,28 @@ GmmResourceInfo::GmmResourceInfo(GmmClientContext *clientContext, GMM_RESCREATE_
|
||||
GmmResourceInfo::GmmResourceInfo(GmmClientContext *clientContext, GMM_RESOURCE_INFO *inputGmmResourceInfo) : GmmResourceInfo(clientContext, inputGmmResourceInfo, false) {}
|
||||
|
||||
GmmResourceInfo::GmmResourceInfo(GmmClientContext *clientContext, GMM_RESOURCE_INFO *inputGmmResourceInfo, bool openingHandle) : clientContext(clientContext) {
|
||||
auto resourceInfoPtr = clientContext->copyResInfoObject(inputGmmResourceInfo);
|
||||
if (openingHandle) {
|
||||
decodeResourceInfo(resourceInfoPtr, inputGmmResourceInfo);
|
||||
decodeResourceInfo(inputGmmResourceInfo);
|
||||
} else {
|
||||
auto resourceInfoPtr = clientContext->copyResInfoObject(inputGmmResourceInfo);
|
||||
createResourceInfo(resourceInfoPtr);
|
||||
}
|
||||
}
|
||||
|
||||
void GmmResourceInfo::decodeResourceInfo(GMM_RESOURCE_INFO *resourceInfoPtr, GMM_RESOURCE_INFO *inputGmmResourceInfo) {
|
||||
void GmmResourceInfo::decodeResourceInfo(GMM_RESOURCE_INFO *inputGmmResourceInfo) {
|
||||
auto customDeleter = [this](GMM_RESOURCE_INFO *gmmResourceInfo) {
|
||||
this->clientContext->destroyResInfoObject(gmmResourceInfo);
|
||||
};
|
||||
if (this->clientContext->getHandleAllocator()) {
|
||||
this->resourceInfo = UniquePtrType(resourceInfoPtr, [](GMM_RESOURCE_INFO *gmmResourceInfo) {});
|
||||
this->clientContext->getHandleAllocator()->openHandle(inputGmmResourceInfo, resourceInfoPtr, this->clientContext->getHandleAllocator()->getHandleSize());
|
||||
this->handle = resourceInfoPtr;
|
||||
this->handleSize = this->clientContext->getHandleAllocator()->getHandleSize();
|
||||
return;
|
||||
}
|
||||
|
||||
UNRECOVERABLE_IF(this->handle != nullptr);
|
||||
|
||||
auto resourceInfoPtr = this->clientContext->copyResInfoObject(inputGmmResourceInfo);
|
||||
this->resourceInfo = UniquePtrType(resourceInfoPtr, customDeleter);
|
||||
|
||||
this->handle = this->clientContext->getHandleAllocator()->createHandle(inputGmmResourceInfo);
|
||||
this->handleSize = this->clientContext->getHandleAllocator()->getHandleSize();
|
||||
|
||||
this->clientContext->getHandleAllocator()->openHandle(inputGmmResourceInfo, this->resourceInfo.get(), this->clientContext->getHandleAllocator()->getHandleSize());
|
||||
}
|
||||
|
||||
void GmmResourceInfo::createResourceInfo(GMM_RESOURCE_INFO *resourceInfoPtr) {
|
||||
@@ -57,8 +59,8 @@ void GmmResourceInfo::createResourceInfo(GMM_RESOURCE_INFO *resourceInfoPtr) {
|
||||
}
|
||||
|
||||
void GmmResourceInfo::refreshHandle() {
|
||||
if (this->clientContext) {
|
||||
this->decodeResourceInfo(this->resourceInfo.release(), static_cast<GMM_RESOURCE_INFO *>(this->handle));
|
||||
if (this->clientContext && this->clientContext->getHandleAllocator()) {
|
||||
this->clientContext->getHandleAllocator()->openHandle(this->handle, this->resourceInfo.get(), this->clientContext->getHandleAllocator()->getHandleSize());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user