i965/cs: Enable barrier in MEDIA_INTERFACE_DESCRIPTOR
authorJordan Justen <jordan.l.justen@intel.com>
Wed, 5 Nov 2014 08:47:41 +0000 (00:47 -0800)
committerJordan Justen <jordan.l.justen@intel.com>
Thu, 10 Sep 2015 23:46:29 +0000 (16:46 -0700)
Enable barrier in MEDIA_INTERFACE_DESCRIPTOR if the program uses the
barrier() GLSL function.

On Ivy Bridge and Haswell, this allows the piglit test
tests/spec/arb_compute_shader/execution/simple-barrier-atomics.shader_test
to pass. On gen8, this enables a similar test with a local group size
of 896 to pass.

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
src/mesa/drivers/dri/i965/brw_context.h
src/mesa/drivers/dri/i965/brw_cs.cpp
src/mesa/drivers/dri/i965/brw_defines.h
src/mesa/drivers/dri/i965/brw_fs_nir.cpp

index 0318a3fb229c8c01c9366948e25d95111b8fe007..b05b8bd69bf1c7390c98e103c25cbfe1be184a8b 100644 (file)
@@ -498,6 +498,7 @@ struct brw_cs_prog_data {
    GLuint dispatch_grf_start_reg_16;
    unsigned local_size[3];
    unsigned simd_size;
+   bool uses_barrier;
 };
 
 /**
index 605a3fa005889dad4aa66941a837d3336bdc7d78..980ef52fe1738bd64adb4efb6d5428d04008bd40 100644 (file)
@@ -431,7 +431,9 @@ brw_upload_cs_state(struct brw_context *brw)
       SET_FIELD(threads, GEN8_MEDIA_GPGPU_THREAD_COUNT) :
       SET_FIELD(threads, MEDIA_GPGPU_THREAD_COUNT);
    assert(threads <= brw->max_cs_threads);
-   desc[dw++] = media_threads;
+   desc[dw++] =
+      SET_FIELD(cs_prog_data->uses_barrier, MEDIA_BARRIER_ENABLE) |
+      media_threads;
 
    BEGIN_BATCH(4);
    OUT_BATCH(MEDIA_INTERFACE_DESCRIPTOR_LOAD << 16 | (4 - 2));
index d18f7ca4f73ed577f8a583e23264df2d02d9cd6d..8fc8cebf11e29cb12786a95d5da5ccdf98ed9b55 100644 (file)
@@ -2690,6 +2690,8 @@ enum brw_wm_barycentric_interp_mode {
 # define MEDIA_CURBE_READ_OFFSET_SHIFT          0
 # define MEDIA_CURBE_READ_OFFSET_MASK           INTEL_MASK(15, 0)
 /* GEN7 DW5, GEN8+ DW6 */
+# define MEDIA_BARRIER_ENABLE_SHIFT             21
+# define MEDIA_BARRIER_ENABLE_MASK              INTEL_MASK(21, 21)
 # define MEDIA_GPGPU_THREAD_COUNT_SHIFT         0
 # define MEDIA_GPGPU_THREAD_COUNT_MASK          INTEL_MASK(7, 0)
 # define GEN8_MEDIA_GPGPU_THREAD_COUNT_SHIFT    0
index 1cc7b0219289bc9d2530fdf6bd3a79a42b1c8b52..8c3c4aed7078db5ce0b5c6d99a8c2daee9084b75 100644 (file)
@@ -1705,6 +1705,8 @@ fs_visitor::nir_emit_intrinsic(const fs_builder &bld, nir_intrinsic_instr *instr
 
    case nir_intrinsic_barrier:
       emit_barrier();
+      if (stage == MESA_SHADER_COMPUTE)
+         ((struct brw_cs_prog_data *) prog_data)->uses_barrier = true;
       break;
 
    default: