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

Function writeTest

util/glreadtest.cpp:353–397  ·  view source on GitHub ↗

Generic GL write test

Source from the content-addressed store, hash-verified

351
352// Generic GL write test
353int writeTest(int format)
354{
355 PF *pf = pf_get(format);
356 unsigned char *rgbaBuffer = NULL;
357 int n, retval = 0;
358 double rbtime;
359 char temps[STRLEN];
360
361 try
362 {
363 fprintf(stderr, "glDrawPixels(): ");
364 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
365 glPixelStorei(GL_PACK_ALIGNMENT, 1);
366 glShadeModel(GL_FLAT);
367 glDisable(GL_DEPTH_TEST);
368 glDisable(GL_LIGHTING);
369 clearFB();
370 if((rgbaBuffer = (unsigned char *)malloc(drawableWidth * drawableHeight *
371 pf->size)) == NULL)
372 THROW("Could not allocate buffer");
373 initBuf(0, 0, drawableWidth, drawableHeight, pf, rgbaBuffer);
374 n = 0;
375 timer.start();
376 do
377 {
378 glDrawPixels(drawableWidth, drawableHeight, glFormat[format],
379 pf_gldatatype[format], rgbaBuffer);
380 glFinish();
381 n++;
382 } while((rbtime = timer.elapsed()) < benchTime || n < 2);
383
384 double avgmps = (double)n * (double)(drawableWidth * drawableHeight) /
385 (1000000. * rbtime);
386 check_errors("frame buffer write");
387 fprintf(stderr, "%s Mpixels/sec\n", sigFig(4, temps, avgmps));
388
389 }
390 catch(std::exception &e)
391 {
392 fprintf(stderr, "%s\n", e.what()); retval = -1;
393 }
394
395 free(rgbaBuffer);
396 return retval;
397}
398
399
400// Generic OpenGL readback test

Callers 1

displayFunction · 0.85

Calls 9

pf_getFunction · 0.85
glFinishFunction · 0.85
check_errorsFunction · 0.85
sigFigFunction · 0.85
elapsedMethod · 0.80
whatMethod · 0.80
clearFBFunction · 0.70
initBufFunction · 0.70
startMethod · 0.45

Tested by

no test coverage detected