59 |
59 |
60 _LIT(KErrEglConfigNotSupported, "EGL config is not supported."); |
60 _LIT(KErrEglConfigNotSupported, "EGL config is not supported."); |
61 _LIT(KInfoRectangles, "Number of dirty rectangles: %d"); |
61 _LIT(KInfoRectangles, "Number of dirty rectangles: %d"); |
62 _LIT(KWarnStressTestRectCount, "Dirty rectangles for stress test don't fit onto window surface (%d of %d)."); |
62 _LIT(KWarnStressTestRectCount, "Dirty rectangles for stress test don't fit onto window surface (%d of %d)."); |
63 |
63 |
|
64 _LIT(KEglSwapBuffersRegionNokMsg, "eglSwapBuffersRegionNOK extension is not supported."); |
64 |
65 |
65 CEglTest_Benchmark_SwapBuffers::CEglTest_Benchmark_SwapBuffers() |
66 CEglTest_Benchmark_SwapBuffers::CEglTest_Benchmark_SwapBuffers() |
66 { |
67 { |
67 SetTestStepName(KBenchmark_SwapBuffers); |
68 SetTestStepName(KBenchmark_SwapBuffers); |
68 } |
69 } |
132 ASSERT_EGL_TRUE(iEglSurface != EGL_NO_SURFACE); |
133 ASSERT_EGL_TRUE(iEglSurface != EGL_NO_SURFACE); |
133 iEglContext = eglCreateContext(iDisplay, matchingConfigs[0], EGL_NO_CONTEXT, NULL); |
134 iEglContext = eglCreateContext(iDisplay, matchingConfigs[0], EGL_NO_CONTEXT, NULL); |
134 ASSERT_EGL_TRUE(iEglContext != EGL_NO_CONTEXT); |
135 ASSERT_EGL_TRUE(iEglContext != EGL_NO_CONTEXT); |
135 ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, iEglSurface, iEglSurface, iEglContext)); |
136 ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, iEglSurface, iEglSurface, iEglContext)); |
136 |
137 |
137 // Get the function pointer for eglSwapBuffersRegionNOK() and check SwapBuffers extension exist |
138 // Get the function pointer for eglSwapBuffersRegionNOK() |
138 PFNEGLSWAPBUFFERSREGIONNOKPROC pfnEglSwapBuffersRegionNok = reinterpret_cast<PFNEGLSWAPBUFFERSREGIONNOKPROC>(eglGetProcAddress("eglSwapBuffersRegionNOK")); |
139 iPfnEglSwapBuffersRegionNok = reinterpret_cast<PFNEGLSWAPBUFFERSREGIONNOKPROC>(eglGetProcAddress("eglSwapBuffersRegionNOK")); |
139 ASSERT_EGL_TRUE(pfnEglSwapBuffersRegionNok); |
|
140 |
140 |
141 return TestStepResult(); |
141 return TestStepResult(); |
142 } |
142 } |
143 |
143 |
144 TVerdict CEglTest_Benchmark_SwapBuffers::doTestStepPostambleL() |
144 TVerdict CEglTest_Benchmark_SwapBuffers::doTestStepPostambleL() |
184 { |
184 { |
185 SetTestStepResult(EAbort); |
185 SetTestStepResult(EAbort); |
186 } |
186 } |
187 RecordTestResultL(); |
187 RecordTestResultL(); |
188 |
188 |
189 // Tests the maximum performance of eglSwapBuffersRegionNOK() |
189 // We only perform swap region benchmark test if eglSwapBuffersRegionNOK extension is supported |
190 SetTestStepID(KTestStep0529); |
190 if (iPfnEglSwapBuffersRegionNok != NULL) |
191 TRAP(err, EglSwapBufferRegionL()); |
191 { |
192 if (err != KErrNone) |
192 // Tests the maximum performance of eglSwapBuffersRegionNOK() |
193 { |
193 SetTestStepID(KTestStep0529); |
194 SetTestStepResult(EAbort); |
194 TRAP(err, EglSwapBufferRegionL()); |
195 } |
|
196 RecordTestResultL(); |
|
197 |
|
198 // Stress tests the performance of eglSwapBuffersRegionNOK() |
|
199 SetTestStepID(KTestStep0530); |
|
200 for (TInt noRects = KStressTestNoRectsStepSize; noRects <= KStressTestMaxNoRects; noRects += KStressTestNoRectsStepSize) |
|
201 { |
|
202 // TRAP here is on purpose, normally you shouldn't use it in loops |
|
203 TRAP(err, EglSwapBufferRegionStressL(noRects)); |
|
204 if (err != KErrNone) |
195 if (err != KErrNone) |
205 { |
196 { |
206 ERR_PRINTF2(_L("EglSwapBufferRegionStressL (leave code: %d)."), err); |
|
207 SetTestStepResult(EAbort); |
197 SetTestStepResult(EAbort); |
|
198 } |
|
199 RecordTestResultL(); |
|
200 |
|
201 // Stress tests the performance of eglSwapBuffersRegionNOK() |
|
202 SetTestStepID(KTestStep0530); |
|
203 for (TInt noRects = KStressTestNoRectsStepSize; noRects <= KStressTestMaxNoRects; noRects += KStressTestNoRectsStepSize) |
|
204 { |
|
205 // TRAP here is on purpose, normally you shouldn't use it in loops |
|
206 TRAP(err, EglSwapBufferRegionStressL(noRects)); |
|
207 if (err != KErrNone) |
|
208 { |
|
209 ERR_PRINTF2(_L("EglSwapBufferRegionStressL (leave code: %d)."), err); |
|
210 SetTestStepResult(EAbort); |
|
211 } |
208 } |
212 } |
209 } |
213 RecordTestResultL(); |
210 RecordTestResultL(); |
214 } |
|
215 else |
|
216 { |
|
217 INFO_PRINTF1(KEglSwapBuffersRegionNokMsg); |
|
218 } |
211 |
219 |
212 // Close the test and return result to the testframework |
220 // Close the test and return result to the testframework |
213 CloseTMSGraphicsStep(); |
221 CloseTMSGraphicsStep(); |
214 return TestStepResult(); |
222 return TestStepResult(); |
215 } |
223 } |
277 // Rectangle for partial swap buffer function |
285 // Rectangle for partial swap buffer function |
278 const EGLint rects[] = {KRegionRect.iTl.iX, KRegionRect.iTl.iY, KRegionRect.Width(), KRegionRect.Height()}; |
286 const EGLint rects[] = {KRegionRect.iTl.iX, KRegionRect.iTl.iY, KRegionRect.Width(), KRegionRect.Height()}; |
279 // Number of rectangles (one rectangle consist of 4 values) |
287 // Number of rectangles (one rectangle consist of 4 values) |
280 const EGLint count = (sizeof(rects) / (sizeof(rects[0] * 4))); |
288 const EGLint count = (sizeof(rects) / (sizeof(rects[0] * 4))); |
281 |
289 |
282 // Get the function pointer for eglSwapBuffersRegionNOK() |
290 // We obtain the func ptr in doTestStepPreambleL and only execute this test if it is not null |
283 PFNEGLSWAPBUFFERSREGIONNOKPROC pfnEglSwapBuffersRegionNok = reinterpret_cast<PFNEGLSWAPBUFFERSREGIONNOKPROC>(eglGetProcAddress("eglSwapBuffersRegionNOK")); |
291 TESTL(iPfnEglSwapBuffersRegionNok != NULL); |
284 |
292 |
285 // Clear the surface |
293 // Clear the surface |
286 vgSetfv(VG_CLEAR_COLOR, 4, KClearColors[0]); |
294 vgSetfv(VG_CLEAR_COLOR, 4, KClearColors[0]); |
287 vgClear(0, 0, iWindowSize.iWidth, iWindowSize.iHeight); |
295 vgClear(0, 0, iWindowSize.iWidth, iWindowSize.iHeight); |
288 ASSERT_EGL_TRUE(eglSwapBuffers(iDisplay, iEglSurface)); |
296 ASSERT_EGL_TRUE(eglSwapBuffers(iDisplay, iEglSurface)); |
294 { |
302 { |
295 // Clean the surface with the background color |
303 // Clean the surface with the background color |
296 vgSetfv(VG_CLEAR_COLOR, 4, KClearColors[i % KMaxClearColors]); |
304 vgSetfv(VG_CLEAR_COLOR, 4, KClearColors[i % KMaxClearColors]); |
297 vgClear(0, 0, iWindowSize.iWidth, iWindowSize.iHeight); |
305 vgClear(0, 0, iWindowSize.iWidth, iWindowSize.iHeight); |
298 // Swap the surface buffers |
306 // Swap the surface buffers |
299 ASSERT_EGL_TRUE(pfnEglSwapBuffersRegionNok(iDisplay, iEglSurface, count, rects)); |
307 ASSERT_EGL_TRUE(iPfnEglSwapBuffersRegionNok(iDisplay, iEglSurface, count, rects)); |
300 } |
308 } |
301 // Mark the time and print the results to the log file |
309 // Mark the time and print the results to the log file |
302 iProfiler->MarkResultSetL(); |
310 iProfiler->MarkResultSetL(); |
303 iProfiler->ResultsAnalysisFrameRate(KTestStep0529, 0, 0, 0, |
311 iProfiler->ResultsAnalysisFrameRate(KTestStep0529, 0, 0, 0, |
304 KIterationsToTest, iWindowSize.iWidth * iWindowSize.iHeight); |
312 KIterationsToTest, iWindowSize.iWidth * iWindowSize.iHeight); |
346 if (actualRectCount != aCount) |
354 if (actualRectCount != aCount) |
347 { |
355 { |
348 WARN_PRINTF3(KWarnStressTestRectCount, actualRectCount, aCount); |
356 WARN_PRINTF3(KWarnStressTestRectCount, actualRectCount, aCount); |
349 } |
357 } |
350 |
358 |
351 // Get the function pointer for eglSwapBuffersRegionNOK() |
359 // We obtain the func ptr in doTestStepPreambleL and only execute this test if it is not null |
352 PFNEGLSWAPBUFFERSREGIONNOKPROC pfnEglSwapBuffersRegionNok = reinterpret_cast<PFNEGLSWAPBUFFERSREGIONNOKPROC>(eglGetProcAddress("eglSwapBuffersRegionNOK")); |
360 TESTL(iPfnEglSwapBuffersRegionNok != NULL); |
353 |
361 |
354 // Clear the surface |
362 // Clear the surface |
355 vgSetfv(VG_CLEAR_COLOR, 4, KClearColors[0]); |
363 vgSetfv(VG_CLEAR_COLOR, 4, KClearColors[0]); |
356 vgClear(0, 0, iWindowSize.iWidth, iWindowSize.iHeight); |
364 vgClear(0, 0, iWindowSize.iWidth, iWindowSize.iHeight); |
357 ASSERT_EGL_TRUE(eglSwapBuffers(iDisplay, iEglSurface)); |
365 ASSERT_EGL_TRUE(eglSwapBuffers(iDisplay, iEglSurface)); |
363 { |
371 { |
364 // Clean the surface with the background color |
372 // Clean the surface with the background color |
365 vgSetfv(VG_CLEAR_COLOR, 4, KClearColors[i % KMaxClearColors]); |
373 vgSetfv(VG_CLEAR_COLOR, 4, KClearColors[i % KMaxClearColors]); |
366 vgClear(0, 0, iWindowSize.iWidth, iWindowSize.iHeight); |
374 vgClear(0, 0, iWindowSize.iWidth, iWindowSize.iHeight); |
367 // Swap the surface buffers |
375 // Swap the surface buffers |
368 ASSERT_EGL_TRUE(pfnEglSwapBuffersRegionNok(iDisplay, iEglSurface, actualRectCount, rects)); |
376 ASSERT_EGL_TRUE(iPfnEglSwapBuffersRegionNok(iDisplay, iEglSurface, actualRectCount, rects)); |
369 } |
377 } |
370 // Mark the time and print the results to the log file |
378 // Mark the time and print the results to the log file |
371 iProfiler->MarkResultSetL(); |
379 iProfiler->MarkResultSetL(); |
372 INFO_PRINTF2(KInfoRectangles, aCount); |
380 INFO_PRINTF2(KInfoRectangles, aCount); |
373 iProfiler->ResultsAnalysisFrameRate(KTestStep0530, 0, 0, 0, |
381 iProfiler->ResultsAnalysisFrameRate(KTestStep0530, 0, 0, 0, |