[Mesa-dev] [PATCH 00/12 v2] The first of the real SPIR-V work

Ian Romanick idr at freedesktop.org
Tue Nov 21 01:23:58 UTC 2017


Almost every patch of the original send was modified, and a couple
patches were added.  I decided it was easier to re-send the whole thing
as a group.

This is the first block of patches to enable generating SPIR-V from
Mesa's GLSL compiler.  The initial use of this is for testing
GL_ARB_spirv, but it may eventually be useful in its own right.  A lot
more work will be necessary for that to happen, though.

Most of the work is done, but there are still some bits, notably UBOs
and images, left to do.  Of the ~46k shaders in my shader-db, I can
generate SPIR-V that passes the validator for nearly 10k.  Many shaders
fail because they use legacy features that cannot be represented in
SPIR-V.  I am sending this series out now to prime the review process.
The whole series is on the order of 80 patches, so I think it's valuable
to send things out in smaller, self-contained chunks.

The whole series (with some work-in-progress patches) is at

    https://cgit.freedesktop.org/~idr/mesa/log/?h=emit-spirv

The implementation is divided into three layers, and this patch series
represents the bottom layer.

1. Raw SPIR-V emit code.  This layer has zero knowledge of GLSL IR or
   anything specific to Mesa.  It should be trivial for someone to pull
   this code out and use it in a separate project.  There are two parts.
   The first handles tracking and managing SPIR-V capabilities.  The
   second part implements a very low-level SPIR-V instruction builder
   sytled after ir_builder and nir_builder.  There are a couple rough
   bits here with respect to automatic setting of SPIR-V capabilites.
   There are cases where a SPIR-V feature requires any one of several
   capabilities, so it is impossible to pick one to enable.

2. Unstructured GLSL IR to SPIR-V.  This layer handles emitting single
   bits of GLSL IR in SPIR-V without knowledge of the global structure.
   This is mostly things like emitting glsl_type, ir_variable, and
   ir_function_signature.  At 38, this is the largest group of patches.
   This is mostly nailed down, but the UBO work is going to cause some
   changes.  I hope to finally wrap that up next week.

3. SPIR-V visitor.  This top-most layer handles the overall structure of
   the shader.  It uses a visitor in a similar fashion to glsl_to_mesa
   and glsl_to_tgsi.  Use a generator styled after nir_opt_algebraic has
   kept the amount of code here pretty small.



More information about the mesa-dev mailing list