anv,intel: Enable nir_opt_large_constants for Vulkan
authorJason Ekstrand <jason.ekstrand@intel.com>
Fri, 29 Jun 2018 05:44:43 +0000 (22:44 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Mon, 2 Jul 2018 19:09:50 +0000 (12:09 -0700)
According to RenderDoc, this shaves 99.6% of the run time off of the
ambient occlusion pass in Skyrim Special Edition when running under DXVK
and shaves 92% off the runtime for a reasonably representative frame.
When running the actual game, Skyrim goes from being a slide-show to a
very stable and playable framerate on my SKL GT4e machine.

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/intel/compiler/brw_compiler.h
src/intel/compiler/brw_nir.c
src/intel/vulkan/anv_device.c

index 2f745d9274597ede387571691018788871894e74..9dfcfcc0115ad6854fa84d98d3acc15f5d50aa6e 100644 (file)
@@ -112,6 +112,12 @@ struct brw_compiler {
     * will attempt to push everything.
     */
    bool supports_pull_constants;
+
+   /**
+    * Whether or not the driver supports NIR shader constants.  This controls
+    * whether nir_opt_large_constants will be run.
+    */
+   bool supports_shader_constants;
 };
 
 /**
index dfeea73b06ac3a0d33343aff6bafaa20a30d25a8..f4aee3d41ee09201b8dea0fecfd230f7499a4578 100644 (file)
@@ -664,6 +664,13 @@ brw_preprocess_nir(const struct brw_compiler *compiler, nir_shader *nir)
 
    nir = brw_nir_optimize(nir, compiler, is_scalar);
 
+   /* This needs to be run after the first optimization pass but before we
+    * lower indirect derefs away
+    */
+   if (compiler->supports_shader_constants) {
+      OPT(nir_opt_large_constants, NULL, 32);
+   }
+
    nir_lower_bit_size(nir, lower_bit_size_callback, NULL);
 
    if (is_scalar) {
index cc319f0901879145f831d45e5b8bd8fa261691d7..9240cbdbe0ab6a8ea421c4a870660556c7ee02a7 100644 (file)
@@ -434,6 +434,7 @@ anv_physical_device_init(struct anv_physical_device *device,
    device->compiler->supports_pull_constants = false;
    device->compiler->constant_buffer_0_is_relative =
       device->info.gen < 8 || !device->has_context_isolation;
+   device->compiler->supports_shader_constants = true;
 
    isl_device_init(&device->isl_dev, &device->info, swizzled);