4

I want to create a framework for automated rendering tests for video games.

I want to test an application that normally renders to a window with OpenGL. Instead, I want it to render into image files for further evaluation. I want to do this on a Linux server with no GPU.

How can I do this with minimal impact on the evaluated application?

Some remarks for clarity:

  • The OpenGL version is 2.1, so software rendering with Mesa should be possible.
  • Preferably, I don't want to change any of the application code. If there is a solution that allows me to emulate a X server or something like that, I would prefer it.
  • I don't want to change any of the rendering code. If it is really necessary, I can change the way I initialize OpenGL, but after that, I want to execute arbitrary OpenGL code.

Ideally, your answer would explain how to set up an environment on a headless Linux server that allows me to start arbitrary OpenGL binaries and render its output into images. If that's not possible, I am open for any suggestions.

Lukas Boersma
  • 1,022
  • 8
  • 26
  • I do this precise sort of thing as part of a certain type of automated server-side testing which emphasizes preserving/enhancing visual qualities (requires human review). I'm not sure if this is the most direct/straightforward approach, but I do it by rendering to offscreen FBOs and then grabbing the resulting raw texture pixels through `glGetTexImage`. The rest is standard image I/O. –  Nov 18 '15 at 18:35
  • Does your solution work on a machine without a GPU? If yes, how do you set this up? – Lukas Boersma Nov 18 '15 at 18:37
  • I do exactly what you are talking about... the only difference is that I use GPU. I never tried with MESA. Besides this detail, I can help you with everything else. – Wagner Patriota Nov 18 '15 at 18:37
  • In my case I use a GPU -- but I would think if the capabilities are there to render FBOs, you should be set. –  Nov 18 '15 at 18:38
  • oh yes, now I see the other comment that showed up while I was writing mine... lol. well... I basically start X Server, create a OpenGL context, then I open frame buffers... render to to frame buffers and then I download the texture I created – Wagner Patriota Nov 18 '15 at 18:39
  • Related: http://stackoverflow.com/questions/3191978/how-to-use-glut-opengl-to-render-to-a-file – Ciro Santilli OurBigBook.com Sep 11 '16 at 14:50

2 Answers2

2

Use Xvfb for your X server. The installation of Mesa deployed on any modern Linux distribution should automatically fall back to software rasterization if no supported GPU is found. You can take screenshots with any X11 screen grabber program; heck even ffmpeg -i x11grab will work.

datenwolf
  • 159,371
  • 13
  • 185
  • 298
1

fbdev/miniglx might be something that you are looking for. http://www.mesa3d.org/fbdev-dri.html I haven't used it so I have no idea if it works for your purpose or not.

Alternative is to just start and xserver without any desktop environment with xinit. That setup is using well tested code paths making it better suited for running your test. miniglx might have bugs which none has noticed because it isn't used everyday.

To capture the rendering output to images could be done with LD_PRELOAD trick to wrap glXSwapBuffers. Basic idea is to add your own swapbuffers function in between your application and gl library where you can use glReadPixels to download rendered frame and then use your favorite image library to write that data to image/video files. After the glReadPixels has completed you can call to library glXSwapBuffers to make swap happen like it would happen in real desktop.

The prog subdirectory has been removed from main git repository and you can find it from git://anongit.freedesktop.org/git/mesa/demos instead.

Pauli Nieminen
  • 1,100
  • 8
  • 7