How can I extract texture data from a trace file?

Tim Allen screwtape at froup.com
Fri Oct 26 19:13:52 PDT 2012


I'm investigating a bug filed against Mesa[1], and I discovered ApiTrace
as a useful tool for diagnosing such things, however I've gotten stuck
and was hoping somebody here would be able to help me out, or at least
point me in the right direction. Specifically, here's where I'm up to:

- In a certain game, there is a certain wall, which is drawn with
  a certain texture, and when this game is run on proprietary OpenGL
  stacks, it renders just fine. When the game is run on Mesa-based GL
  drivers, the wall is rendered in a particularly glitchy way.
- I have located the texture in the game's data files, and it seems to
  be just fine there (it's a DDS file, and the GIMP DDS plugin opens it
  up and saves it out again quite happily).
- I have run the game inside ApiTrace, and captured a record of the game
  rendering this wall to the screen.
- I have browsed the trace with the QApiTrace tool, and found the
  glTexSubImage2D() call where the texture is uploaded. If I use
  QApiTrace to inspect the GL state after the glTexSubImage2D()
  call, I can see the loaded texture is corrupt.
- So either the texture is being corrupted by the game before being
  handed to Mesa (in which case it's a game bug) or the texture is being
  corrupted by Mesa before being loaded into video memory (in which case
  it's a Mesa bug and I might be able to do something about it).

So the question I'm trying to answer is: is the data that the game hands
to Mesa already corrupted or not? ApiTrace clearly has that data
recorded in the trace, since it can replay all the GL calls the game
made, but I can't seem to figure out how to extract that data. I can
dump the sequence of GL calls, but that just gives me output like:

    glTexSubImage2D(
	target = GL_TEXTURE_2D, level = 1, xoffset = 0,
	yoffset = 0, width = 255, height = 128, format = GL_BGRA,
	type = GL_UNSIGNED_BYTE, pixels = [binary data, size = 127.5 kb])

which *describes* the pixel data without actually providing it. I can
also get ApiTrace to dump the GL state after the call has been made, but
that also means 'after Mesa has potentially corrupted the texture', so
that's no good.

If there's no pre-written tool for extracting such data, is there
perhaps a file-format specification for trace-files, so I could write
such a tool myself?

[1]: https://bugs.freedesktop.org/show_bug.cgi?id=55817


More information about the apitrace mailing list