Skip to content

Commit b850491

Browse files
fix: allow for image array type if array size is 1 for Xe2 and later
This commit enabled the use of the array image type with array size 1 from Xe2. Additinally, it removes two incorrect unit tests, as array size of 0 is not correct with the OpenCL specification. Related-To: NEO-13976 Signed-off-by: Kamil Kopryk <[email protected]>
1 parent c8eb085 commit b850491

13 files changed

+88
-14
lines changed

opencl/test/unit_test/mem_obj/image_set_arg_tests.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018-2024 Intel Corporation
2+
* Copyright (C) 2018-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -227,20 +227,20 @@ struct ImageSetArgSurfaceArrayTest : ImageSetArgTest {
227227
}
228228
};
229229

230-
HWTEST_F(ImageSetArgSurfaceArrayTest, givenImage1DArrayAndImageArraySizeIsZeroWhenCallingSetImageArgThenDoNotProgramSurfaceArray) {
231-
testSurfaceArrayProgramming<FamilyType>(CL_MEM_OBJECT_IMAGE1D_ARRAY, 0u, false);
230+
HWTEST2_F(ImageSetArgSurfaceArrayTest, givenImage1DArrayAndImageArraySizeIsOneWhenCallingSetImageArgThenDoNotProgramSurfaceArray, IsAtMostXeHpcCore) {
231+
testSurfaceArrayProgramming<FamilyType>(CL_MEM_OBJECT_IMAGE1D_ARRAY, 1u, false);
232232
}
233233

234-
HWTEST_F(ImageSetArgSurfaceArrayTest, givenImage2DArrayAndImageArraySizeIsZeroWhenCallingSetImageArgThenDoNotProgramSurfaceArray) {
235-
testSurfaceArrayProgramming<FamilyType>(CL_MEM_OBJECT_IMAGE2D_ARRAY, 0u, false);
234+
HWTEST2_F(ImageSetArgSurfaceArrayTest, givenImage2DArrayAndImageArraySizeIsOneWhenCallingSetImageArgThenDoNotProgramSurfaceArray, IsAtMostXeHpcCore) {
235+
testSurfaceArrayProgramming<FamilyType>(CL_MEM_OBJECT_IMAGE2D_ARRAY, 1u, false);
236236
}
237237

238-
HWTEST_F(ImageSetArgSurfaceArrayTest, givenImage1DArrayAndImageArraySizeIsOneWhenCallingSetImageArgThenDoNotProgramSurfaceArray) {
239-
testSurfaceArrayProgramming<FamilyType>(CL_MEM_OBJECT_IMAGE1D_ARRAY, 1u, false);
238+
HWTEST2_F(ImageSetArgSurfaceArrayTest, givenImage1DArrayAndImageArraySizeIsOneWhenCallingSetImageArgThenProgramSurfaceArray, IsAtLeastXe2HpgCore) {
239+
testSurfaceArrayProgramming<FamilyType>(CL_MEM_OBJECT_IMAGE1D_ARRAY, 1u, true);
240240
}
241241

242-
HWTEST_F(ImageSetArgSurfaceArrayTest, givenImage2DArrayAndImageArraySizeIsOneWhenCallingSetImageArgThenDoNotProgramSurfaceArray) {
243-
testSurfaceArrayProgramming<FamilyType>(CL_MEM_OBJECT_IMAGE2D_ARRAY, 1u, false);
242+
HWTEST2_F(ImageSetArgSurfaceArrayTest, givenImage2DArrayAndImageArraySizeIsOneWhenCallingSetImageArgThenProgramSurfaceArray, IsAtLeastXe2HpgCore) {
243+
testSurfaceArrayProgramming<FamilyType>(CL_MEM_OBJECT_IMAGE2D_ARRAY, 1u, true);
244244
}
245245

246246
HWTEST_F(ImageSetArgSurfaceArrayTest, givenImage1DArrayAndImageArraySizeIsGreaterThanOneWhenCallingSetImageArgThenProgramSurfaceArray) {

opencl/test/unit_test/mem_obj/nv12_image_tests.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
/*
2-
* Copyright (C) 2018-2024 Intel Corporation
2+
* Copyright (C) 2018-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
66
*/
77

88
#include "shared/source/gmm_helper/gmm.h"
99
#include "shared/source/helpers/aligned_memory.h"
10+
#include "shared/source/image/image_surface_state.h"
1011
#include "shared/test/common/helpers/debug_manager_state_restore.h"
1112
#include "shared/test/common/helpers/kernel_binary_helper.h"
1213
#include "shared/test/common/mocks/mock_gmm_resource_info.h"
@@ -394,7 +395,12 @@ HWTEST_F(Nv12ImageTest, givenNv12ImageArrayAndImageArraySizeIsZeroWhenCallingSet
394395
image->setCubeFaceIndex(__GMM_NO_CUBE_MAP);
395396

396397
image->setImageArg(&surfaceState, false, 0, context.getDevice(0)->getRootDeviceIndex());
397-
EXPECT_FALSE(surfaceState.getSurfaceArray());
398+
399+
if (ImageSurfaceStateHelper<FamilyType>::imageAsArrayWithArraySizeOf1NotPreferred()) {
400+
EXPECT_FALSE(surfaceState.getSurfaceArray());
401+
} else {
402+
EXPECT_TRUE(surfaceState.getSurfaceArray());
403+
}
398404
}
399405

400406
HWTEST_F(Nv12ImageTest, WhenSettingImageArgUvPlaneImageThenOffsetSurfaceBaseAddressAndCorrectTileModeAreSet) {

shared/source/gen12lp/image_core_gen12lp.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ using GfxFamily = Gen12LpFamily;
1414
}
1515

1616
#include "shared/source/image/image_surface_state.inl"
17+
#include "shared/source/image/image_surface_state_before_xe2.inl"
1718

1819
namespace NEO {
1920
template class ImageSurfaceStateHelper<GfxFamily>;

shared/source/image/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,17 @@ set(NEO_CORE_IMAGE
1010
${CMAKE_CURRENT_SOURCE_DIR}/image_surface_state.inl
1111
)
1212

13+
if(SUPPORT_GEN12LP OR SUPPORT_XE_HPG_CORE OR SUPPORT_XE_HPC_CORE)
14+
list(APPEND NEO_CORE_IMAGE
15+
${CMAKE_CURRENT_SOURCE_DIR}/image_surface_state_before_xe2.inl
16+
)
17+
endif()
18+
19+
if(SUPPORT_XE2_AND_LATER)
20+
list(APPEND NEO_CORE_IMAGE
21+
${CMAKE_CURRENT_SOURCE_DIR}/image_surface_state_xe2_and_later.inl
22+
)
23+
endif()
24+
1325
set_property(GLOBAL PROPERTY NEO_CORE_IMAGE ${NEO_CORE_IMAGE})
1426
add_subdirectories()

shared/source/image/image_surface_state.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,6 @@ class ImageSurfaceStateHelper {
2727
static void setWidthForMediaBlockSurfaceState(RENDER_SURFACE_STATE *surfaceState, const ImageInfo &imageInfo);
2828
static void setUnifiedAuxBaseAddress(RENDER_SURFACE_STATE *surfaceState, const Gmm *gmm);
2929
static void setMipTailStartLOD(RENDER_SURFACE_STATE *surfaceState, Gmm *gmm);
30+
static bool imageAsArrayWithArraySizeOf1NotPreferred();
3031
};
3132
} // namespace NEO

shared/source/image/image_surface_state.inl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,13 @@ void ImageSurfaceStateHelper<GfxFamily>::setImageSurfaceState(RENDER_SURFACE_STA
2727
imageCount = 1;
2828
}
2929

30-
bool isImageArray = imageInfo.imgDesc.imageArraySize > 1 &&
31-
(imageInfo.imgDesc.imageType == ImageType::image2DArray ||
30+
bool isImageArray = (imageInfo.imgDesc.imageType == ImageType::image2DArray ||
3231
imageInfo.imgDesc.imageType == ImageType::image1DArray);
3332

33+
if ((imageInfo.imgDesc.imageArraySize == 1) && ImageSurfaceStateHelper<GfxFamily>::imageAsArrayWithArraySizeOf1NotPreferred()) {
34+
isImageArray = false;
35+
}
36+
3437
isImageArray |= (imageInfo.imgDesc.imageType == ImageType::image2D || imageInfo.imgDesc.imageType == ImageType::image2DArray) && debugManager.flags.Force2dImageAsArray.get() == 1;
3538

3639
renderTargetViewExtent = static_cast<uint32_t>(imageCount);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright (C) 2025 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#include "shared/source/command_container/encode_surface_state.h"
9+
#include "shared/source/debug_settings/debug_settings_manager.h"
10+
#include "shared/source/gmm_helper/gmm.h"
11+
#include "shared/source/gmm_helper/gmm_helper.h"
12+
#include "shared/source/gmm_helper/resource_info.h"
13+
#include "shared/source/helpers/basic_math.h"
14+
#include "shared/source/helpers/surface_format_info.h"
15+
#include "shared/source/image/image_surface_state.h"
16+
17+
namespace NEO {
18+
template <typename GfxFamily>
19+
bool ImageSurfaceStateHelper<GfxFamily>::imageAsArrayWithArraySizeOf1NotPreferred() {
20+
return true;
21+
}
22+
23+
} // namespace NEO
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* Copyright (C) 2025 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#include "shared/source/image/image_surface_state.h"
9+
10+
namespace NEO {
11+
12+
template <typename GfxFamily>
13+
bool ImageSurfaceStateHelper<GfxFamily>::imageAsArrayWithArraySizeOf1NotPreferred() {
14+
return false;
15+
}
16+
17+
} // namespace NEO

shared/source/xe2_hpg_core/image_core_xe2_hpg_core.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ using GfxFamily = Xe2HpgCoreFamily;
1414
}
1515

1616
#include "shared/source/image/image_surface_state.inl"
17+
#include "shared/source/image/image_surface_state_xe2_and_later.inl"
1718

1819
namespace NEO {
1920
template class ImageSurfaceStateHelper<GfxFamily>;

shared/source/xe3_core/image_core_xe3_core.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ namespace NEO {
1313
using GfxFamily = Xe3CoreFamily;
1414
}
1515
#include "shared/source/image/image_surface_state.inl"
16+
#include "shared/source/image/image_surface_state_xe2_and_later.inl"
17+
1618
namespace NEO {
1719
template class ImageSurfaceStateHelper<GfxFamily>;
1820
} // namespace NEO

shared/source/xe_hpc_core/image_core_xe_hpc_core.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ namespace NEO {
1313
using GfxFamily = XeHpcCoreFamily;
1414
}
1515
#include "shared/source/image/image_surface_state.inl"
16+
#include "shared/source/image/image_surface_state_before_xe2.inl"
1617
namespace NEO {
1718
template class ImageSurfaceStateHelper<GfxFamily>;
1819
} // namespace NEO

shared/source/xe_hpg_core/image_core_xe_hpg_core.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ namespace NEO {
1313
using GfxFamily = XeHpgCoreFamily;
1414
}
1515
#include "shared/source/image/image_surface_state.inl"
16+
#include "shared/source/image/image_surface_state_before_xe2.inl"
17+
1618
namespace NEO {
1719
template class ImageSurfaceStateHelper<GfxFamily>;
1820
} // namespace NEO

shared/test/unit_test/image/image_surface_state_tests.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,12 @@ HWTEST_F(ImageSurfaceStateTests, givenImage2DArrayOfSize1When2dImageWAIsDisabled
207207
uint32_t minArrayElement, renderTargetViewExtent;
208208

209209
ImageSurfaceStateHelper<FamilyType>::setImageSurfaceState(castSurfaceState, imageInfo, mockGmm.get(), *gmmHelper, cubeFaceIndex, gpuAddress, surfaceOffsets, true, minArrayElement, renderTargetViewExtent);
210-
EXPECT_FALSE(castSurfaceState->getSurfaceArray());
210+
211+
if (ImageSurfaceStateHelper<FamilyType>::imageAsArrayWithArraySizeOf1NotPreferred()) {
212+
EXPECT_FALSE(castSurfaceState->getSurfaceArray());
213+
} else {
214+
EXPECT_TRUE(castSurfaceState->getSurfaceArray());
215+
}
211216
}
212217

213218
HWTEST_F(ImageSurfaceStateTests, givenImage1DWhen2dImageWAIsEnabledThenArrayFlagIsNotSet) {

0 commit comments

Comments
 (0)