Using “apitrace” with an OpenGL application

The basic commands for using apitrace with an OpenGL application are:

apitrace trace --api=gl MyApp
qapitrace MyApp.trace
apitrace dump --blobs MyApp.trace 

The last command generates blobs that can be inspected with the following command, for example:

tail -c $((12*10)) ~/repos/MyApp/build/blob_call2325.bin | xxd -g1

Or by writing a simple C++ program that converts them into CVS format:

#include <fstream>
#include <iostream>

int main()
{
	std::ifstream file("~/repos/MyApp/build/blob_call2325.bin");
	std::cout.precision(9);
	while(file)
	{
		for(int i=0;i<3 && file;++i)
		{
			float x;
			file.read(reinterpret_cast<char*>(&x),sizeof x);
			if(!file) break;
			switch(i)
			{
			case 0:
				std::cout << x << ',';
				break;
			case 1:
				std::cout << x << ',';
				break;
			case 2:
				std::cout << x << "\n";
				break;
			}
		}
	}
}

And then opening CVS files in LibreOffice:

g++ test.cpp -o test && ./test > test.csv
libreoffice --calc test.csv

libreoffice

In LibreOffice the data looks good, but in qapitrace and in the application we see a bit different picture:

qapitrace

After doing some further experimentation we came to the conclusion that something is wrong with installed OpenGL driver.

glxinfo | grep "OpenGL version"

OpenGL version string: 2.1 Mesa 10.1.3

Finally I switched to Nvidia driver and made my OpenGL code work with the following commands:

263 dmesg|less
264 glxinfo
265 sudo apt-get remove nouveau
266 apt-cache search nouveau
267 echo $$
268 ps -A|grep 3800
269 sudo apt-get install –reinstall nvidia-375
270 ldd `which glxinfo`
271 dpkg -S /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1
272 sudo apt-get remove libgl1-mesa-glx
273 ldd `which glxinfo`
274 find /usr/lib -name ‘libGL.so*’
275 ls -l /usr/lib/x86_64-linux-gnu/libGL.so
276 sudo ln -sv /usr/lib/nvidia-375/libGL.so /usr/lib/x86_64-linux-gnu/libGL.so
277 sudo ln -svf /usr/lib/nvidia-375/libGL.so /usr/lib/x86_64-linux-gnu/libGL.so
278 glxinfo
279 ldd `which glxinfo`
280 sudo ldconfig
281 ldd `which glxinfo`
282 find /usr/lib -name ‘libGL.so.1’
283 ls /etc/ld.so.conf.d/
284 grep mesa /etc/ld.so.conf.d/ -r
285 grep mesa /etc/ld.so.conf
286 cat /etc/ld.so.conf.d/x86_64-linux-gnu_GL.conf
287 grep mesa /etc/ld.so.conf.d/ -r
288 grep -r mesa /etc/ld.so.conf.d/
289 cd /etc/ld.so.conf.d/
290 grep mesa . -r
291 cat *
292 cat *|grep mesa
293 cat *|grep –color mesa
294 type grep
295 grep mesa . -r
296 grep -r mesa .
297 grep -r mes .
298 cat x86_64-linux-gnu_GL.conf
299 ls -lh x86_64-linux-gnu_GL.conf
300 update-alternatives /etc/alternatives/
301 ls -lh x86_64-linux-gnu_GL.conf
302 sudo update-alternatives –config x86_64-linux-gnu_gl_conf
303 sudo update-alternatives –config x86_64-linux-gnu_gl_conf
304 ldd `which glxinfo`
305 sudo ldconfig
306 ldd `which glxinfo`
307 sudo reboot
308 ls /etc/X11/
309 glxinfo
310 ldd `which glxinfo`
311 sudo update-alternatives –config x86_64-linux-gnu_gl_conf
312 grep mesa /etc -r
313 sudo grep mesa /etc -r
314 sudo grep –color mesa /etc -r
315 sudo grep –color nvidia /etc -r
316 sudo ldconfig
317 glxinfo
318 dmesg|less
319 lsmdo
320 lsmod
321 lsmod|grep nvidia
322 sudo apt-get purge nvidia
323 sudo apt-get purge nvidia-375
324 sudo apt-get purge nvidia-*
325 update-alternatives –config x86_64-linux-gnu_gl_conf
326 update-alternatives –config i386-linux-gnu_egl_conf
327 update-alternatives –config x86_64-linux-gnu_gl_conf
328 xwininfo -all
329 xwininfo -all|grep -i process
330 ps -A|grep 13236
331 sudo apt-get update
332 update-alternatives –config x86_64-linux-gnu_gl_conf
333 update-alternatives –config x86_64-linux-gnu_gl_conf
334 sudo reboot
335 glxinfo
336 update-alternatives –config x86_64-linux-gnu_gl_conf
337 grep update-alternatives /etc/ -r
338 sudo grep update-alternatives /etc/ -r
339 inxi -F
340 man inxi
341 update-alternatives –config x86_64-linux-gnu_gl_conf
342 grep x86_64-linux-gnu_gl_conf /etc -r
343 sudo grep x86_64-linux-gnu_gl_conf /etc -r
344 sudo grep x86_64-linux-gnu_gl_conf /usr/bin -r
345 sudo grep x86_64-linux-gnu_gl_conf /bin -r
346 sudo grep x86_64-linux-gnu_gl_conf /usr/lib -r
347 ls -l /etc/alternatives/
348 ls -l /etc/alternatives/|grep GL
349 ls -l /etc/alternatives/|grep gl
350 sudo update-alternatives –config x86_64-linux-gnu_gl_conf
351 sudo ldconfig
352 glxinfo
353 sudo restart lightdm
354 glxinfo
355 echo $DISPLAY
356 sudo stop lightdm
357 sudo update-alternatives –config x86_64-linux-gnu_gl_conf
358 sudo ldconfig
359 update-alternatives –config x86_64-linux-gnu_gl_conf
360 glxinfo
361 glxgears
362 glxinfo
363 cd /etc/lightdm/
364 ls
365 vim -p *
366 kdm
367 sudo apt-get install kdm
368 sudo apt-get purge lightdm
369 ls /var/lib/lightdm-data/
370 grep mesa -r /var/lib/lightdm-data/
371 sudo grep mesa -r /var/lib/lightdm-data/
372 sudo grep mesa -r /etc/lightdm/
373 ls -lA /etc/lightdm/
374 vim /etc/lightdm/lightdm.conf
375 vim /etc/lightdm/lightdm.conf
376 rm /etc/lightdm/lightdm.conf
377 sudo rm /etc/lightdm/lightdm.conf
378 sudo rmdir /etc/lightdm/
379 sudo rm /etc/lightdm/lightdm.conf.orig.vgl
380 sudo rmdir /etc/lightdm/lightdm.conf.orig.vgl
381 sudo rmdir /etc/lightdm/
382 ls
383 /var/lib/lightdm-data
384 ls /var/lib/lightdm-data
385 ls /var/lib/lightdm-data/*
386 sudo ls /var/lib/lightdm-data/*
387 sudo rm -rfv /var/lib/lightdm-data/
388 sync
389 glxinfo
390 update-alternatives –config x86_64-linux-gnu_gl_conf
391 sudo update-alternatives –config x86_64-linux-gnu_gl_conf
392 sudo update-alternatives –config x86_64-linux-gnu_gl_conf
393 sudo ldconfig
394 sudo stop kdm
395 sudo update-alternatives –config x86_64-linux-gnu_gl_conf
396 update-alternatives –config x86_64-linux-gnu_gl_conf
397 cd /etc
398 cd init
399 ls
400 vim kdm.conf
401 glxinfo
402 ls
403 grep alterna . -r
404 cd ..
405 grep alterna . -r
406 sudo grep alterna . -r
407 sudo grep –color alterna . -r
408 screen
409 vim /var/log/Xorg.0.log
410 xterm
411 startx `which xterm`
412 sudo update-alternatives –config x86_64-linux-gnu_gl_conf
413 update-alternatives –config x86_64-linux-gnu_gl_conf
414 startx `which xterm`
415 startx `which startkde`
416 sudo start kdm
417 update-alternatives –config x86_64-linux-gnu_gl_conf
418 grep _gl_ /etc/ -r
419 sudo grep _gl_ /etc/ -r
420 sudo su -c kdm
421 update-alternatives –config x86_64-linux-gnu_gl_conf
422 update-alternatives –config x86_64-linux-gnu_gl_conf
423 sudo killall kdm
424 ps -A|grep kde
425 update-alternatives –config x86_64-linux-gnu_gl_conf
426 ls -l /etc/alternatives/i386-linux-gnu_gl_conf
427 ls -l /etc/alternatives/x86_64-linux-gnu_gl_conf
428 date
429 man strace
430 sudo strace -f -e open -o /tmp/upstart.trace start kdm
431 vim /tmp/upstart.trace
432 update-alternatives –config x86_64-linux-gnu_gl_conf
433 grep mesa /var/ -r
434 sudo grep mesa /var/ -r
435 sudo grep –color mesa /var/ -r
436 sudo grep –color alternati /var/ -r
437 sudo grep –color _gl_ /var/ -r
438 cd /var/log
439 ls gpu-manager.log -l
440 date
441 vim gpu-manager.log
442 vim /etc/modules
443 grep nvidia -r /etc/modprobe.d/
444 sudo apt-get remove bumblebee
445 sudo apt-get remove bumblebee –purge
446 update-alternatives –config x86_64-linux-gnu_gl_conf
447 sudo update-alternatives –config x86_64-linux-gnu_gl_conf
448 sudo stop kdm
449 update-alternatives –config x86_64-linux-gnu_gl_conf
450 sudo start kdm
451 update-alternatives –config x86_64-linux-gnu_gl_conf
452 glxinfo
453 update-alternatives –config x86_64-linux-gnu_gl_conf
454 sudo ldconfig
455 glxinfo
456 inxi -F
457 grep nvidia /etc/moprobe.d
458 grep nvidia /etc/modprobe.d/
459 grep nvidia /etc/modprobe.d/ -r
460 grep nvidia /etc/modprobe.d/ -r –color
461 glxinfo
462 lsmod|grep nviida
463 lsmod|grep nvidia
464 lsmod|grep nouveau
465 update-alternatives –config x86_64-linux-gnu_gl_conf
466 ldd `which glxinfo`
467 sudo apt-get install –reinstall nvidia-376
468 sudo apt-get install –reinstall nvidia-375
469 glxinfo
470 echo $DISPLAY
471 glxinfo
472 vim /var/log/Xorg.0.log
473 locate libnvidia-tls.so.375.66
474 sudo updatedb
475 locate libnvidia-tls.so.375.66
476 sudo ldconfig
477 glxinfo
478 vim /var/log/Xorg.0.log
479 ls -l /usr/lib/x86_64-linux-gnu/xorg/extra-modules/libglx.so
480 fgrep –color ‘375.66’ /var/log/Xorg.0.log
481 grep nvidia -r /etc/ld.so.conf.d/
482 ls -l /etc/ld.so.conf.d/
483 locate libnvidia-tls.so.375.66
484 ls -l /usr/lib/nvidia-375
485 ls /usr/lib/nvidia-375
486 ldd /usr/lib/x86_64-linux-gnu/xorg/extra-modules/libglx.so
487 sudo stop kdm
488 glxinfo
489 cd build/bin/
490 ./sdpd
491 ./Multiplexer
492 ./snetd
493 ./replay
494 startx `which xterm`
495 startx `which startkde`
496 startx `which startkde`

Leave a Reply

Your email address will not be published.