anv: Support VK_KHR_vulkan_memory_model

Submitted by Jason Ekstrand on Sept. 10, 2018, 6:04 p.m.

Details

Reviewer None
Submitted Sept. 10, 2018, 6:04 p.m.
Last Updated Sept. 10, 2018, 6:05 p.m.
Revision 1

Cover Letter

This patch series adds support to the Intel Vulkan driver for the
(currently provisional) VK_KHR_vulkan_memory_model extension.  The
extension provides a few extra SPIR-V decorations along with some
additional guarantees about memory transaction ordering that aim to make
better analysis and use of concurrency possible in Vulkan.  In particular,
it provides sufficient guarantees to allow for the creation and use of
basic lock-free data structures in Vulkan shaders.

The current implementation does little more than rework the barrier code in
the SPIR-V to NIR pass.  This is mostly because NIR currently does little
to no optimization on external memory access.  As we begin to add more
optimizations in this area, we will need to be careful to think about the
Vulkan memory model to ensure that we continue to provide the right
guarantees.  It also points out just how awkward our current handling of
barriers is in NIR.

This series is sent out as an RFC at this point to make people aware of the
extension and to get the discussion going on how we want to do things "for
real".  Also, as can be seen from patch 6, there's still a little work
needed in the Intel back-end compiler to properly support this. :-)

The series can be found on my gitlab:

https://gitlab.freedesktop.org/jekstrand/mesa/commits/wip/VK_KHR_vulkan_memory_model

Cc: Kenneth Graunke <kenneth@whitecape.org>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Francisco Jerez <currojerez@riseup.net>
Cc: Timothy Arceri <tarceri@itsqueeze.com>
Cc: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Cc: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>

Jason Ekstrand (7):
  vulkan: Update the XML and headers to 1.1.84
  spirv: Update Json and headers from Khronos GitHub master
  spirv/info: Add a memorymodel_to_string helper
  spirv: Insert barriers to follow the Vulkan memory model
  spirv: Add support for the Vulkan memory model
  HACK: Disable the instruction scheduler
  anv: Advertise support for VK_KHR_vulkan_memory_model

 include/vulkan/vulkan_core.h               | 139 +++++++++-
 src/compiler/shader_info.h                 |   1 +
 src/compiler/spirv/spirv.core.grammar.json |  95 ++++++-
 src/compiler/spirv/spirv.h                 |  24 ++
 src/compiler/spirv/spirv_info.h            |   1 +
 src/compiler/spirv/spirv_info_c.py         |   1 +
 src/compiler/spirv/spirv_to_nir.c          | 190 +++++++++-----
 src/intel/compiler/brw_fs.cpp              |   4 +-
 src/intel/vulkan/anv_device.c              |   7 +
 src/intel/vulkan/anv_extensions.py         |   1 +
 src/intel/vulkan/anv_pipeline.c            |   1 +
 src/vulkan/registry/vk.xml                 | 280 ++++++++++++++++-----
 12 files changed, 594 insertions(+), 150 deletions(-)
  

Revisions