[RFC] C-source code writing functionality for ApiTrace (glx/egl)

Juha-Pekka Heikkila juhapekka.heikkila at gmail.com
Mon Sep 21 03:00:07 PDT 2015


Hi,

I've been writing feature for ApiTrace to get it to dump source codes
for the traces. I think it now reached some kind of 'alpha' level, thus
if someone else has ideas about such feature maybe voice in opinions.

This new feature is triggered as your give "--csource" parameter to
ApiTrace when replaying a trace, this will cause creation of folder
called <your trace>_c_source_code. Inside this new folder will be
Makefile, stub c code to setup glx or egl, needed data in their own
source file and frame_XXX.c for each frame.

This solution is not yet 100% all perfect solution but it works for some
applications, others will still need some manual work.

Things to know
* Shaders are not yet mapped to match the trace. This mean trace coming
from another computer probably may not work. For now this can be
bypassed by replaying trace and tracing this replay.
* Shaders with multiple shader source strings have hard coded limit of
65k/string for now.
* Linux only.
* In mid frame I drop out all glx/egl calls with exception of swap
buffer calls (I don't know if this will be a problem)
* My Makefiles set CC point to clang, this is because for me clang was
essentially faster to compile generated sources. Other than speedier
compilation gcc works equally for me with the generated source codes.

All in all this is still bit hack-ish looking but start to work for some
things already.

My branch for testing can be found here:
https://github.com/juhapekka/apitrace-1/tree/c_source_code_writer

Example usage:
apitrace retrace --csource <your trace>
cd <your trace>_c_source_code
make

Once you have your trace written out it should be enough to go to the
newly created folder and type in "make" and be prepared for quite long
wait, data.c will take normally quite a while to compile as it will have
textures inside it - because of this I've already though about at first
stage writing each blob into their own file to speed up compilation when
using j parameter for make, later just dump all textures as binary.

Anyhow, any comments are welcome.

/Juha-Pekka


More information about the apitrace mailing list