[Mesa-dev] [RFC PATCH 00/16] A new IR for Mesa
John Kessenich
johnk at lunarg.com
Wed Aug 27 12:20:49 PDT 2014
Hi Connor,
Lots of good work in defining a new IR.
I would like to address the LLVM issues: LunarG's LunarGLASS conventions
on LLVM IR generally solve these problems: It has algorithms to re-deduce
structured control flow, and if you just want to use LLVM IR as an
intermediate language, it could be annotated with the original structured
flow control. Things that should turn into a modifier can be captured as
intrinsics, and statically linking the part of LLVM that you need avoids
all the release schedule and WebKit-type related issues.
If Mesa is looking at adding an IR, I highly recommend something that is
LLVM based, for the following reasons:
- Shaders are going in the direction of having richer C++-like features.
- It saves tons of engineering time in not creating transforms that have
already been written.
- Synergy with other IRs and toolsets that are also being based on LLVM.
JohnK
On Tue, Aug 19, 2014 at 9:04 AM, Connor Abbott <cwabbott0 at gmail.com> wrote:
> On Mon, Aug 18, 2014 at 8:52 PM, Michel Dänzer <michel at daenzer.net> wrote:
> > On 19.08.2014 01:28, Connor Abbott wrote:
> >> On Mon, Aug 18, 2014 at 4:32 AM, Michel Dänzer <michel at daenzer.net>
> wrote:
> >>> On 16.08.2014 09:12, Connor Abbott wrote:
> >>>> I know what you might be thinking right now. "Wait, *another* IR?
> Don't
> >>>> we already have like 5 of those, not counting all the driver-specific
> >>>> ones? Isn't this stuff complicated enough already?" Well, there are
> some
> >>>> pretty good reasons to start afresh (again...). In the years we've
> been
> >>>> using GLSL IR, we've come to realize that, in fact, it's not what we
> >>>> want *at all* to do optimizations on.
> >>>
> >>> Did you evaluate using LLVM IR instead of inventing yet another one?
> >>>
> >>>
> >>> --
> >>> Earthling Michel Dänzer |
> http://www.amd.com
> >>> Libre software enthusiast | Mesa and X
> developer
> >>
> >> Yes. See
> >>
> >>
> http://lists.freedesktop.org/archives/mesa-dev/2014-February/053502.html
> >>
> >> and
> >>
> >>
> http://lists.freedesktop.org/archives/mesa-dev/2014-February/053522.html
> >
> > I know Ian can't deal with LLVM for some reason. I was wondering if
> > *you* evaluated it, and if so, why you rejected it.
> >
> >
> > --
> > Earthling Michel Dänzer | http://www.amd.com
> > Libre software enthusiast | Mesa and X developer
>
>
> Well, first of all, the fact that Ian and Ken don't want to use it
> means that any plan to use LLVM for the Intel driver is dead in the
> water anyways - you can translate NIR into LLVM if you want, but for
> i965 we want to share optimizations between our 2 backends (FS and
> vec4) that we can't do today in GLSL IR so this is what we want to use
> for that, and since nobody else does anything with the core GLSL
> compiler except when they have to, when we start moving things out of
> GLSL IR this will probably replace GLSL IR as the infrastructure that
> all Mesa drivers use. But with that in mind, here are a few reasons
> why we wouldn't want to use LLVM:
>
> * LLVM wasn't built to understand structured CFG's, meaning that you
> need to re-structurize it using a pass that's fragile and prone to
> break if some other pass "optimizes" the shader in a way that makes it
> non-structured (i.e. not expressible in terms of loops and if
> statements). This loss of information also means that passes that need
> to know things like, for example, the loop nesting depth need to do an
> analysis pass whereas with NIR you can just walk up the control flow
> tree and count the number of loops we hit.
>
> * LLVM doesn't do modifiers, meaning that we can't do optimizations
> like "clamp(x, 0.0, 1.0) => mov.sat x" and "clamp(x, 0.25, 1.0) =>
> max.sat(x, .25)" in a generic fashion.
>
> * LLVM is hard to embed into other projects, especially if it's used
> as anything but a command-line tool that only runs once. See, for
> example, http://blog.llvm.org/2014/07/ftl-webkits-llvm-based-jit.html
> under "Linking WebKit with LLVM" - most of those problems would also
> apply to us.
>
> * LLVM is on a different release schedule (6 months vs. 3 months), has
> a different review process, etc., which means that to add support for
> new functionality that involves shaders, we now have to submit patches
> to two separate projects, and then 2 months later when we ship Mesa it
> turns out that nobody can actually use the new feature because it
> depends upon an unreleased version of LLVM that won't be released for
> another 3 months and then packaged by distros even later... we've
> already had problems where distros refused to ship newer Mesa releases
> because radeon depended on a version of LLVM newer than the one they
> were shipping, and if we started using LLVM in core Mesa it would get
> even worse. Proprietary drivers solve this problem by just forking
> LLVM, building it with the rest of their driver, and linking it in as
> a static library, but distro packagers would hate us if we did that.
>
> I wouldn't completely rule out LLVM, and I do think they do a lot of
> things right, but for now it seems like it's not the path that the
> Intel team wants to take.
>
> Connor
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140827/5e2ff958/attachment.html>
More information about the mesa-dev
mailing list