Skip to content

Commit 0c2f5aa

Browse files
Change width programming for GMM
Change-Id: If2a1a0d582cbebb209de182895d1f6decedcfb73 Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
1 parent e2092d2 commit 0c2f5aa

File tree

4 files changed

+18
-11
lines changed

4 files changed

+18
-11
lines changed

runtime/gmm_helper/gmm.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Gmm::Gmm(const void *alignedPtr, size_t alignedSize, bool uncacheable) : Gmm(ali
2121
Gmm::Gmm(const void *alignedPtr, size_t alignedSize, bool uncacheable, bool preferRenderCompressed, bool systemMemoryPool) {
2222
resourceParams.Type = RESOURCE_BUFFER;
2323
resourceParams.Format = GMM_FORMAT_GENERIC_8BIT;
24-
resourceParams.BaseWidth = static_cast<uint32_t>(alignedSize);
24+
resourceParams.BaseWidth64 = static_cast<uint64_t>(alignedSize);
2525
resourceParams.BaseHeight = 1;
2626
resourceParams.Depth = 1;
2727
if (!uncacheable) {
@@ -41,7 +41,7 @@ Gmm::Gmm(const void *alignedPtr, size_t alignedSize, bool uncacheable, bool pref
4141
resourceParams.NoGfxMemory = 1u;
4242
}
4343

44-
if (resourceParams.BaseWidth >= GmmHelper::maxPossiblePitch) {
44+
if (resourceParams.BaseWidth64 >= GmmHelper::maxPossiblePitch) {
4545
resourceParams.Flags.Gpu.NoRestriction = 1;
4646
}
4747

@@ -61,7 +61,7 @@ Gmm::Gmm(ImageInfo &inputOutputImgInfo) {
6161

6262
void Gmm::queryImageParams(ImageInfo &imgInfo) {
6363
this->resourceParams = {};
64-
uint32_t imageWidth = static_cast<uint32_t>(imgInfo.imgDesc->image_width);
64+
uint64_t imageWidth = static_cast<uint64_t>(imgInfo.imgDesc->image_width);
6565
uint32_t imageHeight = 1;
6666
uint32_t imageDepth = 1;
6767
uint32_t imageCount = 1;
@@ -101,7 +101,7 @@ void Gmm::queryImageParams(ImageInfo &imgInfo) {
101101
this->resourceParams.Usage = GMM_RESOURCE_USAGE_TYPE::GMM_RESOURCE_USAGE_OCL_IMAGE;
102102
this->resourceParams.Format = imgInfo.surfaceFormat->GMMSurfaceFormat;
103103
this->resourceParams.Flags.Gpu.Texture = 1;
104-
this->resourceParams.BaseWidth = imageWidth;
104+
this->resourceParams.BaseWidth64 = imageWidth;
105105
this->resourceParams.BaseHeight = imageHeight;
106106
this->resourceParams.Depth = imageDepth;
107107
this->resourceParams.ArraySize = imageCount;

runtime/gmm_helper/gmm_helper.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2017-2018 Intel Corporation
2+
* Copyright (C) 2017-2019 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -35,7 +35,7 @@ class GmmHelper {
3535

3636
static constexpr uint32_t cacheDisabledIndex = 0;
3737
static constexpr uint32_t cacheEnabledIndex = 4;
38-
static constexpr uint32_t maxPossiblePitch = 2147483648;
38+
static constexpr uint64_t maxPossiblePitch = 2147483648;
3939

4040
static uint64_t canonize(uint64_t address);
4141
static uint64_t decanonize(uint64_t address);

unit_tests/gmm_helper/gmm_helper_tests.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ TEST_F(GmmTests, resourceCleanupOnDelete) {
9494
}
9595

9696
TEST_F(GmmTests, GivenBufferSizeLargerThenMaxPitchWhenAskedForGmmCreationThenGMMResourceIsCreatedWithNoRestrictionsFlag) {
97-
auto maxSize = GmmHelper::maxPossiblePitch;
97+
auto maxSize = static_cast<size_t>(GmmHelper::maxPossiblePitch);
9898

9999
MemoryManager *mm = new OsAgnosticMemoryManager(false, false, executionEnvironment);
100100
void *pSysMem = mm->allocateSystemMemory(4096, 4096);
@@ -170,13 +170,20 @@ TEST_F(GmmTests, validImageTypeQuery) {
170170
EXPECT_EQ(static_cast<uint32_t>(queryGmm->resourceParams.Format),
171171
static_cast<uint32_t>(GMM_RESOURCE_FORMAT::GMM_FORMAT_R8G8B8A8_UNORM));
172172
EXPECT_EQ(queryGmm->resourceParams.Flags.Gpu.Texture, 1u);
173-
EXPECT_EQ(queryGmm->resourceParams.BaseWidth, 17u);
173+
EXPECT_EQ(queryGmm->resourceParams.BaseWidth64, 17u);
174174
EXPECT_EQ(queryGmm->resourceParams.BaseHeight, 17u);
175175
EXPECT_EQ(queryGmm->resourceParams.Depth, 17u);
176176
EXPECT_EQ(queryGmm->resourceParams.ArraySize, 1u);
177177
EXPECT_EQ(queryGmm->resourceParams.Flags.Wa.__ForceOtherHVALIGN4, 1u);
178178
}
179179

180+
TEST_F(GmmTests, givenWidthWhenCreatingResourceThenSetWidth64Field) {
181+
const void *dummyPtr = reinterpret_cast<void *>(0x123);
182+
size_t allocationSize = std::numeric_limits<size_t>::max();
183+
Gmm gmm(dummyPtr, allocationSize, false);
184+
EXPECT_EQ(static_cast<uint64_t>(allocationSize), gmm.resourceParams.BaseWidth64);
185+
}
186+
180187
TEST_F(GmmTests, givenNullptrWhenGmmConstructorIsCalledThenNoGfxMemoryIsProperlySet) {
181188
void *pSysMem = nullptr;
182189
std::unique_ptr<Gmm> gmm(new Gmm(pSysMem, 4096, false));
@@ -644,7 +651,7 @@ TEST(GmmTest, whenResourceIsCreatedThenHandleItsOwnership) {
644651
GMM_RESCREATE_PARAMS gmmParams = {};
645652
gmmParams.Type = RESOURCE_BUFFER;
646653
gmmParams.Format = GMM_FORMAT_GENERIC_8BIT;
647-
gmmParams.BaseWidth = 1;
654+
gmmParams.BaseWidth64 = 1;
648655
gmmParams.BaseHeight = 1;
649656
gmmParams.Depth = 1;
650657
gmmParams.Flags.Info.Linear = 1;

unit_tests/mocks/mock_gmm_resource_info.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2017-2018 Intel Corporation
2+
* Copyright (C) 2017-2019 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -70,7 +70,7 @@ void MockGmmResourceInfo::computeRowPitch() {
7070
if (mockResourceCreateParams.OverridePitch) {
7171
rowPitch = mockResourceCreateParams.OverridePitch;
7272
} else {
73-
rowPitch = static_cast<size_t>(mockResourceCreateParams.BaseWidth * (surfaceFormatInfo->PerChannelSizeInBytes * surfaceFormatInfo->NumChannels));
73+
rowPitch = static_cast<size_t>(mockResourceCreateParams.BaseWidth64 * (surfaceFormatInfo->PerChannelSizeInBytes * surfaceFormatInfo->NumChannels));
7474
rowPitch = alignUp(rowPitch, 64);
7575
}
7676
}

0 commit comments

Comments
 (0)