<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Sep 15, 2016 at 1:23 AM, Dave Airlie <span dir="ltr"><<a href="mailto:airlied@gmail.com" target="_blank">airlied@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Dave Airlie <<a href="mailto:airlied@redhat.com" target="_blank">airlied@redhat.com</a>><br>
<br>
SPIR-V/Vulkan have a special image type for input attachments<br>
called the subpass type. It has different characteristics than<br>
other images types.<br>
<br>
The main one being it can only be an input image to fragment<br>
shaders and loads from it are relative to the frag coord.<br>
<br>
This adds support for it to the GLSL types. Unfortunately<br>
we've run out of space in the sampler dim in types, so we<br>
need to use another bit.<br>
---<br>
 src/compiler/builtin_type_mac<wbr>ros.h |  2 ++<br>
 src/compiler/glsl_types.cpp        | 12 ++++++++++++<br>
 src/compiler/glsl_types.h          |  5 +++--<br>
 src/compiler/nir/nir.h             |  1 +<br>
 4 files changed, 18 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/src/compiler/builtin_type_ma<wbr>cros.h b/src/compiler/builtin_type_ma<wbr>cros.h<br>
index da3f19e..8af0e2a 100644<br>
--- a/src/compiler/builtin_type_ma<wbr>cros.h<br>
+++ b/src/compiler/builtin_type_ma<wbr>cros.h<br>
@@ -159,6 +159,8 @@ DECL_TYPE(uimageCubeArray, GL_UNSIGNED_INT_IMAGE_CUBE_MAP<wbr>_ARRAY,       GLSL_TYPE<br>
 DECL_TYPE(uimage2DMS,      GL_UNSIGNED_INT_IMAGE_2D_MULTI<wbr>SAMPLE,       GLSL_TYPE_IMAGE, GLSL_SAMPLER_DIM_MS,     0, 0, GLSL_TYPE_UINT)<br>
 DECL_TYPE(uimage2DMSArray, GL_UNSIGNED_INT_IMAGE_2D_MULTI<wbr>SAMPLE_ARRAY, GLSL_TYPE_IMAGE, GLSL_SAMPLER_DIM_MS,     0, 1, GLSL_TYPE_UINT)<br>
<br>
+DECL_TYPE(imageSubpass,    0,                                          GLSL_TYPE_IMAGE, GLSL_SAMPLER_DIM_SUBPASS,0, 0, GLSL_TYPE_FLOAT)<br></blockquote><div><br></div><div>We should probably call this subpassInput to match the GLSL Vulkan spec.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
 DECL_TYPE(atomic_uint, GL_UNSIGNED_INT_ATOMIC_COUNTER<wbr>, GLSL_TYPE_ATOMIC_UINT, 1, 1)<br>
<br>
 STRUCT_TYPE(gl_DepthRangePara<wbr>meters)<br>
diff --git a/src/compiler/glsl_types.cpp b/src/compiler/glsl_types.cpp<br>
index 641644d..bf72419 100644<br>
--- a/src/compiler/glsl_types.cpp<br>
+++ b/src/compiler/glsl_types.cpp<br>
@@ -674,6 +674,8 @@ glsl_type::get_sampler_instanc<wbr>e(enum glsl_sampler_dim dim,<br>
             return error_type;<br>
          else<br>
             return samplerExternalOES_type;<br>
+      case GLSL_SAMPLER_DIM_SUBPASS:<br>
+         return error_type;<br>
       }<br>
    case GLSL_TYPE_INT:<br>
       if (shadow)<br>
@@ -701,6 +703,8 @@ glsl_type::get_sampler_instanc<wbr>e(enum glsl_sampler_dim dim,<br>
          return (array ? isampler2DMSArray_type : isampler2DMS_type);<br>
       case GLSL_SAMPLER_DIM_EXTERNAL:<br>
          return error_type;<br>
+      case GLSL_SAMPLER_DIM_SUBPASS:<br>
+         return error_type;<br>
       }<br>
    case GLSL_TYPE_UINT:<br>
       if (shadow)<br>
@@ -728,6 +732,8 @@ glsl_type::get_sampler_instanc<wbr>e(enum glsl_sampler_dim dim,<br>
          return (array ? usampler2DMSArray_type : usampler2DMS_type);<br>
       case GLSL_SAMPLER_DIM_EXTERNAL:<br>
          return error_type;<br>
+      case GLSL_SAMPLER_DIM_SUBPASS:<br>
+         return error_type;<br>
       }<br>
    default:<br>
       return error_type;<br>
@@ -740,6 +746,8 @@ const glsl_type *<br>
 glsl_type::get_image_<wbr>instance(enum glsl_sampler_dim dim,<br>
                               bool array, glsl_base_type type)<br>
 {<br>
+   if (dim == GLSL_SAMPLER_DIM_SUBPASS)<br>
+      return imageSubpass_type;<br>
    switch (type) {<br>
    case GLSL_TYPE_FLOAT:<br>
       switch (dim) {<br>
@@ -764,6 +772,7 @@ glsl_type::get_image_instance(<wbr>enum glsl_sampler_dim dim,<br>
       case GLSL_SAMPLER_DIM_MS:<br>
          return (array ? image2DMSArray_type : image2DMS_type);<br>
       case GLSL_SAMPLER_DIM_EXTERNAL:<br>
+      case GLSL_SAMPLER_DIM_SUBPASS:<br>
          return error_type;<br>
       }<br>
    case GLSL_TYPE_INT:<br>
@@ -789,6 +798,7 @@ glsl_type::get_image_instance(<wbr>enum glsl_sampler_dim dim,<br>
       case GLSL_SAMPLER_DIM_MS:<br>
          return (array ? iimage2DMSArray_type : iimage2DMS_type);<br>
       case GLSL_SAMPLER_DIM_EXTERNAL:<br>
+      case GLSL_SAMPLER_DIM_SUBPASS:<br>
          return error_type;<br>
       }<br>
    case GLSL_TYPE_UINT:<br>
@@ -814,6 +824,7 @@ glsl_type::get_image_instance(<wbr>enum glsl_sampler_dim dim,<br>
       case GLSL_SAMPLER_DIM_MS:<br>
          return (array ? uimage2DMSArray_type : uimage2DMS_type);<br>
       case GLSL_SAMPLER_DIM_EXTERNAL:<br>
+      case GLSL_SAMPLER_DIM_SUBPASS:<br>
          return error_type;<br>
       }<br>
    default:<br>
@@ -1975,6 +1986,7 @@ glsl_type::coordinate_componen<wbr>ts() const<br>
    case GLSL_SAMPLER_DIM_RECT:<br>
    case GLSL_SAMPLER_DIM_MS:<br>
    case GLSL_SAMPLER_DIM_EXTERNAL:<br>
+   case GLSL_SAMPLER_DIM_SUBPASS:<br>
       size = 2;<br>
       break;<br>
    case GLSL_SAMPLER_DIM_3D:<br>
diff --git a/src/compiler/glsl_types.h b/src/compiler/glsl_types.h<br>
index 7c4827d..b1e2f7a 100644<br>
--- a/src/compiler/glsl_types.h<br>
+++ b/src/compiler/glsl_types.h<br>
@@ -80,7 +80,8 @@ enum glsl_sampler_dim {<br>
    GLSL_SAMPLER_DIM_RECT,<br>
    GLSL_SAMPLER_DIM_BUF,<br>
    GLSL_SAMPLER_DIM_EXTERNAL,<br>
-   GLSL_SAMPLER_DIM_MS<br>
+   GLSL_SAMPLER_DIM_MS,<br>
+   GLSL_SAMPLER_DIM_SUBPASS, /* for vulkan input attachments */<br>
 };<br>
<br>
 enum glsl_interface_packing {<br>
@@ -127,7 +128,7 @@ struct glsl_type {<br>
    GLenum gl_type;<br>
    glsl_base_type base_type;<br>
<br>
-   unsigned sampler_dimensionality:3; /**< \see glsl_sampler_dim */<br>
+   unsigned sampler_dimensionality:4; /**< \see glsl_sampler_dim */<br>
    unsigned sampler_shadow:1;<br>
    unsigned sampler_array:1;<br>
    unsigned sampled_type:2;    /**< Type of data returned using this<br>
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h<br>
index ff7c422..95659d5 100644<br>
--- a/src/compiler/nir/nir.h<br>
+++ b/src/compiler/nir/nir.h<br>
@@ -1198,6 +1198,7 @@ nir_tex_instr_dest_size(nir_te<wbr>x_instr *instr)<br>
          case GLSL_SAMPLER_DIM_MS:<br>
          case GLSL_SAMPLER_DIM_RECT:<br>
          case GLSL_SAMPLER_DIM_EXTERNAL:<br>
+         case GLSL_SAMPLER_DIM_SUBPASS:<br>
             ret = 2;<br>
             break;<br>
          case GLSL_SAMPLER_DIM_3D:<br>
<span><font color="#888888">--<br>
2.5.5<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>