This little series adds an optimization pass to NIR and wires up up in anv that moves large constant variables to a UBO. This fixes a farily common case in some filter or ambient occlusion shaders where they put some sort of look-up table in the shader itself. This series takes Skyrim Special Edition running under DXVK from a slide show to a smooth and very playable framerate on my SKL desktop.
The first part of the series adds a concept of constant data that can be associated with a NIR shader and adds an optimization pass to move large constant variables into this constant data section. It's left up to the driver to figure out how to get this constant data into the shader. The last three patches wire things up in ANV to put this data into an implicit UBO and enables the optimization. v2 (Jason Ekstrand): - Take anholt's feedback and make it more clear that the units on the number of constants is in bytes by calling it constant_data_size. - Break some of the deref to offset code out into helpers - Add new size/align helpers for types to ensure that we get alignments right when setting up constants. This hasn't usually been a problem in the past because we align most things to a dword and 64-bit values aren't common. We should start being more careful. Jason Ekstrand (9): util/macros: Import ALIGN_POT from ralloc.c nir: Add a deref_instr_has_indirect helper nir/types: Add a natural size and alignment helper nir/deref: Add helpers for getting offsets nir: Add a concept of constant data associated with a shader nir: Add a large constants optimization pass anv: Add support for shader constant data to the pipeline cache anv: Add state setup support for shader constants anv,intel: Enable nir_opt_large_constants for Vulkan src/compiler/Makefile.sources | 1 + src/compiler/nir/meson.build | 1 + src/compiler/nir/nir.h | 14 + src/compiler/nir/nir_clone.c | 6 + src/compiler/nir/nir_deref.c | 109 +++++++ src/compiler/nir/nir_deref.h | 6 + src/compiler/nir/nir_intrinsics.py | 2 + src/compiler/nir/nir_opt_large_constants.c | 301 ++++++++++++++++++ src/compiler/nir/nir_serialize.c | 12 + src/compiler/nir/nir_sweep.c | 2 + src/compiler/nir_types.cpp | 56 ++++ src/compiler/nir_types.h | 6 + src/intel/compiler/brw_compiler.h | 6 + src/intel/compiler/brw_nir.c | 7 + src/intel/vulkan/anv_blorp.c | 1 + src/intel/vulkan/anv_device.c | 1 + .../vulkan/anv_nir_apply_pipeline_layout.c | 47 +++ src/intel/vulkan/anv_pipeline.c | 16 + src/intel/vulkan/anv_pipeline_cache.c | 27 ++ src/intel/vulkan/anv_private.h | 7 + src/intel/vulkan/genX_cmd_buffer.c | 72 +++-- src/util/macros.h | 3 + src/util/ralloc.c | 2 - 23 files changed, 684 insertions(+), 21 deletions(-) create mode 100644 src/compiler/nir/nir_opt_large_constants.c -- 2.17.1 _______________________________________________ mesa-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-dev
