1
1
/*
2
- * Copyright (C) 2019-2021 Intel Corporation
2
+ * Copyright (C) 2019-2022 Intel Corporation
3
3
*
4
4
* SPDX-License-Identifier: MIT
5
5
*
19
19
#include " opencl/source/sharings/d3d/d3d_texture.h"
20
20
#include " opencl/test/unit_test/fixtures/d3d_test_fixture.h"
21
21
22
- #include " gmock/gmock.h"
23
22
#include " gtest/gtest.h"
24
23
25
24
namespace NEO {
@@ -33,9 +32,11 @@ TYPED_TEST_P(D3DAuxTests, given2dSharableTextureWithUnifiedAuxFlagsWhenCreatingT
33
32
this ->mockSharingFcns ->mockTexture2dDesc .MipLevels = 4 ;
34
33
35
34
mockGmmResInfo->setUnifiedAuxTranslationCapable ();
36
- EXPECT_CALL (*this ->mockSharingFcns , getTexture2dDesc (_, _)).Times (1 ).WillOnce (SetArgPointee<0 >(this ->mockSharingFcns ->mockTexture2dDesc ));
37
35
38
- auto image = std::unique_ptr<Image>(D3DTexture<TypeParam>::create2d (this ->context , (D3DTexture2d *)&this ->dummyD3DTexture , CL_MEM_READ_WRITE, 4 , nullptr ));
36
+ this ->mockSharingFcns ->getTexture2dDescSetParams = true ;
37
+ this ->mockSharingFcns ->getTexture2dDescParamsSet .textureDesc = this ->mockSharingFcns ->mockTexture2dDesc ;
38
+
39
+ auto image = std::unique_ptr<Image>(D3DTexture<TypeParam>::create2d (this ->context , reinterpret_cast <D3DTexture2d *>(&this ->dummyD3DTexture ), CL_MEM_READ_WRITE, 4 , nullptr ));
39
40
ASSERT_NE (nullptr , image.get ());
40
41
41
42
const auto &hwInfo = context->getDevice (0 )->getHardwareInfo ();
@@ -44,6 +45,8 @@ TYPED_TEST_P(D3DAuxTests, given2dSharableTextureWithUnifiedAuxFlagsWhenCreatingT
44
45
45
46
EXPECT_EQ (expectedMapAuxGpuVaCalls, mockMM->mapAuxGpuVACalled );
46
47
EXPECT_TRUE (gmm->isCompressionEnabled );
48
+
49
+ EXPECT_EQ (1u , this ->mockSharingFcns ->getTexture2dDescCalled );
47
50
}
48
51
49
52
TYPED_TEST_P (D3DAuxTests, given2dSharableTextureWithUnifiedAuxFlagsWhenFailOnAuxMappingThenDontSetAsCompressed) {
@@ -52,10 +55,12 @@ TYPED_TEST_P(D3DAuxTests, given2dSharableTextureWithUnifiedAuxFlagsWhenFailOnAux
52
55
this ->mockSharingFcns ->mockTexture2dDesc .MipLevels = 4 ;
53
56
54
57
mockGmmResInfo->setUnifiedAuxTranslationCapable ();
55
- EXPECT_CALL (*this ->mockSharingFcns , getTexture2dDesc (_, _)).Times (1 ).WillOnce (SetArgPointee<0 >(this ->mockSharingFcns ->mockTexture2dDesc ));
58
+
59
+ this ->mockSharingFcns ->getTexture2dDescSetParams = true ;
60
+ this ->mockSharingFcns ->getTexture2dDescParamsSet .textureDesc = this ->mockSharingFcns ->mockTexture2dDesc ;
56
61
57
62
mockMM->mapAuxGpuVaRetValue = false ;
58
- auto image = std::unique_ptr<Image>(D3DTexture<TypeParam>::create2d (this ->context , ( D3DTexture2d *) &this ->dummyD3DTexture , CL_MEM_READ_WRITE, 4 , nullptr ));
63
+ auto image = std::unique_ptr<Image>(D3DTexture<TypeParam>::create2d (this ->context , reinterpret_cast < D3DTexture2d *>( &this ->dummyD3DTexture ) , CL_MEM_READ_WRITE, 4 , nullptr ));
59
64
ASSERT_NE (nullptr , image.get ());
60
65
61
66
const auto &hwInfo = context->getDevice (0 )->getHardwareInfo ();
@@ -64,6 +69,8 @@ TYPED_TEST_P(D3DAuxTests, given2dSharableTextureWithUnifiedAuxFlagsWhenFailOnAux
64
69
65
70
EXPECT_EQ (expectedMapAuxGpuVaCalls, mockMM->mapAuxGpuVACalled );
66
71
EXPECT_EQ (!hwInfoConfig.isPageTableManagerSupported (hwInfo), gmm->isCompressionEnabled );
72
+
73
+ EXPECT_EQ (1u , this ->mockSharingFcns ->getTexture2dDescCalled );
67
74
}
68
75
69
76
TYPED_TEST_P (D3DAuxTests, given2dSharableTextureWithoutUnifiedAuxFlagsWhenCreatingThenDontMapAuxTable) {
@@ -73,21 +80,26 @@ TYPED_TEST_P(D3DAuxTests, given2dSharableTextureWithoutUnifiedAuxFlagsWhenCreati
73
80
74
81
EXPECT_FALSE (gmm->unifiedAuxTranslationCapable ());
75
82
76
- EXPECT_CALL (*this ->mockSharingFcns , getTexture2dDesc (_, _)).Times (1 ).WillOnce (SetArgPointee<0 >(this ->mockSharingFcns ->mockTexture2dDesc ));
83
+ this ->mockSharingFcns ->getTexture2dDescSetParams = true ;
84
+ this ->mockSharingFcns ->getTexture2dDescParamsSet .textureDesc = this ->mockSharingFcns ->mockTexture2dDesc ;
77
85
78
- auto image = std::unique_ptr<Image>(D3DTexture<TypeParam>::create2d (this ->context , ( D3DTexture2d *) &this ->dummyD3DTexture , CL_MEM_READ_WRITE, 4 , nullptr ));
86
+ auto image = std::unique_ptr<Image>(D3DTexture<TypeParam>::create2d (this ->context , reinterpret_cast < D3DTexture2d *>( &this ->dummyD3DTexture ) , CL_MEM_READ_WRITE, 4 , nullptr ));
79
87
ASSERT_NE (nullptr , image.get ());
80
88
81
89
EXPECT_EQ (0u , mockMM->mapAuxGpuVACalled );
82
90
EXPECT_FALSE (gmm->isCompressionEnabled );
91
+
92
+ EXPECT_EQ (1u , this ->mockSharingFcns ->getTexture2dDescCalled );
83
93
}
84
94
85
95
TYPED_TEST_P (D3DAuxTests, given2dNonSharableTextureWithUnifiedAuxFlagsWhenCreatingThenMapAuxTableAndSetCompressed) {
86
96
mockGmmResInfo->setUnifiedAuxTranslationCapable ();
87
- EXPECT_CALL (*this ->mockSharingFcns , getTexture2dDesc (_, _)).Times (1 ).WillOnce (SetArgPointee<0 >(this ->mockSharingFcns ->mockTexture2dDesc ));
97
+
98
+ this ->mockSharingFcns ->getTexture2dDescSetParams = true ;
99
+ this ->mockSharingFcns ->getTexture2dDescParamsSet .textureDesc = this ->mockSharingFcns ->mockTexture2dDesc ;
88
100
89
101
mockGmmResInfo->setUnifiedAuxTranslationCapable ();
90
- auto image = std::unique_ptr<Image>(D3DTexture<TypeParam>::create2d (this ->context , ( D3DTexture2d *) &this ->dummyD3DTexture , CL_MEM_READ_WRITE, 1 , nullptr ));
102
+ auto image = std::unique_ptr<Image>(D3DTexture<TypeParam>::create2d (this ->context , reinterpret_cast < D3DTexture2d *>( &this ->dummyD3DTexture ) , CL_MEM_READ_WRITE, 1 , nullptr ));
91
103
ASSERT_NE (nullptr , image.get ());
92
104
93
105
const auto &hwInfo = context->getDevice (0 )->getHardwareInfo ();
@@ -96,15 +108,19 @@ TYPED_TEST_P(D3DAuxTests, given2dNonSharableTextureWithUnifiedAuxFlagsWhenCreati
96
108
97
109
EXPECT_EQ (expectedMapAuxGpuVaCalls, mockMM->mapAuxGpuVACalled );
98
110
EXPECT_TRUE (gmm->isCompressionEnabled );
111
+
112
+ EXPECT_EQ (1u , this ->mockSharingFcns ->getTexture2dDescCalled );
99
113
}
100
114
101
115
TYPED_TEST_P (D3DAuxTests, given3dSharableTextureWithUnifiedAuxFlagsWhenCreatingThenMapAuxTableAndSetAsCompressed) {
102
116
this ->mockSharingFcns ->mockTexture3dDesc .MiscFlags = D3DResourceFlags::MISC_SHARED;
103
117
104
118
mockGmmResInfo->setUnifiedAuxTranslationCapable ();
105
- EXPECT_CALL (*this ->mockSharingFcns , getTexture3dDesc (_, _)).Times (1 ).WillOnce (SetArgPointee<0 >(this ->mockSharingFcns ->mockTexture3dDesc ));
106
119
107
- std::unique_ptr<Image> image (D3DTexture<TypeParam>::create3d (this ->context , (D3DTexture3d *)&this ->dummyD3DTexture , CL_MEM_READ_WRITE, 1 , nullptr ));
120
+ this ->mockSharingFcns ->getTexture3dDescSetParams = true ;
121
+ this ->mockSharingFcns ->getTexture3dDescParamsSet .textureDesc = this ->mockSharingFcns ->mockTexture3dDesc ;
122
+
123
+ std::unique_ptr<Image> image (D3DTexture<TypeParam>::create3d (this ->context , reinterpret_cast <D3DTexture3d *>(&this ->dummyD3DTexture ), CL_MEM_READ_WRITE, 1 , nullptr ));
108
124
ASSERT_NE (nullptr , image.get ());
109
125
110
126
const auto &hwInfo = context->getDevice (0 )->getHardwareInfo ();
@@ -113,16 +129,19 @@ TYPED_TEST_P(D3DAuxTests, given3dSharableTextureWithUnifiedAuxFlagsWhenCreatingT
113
129
114
130
EXPECT_EQ (expectedMapAuxGpuVaCalls, mockMM->mapAuxGpuVACalled );
115
131
EXPECT_TRUE (gmm->isCompressionEnabled );
132
+ EXPECT_EQ (1u , this ->mockSharingFcns ->getTexture3dDescCalled );
116
133
}
117
134
118
135
TYPED_TEST_P (D3DAuxTests, given3dSharableTextureWithUnifiedAuxFlagsWhenFailOnAuxMappingThenDontSetAsCompressed) {
119
136
this ->mockSharingFcns ->mockTexture3dDesc .MiscFlags = D3DResourceFlags::MISC_SHARED;
120
137
121
138
mockGmmResInfo->setUnifiedAuxTranslationCapable ();
122
- EXPECT_CALL (*this ->mockSharingFcns , getTexture3dDesc (_, _)).Times (1 ).WillOnce (SetArgPointee<0 >(this ->mockSharingFcns ->mockTexture3dDesc ));
139
+
140
+ this ->mockSharingFcns ->getTexture3dDescSetParams = true ;
141
+ this ->mockSharingFcns ->getTexture3dDescParamsSet .textureDesc = this ->mockSharingFcns ->mockTexture3dDesc ;
123
142
124
143
mockMM->mapAuxGpuVaRetValue = false ;
125
- std::unique_ptr<Image> image (D3DTexture<TypeParam>::create3d (this ->context , ( D3DTexture3d *) &this ->dummyD3DTexture , CL_MEM_READ_WRITE, 1 , nullptr ));
144
+ std::unique_ptr<Image> image (D3DTexture<TypeParam>::create3d (this ->context , reinterpret_cast < D3DTexture3d *>( &this ->dummyD3DTexture ) , CL_MEM_READ_WRITE, 1 , nullptr ));
126
145
ASSERT_NE (nullptr , image.get ());
127
146
128
147
const auto &hwInfo = context->getDevice (0 )->getHardwareInfo ();
@@ -131,28 +150,33 @@ TYPED_TEST_P(D3DAuxTests, given3dSharableTextureWithUnifiedAuxFlagsWhenFailOnAux
131
150
132
151
EXPECT_EQ (expectedMapAuxGpuVaCalls, mockMM->mapAuxGpuVACalled );
133
152
EXPECT_EQ (!hwInfoConfig.isPageTableManagerSupported (hwInfo), gmm->isCompressionEnabled );
153
+ EXPECT_EQ (1u , this ->mockSharingFcns ->getTexture3dDescCalled );
134
154
}
135
155
136
156
TYPED_TEST_P (D3DAuxTests, given3dSharableTextureWithoutUnifiedAuxFlagsWhenCreatingThenDontMapAuxTable) {
137
157
this ->mockSharingFcns ->mockTexture3dDesc .MiscFlags = D3DResourceFlags::MISC_SHARED;
138
158
139
159
EXPECT_FALSE (gmm->unifiedAuxTranslationCapable ());
140
160
141
- EXPECT_CALL (*this ->mockSharingFcns , getTexture3dDesc (_, _)).Times (1 ).WillOnce (SetArgPointee<0 >(this ->mockSharingFcns ->mockTexture3dDesc ));
161
+ this ->mockSharingFcns ->getTexture3dDescSetParams = true ;
162
+ this ->mockSharingFcns ->getTexture3dDescParamsSet .textureDesc = this ->mockSharingFcns ->mockTexture3dDesc ;
142
163
143
- std::unique_ptr<Image> image (D3DTexture<TypeParam>::create3d (this ->context , ( D3DTexture3d *) &this ->dummyD3DTexture , CL_MEM_READ_WRITE, 1 , nullptr ));
164
+ std::unique_ptr<Image> image (D3DTexture<TypeParam>::create3d (this ->context , reinterpret_cast < D3DTexture3d *>( &this ->dummyD3DTexture ) , CL_MEM_READ_WRITE, 1 , nullptr ));
144
165
ASSERT_NE (nullptr , image.get ());
145
166
146
167
EXPECT_EQ (0u , mockMM->mapAuxGpuVACalled );
147
168
EXPECT_FALSE (gmm->isCompressionEnabled );
169
+ EXPECT_EQ (1u , this ->mockSharingFcns ->getTexture3dDescCalled );
148
170
}
149
171
150
172
TYPED_TEST_P (D3DAuxTests, given3dNonSharableTextureWithUnifiedAuxFlagsWhenCreatingThenMapAuxTableAndSetCompressed) {
151
173
mockGmmResInfo->setUnifiedAuxTranslationCapable ();
152
- EXPECT_CALL (*this ->mockSharingFcns , getTexture3dDesc (_, _)).Times (1 ).WillOnce (SetArgPointee<0 >(this ->mockSharingFcns ->mockTexture3dDesc ));
174
+
175
+ this ->mockSharingFcns ->getTexture3dDescSetParams = true ;
176
+ this ->mockSharingFcns ->getTexture3dDescParamsSet .textureDesc = this ->mockSharingFcns ->mockTexture3dDesc ;
153
177
154
178
mockGmmResInfo->setUnifiedAuxTranslationCapable ();
155
- std::unique_ptr<Image> image (D3DTexture<TypeParam>::create3d (this ->context , ( D3DTexture3d *) &this ->dummyD3DTexture , CL_MEM_READ_WRITE, 1 , nullptr ));
179
+ std::unique_ptr<Image> image (D3DTexture<TypeParam>::create3d (this ->context , reinterpret_cast < D3DTexture3d *>( &this ->dummyD3DTexture ) , CL_MEM_READ_WRITE, 1 , nullptr ));
156
180
ASSERT_NE (nullptr , image.get ());
157
181
158
182
const auto &hwInfo = context->getDevice (0 )->getHardwareInfo ();
@@ -161,6 +185,7 @@ TYPED_TEST_P(D3DAuxTests, given3dNonSharableTextureWithUnifiedAuxFlagsWhenCreati
161
185
162
186
EXPECT_EQ (expectedMapAuxGpuVaCalls, mockMM->mapAuxGpuVACalled );
163
187
EXPECT_TRUE (gmm->isCompressionEnabled );
188
+ EXPECT_EQ (1u , this ->mockSharingFcns ->getTexture3dDescCalled );
164
189
}
165
190
166
191
REGISTER_TYPED_TEST_CASE_P (D3DAuxTests,
0 commit comments