[Mesa-dev] [PATCH 00/20] Rewrite GL API handling of uniforms

Ian Romanick idr at freedesktop.org
Fri Oct 28 10:42:27 PDT 2011


This is it.  All the refactors that I've sent over the last month or
so have been building towards this.  This completely guts the existing
uniform handling code and replaces it with something new.  This work
had a few goals:

1. Separate the way the GL API handles uniforms from the way the
driver stores the data.  Specifically, I wanted to isolate the uses of
gl_program_parameter as much as possible.

2. Enable future optimizations in the glUniform path.  Due to the
current storage mechanism, the glUniform path has a lot of steps and a
lot of extra validation.  Some of that has been removed, and future
changes should allow more optimization.

3. Fix known bugs in the current uniform handling code (e.g.,
currently glGetUniformLocation("foo.bar[3].asdf") will fail).

This work isn't quite done, but it's done enough to get the top layers
in.  As mentioned in the commit message of patch 17/20, a bunch of the
code in ir_to_mesa needs to be split up.  Right now the i965 driver
has to use ir_to_mesa to generate connections between uniforms and
gl_program_parameter structures.  In the process, ir_to_mesa also does
some lowering passes and generates Mesa IR.  These things are
separate, and should be split up.

The structure used to store uniforms from the API's perspective has a
variable numuber of slots where the driver can request data be stored.
The glUniform path will dump data, in the formats requested by the
driver, in each of these locations.  One future optimization is for
drivers to allocate a buffer object or a command buffer and have the
glUniform dump data directly in that buffer.  This would cut out the
extra step of copying from the gl_program_parameter.

Another future step is to store built-in uniforms using the same
mechanism.  Once this happens, drivers will just see uniforms.
Period.  Not only will this simplify driver code, but it will also
enable fixing bug #32403.

For those so inclined, this work is also available in the
uniform-rework branch of my person repo.  The first couple patches in
that branch are not part of this work, and they can be ignored.

   git://anongit.freedesktop.org/~idr/mesa uniform-rework

 src/glsl/glsl_types.h                      |   23 +-
 src/glsl/ir_uniform.h                      |  128 ++++
 src/glsl/link_uniforms.cpp                 |  250 +++++++
 src/glsl/linker.cpp                        |  164 +-----
 src/glsl/linker.h                          |    7 +
 src/mesa/drivers/dri/i965/brw_shader.cpp   |    6 +-
 src/mesa/main/core.h                       |    1 -
 src/mesa/main/mtypes.h                     |   26 +-
 src/mesa/main/shaderapi.c                  |   23 +-
 src/mesa/main/shaderobj.c                  |   13 +-
 src/mesa/main/uniform_query.cpp            |  855 +++++++++++++++++++++++-
 src/mesa/main/uniforms.c                   | 1013 ++--------------------------
 src/mesa/main/uniforms.h                   |   73 ++
 src/mesa/program/ir_to_mesa.cpp            |  115 +++-
 src/mesa/program/ir_to_mesa.h              |    5 +
 src/mesa/program/prog_uniform.c            |  103 ---
 src/mesa/program/prog_uniform.h            |   85 ---
 src/mesa/program/sampler.cpp               |   12 +-
 src/mesa/sources.mak                       |    1 -
 src/mesa/state_tracker/st_draw.c           |   11 +-
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp |   14 +-
 21 files changed, 1543 insertions(+), 1385 deletions(-)



More information about the mesa-dev mailing list