[Mesa-dev] A question about nir_lower_wpos_ytransform

Alejandro Piñeiro apinheiro at igalia.com
Tue May 8 06:34:39 UTC 2018



On 07/05/18 20:36, Jason Ekstrand wrote:
> On Mon, May 7, 2018 at 9:37 AM, Kenneth Graunke <kenneth at whitecape.org
> <mailto:kenneth at whitecape.org>> wrote:
>
>     On Monday, May 7, 2018 8:53:34 AM PDT Jason Ekstrand wrote:
>     > On Mon, May 7, 2018 at 8:02 AM, Alejandro Piñeiro
>     <apinheiro at igalia.com <mailto:apinheiro at igalia.com>>
>     > wrote:
>     >
>     > > Hi Jason,
>     > >
>     > > as part of the ARB_gl_spirv work, we are doing the linking
>     based on the
>     > > nir shader that comes from spirv_to_nir. On some cases,
>     > > nir_lower_wpos_ytransform introduces a new uniform,
>     > > "gl_FbWposYTransform". So as the uniform is there when we
>     start to do
>     > > the linking, it is treated as any other uniform, being added
>     to the
>     > > UniformStorage, accessible through the OpenGL API and so on.
>     Something
>     > > that I understand that we don't want. On GLSL this is not a
>     problem
>     > > because the linking is done based on MESA/IR, then the IR is
>     converted
>     > > to NIR, and the lowering adds the uniform based on the NIR shader,
>     > > really after the linking.
>     > >
>     > > The first solution I thought was just mark the uniform with a
>     special
>     > > location [1]. It would need to be a negative value, not -1 that is
>     > > already reserved for not-assigned locations (we still have
>     some cases
>     > > for those, even if in general ARB_gl_spirv makes explicit location
>     > > mandatory). So it would be a new negative value, like lets say
>     -5. So
>     > > then on the linking, if the uniform location has this value,
>     the uniform
>     > > is skipped.
>     > >
>     > > After checking that this solution worked (although I only
>     tested with
>     > > some tests), I started to search for an alternative, as this
>     solution
>     > > seemed too hacky.
>     >
>     >
>     > It does seem a bit hacky, yes.
>     >
>     >
>     > > But this lowering needs to be run before nir_lower_io,
>     > > and nir_lower_io is part of the uniform lowering. So I didn't
>     see really
>     > > reasonable to do a nir_lower_io without
>     nir_lower_wpos_ytransform, do
>     > > the linking, and then execute again
>     nir_lower_io/nir_lower_wpos_transform.
>     > >
>     >
>     > This is all a bit sticky.  One observation is that the newly
>     added uniform
>     > makes usage of the token system.  Are tokens no longer used with
>     SPIR-V?  I
>     > guess they are kind-of an old mechanism to handle the crufty ARB
>     program
>     > parameters.  However, you could have -5 mean "It uses a token"
>     >
>     > Another option would be to use a system value instead of a
>     uniform.  We can
>     > then convert it to a uniform in the back-end.  We have a few
>     places where
>     > we do things like this for compute shaders.
>     >
>     > I don't have a lot of good ideas or strong opinions, I'm afraid.
>     :-(  Maybe
>     > Ken has some?
>     >
>     > --Jason
>
>     In GLSL IR, we use var->how_declared == ir_var_hidden to hide
>     internally
>     created variables from API introspection.  Why not just port something
>     similar over to the newer NIR code?
>
>
> I wasn't aware of that.  If we're going to do linking in NIR,
> something like that is probably needed.

Oh nice. Yes, I wasn't aware neither. I will add try to add a similar
mechanism on NIR.

Thanks everybody for the feedback.

BR
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20180508/b9cd7acc/attachment-0001.html>


More information about the mesa-dev mailing list