@@ -93,6 +93,105 @@ HWTEST_F(EnqueueReadImageTest, whenEnqueueReadImageThenBuiltinKernelIsResolved)
93
93
pCmdQ->finish ();
94
94
}
95
95
96
+ template <typename GfxFamily>
97
+ struct CreateAllocationForHostSurfaceFailCsr : public CommandStreamReceiverHw <GfxFamily> {
98
+ using CommandStreamReceiverHw<GfxFamily>::CommandStreamReceiverHw;
99
+
100
+ bool createAllocationForHostSurface (HostPtrSurface &surface, bool requiresL3Flush) override {
101
+ return CL_FALSE;
102
+ }
103
+ };
104
+
105
+ HWTEST_F (EnqueueReadImageTest, givenCommandQueueAndFailingAllocationForHostSurfaceWhenEnqueueReadImageThenOutOfResourceIsReturned) {
106
+ MockCommandQueueHw<FamilyType> cmdQ (context, pClDevice, nullptr );
107
+ auto failCsr = std::make_unique<CreateAllocationForHostSurfaceFailCsr<FamilyType>>(*pDevice->getExecutionEnvironment (), pDevice->getRootDeviceIndex (), pDevice->getDeviceBitfield ());
108
+
109
+ failCsr->setupContext (*pDevice->getDefaultEngine ().osContext );
110
+ CommandStreamReceiver *oldCommandStreamReceiver = cmdQ.gpgpuEngine ->commandStreamReceiver ;
111
+ cmdQ.gpgpuEngine ->commandStreamReceiver = failCsr.get ();
112
+
113
+ auto srcImage = Image2dHelper<>::create (context);
114
+ auto retVal = cmdQ.enqueueReadImage (srcImage, CL_FALSE,
115
+ EnqueueReadImageTraits::origin,
116
+ EnqueueReadImageTraits::region,
117
+ EnqueueReadImageTraits::rowPitch,
118
+ EnqueueReadImageTraits::slicePitch,
119
+ EnqueueReadImageTraits::hostPtr,
120
+ EnqueueReadImageTraits::mapAllocation,
121
+ 0u ,
122
+ nullptr ,
123
+ nullptr );
124
+ EXPECT_EQ (CL_OUT_OF_RESOURCES, retVal);
125
+ cmdQ.gpgpuEngine ->commandStreamReceiver = oldCommandStreamReceiver;
126
+ srcImage->release ();
127
+ }
128
+
129
+ HWTEST_F (EnqueueReadImageTest, givenCommandQueueAndFailingAllocationForHostSurfaceWhenBlockingEnqueueReadImageThenOutOfResourceIsReturned) {
130
+ MockCommandQueueHw<FamilyType> cmdQ (context, pClDevice, nullptr );
131
+ auto failCsr = std::make_unique<CreateAllocationForHostSurfaceFailCsr<FamilyType>>(*pDevice->getExecutionEnvironment (), pDevice->getRootDeviceIndex (), pDevice->getDeviceBitfield ());
132
+
133
+ failCsr->setupContext (*pDevice->getDefaultEngine ().osContext );
134
+ CommandStreamReceiver *oldCommandStreamReceiver = cmdQ.gpgpuEngine ->commandStreamReceiver ;
135
+ cmdQ.gpgpuEngine ->commandStreamReceiver = failCsr.get ();
136
+
137
+ auto srcImage = Image2dHelper<>::create (context);
138
+ auto retVal = cmdQ.enqueueReadImage (srcImage, CL_TRUE,
139
+ EnqueueReadImageTraits::origin,
140
+ EnqueueReadImageTraits::region,
141
+ EnqueueReadImageTraits::rowPitch,
142
+ EnqueueReadImageTraits::slicePitch,
143
+ EnqueueReadImageTraits::hostPtr,
144
+ EnqueueReadImageTraits::mapAllocation,
145
+ 0u ,
146
+ nullptr ,
147
+ nullptr );
148
+ EXPECT_EQ (CL_OUT_OF_RESOURCES, retVal);
149
+ cmdQ.gpgpuEngine ->commandStreamReceiver = oldCommandStreamReceiver;
150
+ srcImage->release ();
151
+ }
152
+
153
+ template <typename GfxFamily>
154
+ struct CreateAllocationForHostSurfaceCsr : public CommandStreamReceiverHw <GfxFamily> {
155
+ using CommandStreamReceiverHw<GfxFamily>::CommandStreamReceiverHw;
156
+
157
+ bool createAllocationForHostSurface (HostPtrSurface &surface, bool requiresL3Flush) override {
158
+ if (surface.peekIsPtrCopyAllowed ()) {
159
+ return CommandStreamReceiverHw<GfxFamily>::createAllocationForHostSurface (surface, requiresL3Flush);
160
+ } else {
161
+ return CL_FALSE;
162
+ }
163
+ }
164
+
165
+ CompletionStamp flushTask (LinearStream &commandStream, size_t commandStreamStart,
166
+ const IndirectHeap &dsh, const IndirectHeap &ioh, const IndirectHeap &ssh,
167
+ uint32_t taskLevel, DispatchFlags &dispatchFlags, Device &device) override {
168
+ return CompletionStamp{0u , 0u , static_cast <FlushStamp>(0u )};
169
+ }
170
+ };
171
+
172
+ HWTEST_F (EnqueueReadImageTest, givenCommandQueueAndPtrCopyAllowedForHostSurfaceWhenBlockingEnqueueReadImageThenSuccessIsReturned) {
173
+ auto csr = std::make_unique<CreateAllocationForHostSurfaceCsr<FamilyType>>(*pDevice->getExecutionEnvironment (), pDevice->getRootDeviceIndex (), pDevice->getDeviceBitfield ());
174
+ auto cmdQ = std::make_unique<MockCommandQueueHw<FamilyType>>(context, pClDevice, nullptr );
175
+
176
+ csr->setupContext (*pDevice->getDefaultEngine ().osContext );
177
+ CommandStreamReceiver *oldCommandStreamReceiver = cmdQ->gpgpuEngine ->commandStreamReceiver ;
178
+ cmdQ->gpgpuEngine ->commandStreamReceiver = csr.get ();
179
+ csr->initializeTagAllocation ();
180
+
181
+ auto retVal = cmdQ->enqueueReadImage (srcImage, CL_TRUE,
182
+ EnqueueReadImageTraits::origin,
183
+ EnqueueReadImageTraits::region,
184
+ EnqueueReadImageTraits::rowPitch,
185
+ EnqueueReadImageTraits::slicePitch,
186
+ EnqueueReadImageTraits::hostPtr,
187
+ EnqueueReadImageTraits::mapAllocation,
188
+ 0u ,
189
+ nullptr ,
190
+ nullptr );
191
+ EXPECT_EQ (CL_SUCCESS, retVal);
192
+ cmdQ->gpgpuEngine ->commandStreamReceiver = oldCommandStreamReceiver;
193
+ }
194
+
96
195
HWTEST_F (EnqueueReadImageTest, givenMultiRootDeviceImageWhenEnqueueReadImageThenKernelRequiresMigration) {
97
196
98
197
MockDefaultContext context;
0 commit comments