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

Tapani Pälli tapani.palli at intel.com
Mon Sep 21 22:54:07 PDT 2015


Hi;

On 09/21/2015 01:00 PM, Juha-Pekka Heikkila wrote:
> 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.

I see this very useful in creating small executables that just repeat 
one given frame for n times or for example playback only wanted set of 
frame 'from 50 to 100'. IMO these would be nice future additions, now 
one needs to recompile which feels cumbersome and not always even 
possible when investigating some trace in a production machine without 
compiler or dev library dependencies.

> 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.

For me it didn't, I'm getting errors like this with gcc 5.1.1:

frame_0.c:6555:17: error: expected declaration specifiers or ‘...’ 
before numeric constant
      glUniform4f(3, 0.1434, 0.1329, 0.7755, 1);

frame_0.c:6556:23: error: expected declaration specifiers or ‘...’ 
before numeric constant
      glBindVertexArray(197);

...

> 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
> _______________________________________________
> apitrace mailing list
> apitrace at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/apitrace
>


More information about the apitrace mailing list