mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-10 12:53:42 +08:00
Remove virtual padding support
Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
70cf43fd6e
commit
39c1c4d530
@ -268,16 +268,6 @@ Image *Image::create(Context *context,
|
|||||||
|
|
||||||
UNRECOVERABLE_IF(imgInfo.offset != 0);
|
UNRECOVERABLE_IF(imgInfo.offset != 0);
|
||||||
imgInfo.offset = parentBuffer->getOffset();
|
imgInfo.offset = parentBuffer->getOffset();
|
||||||
|
|
||||||
if (memoryManager->peekVirtualPaddingSupport() && (imageDesc->image_type == CL_MEM_OBJECT_IMAGE2D) && (allocationInfo[rootDeviceIndex].memory->getUnderlyingBuffer() != 0)) {
|
|
||||||
// Retrieve sizes from GMM and apply virtual padding if buffer storage is not big enough
|
|
||||||
auto queryGmmImgInfo(imgInfo);
|
|
||||||
auto gmm = std::make_unique<Gmm>(gmmHelper, queryGmmImgInfo, StorageInfo{}, preferCompression);
|
|
||||||
auto gmmAllocationSize = gmm->gmmResourceInfo->getSizeAllocation();
|
|
||||||
if (gmmAllocationSize > allocationInfo[rootDeviceIndex].memory->getUnderlyingBufferSize()) {
|
|
||||||
allocationInfo[rootDeviceIndex].memory = memoryManager->createGraphicsAllocationWithPadding(allocationInfo[rootDeviceIndex].memory, gmmAllocationSize);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (parentImage != nullptr) {
|
} else if (parentImage != nullptr) {
|
||||||
allocationInfo[rootDeviceIndex].memory = parentImage->getGraphicsAllocation(rootDeviceIndex);
|
allocationInfo[rootDeviceIndex].memory = parentImage->getGraphicsAllocation(rootDeviceIndex);
|
||||||
allocationInfo[rootDeviceIndex].memory->getDefaultGmm()->queryImageParams(imgInfo);
|
allocationInfo[rootDeviceIndex].memory->getDefaultGmm()->queryImageParams(imgInfo);
|
||||||
|
@ -99,11 +99,6 @@ MemObj::~MemObj() {
|
|||||||
if (mcsAllocation) {
|
if (mcsAllocation) {
|
||||||
destroyGraphicsAllocation(mcsAllocation, false);
|
destroyGraphicsAllocation(mcsAllocation, false);
|
||||||
}
|
}
|
||||||
if (graphicsAllocation && associatedMemObject) {
|
|
||||||
if (associatedMemObject->getGraphicsAllocation(graphicsAllocation->getRootDeviceIndex()) != graphicsAllocation) {
|
|
||||||
destroyGraphicsAllocation(graphicsAllocation, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (associatedMemObject) {
|
if (associatedMemObject) {
|
||||||
associatedMemObject->decRefInternal();
|
associatedMemObject->decRefInternal();
|
||||||
|
@ -262,27 +262,6 @@ TEST_F(GmmTests, given2DimageFromBufferParametersWhenGmmResourceIsCreatedThenItH
|
|||||||
EXPECT_EQ(imgDesc.imageRowPitch, queryGmm->gmmResourceInfo->getRenderPitch());
|
EXPECT_EQ(imgDesc.imageRowPitch, queryGmm->gmmResourceInfo->getRenderPitch());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(GmmTests, given2DimageFromBufferParametersWhenGmmResourceIsCreatedAndPitchIsOverridenThenItHasDesiredPitchAndSize) {
|
|
||||||
ImageDescriptor imgDesc = {};
|
|
||||||
imgDesc.imageType = ImageType::Image2D;
|
|
||||||
imgDesc.imageWidth = 329;
|
|
||||||
imgDesc.imageHeight = 349;
|
|
||||||
imgDesc.imageDepth = 1;
|
|
||||||
imgDesc.imageRowPitch = 5376;
|
|
||||||
imgDesc.fromParent = true;
|
|
||||||
|
|
||||||
SurfaceFormatInfo surfaceFormat = {GMM_FORMAT_R32G32B32A32_FLOAT_TYPE, (GFX3DSTATE_SURFACEFORMAT)0, 0, 4, 4, 16};
|
|
||||||
|
|
||||||
auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, &surfaceFormat);
|
|
||||||
EXPECT_EQ(imgInfo.imgDesc.imageRowPitch, imgDesc.imageRowPitch);
|
|
||||||
auto queryGmm = MockGmm::queryImgParams(getGmmHelper(), imgInfo, false);
|
|
||||||
auto renderSize = queryGmm->gmmResourceInfo->getSizeAllocation();
|
|
||||||
|
|
||||||
size_t expectedSize = imgDesc.imageRowPitch * imgDesc.imageHeight;
|
|
||||||
EXPECT_GE(renderSize, expectedSize);
|
|
||||||
EXPECT_EQ(imgDesc.imageRowPitch, queryGmm->gmmResourceInfo->getRenderPitch());
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(GmmTests, givenPlanarFormatsWhenQueryingImageParamsThenUvOffsetIsQueried) {
|
TEST_F(GmmTests, givenPlanarFormatsWhenQueryingImageParamsThenUvOffsetIsQueried) {
|
||||||
ImageDescriptor imgDesc = {};
|
ImageDescriptor imgDesc = {};
|
||||||
imgDesc.imageType = ImageType::Image2D;
|
imgDesc.imageType = ImageType::Image2D;
|
||||||
|
@ -302,157 +302,6 @@ TEST_F(Image2dFromBufferTest, givenImageFromBufferWhenItIsRedescribedThenItRetur
|
|||||||
EXPECT_TRUE(redescribedfillImage->isImageFromBuffer());
|
EXPECT_TRUE(redescribedfillImage->isImageFromBuffer());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(Image2dFromBufferTest, givenMemoryManagerNotSupportingVirtualPaddingWhenImageIsCreatedThenPaddingIsNotApplied) {
|
|
||||||
auto memoryManager = context.getMemoryManager();
|
|
||||||
memoryManager->setVirtualPaddingSupport(false);
|
|
||||||
|
|
||||||
auto buffer = castToObject<Buffer>(imageDesc.mem_object);
|
|
||||||
ASSERT_NE(nullptr, buffer);
|
|
||||||
EXPECT_EQ(1, buffer->getRefInternalCount());
|
|
||||||
|
|
||||||
std::unique_ptr<Image> imageFromBuffer(createImage());
|
|
||||||
ASSERT_EQ(CL_SUCCESS, retVal);
|
|
||||||
|
|
||||||
//graphics allocation for image and buffer is the same
|
|
||||||
auto bufferGraphicsAllocation = buffer->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex());
|
|
||||||
auto imageGraphicsAllocation = imageFromBuffer->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex());
|
|
||||||
|
|
||||||
EXPECT_EQ(bufferGraphicsAllocation, imageGraphicsAllocation);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(Image2dFromBufferTest, givenMemoryManagerSupportingVirtualPaddingWhenImageIsCreatedThatFitsInTheBufferThenPaddingIsNotApplied) {
|
|
||||||
auto memoryManager = context.getMemoryManager();
|
|
||||||
memoryManager->setVirtualPaddingSupport(true);
|
|
||||||
|
|
||||||
auto buffer = castToObject<Buffer>(imageDesc.mem_object);
|
|
||||||
|
|
||||||
ASSERT_NE(nullptr, buffer);
|
|
||||||
EXPECT_EQ(1, buffer->getRefInternalCount());
|
|
||||||
|
|
||||||
std::unique_ptr<Image> imageFromBuffer(createImage());
|
|
||||||
ASSERT_EQ(CL_SUCCESS, retVal);
|
|
||||||
|
|
||||||
//graphics allocation for image and buffer is the same
|
|
||||||
auto bufferGraphicsAllocation = buffer->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex());
|
|
||||||
auto imageGraphicsAllocation = imageFromBuffer->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex());
|
|
||||||
|
|
||||||
EXPECT_EQ(this->size, bufferGraphicsAllocation->getUnderlyingBufferSize());
|
|
||||||
|
|
||||||
auto imageDescriptor = Image::convertDescriptor(imageDesc);
|
|
||||||
auto imgInfo = MockGmm::initImgInfo(imageDescriptor, 0, &imageFromBuffer->getSurfaceFormatInfo().surfaceFormat);
|
|
||||||
auto queryGmm = MockGmm::queryImgParams(context.getDevice(0)->getGmmHelper(), imgInfo, false);
|
|
||||||
|
|
||||||
EXPECT_TRUE(queryGmm->gmmResourceInfo->getSizeAllocation() >= this->size);
|
|
||||||
|
|
||||||
EXPECT_EQ(bufferGraphicsAllocation, imageGraphicsAllocation);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(Image2dFromBufferTest, givenMemoryManagerSupportingVirtualPaddingWhenImageIsCreatedFromLocalMemoryBufferThenPaddingIsNotApplied) {
|
|
||||||
auto memoryManager = context.getMemoryManager();
|
|
||||||
memoryManager->setVirtualPaddingSupport(true);
|
|
||||||
|
|
||||||
auto buffer = castToObject<Buffer>(imageDesc.mem_object);
|
|
||||||
|
|
||||||
uint64_t gpuAddress = 0x1234;
|
|
||||||
auto cpuAddress = buffer->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex())->getUnderlyingBuffer();
|
|
||||||
auto gmmHelper = context.getDevice(0)->getGmmHelper();
|
|
||||||
auto canonizedGpuAddress = gmmHelper->canonize(gpuAddress);
|
|
||||||
|
|
||||||
buffer->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex())->setCpuPtrAndGpuAddress(0, canonizedGpuAddress);
|
|
||||||
|
|
||||||
ASSERT_NE(nullptr, buffer);
|
|
||||||
EXPECT_EQ(1, buffer->getRefInternalCount());
|
|
||||||
|
|
||||||
std::unique_ptr<Image> imageFromBuffer(createImage());
|
|
||||||
ASSERT_EQ(CL_SUCCESS, retVal);
|
|
||||||
|
|
||||||
//graphics allocation for image and buffer is the same
|
|
||||||
auto bufferGraphicsAllocation = buffer->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex());
|
|
||||||
auto imageGraphicsAllocation = imageFromBuffer->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex());
|
|
||||||
|
|
||||||
EXPECT_EQ(this->size, bufferGraphicsAllocation->getUnderlyingBufferSize());
|
|
||||||
|
|
||||||
auto imageDescriptor = Image::convertDescriptor(imageDesc);
|
|
||||||
auto imgInfo = MockGmm::initImgInfo(imageDescriptor, 0, &imageFromBuffer->getSurfaceFormatInfo().surfaceFormat);
|
|
||||||
auto queryGmm = MockGmm::queryImgParams(context.getDevice(0)->getGmmHelper(), imgInfo, false);
|
|
||||||
|
|
||||||
EXPECT_TRUE(queryGmm->gmmResourceInfo->getSizeAllocation() >= this->size);
|
|
||||||
|
|
||||||
EXPECT_EQ(bufferGraphicsAllocation, imageGraphicsAllocation);
|
|
||||||
|
|
||||||
buffer->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex())->setCpuPtrAndGpuAddress(cpuAddress, canonizedGpuAddress);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(Image2dFromBufferTest, givenMemoryManagerSupportingVirtualPaddingWhenImageIsCreatedThatDoesntFitInTheBufferThenPaddingIsApplied) {
|
|
||||||
imageFormat.image_channel_data_type = CL_FLOAT;
|
|
||||||
imageFormat.image_channel_order = CL_RGBA;
|
|
||||||
imageDesc.image_width = 29;
|
|
||||||
imageDesc.image_height = 29;
|
|
||||||
imageDesc.image_row_pitch = 512;
|
|
||||||
|
|
||||||
//application calcualted buffer size
|
|
||||||
auto bufferSize = imageDesc.image_row_pitch * imageDesc.image_height;
|
|
||||||
auto buffer2 = clCreateBuffer(&context, CL_MEM_READ_WRITE, bufferSize, nullptr, nullptr);
|
|
||||||
|
|
||||||
auto storeMem = imageDesc.mem_object;
|
|
||||||
|
|
||||||
imageDesc.mem_object = buffer2;
|
|
||||||
|
|
||||||
auto memoryManager = context.getMemoryManager();
|
|
||||||
memoryManager->setVirtualPaddingSupport(true);
|
|
||||||
|
|
||||||
auto buffer = castToObject<Buffer>(imageDesc.mem_object);
|
|
||||||
|
|
||||||
std::unique_ptr<Image> imageFromBuffer(createImage());
|
|
||||||
ASSERT_EQ(CL_SUCCESS, retVal);
|
|
||||||
|
|
||||||
//graphics allocation for image and buffer is the same
|
|
||||||
auto bufferGraphicsAllocation = buffer->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex());
|
|
||||||
auto imageGraphicsAllocation = imageFromBuffer->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex());
|
|
||||||
|
|
||||||
EXPECT_EQ(bufferSize, bufferGraphicsAllocation->getUnderlyingBufferSize());
|
|
||||||
|
|
||||||
auto imageDescriptor = Image::convertDescriptor(imageDesc);
|
|
||||||
auto imgInfo = MockGmm::initImgInfo(imageDescriptor, 0, &imageFromBuffer->getSurfaceFormatInfo().surfaceFormat);
|
|
||||||
auto queryGmm = MockGmm::queryImgParams(context.getDevice(0)->getGmmHelper(), imgInfo, false);
|
|
||||||
|
|
||||||
EXPECT_GT(queryGmm->gmmResourceInfo->getSizeAllocation(), bufferSize);
|
|
||||||
|
|
||||||
EXPECT_NE(bufferGraphicsAllocation, imageGraphicsAllocation);
|
|
||||||
EXPECT_EQ(queryGmm->gmmResourceInfo->getSizeAllocation(), imageFromBuffer->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex())->getUnderlyingBufferSize());
|
|
||||||
EXPECT_EQ(bufferSize, imageFromBuffer->getSize());
|
|
||||||
imageDesc.mem_object = storeMem;
|
|
||||||
clReleaseMemObject(buffer2);
|
|
||||||
}
|
|
||||||
TEST_F(Image2dFromBufferTest, givenMemoryManagerSupportingVirtualPaddingWhen1DImageFromBufferImageIsCreatedThenVirtualPaddingIsNotApplied) {
|
|
||||||
imageFormat.image_channel_data_type = CL_FLOAT;
|
|
||||||
imageFormat.image_channel_order = CL_RGBA;
|
|
||||||
imageDesc.image_width = 1024;
|
|
||||||
imageDesc.image_type = CL_MEM_OBJECT_IMAGE1D_BUFFER;
|
|
||||||
|
|
||||||
//application calcualted buffer size
|
|
||||||
auto bufferSize = imageDesc.image_width * 16;
|
|
||||||
auto buffer2 = clCreateBuffer(&context, CL_MEM_READ_WRITE, bufferSize, nullptr, nullptr);
|
|
||||||
auto storeMem = imageDesc.mem_object;
|
|
||||||
imageDesc.mem_object = buffer2;
|
|
||||||
|
|
||||||
auto memoryManager = context.getMemoryManager();
|
|
||||||
memoryManager->setVirtualPaddingSupport(true);
|
|
||||||
|
|
||||||
auto buffer = castToObject<Buffer>(imageDesc.mem_object);
|
|
||||||
|
|
||||||
std::unique_ptr<Image> imageFromBuffer(createImage());
|
|
||||||
ASSERT_EQ(CL_SUCCESS, retVal);
|
|
||||||
|
|
||||||
//graphics allocation match
|
|
||||||
auto bufferGraphicsAllocation = buffer->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex());
|
|
||||||
auto imageGraphicsAllocation = imageFromBuffer->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex());
|
|
||||||
|
|
||||||
EXPECT_EQ(bufferGraphicsAllocation, imageGraphicsAllocation);
|
|
||||||
imageDesc.mem_object = storeMem;
|
|
||||||
clReleaseMemObject(buffer2);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(Image2dFromBufferTest, givenMemoryManagerSupporting1DImageFromBufferWhenNoBufferThenCreatesImage) {
|
TEST_F(Image2dFromBufferTest, givenMemoryManagerSupporting1DImageFromBufferWhenNoBufferThenCreatesImage) {
|
||||||
|
|
||||||
imageDesc.image_type = CL_MEM_OBJECT_IMAGE1D_BUFFER;
|
imageDesc.image_type = CL_MEM_OBJECT_IMAGE1D_BUFFER;
|
||||||
|
@ -1241,20 +1241,6 @@ TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerWhenGraphicsAllocationCon
|
|||||||
memoryManager.freeGraphicsMemory(graphicsAllocation);
|
memoryManager.freeGraphicsMemory(graphicsAllocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerWhenGraphicsAllocationIsPaddedThenNewGraphicsAllocationIsCreated) {
|
|
||||||
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
|
||||||
MemoryManagerCreate<OsAgnosticMemoryManager> memoryManager(false, false, executionEnvironment);
|
|
||||||
auto graphicsAllocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{0, MemoryConstants::pageSize});
|
|
||||||
|
|
||||||
auto sizeWithPadding = 8192;
|
|
||||||
auto paddedGraphicsAllocation = memoryManager.createGraphicsAllocationWithPadding(graphicsAllocation, sizeWithPadding);
|
|
||||||
ASSERT_NE(nullptr, paddedGraphicsAllocation);
|
|
||||||
EXPECT_NE(paddedGraphicsAllocation, graphicsAllocation);
|
|
||||||
|
|
||||||
memoryManager.freeGraphicsMemory(paddedGraphicsAllocation);
|
|
||||||
memoryManager.freeGraphicsMemory(graphicsAllocation);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(OsAgnosticMemoryManager, WhenPointerIsCreatedThenLeakIsDetected) {
|
TEST(OsAgnosticMemoryManager, WhenPointerIsCreatedThenLeakIsDetected) {
|
||||||
void *ptr = new int[10];
|
void *ptr = new int[10];
|
||||||
EXPECT_NE(nullptr, ptr); // NOLINT(clang-analyzer-cplusplus.NewDeleteLeaks)
|
EXPECT_NE(nullptr, ptr); // NOLINT(clang-analyzer-cplusplus.NewDeleteLeaks)
|
||||||
|
@ -2855,41 +2855,6 @@ TEST_F(DrmMemoryManagerTest, givenSharedAllocationWithSmallerThenRealSizeWhenCre
|
|||||||
memoryManager->freeGraphicsMemory(graphicsAllocation);
|
memoryManager->freeGraphicsMemory(graphicsAllocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(DrmMemoryManagerTest, givenMemoryManagerSupportingVirutalPaddingWhenItIsRequiredThenNewGraphicsAllocationIsCreated) {
|
|
||||||
mock->ioctl_expected.gemUserptr = 2;
|
|
||||||
mock->ioctl_expected.gemWait = 2;
|
|
||||||
mock->ioctl_expected.gemClose = 2;
|
|
||||||
// first let's create normal buffer
|
|
||||||
auto bufferSize = MemoryConstants::pageSize;
|
|
||||||
auto buffer = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{rootDeviceIndex, bufferSize});
|
|
||||||
|
|
||||||
// buffer should have size 16
|
|
||||||
EXPECT_EQ(bufferSize, buffer->getUnderlyingBufferSize());
|
|
||||||
|
|
||||||
auto bufferWithPaddingSize = 8192u;
|
|
||||||
auto paddedAllocation = memoryManager->createGraphicsAllocationWithPadding(buffer, 8192u);
|
|
||||||
EXPECT_NE(nullptr, paddedAllocation);
|
|
||||||
|
|
||||||
EXPECT_NE(0u, paddedAllocation->getGpuAddress());
|
|
||||||
EXPECT_NE(0u, paddedAllocation->getGpuAddressToPatch());
|
|
||||||
EXPECT_NE(buffer->getGpuAddress(), paddedAllocation->getGpuAddress());
|
|
||||||
EXPECT_NE(buffer->getGpuAddressToPatch(), paddedAllocation->getGpuAddressToPatch());
|
|
||||||
EXPECT_EQ(buffer->getUnderlyingBuffer(), paddedAllocation->getUnderlyingBuffer());
|
|
||||||
|
|
||||||
EXPECT_EQ(bufferWithPaddingSize, paddedAllocation->getUnderlyingBufferSize());
|
|
||||||
EXPECT_FALSE(paddedAllocation->isCoherent());
|
|
||||||
EXPECT_EQ(0u, paddedAllocation->fragmentsStorage.fragmentCount);
|
|
||||||
|
|
||||||
auto bufferbo = static_cast<DrmAllocation *>(buffer)->getBO();
|
|
||||||
auto bo = static_cast<DrmAllocation *>(paddedAllocation)->getBO();
|
|
||||||
EXPECT_NE(nullptr, bo);
|
|
||||||
|
|
||||||
EXPECT_NE(bufferbo->peekHandle(), bo->peekHandle());
|
|
||||||
|
|
||||||
memoryManager->freeGraphicsMemory(paddedAllocation);
|
|
||||||
memoryManager->freeGraphicsMemory(buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(DrmMemoryManagerTest, givenMemoryManagerWhenAskedForInternalAllocationWithNoPointerThenAllocationFromInternalHeapIsReturned) {
|
TEST_F(DrmMemoryManagerTest, givenMemoryManagerWhenAskedForInternalAllocationWithNoPointerThenAllocationFromInternalHeapIsReturned) {
|
||||||
mock->ioctl_expected.gemUserptr = 1;
|
mock->ioctl_expected.gemUserptr = 1;
|
||||||
mock->ioctl_expected.gemWait = 1;
|
mock->ioctl_expected.gemWait = 1;
|
||||||
@ -3008,28 +2973,6 @@ TEST_F(DrmMemoryManagerTest, givenMemoryManagerWhenAskedForInternalAllocationWit
|
|||||||
memoryManager->freeGraphicsMemory(drmAllocation);
|
memoryManager->freeGraphicsMemory(drmAllocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(DrmMemoryManagerTest, givenMemoryManagerSupportingVirutalPaddingWhenAllocUserptrFailsThenReturnsNullptr) {
|
|
||||||
mock->ioctl_expected.gemUserptr = 2;
|
|
||||||
mock->ioctl_expected.gemWait = 1;
|
|
||||||
mock->ioctl_expected.gemClose = 1;
|
|
||||||
this->ioctlResExt = {mock->ioctl_cnt.total + 1, -1};
|
|
||||||
mock->ioctl_res_ext = &ioctlResExt;
|
|
||||||
|
|
||||||
// first let's create normal buffer
|
|
||||||
auto bufferSize = MemoryConstants::pageSize;
|
|
||||||
auto buffer = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{rootDeviceIndex, bufferSize});
|
|
||||||
|
|
||||||
// buffer should have size 16
|
|
||||||
EXPECT_EQ(bufferSize, buffer->getUnderlyingBufferSize());
|
|
||||||
|
|
||||||
auto bufferWithPaddingSize = 8192u;
|
|
||||||
auto paddedAllocation = memoryManager->createGraphicsAllocationWithPadding(buffer, bufferWithPaddingSize);
|
|
||||||
EXPECT_EQ(nullptr, paddedAllocation);
|
|
||||||
|
|
||||||
memoryManager->freeGraphicsMemory(buffer);
|
|
||||||
mock->ioctl_res_ext = &mock->NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
using DrmMemoryManagerUSMHostAllocationTests = Test<DrmMemoryManagerFixture>;
|
using DrmMemoryManagerUSMHostAllocationTests = Test<DrmMemoryManagerFixture>;
|
||||||
|
|
||||||
TEST_F(DrmMemoryManagerUSMHostAllocationTests, givenCallToAllocateGraphicsMemoryWithAlignmentWithIsHostUsmAllocationSetToFalseThenNewHostPointerIsUsedAndAllocationIsCreatedSuccesfully) {
|
TEST_F(DrmMemoryManagerUSMHostAllocationTests, givenCallToAllocateGraphicsMemoryWithAlignmentWithIsHostUsmAllocationSetToFalseThenNewHostPointerIsUsedAndAllocationIsCreatedSuccesfully) {
|
||||||
@ -3101,10 +3044,6 @@ TEST_F(DrmMemoryManagerUSMHostAllocationTests,
|
|||||||
alignedFree(hostPtr);
|
alignedFree(hostPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenDefaultDrmMemoryManagerWhenAskedForVirtualPaddingSupportThenTrueIsReturned) {
|
|
||||||
EXPECT_FALSE(memoryManager->peekVirtualPaddingSupport());
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenDefaultDrmMemoryManagerWhenAskedForAlignedMallocRestrictionsThenNullPtrIsReturned) {
|
TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenDefaultDrmMemoryManagerWhenAskedForAlignedMallocRestrictionsThenNullPtrIsReturned) {
|
||||||
EXPECT_EQ(nullptr, memoryManager->getAlignedMallocRestrictions());
|
EXPECT_EQ(nullptr, memoryManager->getAlignedMallocRestrictions());
|
||||||
}
|
}
|
||||||
@ -5775,51 +5714,6 @@ TEST_F(DrmMemoryManagerTest, givenDrmWhenRetrieveMmapOffsetForBufferObjectIsCall
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(DrmMemoryManagerTest, whenCallPaddedAllocationWithoutMmapPtrThenOnlyUserptrCalled) {
|
|
||||||
mock->ioctl_expected.gemUserptr = 1;
|
|
||||||
mock->ioctl_expected.gemClose = 1;
|
|
||||||
|
|
||||||
void *cpuPtr = (void *)0x30000;
|
|
||||||
size_t size = 0x1000;
|
|
||||||
DrmAllocation gfxAllocation(rootDeviceIndex, AllocationType::UNKNOWN, nullptr, cpuPtr, size, (osHandle)1u, MemoryPool::MemoryNull);
|
|
||||||
auto gfxPaddedAllocation = memoryManager->createPaddedAllocation(&gfxAllocation, size);
|
|
||||||
ASSERT_NE(nullptr, gfxPaddedAllocation);
|
|
||||||
memoryManager->freeGraphicsMemoryImpl(gfxPaddedAllocation);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(DrmMemoryManagerTest, whenCallPaddedAllocationWithMmapPtrThenMmapCalled) {
|
|
||||||
mock->ioctl_expected.gemMmap = 1;
|
|
||||||
mock->ioctl_expected.gemUserptr = 1;
|
|
||||||
mock->ioctl_expected.gemClose = 1;
|
|
||||||
BufferObject bo(mock, 3, 1, 1024, 0);
|
|
||||||
|
|
||||||
void *cpuPtr = (void *)0x30000;
|
|
||||||
size_t size = 0x1000;
|
|
||||||
DrmAllocation gfxAllocation(rootDeviceIndex, AllocationType::UNKNOWN, &bo, cpuPtr, size, (osHandle)1u, MemoryPool::MemoryNull);
|
|
||||||
gfxAllocation.setMmapPtr(cpuPtr);
|
|
||||||
gfxAllocation.setMmapSize(size);
|
|
||||||
auto gfxPaddedAllocation = memoryManager->createPaddedAllocation(&gfxAllocation, size);
|
|
||||||
ASSERT_NE(nullptr, gfxPaddedAllocation);
|
|
||||||
EXPECT_TRUE(gfxAllocation.isLocked());
|
|
||||||
memoryManager->freeGraphicsMemoryImpl(gfxPaddedAllocation);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(DrmMemoryManagerTest, whenCallPaddedAllocationWithMmapPtrAndFailedMmapCalledThenReturnNullptr) {
|
|
||||||
mock->ioctl_expected.gemMmap = 1;
|
|
||||||
mock->ioctl_res = -1;
|
|
||||||
|
|
||||||
BufferObject bo(mock, 3, 1, 1024, 0);
|
|
||||||
|
|
||||||
void *cpuPtr = (void *)0x30000;
|
|
||||||
size_t size = 0x1000;
|
|
||||||
DrmAllocation gfxAllocation(rootDeviceIndex, AllocationType::UNKNOWN, &bo, cpuPtr, size, (osHandle)1u, MemoryPool::MemoryNull);
|
|
||||||
gfxAllocation.setMmapPtr(cpuPtr);
|
|
||||||
gfxAllocation.setMmapSize(size);
|
|
||||||
auto gfxPaddedAllocation = memoryManager->createPaddedAllocation(&gfxAllocation, size);
|
|
||||||
ASSERT_EQ(nullptr, gfxPaddedAllocation);
|
|
||||||
mock->ioctl_res = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(DrmMemoryManagerTest, GivenEligbleAllocationTypeWhenCheckingAllocationEligbleForCompletionFenceThenReturnTrue) {
|
TEST_F(DrmMemoryManagerTest, GivenEligbleAllocationTypeWhenCheckingAllocationEligbleForCompletionFenceThenReturnTrue) {
|
||||||
AllocationType validAllocations[] = {
|
AllocationType validAllocations[] = {
|
||||||
AllocationType::COMMAND_BUFFER,
|
AllocationType::COMMAND_BUFFER,
|
||||||
|
@ -569,10 +569,6 @@ TEST_F(WddmMemoryManagerSimpleTest, givenWddmMemoryManagerWhenAllocatingWithGpuV
|
|||||||
EXPECT_EQ(nullptr, allocation);
|
EXPECT_EQ(nullptr, allocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(WddmMemoryManagerTest, givenDefaultWddmMemoryManagerWhenAskedForVirtualPaddingSupportThenFalseIsReturned) {
|
|
||||||
EXPECT_FALSE(memoryManager->peekVirtualPaddingSupport());
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(WddmMemoryManagerTest, GivenGraphicsAllocationWhenAddAndRemoveAllocationToHostPtrManagerThenFragmentHasCorrectValues) {
|
TEST_F(WddmMemoryManagerTest, GivenGraphicsAllocationWhenAddAndRemoveAllocationToHostPtrManagerThenFragmentHasCorrectValues) {
|
||||||
void *cpuPtr = (void *)0x30000;
|
void *cpuPtr = (void *)0x30000;
|
||||||
size_t size = 0x1000;
|
size_t size = 0x1000;
|
||||||
|
@ -129,10 +129,6 @@ void Gmm::setupImageResourceParams(ImageInfo &imgInfo, bool preferCompressed) {
|
|||||||
resourceParams.ArraySize = imageCount;
|
resourceParams.ArraySize = imageCount;
|
||||||
resourceParams.Flags.Wa.__ForceOtherHVALIGN4 = hwHelper.hvAlign4Required();
|
resourceParams.Flags.Wa.__ForceOtherHVALIGN4 = hwHelper.hvAlign4Required();
|
||||||
resourceParams.MaxLod = imgInfo.baseMipLevel + imgInfo.mipCount;
|
resourceParams.MaxLod = imgInfo.baseMipLevel + imgInfo.mipCount;
|
||||||
if (imgInfo.imgDesc.imageRowPitch && imgInfo.imgDesc.fromParent) {
|
|
||||||
resourceParams.OverridePitch = (uint32_t)imgInfo.imgDesc.imageRowPitch;
|
|
||||||
resourceParams.Flags.Info.AllowVirtualPadding = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
applyAuxFlagsForImage(imgInfo, preferCompressed);
|
applyAuxFlagsForImage(imgInfo, preferCompressed);
|
||||||
}
|
}
|
||||||
|
@ -139,14 +139,6 @@ void MemoryManager::cleanGraphicsMemoryCreatedFromHostPtr(GraphicsAllocation *gr
|
|||||||
cleanOsHandles(graphicsAllocation->fragmentsStorage, graphicsAllocation->getRootDeviceIndex());
|
cleanOsHandles(graphicsAllocation->fragmentsStorage, graphicsAllocation->getRootDeviceIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphicsAllocation *MemoryManager::createGraphicsAllocationWithPadding(GraphicsAllocation *inputGraphicsAllocation, size_t sizeWithPadding) {
|
|
||||||
return createPaddedAllocation(inputGraphicsAllocation, sizeWithPadding);
|
|
||||||
}
|
|
||||||
|
|
||||||
GraphicsAllocation *MemoryManager::createPaddedAllocation(GraphicsAllocation *inputGraphicsAllocation, size_t sizeWithPadding) {
|
|
||||||
return allocateGraphicsMemoryWithProperties({inputGraphicsAllocation->getRootDeviceIndex(), sizeWithPadding, AllocationType::INTERNAL_HOST_MEMORY, systemMemoryBitfield});
|
|
||||||
}
|
|
||||||
|
|
||||||
void *MemoryManager::createMultiGraphicsAllocationInSystemMemoryPool(RootDeviceIndicesContainer &rootDeviceIndices, AllocationProperties &properties, MultiGraphicsAllocation &multiGraphicsAllocation, void *ptr) {
|
void *MemoryManager::createMultiGraphicsAllocationInSystemMemoryPool(RootDeviceIndicesContainer &rootDeviceIndices, AllocationProperties &properties, MultiGraphicsAllocation &multiGraphicsAllocation, void *ptr) {
|
||||||
properties.flags.forceSystemMemory = true;
|
properties.flags.forceSystemMemory = true;
|
||||||
for (auto &rootDeviceIndex : rootDeviceIndices) {
|
for (auto &rootDeviceIndex : rootDeviceIndices) {
|
||||||
|
@ -114,8 +114,6 @@ class MemoryManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void cleanGraphicsMemoryCreatedFromHostPtr(GraphicsAllocation *);
|
void cleanGraphicsMemoryCreatedFromHostPtr(GraphicsAllocation *);
|
||||||
GraphicsAllocation *createGraphicsAllocationWithPadding(GraphicsAllocation *inputGraphicsAllocation, size_t sizeWithPadding);
|
|
||||||
virtual GraphicsAllocation *createPaddedAllocation(GraphicsAllocation *inputGraphicsAllocation, size_t sizeWithPadding);
|
|
||||||
|
|
||||||
MOCKABLE_VIRTUAL void *createMultiGraphicsAllocationInSystemMemoryPool(RootDeviceIndicesContainer &rootDeviceIndices, AllocationProperties &properties, MultiGraphicsAllocation &multiGraphicsAllocation, void *ptr);
|
MOCKABLE_VIRTUAL void *createMultiGraphicsAllocationInSystemMemoryPool(RootDeviceIndicesContainer &rootDeviceIndices, AllocationProperties &properties, MultiGraphicsAllocation &multiGraphicsAllocation, void *ptr);
|
||||||
MOCKABLE_VIRTUAL void *createMultiGraphicsAllocationInSystemMemoryPool(RootDeviceIndicesContainer &rootDeviceIndices, AllocationProperties &properties, MultiGraphicsAllocation &multiGraphicsAllocation) {
|
MOCKABLE_VIRTUAL void *createMultiGraphicsAllocationInSystemMemoryPool(RootDeviceIndicesContainer &rootDeviceIndices, AllocationProperties &properties, MultiGraphicsAllocation &multiGraphicsAllocation) {
|
||||||
@ -150,9 +148,6 @@ class MemoryManager {
|
|||||||
bool peekForce32BitAllocations() const { return force32bitAllocations; }
|
bool peekForce32BitAllocations() const { return force32bitAllocations; }
|
||||||
void setForce32BitAllocations(bool newValue) { force32bitAllocations = newValue; }
|
void setForce32BitAllocations(bool newValue) { force32bitAllocations = newValue; }
|
||||||
|
|
||||||
bool peekVirtualPaddingSupport() const { return virtualPaddingAvailable; }
|
|
||||||
void setVirtualPaddingSupport(bool virtualPaddingSupport) { virtualPaddingAvailable = virtualPaddingSupport; }
|
|
||||||
|
|
||||||
DeferredDeleter *getDeferredDeleter() const {
|
DeferredDeleter *getDeferredDeleter() const {
|
||||||
return deferredDeleter.get();
|
return deferredDeleter.get();
|
||||||
}
|
}
|
||||||
@ -302,7 +297,6 @@ class MemoryManager {
|
|||||||
bool initialized = false;
|
bool initialized = false;
|
||||||
bool forceNonSvmForExternalHostPtr = false;
|
bool forceNonSvmForExternalHostPtr = false;
|
||||||
bool force32bitAllocations = false;
|
bool force32bitAllocations = false;
|
||||||
bool virtualPaddingAvailable = false;
|
|
||||||
std::unique_ptr<DeferredDeleter> deferredDeleter;
|
std::unique_ptr<DeferredDeleter> deferredDeleter;
|
||||||
bool asyncDeleterEnabled = false;
|
bool asyncDeleterEnabled = false;
|
||||||
std::vector<bool> enable64kbpages;
|
std::vector<bool> enable64kbpages;
|
||||||
|
@ -848,48 +848,6 @@ void DrmMemoryManager::closeSharedHandle(GraphicsAllocation *gfxAllocation) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphicsAllocation *DrmMemoryManager::createPaddedAllocation(GraphicsAllocation *inputGraphicsAllocation, size_t sizeWithPadding) {
|
|
||||||
uint64_t gpuRange = 0llu;
|
|
||||||
|
|
||||||
auto rootDeviceIndex = inputGraphicsAllocation->getRootDeviceIndex();
|
|
||||||
gpuRange = acquireGpuRange(sizeWithPadding, rootDeviceIndex, HeapIndex::HEAP_STANDARD);
|
|
||||||
|
|
||||||
void *srcPtr = nullptr;
|
|
||||||
auto drmInputAllocation = static_cast<DrmAllocation *>(inputGraphicsAllocation);
|
|
||||||
if (drmInputAllocation->getMmapPtr()) {
|
|
||||||
auto bo = drmInputAllocation->getBO();
|
|
||||||
GemMmap mmapArg = {};
|
|
||||||
mmapArg.handle = bo->peekHandle();
|
|
||||||
mmapArg.size = bo->peekSize();
|
|
||||||
if (getDrm(rootDeviceIndex).ioctl(DrmIoctl::GemMmap, &mmapArg) != 0) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
srcPtr = addrToPtr(mmapArg.addrPtr);
|
|
||||||
inputGraphicsAllocation->lock(srcPtr);
|
|
||||||
} else {
|
|
||||||
srcPtr = inputGraphicsAllocation->getUnderlyingBuffer();
|
|
||||||
}
|
|
||||||
auto srcSize = inputGraphicsAllocation->getUnderlyingBufferSize();
|
|
||||||
auto alignedSrcSize = alignUp(srcSize, MemoryConstants::pageSize);
|
|
||||||
auto alignedPtr = reinterpret_cast<uintptr_t>(alignDown(srcPtr, MemoryConstants::pageSize));
|
|
||||||
auto offset = ptrDiff(srcPtr, alignedPtr);
|
|
||||||
|
|
||||||
std::unique_ptr<BufferObject, BufferObject::Deleter> bo(allocUserptr(alignedPtr, alignedSrcSize, rootDeviceIndex));
|
|
||||||
if (!bo) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
bo->setAddress(gpuRange);
|
|
||||||
auto gmmHelper = getGmmHelper(rootDeviceIndex);
|
|
||||||
auto canonizedGpuAddress = gmmHelper->canonize(ptrOffset(gpuRange, offset));
|
|
||||||
auto allocation = new DrmAllocation(rootDeviceIndex, inputGraphicsAllocation->getAllocationType(), bo.get(), srcPtr,
|
|
||||||
canonizedGpuAddress, sizeWithPadding,
|
|
||||||
inputGraphicsAllocation->getMemoryPool());
|
|
||||||
|
|
||||||
allocation->setReservedAddressRange(reinterpret_cast<void *>(gpuRange), sizeWithPadding);
|
|
||||||
bo.release();
|
|
||||||
return allocation;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DrmMemoryManager::addAllocationToHostPtrManager(GraphicsAllocation *gfxAllocation) {
|
void DrmMemoryManager::addAllocationToHostPtrManager(GraphicsAllocation *gfxAllocation) {
|
||||||
DrmAllocation *drmMemory = static_cast<DrmAllocation *>(gfxAllocation);
|
DrmAllocation *drmMemory = static_cast<DrmAllocation *>(gfxAllocation);
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ class DrmMemoryManager : public MemoryManager {
|
|||||||
GraphicsAllocation *createGraphicsAllocationFromMultipleSharedHandles(std::vector<osHandle> handles, AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation) override;
|
GraphicsAllocation *createGraphicsAllocationFromMultipleSharedHandles(std::vector<osHandle> handles, AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation) override;
|
||||||
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation) override;
|
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation) override;
|
||||||
void closeSharedHandle(GraphicsAllocation *gfxAllocation) override;
|
void closeSharedHandle(GraphicsAllocation *gfxAllocation) override;
|
||||||
GraphicsAllocation *createPaddedAllocation(GraphicsAllocation *inputGraphicsAllocation, size_t sizeWithPadding) override;
|
|
||||||
GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex, AllocationType allocType) override { return nullptr; }
|
GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex, AllocationType allocType) override { return nullptr; }
|
||||||
|
|
||||||
uint64_t getSystemSharedMemory(uint32_t rootDeviceIndex) override;
|
uint64_t getSystemSharedMemory(uint32_t rootDeviceIndex) override;
|
||||||
|
@ -74,12 +74,8 @@ GMM_STATUS MockGmmResourceInfo::getOffset(GMM_REQ_OFFSET_INFO &reqOffsetInfo) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MockGmmResourceInfo::computeRowPitch() {
|
void MockGmmResourceInfo::computeRowPitch() {
|
||||||
if (mockResourceCreateParams.OverridePitch) {
|
rowPitch = static_cast<size_t>(mockResourceCreateParams.BaseWidth64 * (surfaceFormatInfo->ImageElementSizeInBytes));
|
||||||
rowPitch = mockResourceCreateParams.OverridePitch;
|
rowPitch = alignUp(rowPitch, 64);
|
||||||
} else {
|
|
||||||
rowPitch = static_cast<size_t>(mockResourceCreateParams.BaseWidth64 * (surfaceFormatInfo->ImageElementSizeInBytes));
|
|
||||||
rowPitch = alignUp(rowPitch, 64);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t MockGmmResourceInfo::getBitsPerPixel() {
|
uint32_t MockGmmResourceInfo::getBitsPerPixel() {
|
||||||
|
Reference in New Issue
Block a user