]> git.cworth.org Git - apitrace/commit
trim: Conservatively make shader programs depend on textures
authorCarl Worth <cworth@cworth.org>
Fri, 17 Aug 2012 15:09:19 +0000 (08:09 -0700)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Thu, 22 Nov 2012 08:03:25 +0000 (08:03 +0000)
commit81bda5afcccf41002128b2095442fe838d395969
tree3888941592e56f19befb5f37f6021b83e095c1d8
parent65692823c1260168ff09e97fa562fa59b7258a59
trim: Conservatively make shader programs depend on textures

Some shader programs sample textures, so if the shader is included in
the trimmed output the texture needs to be included as well.

We don't have support inside of "apitrace trim" to parse GLSL to find
names of samplers to find these dependencies. Instead, we provide here
a simple heuristic:

In order to sample a texture, the OpenGL program must associate the
name of a texture unit with a location in the shader by calling
glUniform1i (or glUniform1iv). So we can notice whenever texture-unit
names are being passed and create a dependency from the shader to all
texture targets for that unit.

This is conservative on two fronts:

  1. The value being passed to glUniformi might only be coincidentally
     the same as a texture-unit name and be actually unrelated to
     texture sampling.

  2. The shader likely doesn't depend on all texture targets, but
     again we can't know which without looking inside the shader, so
     we associate all of them.
cli/cli_trim.cpp