<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p><br>
    </p>
    <br>
    <div class="moz-cite-prefix">On 07/05/18 20:36, Jason Ekstrand
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAOFGe95N_J8qeVEQfJBcc-7AsNYeqcfD+nG1hhZ7kmwJADDJMg@mail.gmail.com">
      <div dir="ltr">
        <div class="gmail_extra">
          <div class="gmail_quote">On Mon, May 7, 2018 at 9:37 AM,
            Kenneth Graunke <span dir="ltr"><<a
                href="mailto:kenneth@whitecape.org" target="_blank"
                moz-do-not-send="true">kenneth@whitecape.org</a>></span>
            wrote:<br>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div class="HOEnZb">
                <div class="h5">On Monday, May 7, 2018 8:53:34 AM PDT
                  Jason Ekstrand wrote:<br>
                  > On Mon, May 7, 2018 at 8:02 AM, Alejandro Piñeiro
                  <<a href="mailto:apinheiro@igalia.com"
                    moz-do-not-send="true">apinheiro@igalia.com</a>><br>
                  > wrote:<br>
                  > <br>
                  > > Hi Jason,<br>
                  > ><br>
                  > > as part of the ARB_gl_spirv work, we are
                  doing the linking based on the<br>
                  > > nir shader that comes from spirv_to_nir. On
                  some cases,<br>
                  > > nir_lower_wpos_ytransform introduces a new
                  uniform,<br>
                  > > "gl_FbWposYTransform". So as the uniform is
                  there when we start to do<br>
                  > > the linking, it is treated as any other
                  uniform, being added to the<br>
                  > > UniformStorage, accessible through the
                  OpenGL API and so on. Something<br>
                  > > that I understand that we don't want. On
                  GLSL this is not a problem<br>
                  > > because the linking is done based on
                  MESA/IR, then the IR is converted<br>
                  > > to NIR, and the lowering adds the uniform
                  based on the NIR shader,<br>
                  > > really after the linking.<br>
                  > ><br>
                  > > The first solution I thought was just mark
                  the uniform with a special<br>
                  > > location [1]. It would need to be a negative
                  value, not -1 that is<br>
                  > > already reserved for not-assigned locations
                  (we still have some cases<br>
                  > > for those, even if in general ARB_gl_spirv
                  makes explicit location<br>
                  > > mandatory). So it would be a new negative
                  value, like lets say -5. So<br>
                  > > then on the linking, if the uniform location
                  has this value, the uniform<br>
                  > > is skipped.<br>
                  > ><br>
                  > > After checking that this solution worked
                  (although I only tested with<br>
                  > > some tests), I started to search for an
                  alternative, as this solution<br>
                  > > seemed too hacky.<br>
                  > <br>
                  > <br>
                  > It does seem a bit hacky, yes.<br>
                  > <br>
                  > <br>
                  > > But this lowering needs to be run before
                  nir_lower_io,<br>
                  > > and nir_lower_io is part of the uniform
                  lowering. So I didn't see really<br>
                  > > reasonable to do a nir_lower_io without
                  nir_lower_wpos_ytransform, do<br>
                  > > the linking, and then execute again
                  nir_lower_io/nir_lower_wpos_<wbr>transform.<br>
                  > ><br>
                  > <br>
                  > This is all a bit sticky.  One observation is
                  that the newly added uniform<br>
                  > makes usage of the token system.  Are tokens no
                  longer used with SPIR-V?  I<br>
                  > guess they are kind-of an old mechanism to handle
                  the crufty ARB program<br>
                  > parameters.  However, you could have -5 mean "It
                  uses a token"<br>
                  > <br>
                  > Another option would be to use a system value
                  instead of a uniform.  We can<br>
                  > then convert it to a uniform in the back-end.  We
                  have a few places where<br>
                  > we do things like this for compute shaders.<br>
                  > <br>
                  > I don't have a lot of good ideas or strong
                  opinions, I'm afraid. :-(  Maybe<br>
                  > Ken has some?<br>
                  > <br>
                  > --Jason<br>
                  <br>
                </div>
              </div>
              In GLSL IR, we use var->how_declared == ir_var_hidden
              to hide internally<br>
              created variables from API introspection.  Why not just
              port something<br>
              similar over to the newer NIR code?<br>
            </blockquote>
            <div><br>
            </div>
            <div>I wasn't aware of that.  If we're going to do linking
              in NIR, something like that is probably needed.<br>
            </div>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    Oh nice. Yes, I wasn't aware neither. I will add try to add a
    similar mechanism on NIR. <br>
    <br>
    Thanks everybody for the feedback.<br>
    <br>
    BR<br>
  </body>
</html>