mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Create and implement WSL handle refreshing
Additionally rename createResourceInfo overload to decodeResourceInfo. createResourceInfo(GMM_RESOURCE_INFO *, GMM_RESOURCE_INFO) does not create a new ResourceInfo, but decodes one on the basis of the provided existing gmmResourceInfo. Signed-off-by: Fabian Zwolinski <fabian.zwolinski@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
d5bc7e66e7
commit
0966651a78
@ -83,6 +83,8 @@ class GmmResourceInfo {
|
|||||||
|
|
||||||
MOCKABLE_VIRTUAL size_t peekHandleSize() const { return handleSize; }
|
MOCKABLE_VIRTUAL size_t peekHandleSize() const { return handleSize; }
|
||||||
|
|
||||||
|
MOCKABLE_VIRTUAL void refreshHandle();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
using UniquePtrType = std::unique_ptr<GMM_RESOURCE_INFO, std::function<void(GMM_RESOURCE_INFO *)>>;
|
using UniquePtrType = std::unique_ptr<GMM_RESOURCE_INFO, std::function<void(GMM_RESOURCE_INFO *)>>;
|
||||||
|
|
||||||
@ -95,7 +97,7 @@ class GmmResourceInfo {
|
|||||||
GmmResourceInfo(GmmClientContext *clientContext, GMM_RESOURCE_INFO *inputGmmResourceInfo, bool openingHandle);
|
GmmResourceInfo(GmmClientContext *clientContext, GMM_RESOURCE_INFO *inputGmmResourceInfo, bool openingHandle);
|
||||||
|
|
||||||
void createResourceInfo(GMM_RESOURCE_INFO *resourceInfoPtr);
|
void createResourceInfo(GMM_RESOURCE_INFO *resourceInfoPtr);
|
||||||
void createResourceInfo(GMM_RESOURCE_INFO *resourceInfoPtr, GMM_RESOURCE_INFO *inputGmmResourceInfo);
|
void decodeResourceInfo(GMM_RESOURCE_INFO *resourceInfoPtr, GMM_RESOURCE_INFO *inputGmmResourceInfo);
|
||||||
|
|
||||||
UniquePtrType resourceInfo;
|
UniquePtrType resourceInfo;
|
||||||
|
|
||||||
|
@ -21,13 +21,13 @@ GmmResourceInfo::GmmResourceInfo(GmmClientContext *clientContext, GMM_RESOURCE_I
|
|||||||
GmmResourceInfo::GmmResourceInfo(GmmClientContext *clientContext, GMM_RESOURCE_INFO *inputGmmResourceInfo, bool openingHandle) : clientContext(clientContext) {
|
GmmResourceInfo::GmmResourceInfo(GmmClientContext *clientContext, GMM_RESOURCE_INFO *inputGmmResourceInfo, bool openingHandle) : clientContext(clientContext) {
|
||||||
auto resourceInfoPtr = clientContext->copyResInfoObject(inputGmmResourceInfo);
|
auto resourceInfoPtr = clientContext->copyResInfoObject(inputGmmResourceInfo);
|
||||||
if (openingHandle) {
|
if (openingHandle) {
|
||||||
createResourceInfo(resourceInfoPtr, inputGmmResourceInfo);
|
decodeResourceInfo(resourceInfoPtr, inputGmmResourceInfo);
|
||||||
} else {
|
} else {
|
||||||
createResourceInfo(resourceInfoPtr);
|
createResourceInfo(resourceInfoPtr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GmmResourceInfo::createResourceInfo(GMM_RESOURCE_INFO *resourceInfoPtr, GMM_RESOURCE_INFO *inputGmmResourceInfo) {
|
void GmmResourceInfo::decodeResourceInfo(GMM_RESOURCE_INFO *resourceInfoPtr, GMM_RESOURCE_INFO *inputGmmResourceInfo) {
|
||||||
auto customDeleter = [this](GMM_RESOURCE_INFO *gmmResourceInfo) {
|
auto customDeleter = [this](GMM_RESOURCE_INFO *gmmResourceInfo) {
|
||||||
this->clientContext->destroyResInfoObject(gmmResourceInfo);
|
this->clientContext->destroyResInfoObject(gmmResourceInfo);
|
||||||
};
|
};
|
||||||
@ -56,6 +56,12 @@ 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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GmmResourceInfo::~GmmResourceInfo() {
|
GmmResourceInfo::~GmmResourceInfo() {
|
||||||
if (this->clientContext && this->clientContext->getHandleAllocator()) {
|
if (this->clientContext && this->clientContext->getHandleAllocator()) {
|
||||||
this->clientContext->getHandleAllocator()->destroyHandle(this->handle);
|
this->clientContext->getHandleAllocator()->destroyHandle(this->handle);
|
||||||
|
@ -521,6 +521,8 @@ NTSTATUS Wddm::createAllocation(const void *alignedCpuPtr, const Gmm *gmm, D3DKM
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gmm->gmmResourceInfo->refreshHandle();
|
||||||
|
|
||||||
outHandle = allocationInfo.hAllocation;
|
outHandle = allocationInfo.hAllocation;
|
||||||
outResourceHandle = createAllocation.hResource;
|
outResourceHandle = createAllocation.hResource;
|
||||||
if (outSharedHandle) {
|
if (outSharedHandle) {
|
||||||
|
@ -100,8 +100,14 @@ class MockGmmResourceInfo : public GmmResourceInfo {
|
|||||||
void setAuxQPitch(uint32_t value);
|
void setAuxQPitch(uint32_t value);
|
||||||
void setMipTailStartLod(uint32_t newMipTailStartLod) { mipTailStartLod = newMipTailStartLod; }
|
void setMipTailStartLod(uint32_t newMipTailStartLod) { mipTailStartLod = newMipTailStartLod; }
|
||||||
|
|
||||||
|
void refreshHandle() override {
|
||||||
|
refreshHandleCalled++;
|
||||||
|
GmmResourceInfo::refreshHandle();
|
||||||
|
};
|
||||||
|
|
||||||
using GmmResourceInfo::clientContext;
|
using GmmResourceInfo::clientContext;
|
||||||
using GmmResourceInfo::createResourceInfo;
|
using GmmResourceInfo::createResourceInfo;
|
||||||
|
using GmmResourceInfo::decodeResourceInfo;
|
||||||
|
|
||||||
uint64_t driverProtectionBits = 0;
|
uint64_t driverProtectionBits = 0;
|
||||||
uint32_t getOffsetCalled = 0u;
|
uint32_t getOffsetCalled = 0u;
|
||||||
@ -113,6 +119,7 @@ class MockGmmResourceInfo : public GmmResourceInfo {
|
|||||||
uint8_t cpuBltResult = 1u;
|
uint8_t cpuBltResult = 1u;
|
||||||
static constexpr uint32_t getHAlignSurfaceStateResult = 2u;
|
static constexpr uint32_t getHAlignSurfaceStateResult = 2u;
|
||||||
static constexpr uint32_t yMajorTileModeValue = 3u;
|
static constexpr uint32_t yMajorTileModeValue = 3u;
|
||||||
|
uint32_t refreshHandleCalled = 0u;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
MockGmmResourceInfo();
|
MockGmmResourceInfo();
|
||||||
|
@ -69,7 +69,7 @@ TEST(GmmResourceInfo, WhenGmmHandleAllocatorIsPresentThenItsBeingUsedForCreating
|
|||||||
EXPECT_NE(destroyed.end(), std::find(destroyed.begin(), destroyed.end(), handle));
|
EXPECT_NE(destroyed.end(), std::find(destroyed.begin(), destroyed.end(), handle));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(GmmResourceInfo, GivenGmmResourceInfoAndHandleAllocatorInClientContextWhenCreatingResourceInfoThenExistingHandleIsOpened) {
|
TEST(GmmResourceInfo, GivenGmmResourceInfoAndHandleAllocatorInClientContextWhenDecodingResourceInfoThenExistingHandleIsOpened) {
|
||||||
NEO::HardwareInfo hwInfo;
|
NEO::HardwareInfo hwInfo;
|
||||||
hwInfo.platform.eProductFamily = productFamily;
|
hwInfo.platform.eProductFamily = productFamily;
|
||||||
NEO::MockGmmClientContext gmmClientCtx{nullptr, &hwInfo};
|
NEO::MockGmmClientContext gmmClientCtx{nullptr, &hwInfo};
|
||||||
@ -94,7 +94,7 @@ TEST(GmmResourceInfo, GivenGmmResourceInfoAndHandleAllocatorInClientContextWhenC
|
|||||||
ASSERT_NE(nullptr, resInfo2);
|
ASSERT_NE(nullptr, resInfo2);
|
||||||
resInfo2->clientContext = &gmmClientCtx;
|
resInfo2->clientContext = &gmmClientCtx;
|
||||||
auto resourceInfoPtr = resInfo2->clientContext->copyResInfoObject(static_cast<GMM_RESOURCE_INFO *>(resInfo->GmmResourceInfo::peekHandle()));
|
auto resourceInfoPtr = resInfo2->clientContext->copyResInfoObject(static_cast<GMM_RESOURCE_INFO *>(resInfo->GmmResourceInfo::peekHandle()));
|
||||||
resInfo2->createResourceInfo(resourceInfoPtr, static_cast<GMM_RESOURCE_INFO *>(resInfo->GmmResourceInfo::peekHandle()));
|
resInfo2->decodeResourceInfo(resourceInfoPtr, static_cast<GMM_RESOURCE_INFO *>(resInfo->GmmResourceInfo::peekHandle()));
|
||||||
|
|
||||||
EXPECT_EQ(1U, created.size());
|
EXPECT_EQ(1U, created.size());
|
||||||
EXPECT_EQ(1U, opened.size());
|
EXPECT_EQ(1U, opened.size());
|
||||||
@ -110,11 +110,20 @@ TEST(GmmResourceInfo, GivenGmmResourceInfoAndHandleAllocatorInClientContextWhenC
|
|||||||
auto handle2 = resInfo2->GmmResourceInfo::peekHandle();
|
auto handle2 = resInfo2->GmmResourceInfo::peekHandle();
|
||||||
EXPECT_NE(nullptr, handle2);
|
EXPECT_NE(nullptr, handle2);
|
||||||
|
|
||||||
|
EXPECT_EQ(0u, resInfo2->refreshHandleCalled);
|
||||||
|
|
||||||
|
resInfo2->refreshHandle();
|
||||||
|
|
||||||
|
EXPECT_EQ(1U, created.size());
|
||||||
|
EXPECT_EQ(2U, opened.size());
|
||||||
|
EXPECT_EQ(0U, destroyed.size());
|
||||||
|
EXPECT_EQ(1u, resInfo2->refreshHandleCalled);
|
||||||
|
|
||||||
delete resInfo;
|
delete resInfo;
|
||||||
delete resInfo2;
|
delete resInfo2;
|
||||||
|
|
||||||
EXPECT_EQ(1U, created.size());
|
EXPECT_EQ(1U, created.size());
|
||||||
EXPECT_EQ(1U, opened.size());
|
EXPECT_EQ(2U, opened.size());
|
||||||
EXPECT_EQ(2U, destroyed.size());
|
EXPECT_EQ(2U, destroyed.size());
|
||||||
EXPECT_NE(destroyed.end(), std::find(destroyed.begin(), destroyed.end(), handle));
|
EXPECT_NE(destroyed.end(), std::find(destroyed.begin(), destroyed.end(), handle));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user