[Mesa-dev] [PATCH 0/8] spirv: Types, types, and OpSwitch
Jason Ekstrand
jason at jlekstrand.net
Thu Dec 7 16:12:07 UTC 2017
When I started working on switching spirv_to_nir from having piles of
assert() to vtn_assert/fail, Ian and I both agreed that we should start
moving in a direction where we had vtn_fail with reasonable error messages
rather than vtn_assert() with some compiler-internal garbage message.
However some error checking is better than none, so we let it through with
the plan to come back and improve things. This series starts us down that
road.
The first two patches add an autogenerated pre-pass which records the types
of all SPIR-V values. Previously, we only really recorded types for
OpType*, OpConstant*, and OpSpecConstant*. Now, we have types for
everything.
The next four add some very basic parameter validation for OpTypeVector and
OpTypeMatrix and type validation for OpLoad, OpStore, OpCopyMemory, and
OpSelect. Now that we have the types recorded everywhere, it's fairly easy
to provide validation that looks a lot more like the SPIR-V spec than our
asserts and provides reasonable error messages. The reason for choosing to
start with those four is that they (along with OpPhi) are the hot-spots for
variable pointers and type mismatches are death there.
The last two patches fix a long-standing bug where we didn't properly
implement switch statements with 64-bit selectors. Given the infrequency
of 64-bit integers in shaders combined with the infrequency of switch
statements, the chances of hitting this in the wild are low (hence no CC to
stable) but we should make it work correctly. I haven't done this until
now because it relies on the type pre-pass because we need to know the type
of the OpSwitch selector while we're in the CFG pre-pass which happens
before we emit actual instructions.
Cc: Ian Romanick <ian.d.romanick at intel.com>
Jason Ekstrand (8):
spirv: Add a vtn_type field to all vtn_values
spirv: Add a prepass to set types on vtn_values
spirv: Add basic type validation for OpLoad, OpStore, and OpCopyMemory
spirv: Set lengths on scalar and vector types
spirv: Add type validation for OpSelect
spirv: Add better parameter validation for vector and matrix types
spirv: Restructure the case loop in OpSwitch handling
spirv: Add support for all bit sizes in OpSwitch
src/compiler/Makefile.nir.am | 4 +
src/compiler/nir/meson.build | 11 ++-
src/compiler/spirv/spirv_to_nir.c | 117 +++++++++++++++++++----------
src/compiler/spirv/vtn_cfg.c | 44 +++++++++--
src/compiler/spirv/vtn_gather_types_c.py | 125 +++++++++++++++++++++++++++++++
src/compiler/spirv/vtn_private.h | 11 +--
src/compiler/spirv/vtn_variables.c | 18 ++++-
7 files changed, 273 insertions(+), 57 deletions(-)
create mode 100644 src/compiler/spirv/vtn_gather_types_c.py
--
2.5.0.400.gff86faf
More information about the mesa-dev
mailing list