This series implements support for the shaderInt16 capability, which allows
Vulkan applications to use 16-bit integers in shaders. A branch with these
patches can be found in the 'itoral/shaderInt16ForReview' branch of the Igalia
mesa repository at

A lot of the work required for this was already done prior to this series,
including load/store support via VK_KHR_16bit_storage, so here we only take care
of addressing the few missing things that the available CTS tests exposed.
These include ~850 new tests focused on testing conversions from / to 16-bit
integers, ALU operations and shader functions that accept integer parameters
(plus of course all the coverage for load/store operations with 16-bit integer
types that were already included for VK_KHR_16bit_storage).

We identified a few areas that were lacking coverage in CTS at present,
namely bitwise operations, conversions between integers and non integer types,
comparators and 16-bit constants. There are plans to add these already, although
we did some smoke testing of our own and we did not find any problems, so
we expect that we will pass the tests when they are made available.

We also found that the SPIR-V specification suggests that bitfield operations
should work with any bit-size, which sounds odd considering that, for example,
OpenGL doesn't support 64-bit bitfields and that there other vendors (besides
Intel) that only support 32-bit bitfields natively. We filed an issue to
Khronos to address this which is under discussion at present.

A quick overview of the series:

Patch 1 addresses the main issue: the extended Math function does
not support 16-bit integers so we need to run these instructions in 32-bit and
convert the result back to 16-bit.

Patch 2 is a trivial fix for 16-bit isign.

Patches 3-5 handle conversions from/to 16-bit types

Patches 6-8 add support for 16-bit constants

Patches 9-11 expose the spirv and vulkan features. We might want to postpone
landing this until the additional coverage lands in CTS and/or the bitfield
issue we filed is resolved. Up to the reviewers :)

Iago Toral Quiroga (8):
  intel/compiler: lower 16-bit integer extended math instructions
  intel/compiler: fix isign for 16-bit integers
  i965/compiler: handle conversion to smaller type in the lowering pass
    for that
  intel/compiler: implement conversion between float/int 16-bit types
  intel/compiler: implement conversions from 16-bit int/float to bool
  compiler/spirv: add implementation to check for SpvCapabilityInt16
  anv/pipeline: support SpvCapabilityInt16 in gen8+
  anv/device: expose shaderInt16 support in gen8+

Jose Maria Casanova Crespo (3):
  nir/constant_folding: support 16-bit constants
  intel/compiler: implement nir_instr_type_load_const for 16-bit
  intel/compiler: fix brw_negate_immediate for 16-bit types

 src/compiler/nir/nir_opt_constant_folding.c       |   2 +
 src/compiler/shader_info.h                        |   1 +
 src/compiler/spirv/spirv_to_nir.c                 |   4 +-
 src/intel/Makefile.sources                        |   1 +
 src/intel/compiler/brw_fs_lower_conversions.cpp   |   5 +-
 src/intel/compiler/brw_fs_nir.cpp                 |  56 ++++++-----
 src/intel/compiler/brw_nir.c                      |   2 +
 src/intel/compiler/brw_nir.h                      |   2 +
 src/intel/compiler/brw_nir_lower_16bit_int_math.c | 108 ++++++++++++++++++++++
 src/intel/compiler/brw_shader.cpp                 |   5 +-
 src/intel/compiler/                    |   1 +
 src/intel/vulkan/anv_device.c                     |   2 +-
 src/intel/vulkan/anv_pipeline.c                   |   1 +
 13 files changed, 163 insertions(+), 27 deletions(-)
 create mode 100644 src/intel/compiler/brw_nir_lower_16bit_int_math.c


mesa-dev mailing list

Reply via email to