Read resource info from internal represenation for WSL

Related-To: LOCI-3037
Signed-off-by: Fabian Zwolinski <fabian.zwolinski@intel.com>
This commit is contained in:
Fabian Zwolinski
2022-04-19 14:11:45 +02:00
committed by Compute-Runtime-Automation
parent 2578a988c5
commit 7bb3bcbc05
13 changed files with 210 additions and 17 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 Intel Corporation
* Copyright (C) 2021-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -22,6 +22,9 @@ class GmmHandleAllocator {
}
virtual void destroyHandle(void *handle) {
}
virtual bool openHandle(void *handle, GMM_RESOURCE_INFO *dstResInfo, size_t handleSize) {
return true;
}
virtual size_t getHandleSize() {
return 0;
}

View File

@@ -60,8 +60,10 @@ Gmm::Gmm(GmmHelper *gmmHelper, const void *alignedPtr, size_t alignedSize, size_
gmmResourceInfo.reset(GmmResourceInfo::create(gmmHelper->getClientContext(), &resourceParams));
}
Gmm::Gmm(GmmHelper *gmmHelper, GMM_RESOURCE_INFO *inputGmm) : gmmHelper(gmmHelper) {
gmmResourceInfo.reset(GmmResourceInfo::create(gmmHelper->getClientContext(), inputGmm));
Gmm::Gmm(GmmHelper *gmmHelper, GMM_RESOURCE_INFO *inputGmm) : Gmm(gmmHelper, inputGmm, false) {}
Gmm::Gmm(GmmHelper *gmmHelper, GMM_RESOURCE_INFO *inputGmm, bool openingHandle) : gmmHelper(gmmHelper) {
gmmResourceInfo.reset(GmmResourceInfo::create(gmmHelper->getClientContext(), inputGmm, openingHandle));
applyDebugOverrides();
}

View File

@@ -28,6 +28,7 @@ class Gmm {
Gmm(GmmHelper *gmmHelper, const void *alignedPtr, size_t alignedSize, size_t alignment,
GMM_RESOURCE_USAGE_TYPE_ENUM gmmResourceUsage, bool preferCompressed, StorageInfo storageInfo, bool allowLargePages);
Gmm(GmmHelper *gmmHelper, GMM_RESOURCE_INFO *inputGmm);
Gmm(GmmHelper *gmmHelper, GMM_RESOURCE_INFO *inputGmm, bool openingHandle);
void queryImageParams(ImageInfo &inputOutputImgInfo);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2021 Intel Corporation
* Copyright (C) 2020-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -15,4 +15,9 @@ GmmResourceInfo *GmmResourceInfo::create(GmmClientContext *clientContext, GMM_RE
GmmResourceInfo *GmmResourceInfo::create(GmmClientContext *clientContext, GMM_RESOURCE_INFO *inputGmmResourceInfo) {
return new GmmResourceInfo(clientContext, inputGmmResourceInfo);
}
GmmResourceInfo *GmmResourceInfo::create(GmmClientContext *clientContext, GMM_RESOURCE_INFO *inputGmmResourceInfo, bool openingHandle) {
return new GmmResourceInfo(clientContext, inputGmmResourceInfo, openingHandle);
}
} // namespace NEO

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021 Intel Corporation
* Copyright (C) 2018-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -19,6 +19,8 @@ class GmmResourceInfo {
static GmmResourceInfo *create(GmmClientContext *clientContext, GMM_RESOURCE_INFO *inputGmmResourceInfo);
static GmmResourceInfo *create(GmmClientContext *clientContext, GMM_RESOURCE_INFO *inputGmmResourceInfo, bool openingHandle);
MOCKABLE_VIRTUAL ~GmmResourceInfo();
MOCKABLE_VIRTUAL size_t getSizeAllocation() { return static_cast<size_t>(resourceInfo->GetSize(GMM_TOTAL_SURF)); }
@@ -90,7 +92,10 @@ class GmmResourceInfo {
GmmResourceInfo(GmmClientContext *clientContext, GMM_RESOURCE_INFO *inputGmmResourceInfo);
GmmResourceInfo(GmmClientContext *clientContext, GMM_RESOURCE_INFO *inputGmmResourceInfo, bool openingHandle);
void createResourceInfo(GMM_RESOURCE_INFO *resourceInfoPtr);
void createResourceInfo(GMM_RESOURCE_INFO *resourceInfoPtr, GMM_RESOURCE_INFO *inputGmmResourceInfo);
UniquePtrType resourceInfo;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021 Intel Corporation
* Copyright (C) 2018-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -16,15 +16,29 @@ GmmResourceInfo::GmmResourceInfo(GmmClientContext *clientContext, GMM_RESCREATE_
createResourceInfo(resourceInfoPtr);
}
GmmResourceInfo::GmmResourceInfo(GmmClientContext *clientContext, GMM_RESOURCE_INFO *inputGmmResourceInfo) : clientContext(clientContext) {
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);
createResourceInfo(resourceInfoPtr);
if (openingHandle) {
createResourceInfo(resourceInfoPtr, inputGmmResourceInfo);
} else {
createResourceInfo(resourceInfoPtr);
}
}
GmmResourceInfo::~GmmResourceInfo() {
if (this->clientContext && this->clientContext->getHandleAllocator()) {
this->clientContext->getHandleAllocator()->destroyHandle(this->handle);
void GmmResourceInfo::createResourceInfo(GMM_RESOURCE_INFO *resourceInfoPtr, 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;
}
this->resourceInfo = UniquePtrType(resourceInfoPtr, customDeleter);
}
void GmmResourceInfo::createResourceInfo(GMM_RESOURCE_INFO *resourceInfoPtr) {
@@ -42,4 +56,10 @@ void GmmResourceInfo::createResourceInfo(GMM_RESOURCE_INFO *resourceInfoPtr) {
}
}
GmmResourceInfo::~GmmResourceInfo() {
if (this->clientContext && this->clientContext->getHandleAllocator()) {
this->clientContext->getHandleAllocator()->destroyHandle(this->handle);
}
}
} // namespace NEO