Merge remote-tracking branch 'public/master' into vulkan
authorJason Ekstrand <jason.ekstrand@intel.com>
Fri, 15 Apr 2016 00:14:28 +0000 (17:14 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Fri, 15 Apr 2016 00:14:28 +0000 (17:14 -0700)
1  2 
configure.ac
src/compiler/nir/nir.h
src/compiler/nir/nir_intrinsics.h
src/compiler/nir/nir_lower_io.c

diff --combined configure.ac
index 0d3f0ff3c9d80f113387f51261afcf9b9189d862,8c82c43501b1ba8a2a090afb37c67369497e7d22..2aa46dccdbb6758b675b30ad148c2f3b6df46fc0
@@@ -1545,59 -1545,6 +1545,59 @@@ if test -n "$with_dri_drivers"; the
      DRI_DIRS=`echo $DRI_DIRS|tr " " "\n"|sort -u|tr "\n" " "`
  fi
  
 +
 +#
 +# Vulkan driver configuration
 +#
 +
 +# Keep this in sync with the --with-vulkan-drivers help string default value
 +VULKAN_DRIVERS_DEFAULT="intel"
 +
 +AC_ARG_WITH([vulkan-drivers],
 +    [AS_HELP_STRING([--with-vulkan-drivers@<:@=DIRS...@:>@],
 +        [comma delimited Vulkan drivers list, e.g.
 +        "intel"
 +        @<:@default=intel@:>@])],
 +    [with_vulkan_drivers="$withval"],
 +    [with_vulkan_drivers="$VULKAN_DRIVERS_DEFAULT"])
 +
 +# Doing '--without-vulkan-drivers' will set this variable to 'no'.  Clear it
 +# here so that the script doesn't choke on an unknown driver name later.
 +case "$with_vulkan_drivers" in
 +    yes) with_vulkan_drivers="$VULKAN_DRIVERS_DEFAULT" ;;
 +    no) with_vulkan_drivers='' ;;
 +esac
 +
 +AC_ARG_WITH([vulkan-icddir],
 +    [AS_HELP_STRING([--with-vulkan-icddir=DIR],
 +        [directory for the Vulkan driver icd files @<:@${libdir}/dri@:>@])],
 +    [VULKAN_ICD_INSTALL_DIR="$withval"],
 +    [VULKAN_ICD_INSTALL_DIR='${sysconfdir}/vulkan/icd.d'])
 +AC_SUBST([VULKAN_ICD_INSTALL_DIR])
 +
 +if test -n "$with_vulkan_drivers"; then
 +    VULKAN_DRIVERS=`IFS=', '; echo $with_vulkan_drivers`
 +    for driver in $VULKAN_DRIVERS; do
 +        case "x$driver" in
 +        xintel)
 +            if test "x$HAVE_I965_DRI" != xyes; then
 +                AC_MSG_ERROR([Intel Vulkan driver requires the i965 dri driver])
 +            fi
 +            if test "x$with_sha1" == "x"; then
 +                AC_MSG_ERROR([Intel Vulkan driver requires SHA1])
 +            fi
 +            HAVE_INTEL_VULKAN=yes;
 +
 +            ;;
 +        *)
 +            AC_MSG_ERROR([Vulkan driver '$driver' does not exist])
 +            ;;
 +        esac
 +    done
 +    VULKAN_DRIVERS=`echo $VULKAN_DRIVERS|tr " " "\n"|sort -u|tr "\n" " "`
 +fi
 +
 +
  AM_CONDITIONAL(NEED_MEGADRIVER, test -n "$DRI_DIRS")
  AM_CONDITIONAL(NEED_LIBMESA, test "x$enable_xlib_glx" = xyes -o \
                                    "x$enable_osmesa" = xyes -o \
@@@ -2452,10 -2399,6 +2452,10 @@@ AM_CONDITIONAL(HAVE_R200_DRI, test x$HA
  AM_CONDITIONAL(HAVE_RADEON_DRI, test x$HAVE_RADEON_DRI = xyes)
  AM_CONDITIONAL(HAVE_SWRAST_DRI, test x$HAVE_SWRAST_DRI = xyes)
  
 +AM_CONDITIONAL(HAVE_INTEL_VULKAN, test "x$HAVE_INTEL_VULKAN" = xyes)
 +
 +AM_CONDITIONAL(HAVE_INTEL_DRIVERS, test "x$HAVE_INTEL_VULKAN" = xyes)
 +
  AM_CONDITIONAL(NEED_RADEON_DRM_WINSYS, test "x$HAVE_GALLIUM_R300" = xyes -o \
                                              "x$HAVE_GALLIUM_R600" = xyes -o \
                                              "x$HAVE_GALLIUM_RADEONSI" = xyes)
@@@ -2503,13 -2446,6 +2503,13 @@@ AC_SUBST([XA_MINOR], $XA_MINOR
  AC_SUBST([XA_TINY], $XA_TINY)
  AC_SUBST([XA_VERSION], "$XA_MAJOR.$XA_MINOR.$XA_TINY")
  
 +PKG_CHECK_MODULES(VALGRIND, [valgrind],
 +                  [have_valgrind=yes], [have_valgrind=no])
 +if test "x$have_valgrind" = "xyes"; then
 +    AC_DEFINE([HAVE_VALGRIND], 1,
 +              [Use valgrind intrinsics to suppress false warnings])
 +fi
 +
  dnl Restore LDFLAGS and CPPFLAGS
  LDFLAGS="$_SAVE_LDFLAGS"
  CPPFLAGS="$_SAVE_CPPFLAGS"
@@@ -2551,8 -2487,6 +2551,6 @@@ AC_CONFIG_FILES([Makefil
                src/gallium/drivers/softpipe/Makefile
                src/gallium/drivers/svga/Makefile
                src/gallium/drivers/swr/Makefile
-               src/gallium/drivers/swr/avx/Makefile
-               src/gallium/drivers/swr/avx2/Makefile
                src/gallium/drivers/trace/Makefile
                src/gallium/drivers/vc4/Makefile
                src/gallium/drivers/virgl/Makefile
                src/glx/apple/Makefile
                src/glx/tests/Makefile
                src/gtest/Makefile
 +              src/intel/Makefile
 +              src/intel/genxml/Makefile
 +              src/intel/isl/Makefile
 +              src/intel/vulkan/Makefile
 +              src/intel/vulkan/tests/Makefile
                src/loader/Makefile
                src/mapi/Makefile
                src/mapi/es1api/glesv1_cm.pc
@@@ -2702,15 -2631,6 +2700,15 @@@ if test "$enable_egl" = yes; the
      echo "        EGL drivers:    $egl_drivers"
  fi
  
 +# Vulkan
 +echo ""
 +if test "x$VULKAN_DRIVERS" != x; then
 +    echo "        Vulkan drivers:  $VULKAN_DRIVERS"
 +    echo "        Vulkan ICD dir:  $VULKAN_ICD_INSTALL_DIR"
 +else
 +    echo "        Vulkan drivers:  no"
 +fi
 +
  echo ""
  if test "x$MESA_LLVM" = x1; then
      echo "        llvm:            yes"
diff --combined src/compiler/nir/nir.h
index fede1954cf0360e971978dd699a334f445275e12,9d48356c6de0be2a6ccbc7d25d1fe58ba0b9f0df..bbbc2089db3f21960f49440fa014be07475afd53
@@@ -265,11 -265,6 +265,11 @@@ typedef struct nir_variable 
         */
        int index;
  
 +      /**
 +       * Descriptor set binding for sampler or UBO.
 +       */
 +      int descriptor_set;
 +
        /**
         * Initial binding point for a sampler or UBO.
         *
@@@ -507,7 -502,14 +507,14 @@@ typedef struct nir_src 
     bool is_ssa;
  } nir_src;
  
- #define NIR_SRC_INIT (nir_src) { { NULL } }
+ static inline nir_src
+ nir_src_init(void)
+ {
+    nir_src src = { { NULL } };
+    return src;
+ }
+ #define NIR_SRC_INIT nir_src_init()
  
  #define nir_foreach_use(reg_or_ssa_def, src) \
     list_for_each_entry(nir_src, src, &(reg_or_ssa_def)->uses, use_link)
@@@ -530,7 -532,14 +537,14 @@@ typedef struct 
     bool is_ssa;
  } nir_dest;
  
- #define NIR_DEST_INIT (nir_dest) { { { NULL } } }
+ static inline nir_dest
+ nir_dest_init(void)
+ {
+    nir_dest dest = { { { NULL } } };
+    return dest;
+ }
+ #define NIR_DEST_INIT nir_dest_init()
  
  #define nir_foreach_def(reg, dest) \
     list_for_each_entry(nir_dest, dest, &(reg)->defs, reg.def_link)
@@@ -957,21 -966,11 +971,21 @@@ typedef enum 
     NIR_INTRINSIC_UCP_ID = 4,
  
     /**
-     * The ammount of data, starting from BASE, that this instruction may
+     * The amount of data, starting from BASE, that this instruction may
      * access.  This is used to provide bounds if the offset is not constant.
      */
     NIR_INTRINSIC_RANGE = 5,
  
 +   /**
 +    * The Vulkan descriptor set for vulkan_resource_index intrinsic.
 +    */
 +   NIR_INTRINSIC_DESC_SET = 6,
 +
 +   /**
 +    * The Vulkan descriptor set binding for vulkan_resource_index intrinsic.
 +    */
 +   NIR_INTRINSIC_BINDING = 7,
 +
     NIR_INTRINSIC_NUM_INDEX_FLAGS,
  
  } nir_intrinsic_index_flag;
@@@ -1036,8 -1035,6 +1050,8 @@@ INTRINSIC_IDX_ACCESSORS(base, BASE, int
  INTRINSIC_IDX_ACCESSORS(stream_id, STREAM_ID, unsigned)
  INTRINSIC_IDX_ACCESSORS(ucp_id, UCP_ID, unsigned)
  INTRINSIC_IDX_ACCESSORS(range, RANGE, unsigned)
 +INTRINSIC_IDX_ACCESSORS(desc_set, DESC_SET, unsigned)
 +INTRINSIC_IDX_ACCESSORS(binding, BINDING, unsigned)
  
  /**
   * \group texture information
index fa162f9d126927f475f7abbeeb5dcfd06d39d00a,05507dc6579b2878ac4be98d42570fb520728a2e..3cb4f95394c6d683ee03862402aaf03a82e84b62
@@@ -42,9 -42,9 +42,9 @@@
  #define ARR(...) { __VA_ARGS__ }
  
  
- INTRINSIC(load_var, 0, ARR(), true, 0, 1, 0, xx, xx, xx, NIR_INTRINSIC_CAN_ELIMINATE)
+ INTRINSIC(load_var, 0, ARR(0), true, 0, 1, 0, xx, xx, xx, NIR_INTRINSIC_CAN_ELIMINATE)
  INTRINSIC(store_var, 1, ARR(0), false, 0, 1, 1, WRMASK, xx, xx, 0)
- INTRINSIC(copy_var, 0, ARR(), false, 0, 2, 0, xx, xx, xx, 0)
+ INTRINSIC(copy_var, 0, ARR(0), false, 0, 2, 0, xx, xx, xx, 0)
  
  /*
   * Interpolation of input.  The interp_var_at* intrinsics are similar to the
@@@ -72,7 -72,7 +72,7 @@@ INTRINSIC(get_buffer_size, 1, ARR(1), t
   * a barrier is an intrinsic with no inputs/outputs but which can't be moved
   * around/optimized in general
   */
- #define BARRIER(name) INTRINSIC(name, 0, ARR(), false, 0, 0, 0, xx, xx, xx, 0)
+ #define BARRIER(name) INTRINSIC(name, 0, ARR(0), false, 0, 0, 0, xx, xx, xx, 0)
  
  BARRIER(barrier)
  BARRIER(discard)
@@@ -89,7 -89,7 +89,7 @@@ BARRIER(memory_barrier
   * The latter can be used as code motion barrier, which is currently not
   * feasible with NIR.
   */
- INTRINSIC(shader_clock, 0, ARR(), true, 1, 0, 0, xx, xx, xx, NIR_INTRINSIC_CAN_ELIMINATE)
+ INTRINSIC(shader_clock, 0, ARR(0), true, 1, 0, 0, xx, xx, xx, NIR_INTRINSIC_CAN_ELIMINATE)
  
  /*
   * Memory barrier with semantics analogous to the compute shader
@@@ -113,8 -113,8 +113,8 @@@ INTRINSIC(discard_if, 1, ARR(1), false
   *
   * end_primitive implements GLSL's EndPrimitive() built-in.
   */
- INTRINSIC(emit_vertex,   0, ARR(), false, 0, 0, 1, STREAM_ID, xx, xx, 0)
- INTRINSIC(end_primitive, 0, ARR(), false, 0, 0, 1, STREAM_ID, xx, xx, 0)
+ INTRINSIC(emit_vertex,   0, ARR(0), false, 0, 0, 1, STREAM_ID, xx, xx, 0)
+ INTRINSIC(end_primitive, 0, ARR(0), false, 0, 0, 1, STREAM_ID, xx, xx, 0)
  
  /**
   * Geometry Shader intrinsics with a vertex count.
@@@ -137,7 -137,7 +137,7 @@@ INTRINSIC(set_vertex_count, 1, ARR(1), 
   */
  
  #define ATOMIC(name, flags) \
-    INTRINSIC(atomic_counter_##name##_var, 0, ARR(), true, 1, 1, 0, xx, xx, xx, flags) \
+    INTRINSIC(atomic_counter_##name##_var, 0, ARR(0), true, 1, 1, 0, xx, xx, xx, flags) \
     INTRINSIC(atomic_counter_##name, 1, ARR(1), true, 1, 0, 1, BASE, xx, xx, flags)
  
  ATOMIC(inc, 0)
@@@ -170,31 -170,11 +170,31 @@@ INTRINSIC(image_atomic_or, 3, ARR(4, 1
  INTRINSIC(image_atomic_xor, 3, ARR(4, 1, 1), true, 1, 1, 0, xx, xx, xx, 0)
  INTRINSIC(image_atomic_exchange, 3, ARR(4, 1, 1), true, 1, 1, 0, xx, xx, xx, 0)
  INTRINSIC(image_atomic_comp_swap, 4, ARR(4, 1, 1, 1), true, 1, 1, 0, xx, xx, xx, 0)
- INTRINSIC(image_size, 0, ARR(), true, 4, 1, 0, xx, xx, xx,
+ INTRINSIC(image_size, 0, ARR(0), true, 4, 1, 0, xx, xx, xx,
            NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
- INTRINSIC(image_samples, 0, ARR(), true, 1, 1, 0, xx, xx, xx,
+ INTRINSIC(image_samples, 0, ARR(0), true, 1, 1, 0, xx, xx, xx,
            NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
  
 +/*
 + * Vulkan descriptor set intrinsic
 + *
 + * The Vulkan API uses a different binding model from GL.  In the Vulkan
 + * API, all external resources are represented by a tripple:
 + *
 + * (descriptor set, binding, array index)
 + *
 + * where the array index is the only thing allowed to be indirect.  The
 + * vulkan_surface_index intrinsic takes the descriptor set and binding as
 + * its first two indices and the array index as its source.  The third
 + * index is a nir_variable_mode in case that's useful to the backend.
 + *
 + * The intended usage is that the shader will call vulkan_surface_index to
 + * get an index and then pass that as the buffer index ubo/ssbo calls.
 + */
 +INTRINSIC(vulkan_resource_index, 1, ARR(1), true, 1, 0, 2,
 +          DESC_SET, BINDING, xx,
 +          NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
 +
  /*
   * variable atomic intrinsics
   *
@@@ -278,7 -258,7 +278,7 @@@ INTRINSIC(shared_atomic_exchange, 2, AR
  INTRINSIC(shared_atomic_comp_swap, 3, ARR(1, 1, 1), true, 1, 0, 0, xx, xx, xx, 0)
  
  #define SYSTEM_VALUE(name, components, num_indices, idx0, idx1, idx2) \
-    INTRINSIC(load_##name, 0, ARR(), true, components, 0, num_indices, \
+    INTRINSIC(load_##name, 0, ARR(0), true, components, 0, num_indices, \
     idx0, idx1, idx2, \
     NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
  
@@@ -313,8 -293,9 +313,9 @@@ SYSTEM_VALUE(helper_invocation, 1, 0, x
   * of the start of the variable being loaded and and the offset source is a
   * offset into that variable.
   *
-  * Uniform load operations have a second index that specifies the size of the
-  * variable being loaded.  If const_index[1] == 0, then the size is unknown.
+  * Uniform load operations have a second "range" index that specifies the
+  * range (starting at base) of the data from which we are loading.  If
+  * const_index[1] == 0, then the range is unknown.
   *
   * Some load operations such as UBO/SSBO load and per_vertex loads take an
   * additional source to specify which UBO/SSBO/vertex to load from.
  #define LOAD(name, srcs, num_indices, idx0, idx1, idx2, flags) \
     INTRINSIC(load_##name, srcs, ARR(1, 1, 1, 1), true, 0, 0, num_indices, idx0, idx1, idx2, flags)
  
- /* src[] = { offset }. const_index[] = { base, range } */
- LOAD(uniform, 1, 2, BASE, RANGE, xx,
-      NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
+ /* src[] = { offset }. const_index[] = { base } */
+ LOAD(uniform, 1, 2, BASE, RANGE, xx, NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
  /* src[] = { buffer_index, offset }. No const_index */
  LOAD(ubo, 2, 0, xx, xx, xx, NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
  /* src[] = { offset }. const_index[] = { base } */
@@@ -345,9 -325,6 +345,9 @@@ LOAD(output, 1, 1, BASE, xx, xx, NIR_IN
  LOAD(per_vertex_output, 2, 1, BASE, xx, xx, NIR_INTRINSIC_CAN_ELIMINATE)
  /* src[] = { offset }. const_index[] = { base } */
  LOAD(shared, 1, 1, BASE, xx, xx, NIR_INTRINSIC_CAN_ELIMINATE)
 +/* src[] = { offset }. const_index[] = { base, range } */
 +LOAD(push_constant, 1, 2, BASE, RANGE, xx,
 +     NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
  
  /*
   * Stores work the same way as loads, except now the first source is the value
index 369a8ee537ed7d6a24ec16eb168ea5aeaca94840,6d4a3d8cd894410a6fb9567182f55302ad12f2cb..df1f7a5d76535346d5ef2ff9655c4b7599ea5295
@@@ -278,8 -278,8 +278,8 @@@ nir_lower_io_block(nir_block *block, vo
              intrin->variables[0]->var->data.driver_location);
  
           if (load->intrinsic == nir_intrinsic_load_uniform) {
-             load->const_index[1] =
-                state->type_size(intrin->variables[0]->var->type);
+             nir_intrinsic_set_range(load,
+                state->type_size(intrin->variables[0]->var->type));
           }
  
           if (per_vertex)
@@@ -430,13 -430,10 +430,13 @@@ nir_get_io_offset_src(nir_intrinsic_ins
     case nir_intrinsic_load_output:
     case nir_intrinsic_load_uniform:
        return &instr->src[0];
 +   case nir_intrinsic_load_ubo:
 +   case nir_intrinsic_load_ssbo:
     case nir_intrinsic_load_per_vertex_input:
     case nir_intrinsic_load_per_vertex_output:
     case nir_intrinsic_store_output:
        return &instr->src[1];
 +   case nir_intrinsic_store_ssbo:
     case nir_intrinsic_store_per_vertex_output:
        return &instr->src[2];
     default: