[Mesa-dev] [PATCH 09/21] intel/compiler: Add a flag for pull constant support

Jason Ekstrand jason at jlekstrand.net
Fri Sep 29 21:25:09 UTC 2017


The Vulkan driver does not support pull constants.  It simply limits
things such that we can always push everything.  Previously, we were
determining whether or not to push things based on whether or not the
prog_data::pull_param array is non-null.  This is rather hackish and
about to stop working.
---
 src/intel/compiler/brw_compiler.h        | 6 ++++++
 src/intel/compiler/brw_fs.cpp            | 5 ++++-
 src/intel/compiler/brw_vec4_visitor.cpp  | 2 +-
 src/intel/vulkan/anv_device.c            | 1 +
 src/mesa/drivers/dri/i965/intel_screen.c | 1 +
 5 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/intel/compiler/brw_compiler.h b/src/intel/compiler/brw_compiler.h
index 04160aa..1ec79f6 100644
--- a/src/intel/compiler/brw_compiler.h
+++ b/src/intel/compiler/brw_compiler.h
@@ -106,6 +106,12 @@ struct brw_compiler {
     * Base Address?  (If not, it's a normal GPU address.)
     */
    bool constant_buffer_0_is_relative;
+
+   /**
+    * Whether or not the driver supports pull constants.  If not, the compiler
+    * will attempt to push everything.
+    */
+   bool supports_pull_constants;
 };
 
 
diff --git a/src/intel/compiler/brw_fs.cpp b/src/intel/compiler/brw_fs.cpp
index 0b7c3d0..4c1e614 100644
--- a/src/intel/compiler/brw_fs.cpp
+++ b/src/intel/compiler/brw_fs.cpp
@@ -1890,6 +1890,7 @@ set_push_pull_constant_loc(unsigned uniform, int *chunk_start,
                            unsigned *num_pull_constants,
                            const unsigned max_push_components,
                            const unsigned max_chunk_size,
+                           bool allow_pull_constants,
                            struct brw_stage_prog_data *stage_prog_data)
 {
    /* This is the first live uniform in the chunk */
@@ -1919,7 +1920,7 @@ set_push_pull_constant_loc(unsigned uniform, int *chunk_start,
        * Vulkan driver, push constants are explicitly exposed via the API
        * so we push everything.  In GL, we only push small arrays.
        */
-      if (stage_prog_data->pull_param == NULL ||
+      if (!allow_pull_constants ||
           (*num_push_constants + chunk_size <= max_push_components &&
            chunk_size <= max_chunk_size)) {
          assert(*num_push_constants + chunk_size <= max_push_components);
@@ -2055,6 +2056,7 @@ fs_visitor::assign_constant_locations()
                                  push_constant_loc, pull_constant_loc,
                                  &num_push_constants, &num_pull_constants,
                                  max_push_components, max_chunk_size,
+                                 compiler->supports_pull_constants,
                                  stage_prog_data);
 
    }
@@ -2075,6 +2077,7 @@ fs_visitor::assign_constant_locations()
                                  push_constant_loc, pull_constant_loc,
                                  &num_push_constants, &num_pull_constants,
                                  max_push_components, max_chunk_size,
+                                 compiler->supports_pull_constants,
                                  stage_prog_data);
    }
 
diff --git a/src/intel/compiler/brw_vec4_visitor.cpp b/src/intel/compiler/brw_vec4_visitor.cpp
index 88e80aa..ff5cd2d 100644
--- a/src/intel/compiler/brw_vec4_visitor.cpp
+++ b/src/intel/compiler/brw_vec4_visitor.cpp
@@ -1777,7 +1777,7 @@ vec4_visitor::move_uniform_array_access_to_pull_constants()
    /* The vulkan dirver doesn't support pull constants other than UBOs so
     * everything has to be pushed regardless.
     */
-   if (stage_prog_data->pull_param == NULL) {
+   if (!compiler->supports_pull_constants) {
       split_uniform_registers();
       return;
    }
diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index d576bb5..b8fa2c8 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -390,6 +390,7 @@ anv_physical_device_init(struct anv_physical_device *device,
    }
    device->compiler->shader_debug_log = compiler_debug_log;
    device->compiler->shader_perf_log = compiler_perf_log;
+   device->compiler->supports_pull_constants = false;
 
    isl_device_init(&device->isl_dev, &device->info, swizzled);
 
diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c
index bd1365f..8abd260 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -2510,6 +2510,7 @@ __DRIconfig **intelInitScreen2(__DRIscreen *dri_screen)
    screen->compiler->shader_debug_log = shader_debug_log_mesa;
    screen->compiler->shader_perf_log = shader_perf_log_mesa;
    screen->compiler->constant_buffer_0_is_relative = devinfo->gen < 8;
+   screen->compiler->supports_pull_constants = true;
 
    screen->has_exec_fence =
      intel_get_boolean(screen, I915_PARAM_HAS_EXEC_FENCE);
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list