[Mesa-dev] [PATCH 00/10] Shader compilation and interface improvements

Luca Barbieri luca at luca-barbieri.com
Sun Sep 5 18:30:42 PDT 2010


This patchset introduces several changes to shader code.

The most significant and potentially contentious issue is a change in
the pipe_screen interface to add a better mechanism to query capabilities
that can vary depending on the shader stage.

The basic idea is that instead of asking for PIPE_CAP_MAX_FS_INSTRUCTIONS,
you ask for PIPE_SHADER_CAP_MAX_INSTRUCTIONS relative to the
PIPE_SHADER_FRAGMENT shader stage.

This allows to write code independent of the stage in question but with
the appropriate behavior for it.

It also avoids an explosion of capabilities once geometry and tessellation
shaders are added, while still allowing the driver to return different
values for each stage if desired.

All drivers have been changed and compiled but almost none tested.

The implementation style is different for drivers with unified and
non-unified shaders, and both kinds of drivers can be implemented
concisely.

The first part changes Mesa and GLSL to:
1. Use the proper token for GL_GEOMETRY_PROGRAM_NV
2. Acknowledge the existence of tessellation shaders
3. Add shader type defines allowing to create arrays with one entry
   per shader stage
4. Make the GLSL code generation option per-shader-stage instead of global
5. Add more GLSL code generation options

The second part changes Gallium to:
1. Make TGSI_PROCESSOR_VERTEX == PIPE_SHADER_VERTEX, and same for
   fragment
2. Acknowledge the existence of tessellation shaders
3. Add a new "get_shader_param" entry
4. Make #5 have no effect on r300g
5. Set the GLSL compiler options depending on the Gallium caps

Luca Barbieri (10):
  mesa: s/MESA_GEOMETRY_PROGRAM/GL_GEOMETRY_PROGRAM_NV
  mesa: add ARB_tessellation_shader boolean and constants
  mesa: add PIPE_SHADER_* like constants and conversions to/from enums
  glsl: make compiler options per-target
  glsl: add several EmitNo* options, and MaxUnrollIterations
  gallium: swap TGSI_PROCESSOR_VERTEX and TGSI_PROCESSOR_FRAGMENT
  gallium: add tessellation shader stage defines
  gallium: introduce get_shader_param (ALL DRIVERS CHANGED)
  r300g: claim control flow support since the driver emulates it
  mesa/st: set compiler options based on Gallium shader caps

 src/gallium/auxiliary/draw/draw_context.h  |   13 +++
 src/gallium/auxiliary/tgsi/tgsi_exec.h     |   30 +++++++
 src/gallium/auxiliary/util/u_caps.c        |   29 ++++---
 src/gallium/auxiliary/util/u_caps.h        |    4 +
 src/gallium/auxiliary/util/u_inlines.h     |    1 -
 src/gallium/drivers/cell/ppu/cell_screen.c |   17 ++++-
 src/gallium/drivers/failover/fo_context.c  |    1 +
 src/gallium/drivers/galahad/glhd_context.c |    4 +-
 src/gallium/drivers/galahad/glhd_screen.c  |   12 +++
 src/gallium/drivers/i915/i915_screen.c     |   44 ++++++++++
 src/gallium/drivers/i965/brw_screen.c      |   44 ++++++++++
 src/gallium/drivers/identity/id_screen.c   |   14 +++-
 src/gallium/drivers/llvmpipe/lp_screen.c   |   50 ++++--------
 src/gallium/drivers/nv50/nv50_screen.c     |   64 ++++++++------
 src/gallium/drivers/nvfx/nvfx_screen.c     |  119 ++++++++++++++++----------
 src/gallium/drivers/r300/r300_screen.c     |  100 ++++++++++++++--------
 src/gallium/drivers/r600/r600_screen.c     |   96 +++++++++++----------
 src/gallium/drivers/rbug/rbug_screen.c     |   12 +++
 src/gallium/drivers/softpipe/sp_screen.c   |   55 ++++---------
 src/gallium/drivers/svga/svga_screen.c     |  127 +++++++++++++++++-----------
 src/gallium/include/pipe/p_compiler.h      |    1 +
 src/gallium/include/pipe/p_defines.h       |   50 ++++-------
 src/gallium/include/pipe/p_screen.h        |    6 ++
 src/gallium/include/pipe/p_shader_tokens.h |    6 +-
 src/glsl/glsl_parser_extras.cpp            |    4 +-
 src/glsl/ir_optimization.h                 |    2 +-
 src/glsl/linker.cpp                        |    2 +-
 src/glsl/loop_analysis.h                   |    2 +-
 src/glsl/loop_unroll.cpp                   |   10 ++-
 src/glsl/main.cpp                          |    2 +-
 src/mesa/drivers/dri/i965/brw_fs.cpp       |    2 +-
 src/mesa/main/context.c                    |    4 +-
 src/mesa/main/extensions.c                 |    1 +
 src/mesa/main/mtypes.h                     |   48 ++++++++---
 src/mesa/main/nvprogram.c                  |    4 +-
 src/mesa/main/shaderapi.c                  |   35 +++++---
 src/mesa/main/shaderobj.h                  |   39 +++++++++
 src/mesa/main/state.c                      |    2 +-
 src/mesa/program/ir_to_mesa.cpp            |   36 +++++++--
 src/mesa/program/prog_print.c              |    2 +-
 src/mesa/program/prog_uniform.c            |    2 +-
 src/mesa/program/program.c                 |   12 ++--
 src/mesa/program/program.h                 |   38 ++++++++
 src/mesa/state_tracker/st_atom_shader.c    |    2 +-
 src/mesa/state_tracker/st_cb_program.c     |    8 +-
 src/mesa/state_tracker/st_extensions.c     |   75 +++++++++++------
 46 files changed, 822 insertions(+), 409 deletions(-)




More information about the mesa-dev mailing list