Skip to content

Commit e87056f

Browse files
Implement WA for 2d Images
Related-To: NEO-5659, NEO-5654, NEO-5653 Signed-off-by: Maciej Plewka <[email protected]>
1 parent f6efba9 commit e87056f

File tree

7 files changed

+81
-4
lines changed

7 files changed

+81
-4
lines changed

opencl/test/unit_test/kernel/kernel_transformable_tests.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,8 @@ HWTEST_F(KernelTransformableTest, givenKernelWithImages2dAndTwoTransformableSamp
209209
EXPECT_FALSE(secondSurfaceState->getSurfaceArray());
210210
}
211211

212+
HWTEST_EXCLUDE_PRODUCT(KernelTransformableTest, givenKernelWithImages2dAndTwoTransformableSamplersWhenAnyArgIsResetThenImagesAreNotTransformed, IGFX_XE_HP_SDV);
213+
212214
HWTEST_F(KernelTransformableTest, givenKernelWithTwoTransformableImagesAndTwoTransformableSamplersWhenChangeSamplerToNontransformableThenImagesAreTransformedTo3d) {
213215
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
214216
using SURFACE_TYPE = typename RENDER_SURFACE_STATE::SURFACE_TYPE;

shared/source/gen12lp/image_core_gen12lp.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@ namespace NEO {
1212

1313
using Family = TGLLPFamily;
1414

15-
template <>
16-
void setFilterMode<Family>(Family::RENDER_SURFACE_STATE *surfaceState, const HardwareInfo *hwInfo){};
17-
1815
// clang-format off
16+
#include "shared/source/image/image_bdw_plus.inl"
1917
#include "shared/source/image/image_skl_plus.inl"
2018
// clang-format on
2119
} // namespace NEO

shared/source/image/image_bdw_plus.inl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,8 @@
77

88
template <>
99
void setFilterMode<Family>(typename Family::RENDER_SURFACE_STATE *surfaceState, const HardwareInfo *hwInfo){};
10+
11+
template <>
12+
bool checkIfArrayNeeded<Family>(ImageType type, const HardwareInfo *hwInfo) {
13+
return false;
14+
};

shared/source/image/image_surface_state.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
namespace NEO {
1818
template <typename GfxFamily>
1919
void setFilterMode(typename GfxFamily::RENDER_SURFACE_STATE *surfaceState, const HardwareInfo *hwInfo);
20+
template <typename GfxFamily>
21+
bool checkIfArrayNeeded(ImageType type, const HardwareInfo *hwInfo);
2022

2123
template <typename GfxFamily>
2224
inline void setImageSurfaceState(typename GfxFamily::RENDER_SURFACE_STATE *surfaceState, const ImageInfo &imageInfo, Gmm *gmm, GmmHelper &gmmHelper, uint32_t cubeFaceIndex, uint64_t gpuAddress, const SurfaceOffsets &surfaceOffsets, bool isNV12Format) {
@@ -48,6 +50,7 @@ inline void setImageSurfaceState(typename GfxFamily::RENDER_SURFACE_STATE *surfa
4850
renderTargetViewExtent = 1;
4951
minimumArrayElement = cubeFaceIndex;
5052
}
53+
isImageArray |= checkIfArrayNeeded<GfxFamily>(imageInfo.imgDesc.imageType, gmmHelper.getHardwareInfo());
5154

5255
surfaceState->setAuxiliarySurfaceMode(AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_NONE);
5356
surfaceState->setAuxiliarySurfacePitch(1u);

shared/source/xe_hp_core/image_core_xe_hp_core.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*
66
*/
77

8+
#include "shared/source/helpers/hw_helper.h"
89
#include "shared/source/image/image_surface_state.h"
910
#include "shared/source/xe_hp_core/hw_cmds_base.h"
1011

@@ -14,6 +15,13 @@ using Family = XeHpFamily;
1415

1516
template <>
1617
void setFilterMode<Family>(Family::RENDER_SURFACE_STATE *surfaceState, const HardwareInfo *hwInfo) {}
18+
template <>
19+
bool checkIfArrayNeeded<Family>(ImageType type, const HardwareInfo *hwInfo) {
20+
if (type == ImageType::Image2D) {
21+
return true;
22+
}
23+
return false;
24+
}
1725
// clang-format off
1826
#include "shared/source/image/image_skl_plus.inl"
1927
// clang-format on

shared/test/unit_test/image/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (C) 2020 Intel Corporation
2+
# Copyright (C) 2020-2021 Intel Corporation
33
#
44
# SPDX-License-Identifier: MIT
55
#
@@ -9,3 +9,5 @@ target_sources(${TARGET_NAME} PRIVATE
99
${CMAKE_CURRENT_SOURCE_DIR}/image_surface_state_fixture.h
1010
${CMAKE_CURRENT_SOURCE_DIR}/image_surface_state_tests.cpp
1111
)
12+
13+
add_subdirectories()

shared/test/unit_test/image/image_surface_state_tests.cpp

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,62 @@ HWTEST_F(ImageSurfaceStateTests, givenGmmWhenSetAuxParamsForCCSThenAuxiliarySurf
106106
mockGmm.isCompressionEnabled = true;
107107
EXPECT_TRUE(EncodeSurfaceState<FamilyType>::isAuxModeEnabled(castSurfaceState, &mockGmm));
108108
}
109+
110+
HWTEST_F(ImageSurfaceStateTests, givenHwInfoAndSurfaceStateWhenCheckIfArrayNeededThenFalseReturned) {
111+
EXPECT_FALSE(checkIfArrayNeeded<FamilyType>(ImageType::Image2D, &pDevice->getHardwareInfo()));
112+
}
113+
HWTEST_EXCLUDE_PRODUCT(ImageSurfaceStateTests, givenHwInfoAndSurfaceStateWhenCheckIfArrayNeededThenFalseReturned, IGFX_XE_HP_SDV);
114+
115+
HWTEST2_F(ImageSurfaceStateTests, givenHwInfoAndSurfaceStateWhenSurfaceTypeIsNotSurface2DThenCheckIfArrayReturnFalse, IsXeHpCore) {
116+
EXPECT_FALSE(checkIfArrayNeeded<FamilyType>(ImageType::Image1D, &pDevice->getHardwareInfo()));
117+
}
118+
HWTEST2_F(ImageSurfaceStateTests, givenHwInfoWhenSurface2DThenCheckIfArrayReturnTrue, IsXeHpCore) {
119+
EXPECT_TRUE(checkIfArrayNeeded<FamilyType>(ImageType::Image2D, &pDevice->getHardwareInfo()));
120+
}
121+
122+
HWTEST_F(ImageSurfaceStateTests, givenImage2DTypeWhenCheckIfArrayNeededReturnsTureThenArrayFlagIsSet) {
123+
if (!checkIfArrayNeeded<FamilyType>(ImageType::Image2D, &pDevice->getHardwareInfo())) {
124+
GTEST_SKIP();
125+
}
126+
auto size = sizeof(typename FamilyType::RENDER_SURFACE_STATE);
127+
auto surfaceState = std::make_unique<char[]>(size);
128+
auto castSurfaceState = reinterpret_cast<typename FamilyType::RENDER_SURFACE_STATE *>(surfaceState.get());
129+
130+
imageInfo.imgDesc.imageType = ImageType::Image2D;
131+
imageInfo.imgDesc.imageDepth = 1;
132+
imageInfo.imgDesc.imageArraySize = 1;
133+
SurfaceOffsets surfaceOffsets = {0, 0, 0, 0};
134+
const uint32_t cubeFaceIndex = __GMM_NO_CUBE_MAP;
135+
SurfaceFormatInfo surfaceFormatInfo;
136+
surfaceFormatInfo.GenxSurfaceFormat = GFX3DSTATE_SURFACEFORMAT::GFX3DSTATE_SURFACEFORMAT_A32_FLOAT;
137+
imageInfo.surfaceFormat = &surfaceFormatInfo;
138+
139+
const uint64_t gpuAddress = 0x000001a78a8a8000;
140+
141+
setImageSurfaceState<FamilyType>(castSurfaceState, imageInfo, &mockGmm, *gmmHelper, cubeFaceIndex, gpuAddress, surfaceOffsets, true);
142+
EXPECT_TRUE(castSurfaceState->getSurfaceArray());
143+
}
144+
145+
HWTEST_F(ImageSurfaceStateTests, givenImage2DTypeWhenCheckIfArrayNeededReturnsFalseThenArrayFlagIsNotSet) {
146+
if (checkIfArrayNeeded<FamilyType>(ImageType::Image2D, &pDevice->getHardwareInfo())) {
147+
GTEST_SKIP();
148+
}
149+
auto size = sizeof(typename FamilyType::RENDER_SURFACE_STATE);
150+
auto surfaceState = std::make_unique<char[]>(size);
151+
auto castSurfaceState = reinterpret_cast<typename FamilyType::RENDER_SURFACE_STATE *>(surfaceState.get());
152+
153+
imageInfo.imgDesc.imageType = ImageType::Image2D;
154+
imageInfo.imgDesc.imageDepth = 1;
155+
imageInfo.imgDesc.imageArraySize = 1;
156+
imageInfo.qPitch = 0;
157+
SurfaceOffsets surfaceOffsets = {0, 0, 0, 0};
158+
const uint32_t cubeFaceIndex = __GMM_NO_CUBE_MAP;
159+
SurfaceFormatInfo surfaceFormatInfo;
160+
surfaceFormatInfo.GenxSurfaceFormat = GFX3DSTATE_SURFACEFORMAT::GFX3DSTATE_SURFACEFORMAT_A32_FLOAT;
161+
imageInfo.surfaceFormat = &surfaceFormatInfo;
162+
163+
const uint64_t gpuAddress = 0x000001a78a8a8000;
164+
165+
setImageSurfaceState<FamilyType>(castSurfaceState, imageInfo, &mockGmm, *gmmHelper, cubeFaceIndex, gpuAddress, surfaceOffsets, true);
166+
EXPECT_FALSE(castSurfaceState->getSurfaceArray());
167+
}

0 commit comments

Comments
 (0)