MCPcopy Create free account
hub / github.com/VirtualGL/virtualgl / nativeRead

Function nativeRead

util/fbxtest.cpp:278–327  ·  view source on GitHub ↗

Platform-specific readback test

Source from the content-addressed store, hash-verified

276
277// Platform-specific readback test
278void nativeRead(bool useShm)
279{
280 fbx_struct fb; int i, error = 0; double readTime;
281 Timer timer, timer2;
282
283 memset(&fb, 0, sizeof(fb));
284
285 try
286 {
287 TRY_FBX(fbx_init(&fb, wh, 0, 0, useShm ? 1 : 0));
288 if(useShm && !fb.shm) THROW("MIT-SHM not available");
289 if(fb.width != drawableWidth || fb.height != drawableHeight)
290 {
291 fprintf(stderr, "WARNING: Requested size = %d x %d Actual size = %d x %d\n",
292 drawableWidth, drawableHeight, fb.width, fb.height);
293 }
294
295 if(useShm)
296 fprintf(stderr, "FBX read [SHM]: ");
297 else
298 fprintf(stderr, "FBX read: ");
299 memset(fb.bits, 0, fb.width * fb.height * fb.pf->size);
300 i = 0; readTime = 0.; timer2.start();
301 do
302 {
303 timer.start();
304 TRY_FBX(fbx_read(&fb, 0, 0));
305 readTime += timer.elapsed();
306 if(!cmpBuf(0, 0, fb.width, fb.pitch, fb.height, fb.pf,
307 (unsigned char *)fb.bits, pixelOffset))
308 error = 1;
309 i++;
310 } while(timer2.elapsed() < benchTime);
311 fprintf(stderr, "%f Mpixels/sec",
312 (double)i * (double)(fb.width * fb.height) / (1000000. * readTime));
313 if(error)
314 {
315 fprintf(stderr, " (ERROR CHECK FAILED)\n");
316 retCode = -1;
317 }
318 else fprintf(stderr, " (no errors)\n");
319
320 }
321 catch(std::exception &e)
322 {
323 fprintf(stderr, "%s\n", e.what()); retCode = -1;
324 }
325
326 fbx_term(&fb);
327}
328
329
330// This serves as a unit test for the FBX library

Callers 1

displayFunction · 0.85

Calls 6

fbx_readFunction · 0.85
fbx_termFunction · 0.85
elapsedMethod · 0.80
whatMethod · 0.80
cmpBufFunction · 0.70
startMethod · 0.45

Tested by

no test coverage detected