i965: Enable cross-thread constants and compact local IDs for hsw+
authorJordan Justen <jordan.l.justen@intel.com>
Tue, 31 May 2016 22:45:24 +0000 (15:45 -0700)
committerJordan Justen <jordan.l.justen@intel.com>
Thu, 2 Jun 2016 02:29:02 +0000 (19:29 -0700)
The cross thread constant support appears on Haswell. It allows us to
upload a set of uniform data for all threads without duplicating it
per thread.

One complication is that cross-thread constants are loaded into
registers before per-thread constants. Previously, our local IDs were
loaded before the uniform data and treated as 'payload' data, even
though they were actually pushed into the registers like the other
uniform data.

Therefore, in this patch we simultaneously enable a newer layout where
each thread now uses a single uniform slot for a unique local ID for
the thread. This uniform is handled specially to make sure it is added
last into the uniform push constant registers. This minimizes our
usage of push constant registers, and maximizes our ability to use
cross-thread constants for registers.

To swap from the old to the new layout, we also need to flip some
lowering pass switches to let our driver handle the lowering instead.
We also no longer force thread_local_id_index to -1.

v4:
 * Minimize size of patch that switches from the old local ID layout
   to the new layout (Jason)

Cc: "12.0" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/mesa/drivers/dri/i965/brw_compiler.c
src/mesa/drivers/dri/i965/brw_context.c
src/mesa/drivers/dri/i965/brw_fs.cpp

index bb06733bb0a97d275166ccaba4319bb6b6102f0b..a4855a0913762d45ba27c9ea6c8a337af68d5b84 100644 (file)
@@ -40,8 +40,7 @@
    .lower_fdiv = true,                                                        \
    .lower_flrp64 = true,                                                      \
    .native_integers = true,                                                   \
-   .vertex_id_zero_based = true,                                              \
-   .lower_cs_local_index_from_id = true
+   .vertex_id_zero_based = true
 
 static const struct nir_shader_compiler_options scalar_nir_options = {
    COMMON_OPTIONS,
index ad8d5140a3f6415943a57e0526e9ab2f2979abe2..97dc22621c96bc12cf76d38ddfbdb07e71674560 100644 (file)
@@ -599,7 +599,6 @@ brw_initialize_context_constants(struct brw_context *brw)
       ctx->Const.MaxClipPlanes = 8;
 
    ctx->Const.LowerTessLevel = true;
-   ctx->Const.LowerCsDerivedVariables = true;
    ctx->Const.PrimitiveRestartForPatches = true;
 
    ctx->Const.Program[MESA_SHADER_VERTEX].MaxNativeInstructions = 16 * 1024;
index 4de2563e66c7e4afaa56469e6971e812a6e2b13b..0b766a4a848a532a252abd7b2927286e0e986af2 100644 (file)
@@ -6586,7 +6586,7 @@ cs_fill_push_const_info(const struct brw_device_info *devinfo,
    bool fill_thread_id =
       cs_prog_data->thread_local_id_index >= 0 &&
       cs_prog_data->thread_local_id_index < (int)prog_data->nr_params;
-   bool cross_thread_supported = false; /* Not yet supported by driver. */
+   bool cross_thread_supported = devinfo->gen > 7 || devinfo->is_haswell;
 
    /* The thread ID should be stored in the last param dword */
    assert(prog_data->nr_params > 0 || !fill_thread_id);
@@ -6652,19 +6652,13 @@ brw_compile_cs(const struct brw_compiler *compiler, void *log_data,
    brw_nir_lower_cs_shared(shader);
    prog_data->base.total_shared += shader->num_shared;
 
-   /* The driver isn't yet ready to support thread_local_id_index, so we force
-    * it to disabled for now.
-    */
-   prog_data->thread_local_id_index = -1;
-
    /* Now that we cloned the nir_shader, we can update num_uniforms based on
     * the thread_local_id_index.
     */
-   if (prog_data->thread_local_id_index >= 0) {
-      shader->num_uniforms =
-         MAX2(shader->num_uniforms,
-              (unsigned)4 * (prog_data->thread_local_id_index + 1));
-   }
+   assert(prog_data->thread_local_id_index >= 0);
+   shader->num_uniforms =
+      MAX2(shader->num_uniforms,
+           (unsigned)4 * (prog_data->thread_local_id_index + 1));
 
    brw_nir_lower_intrinsics(shader, &prog_data->base);
    shader = brw_postprocess_nir(shader, compiler->devinfo, true);