<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">On 23/08/2018 13:50, Jason Ekstrand
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAOFGe94tYF=geWu8wR=t-bGRcmraLdWs5LqUuarVSa2a2Dg86g@mail.gmail.com">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <div dir="ltr">
        <div class="gmail_quote">
          <div dir="ltr">On Thu, Aug 23, 2018 at 7:04 AM Lionel
            Landwerlin <<a
              href="mailto:lionel.g.landwerlin@intel.com"
              moz-do-not-send="true">lionel.g.landwerlin@intel.com</a>>
            wrote:<br>
          </div>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">We're
            hitting an assert in gfxbench because one of the local
            variable is a sampler :<br>
          </blockquote>
          <div><br>
          </div>
          <div>Of course we were.... That's because gfxbench does
            illegal things like creating local variables which are
            samplers. :-(  I don't think such a variable is being used
            so maybe we can just ensure that dead_variables is run on
            locals before opt_large_constants.  Or maybe we can improve
            the spirv_to_nir hack to never add the variable to the IR in
            the first place.<br>
          </div>
        </div>
      </div>
    </blockquote>
    <p><br>
    </p>
    <p>Indeed, it's not used.</p>
    <p>Let me send a more sensible workaround/fix.<br>
    </p>
    <p><br>
    </p>
    <blockquote type="cite"
cite="mid:CAOFGe94tYF=geWu8wR=t-bGRcmraLdWs5LqUuarVSa2a2Dg86g@mail.gmail.com">
      <div dir="ltr">
        <div class="gmail_quote">
          <div> </div>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            testfw_app: ../src/compiler/nir_types.cpp:551: void
            glsl_get_natural_size_align_bytes(const glsl_type*, unsigned
            int*, unsigned int*): Assertion `!"type does not have a
            natural size"' failed.<br>
            <br>
            Signed-off-by: Lionel Landwerlin <<a
              href="mailto:lionel.g.landwerlin@intel.com"
              target="_blank" moz-do-not-send="true">lionel.g.landwerlin@intel.com</a>><br>
            Fixes: 1235850522cd5e ("nir: Add a large constants
            optimization pass")<br>
            ---<br>
             src/compiler/nir/nir_opt_large_constants.c | 10 +++++++++-<br>
             src/compiler/nir_types.cpp                 |  4 +++-<br>
             2 files changed, 12 insertions(+), 2 deletions(-)<br>
            <br>
            diff --git a/src/compiler/nir/nir_opt_large_constants.c
            b/src/compiler/nir/nir_opt_large_constants.c<br>
            index 25a921963df..5dfb07aed27 100644<br>
            --- a/src/compiler/nir/nir_opt_large_constants.c<br>
            +++ b/src/compiler/nir/nir_opt_large_constants.c<br>
            @@ -178,11 +178,19 @@ nir_opt_large_constants(nir_shader
            *shader,<br>
                         nir_variable *var =
            nir_deref_instr_get_variable(dst_deref);<br>
                         assert(var->data.mode == nir_var_local);<br>
            <br>
            +            struct var_info *info =
            &var_infos[var->data.index];<br>
            +            /* Variable with empty natural size (samplers,
            images, etc...) are<br>
            +             * not considered constant.<br>
            +             */<br>
            +            unsigned var_size, var_align;<br>
            +            size_align(var->type, &var_size,
            &var_align);<br>
            +            if (!var_size)<br>
            +               info->is_constant = false;<br>
            +<br>
                         /* We only consider variables constant if they
            only have constant<br>
                          * stores, all the stores come before any
            reads, and all stores<br>
                          * come in the first block.  We also can't
            handle indirect stores.<br>
                          */<br>
            -            struct var_info *info =
            &var_infos[var->data.index];<br>
                         if (!src_is_const || info->found_read ||
            !first_block ||<br>
                             nir_deref_instr_has_indirect(dst_deref))<br>
                            info->is_constant = false;<br>
            diff --git a/src/compiler/nir_types.cpp
            b/src/compiler/nir_types.cpp<br>
            index c8a29404969..e3a2fc2eac0 100644<br>
            --- a/src/compiler/nir_types.cpp<br>
            +++ b/src/compiler/nir_types.cpp<br>
            @@ -548,7 +548,9 @@ glsl_get_natural_size_align_bytes(const
            struct glsl_type *type,<br>
                case GLSL_TYPE_ERROR:<br>
                case GLSL_TYPE_INTERFACE:<br>
                case GLSL_TYPE_FUNCTION:<br>
            -      unreachable("type does not have a natural size");<br>
            +      *align = 1;<br>
            +      *size = 0;<br>
            +      break;<br>
                }<br>
             }<br>
            <br>
            -- <br>
            2.18.0<br>
            <br>
          </blockquote>
        </div>
      </div>
    </blockquote>
    <p><br>
    </p>
  </body>
</html>