Skip to content

Commit b04fc11

Browse files
Apply memory flag when creating Gmm with image info
Resolves: NEO-3294 Change-Id: I2702611c5b3b2ccd8d48219b90479a6fd3fbe1f7 Signed-off-by: Mateusz Jablonski <[email protected]>
1 parent cf78aab commit b04fc11

File tree

9 files changed

+14
-13
lines changed

9 files changed

+14
-13
lines changed

runtime/gmm_helper/gmm.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,10 @@ Gmm::Gmm(GMM_RESOURCE_INFO *inputGmm) {
5656
gmmResourceInfo.reset(GmmResourceInfo::create(inputGmm));
5757
}
5858

59-
Gmm::Gmm(ImageInfo &inputOutputImgInfo) {
59+
Gmm::Gmm(ImageInfo &inputOutputImgInfo, StorageInfo storageInfo) {
6060
this->resourceParams = {};
6161
setupImageResourceParams(inputOutputImgInfo);
62+
applyMemoryFlags(!inputOutputImgInfo.useLocalMemory, storageInfo);
6263
this->gmmResourceInfo.reset(GmmResourceInfo::create(&this->resourceParams));
6364
UNRECOVERABLE_IF(this->gmmResourceInfo == nullptr);
6465

runtime/gmm_helper/gmm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Gmm {
2525
public:
2626
virtual ~Gmm() = default;
2727
Gmm() = delete;
28-
Gmm(ImageInfo &inputOutputImgInfo);
28+
Gmm(ImageInfo &inputOutputImgInfo, StorageInfo storageInfo);
2929
Gmm(const void *alignedPtr, size_t alignedSize, bool uncacheable);
3030
Gmm(const void *alignedPtr, size_t alignedSize, bool uncacheable, bool preferRenderCompressed, bool systemMemoryPool, StorageInfo storageInfo);
3131
Gmm(GMM_RESOURCE_INFO *inputGmm);

runtime/mem_obj/image.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ Image *Image::create(Context *context,
208208
if (memoryManager->peekVirtualPaddingSupport() && (imageDesc->image_type == CL_MEM_OBJECT_IMAGE2D)) {
209209
// Retrieve sizes from GMM and apply virtual padding if buffer storage is not big enough
210210
auto queryGmmImgInfo(imgInfo);
211-
std::unique_ptr<Gmm> gmm(new Gmm(queryGmmImgInfo));
211+
std::unique_ptr<Gmm> gmm(new Gmm(queryGmmImgInfo, StorageInfo{}));
212212
auto gmmAllocationSize = gmm->gmmResourceInfo->getSizeAllocation();
213213
if (gmmAllocationSize > memory->getUnderlyingBufferSize()) {
214214
memory = memoryManager->createGraphicsAllocationWithPadding(memory, gmmAllocationSize);
@@ -236,7 +236,7 @@ Image *Image::create(Context *context,
236236
}
237237
}
238238
} else {
239-
gmm = new Gmm(imgInfo);
239+
gmm = new Gmm(imgInfo, StorageInfo{});
240240
memory = memoryManager->allocateGraphicsMemoryWithProperties({false, imgInfo.size, GraphicsAllocation::AllocationType::SHARED_CONTEXT_IMAGE}, hostPtr);
241241
memory->setDefaultGmm(gmm);
242242
zeroCopy = true;
@@ -646,7 +646,7 @@ cl_int Image::getImageParams(Context *context,
646646
imgInfo.imgDesc = &imageDescriptor;
647647
imgInfo.surfaceFormat = surfaceFormat;
648648

649-
std::unique_ptr<Gmm> gmm(new Gmm(imgInfo)); // query imgInfo
649+
std::unique_ptr<Gmm> gmm(new Gmm(imgInfo, StorageInfo{})); // query imgInfo
650650

651651
*imageRowPitch = imgInfo.rowPitch;
652652
*imageSlicePitch = imgInfo.slicePitch;

runtime/memory_manager/memory_manager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ GraphicsAllocation *MemoryManager::allocateGraphicsMemory(const AllocationData &
355355
}
356356

357357
GraphicsAllocation *MemoryManager::allocateGraphicsMemoryForImage(const AllocationData &allocationData) {
358-
auto gmm = std::make_unique<Gmm>(*allocationData.imgInfo);
358+
auto gmm = std::make_unique<Gmm>(*allocationData.imgInfo, allocationData.storageInfo);
359359

360360
// AllocationData needs to be reconfigured for System Memory paths
361361
AllocationData allocationDataWithSize = allocationData;

runtime/memory_manager/os_agnostic_memory_manager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ GraphicsAllocation *OsAgnosticMemoryManager::createGraphicsAllocationFromSharedH
145145
graphicsAllocation->set32BitAllocation(requireSpecificBitness);
146146

147147
if (properties.imgInfo) {
148-
Gmm *gmm = new Gmm(*properties.imgInfo);
148+
Gmm *gmm = new Gmm(*properties.imgInfo, createStorageInfoFromProperties(properties));
149149
graphicsAllocation->setDefaultGmm(gmm);
150150
}
151151

runtime/os_interface/linux/drm_memory_manager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromSharedHandle(o
521521
((void)(ret));
522522

523523
properties.imgInfo->tilingMode = TilingModeHelper::convert(getTiling.tiling_mode);
524-
Gmm *gmm = new Gmm(*properties.imgInfo);
524+
Gmm *gmm = new Gmm(*properties.imgInfo, createStorageInfoFromProperties(properties));
525525
drmAllocation->setDefaultGmm(gmm);
526526
}
527527
return drmAllocation;

unit_tests/d3d_sharing/d3d9_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class D3D9Tests : public PlatformFixture, public ::testing::Test {
4848
return alloc;
4949
}
5050
GraphicsAllocation *allocateGraphicsMemoryForImage(const AllocationData &allocationData) override {
51-
auto gmm = std::make_unique<Gmm>(*allocationData.imgInfo);
51+
auto gmm = std::make_unique<Gmm>(*allocationData.imgInfo, StorageInfo{});
5252
AllocationProperties properties(nullptr, false, GraphicsAllocation::AllocationType::SHARED_IMAGE);
5353
auto alloc = OsAgnosticMemoryManager::createGraphicsAllocationFromSharedHandle(1, properties, false);
5454
alloc->setDefaultGmm(forceGmm);

unit_tests/gmm_helper/gmm_helper_tests.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ TEST_F(GmmTests, givenTilingModeSetToTileYWhenHwSupportsTilingThenTileYFlagIsSet
304304

305305
auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr);
306306
imgInfo.tilingMode = TilingMode::TILE_Y;
307-
auto gmm = std::make_unique<Gmm>(imgInfo);
307+
auto gmm = std::make_unique<Gmm>(imgInfo, StorageInfo{});
308308

309309
auto &hwHelper = HwHelper::get(GmmHelper::getInstance()->getHardwareInfo()->platform.eRenderCoreFamily);
310310
bool supportsYTiling = hwHelper.supportsYTiling();
@@ -327,7 +327,7 @@ TEST_F(GmmTests, givenTilingModeSetToNonTiledWhenCreatingGmmThenLinearFlagIsSet)
327327

328328
auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr);
329329
imgInfo.tilingMode = TilingMode::NON_TILED;
330-
auto gmm = std::make_unique<Gmm>(imgInfo);
330+
auto gmm = std::make_unique<Gmm>(imgInfo, StorageInfo{});
331331

332332
EXPECT_EQ(gmm->resourceParams.Flags.Info.Linear, 1u);
333333
EXPECT_EQ(gmm->resourceParams.Flags.Info.TiledY, 0u);
@@ -343,7 +343,7 @@ TEST_F(GmmTests, givenTilingModeSetToTileXWhenCreatingGmmThenUnrecoverableIfIsCa
343343
auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr);
344344
imgInfo.tilingMode = TilingMode::TILE_X;
345345

346-
EXPECT_THROW(new Gmm(imgInfo), std::exception);
346+
EXPECT_THROW(new Gmm(imgInfo, {}), std::exception);
347347
}
348348

349349
TEST_F(GmmTests, givenZeroRowPitchWhenQueryImgFromBufferParamsThenCalculate) {

unit_tests/mocks/mock_gmm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ static SurfaceFormatInfo mockSurfaceFormat;
2121
class MockGmm : public Gmm {
2222
public:
2323
static std::unique_ptr<Gmm> queryImgParams(ImageInfo &imgInfo) {
24-
return std::unique_ptr<Gmm>(new Gmm(imgInfo));
24+
return std::unique_ptr<Gmm>(new Gmm(imgInfo, {}));
2525
}
2626

2727
static ImageInfo initImgInfo(cl_image_desc &imgDesc, int baseMipLevel, const SurfaceFormatInfo *surfaceFormat) {

0 commit comments

Comments
 (0)