Skip to content

Commit 1bba325

Browse files
MemObj uses isRenderCompressed when it's an image
Related-To: NEO-5139 Signed-off-by: Dominik Dabek <[email protected]>
1 parent c0b1b79 commit 1bba325

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

opencl/source/mem_obj/mem_obj.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2017-2020 Intel Corporation
2+
* Copyright (C) 2017-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -124,7 +124,8 @@ cl_int MemObj::getMemObjectInfo(cl_mem_info paramName,
124124
cl_context ctx = nullptr;
125125
uint64_t internalHandle = 0llu;
126126
auto allocation = getMultiGraphicsAllocation().getDefaultGraphicsAllocation();
127-
cl_bool usesCompression = allocation->getAllocationType() == GraphicsAllocation::AllocationType::BUFFER_COMPRESSED;
127+
Gmm *gmm;
128+
cl_bool usesCompression;
128129

129130
switch (paramName) {
130131
case CL_MEM_TYPE:
@@ -188,6 +189,12 @@ cl_int MemObj::getMemObjectInfo(cl_mem_info paramName,
188189
break;
189190

190191
case CL_MEM_USES_COMPRESSION_INTEL:
192+
gmm = allocation->getDefaultGmm();
193+
if (gmm != nullptr) {
194+
usesCompression = gmm->isRenderCompressed;
195+
} else {
196+
usesCompression = allocation->getAllocationType() == GraphicsAllocation::AllocationType::BUFFER_COMPRESSED;
197+
}
191198
srcParam = &usesCompression;
192199
srcParamSize = sizeof(cl_bool);
193200
break;

opencl/test/unit_test/mem_obj/image_tests.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,6 +1190,38 @@ TEST_F(ImageCompressionTests, givenNonTiledImageWhenCreatingAllocationThenDontPr
11901190
EXPECT_FALSE(myMemoryManager->capturedImgInfo.preferRenderCompression);
11911191
}
11921192

1193+
TEST(ImageTest, givenImageWhenGettingCompressionOfImageThenCorrectValueIsReturned) {
1194+
MockContext context;
1195+
std::unique_ptr<Image> image(ImageHelper<Image3dDefaults>::create(&context));
1196+
EXPECT_NE(nullptr, image);
1197+
1198+
auto allocation = image->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex());
1199+
allocation->getDefaultGmm()->isRenderCompressed = true;
1200+
size_t sizeReturned = 0;
1201+
cl_bool usesCompression;
1202+
cl_int retVal = CL_SUCCESS;
1203+
retVal = image->getMemObjectInfo(
1204+
CL_MEM_USES_COMPRESSION_INTEL,
1205+
sizeof(cl_bool),
1206+
&usesCompression,
1207+
&sizeReturned);
1208+
EXPECT_EQ(CL_SUCCESS, retVal);
1209+
ASSERT_EQ(sizeof(cl_bool), sizeReturned);
1210+
EXPECT_TRUE(usesCompression);
1211+
1212+
allocation->getDefaultGmm()->isRenderCompressed = false;
1213+
sizeReturned = 0;
1214+
usesCompression = cl_bool{CL_FALSE};
1215+
retVal = image->getMemObjectInfo(
1216+
CL_MEM_USES_COMPRESSION_INTEL,
1217+
sizeof(cl_bool),
1218+
&usesCompression,
1219+
&sizeReturned);
1220+
EXPECT_EQ(CL_SUCCESS, retVal);
1221+
ASSERT_EQ(sizeof(cl_bool), sizeReturned);
1222+
EXPECT_FALSE(usesCompression);
1223+
}
1224+
11931225
using ImageTests = ::testing::Test;
11941226
HWTEST_F(ImageTests, givenImageWhenAskedForPtrOffsetForGpuMappingThenReturnCorrectValue) {
11951227
if (!UnitTestHelper<FamilyType>::tiledImagesSupported) {

0 commit comments

Comments
 (0)