[Mesa-dev] [PATCH] gallium: remove support for predicates from TGSI

Roland Scheidegger sroland at vmware.com
Mon Aug 11 07:52:33 PDT 2014


Am 09.08.2014 05:24, schrieb Connor Abbott:
> On Wed, Aug 6, 2014 at 6:29 PM, Marek Olšák <maraeo at gmail.com> wrote:
>> What IR? A flatland GLSL IR? A replacement for Mesa IR? Something else?
> 
> It's a flatland IR, similar to TGSI/Direct3D style with enough GLSL
> IR-like stuff to get existing things working now and enable us to
> eventually do linking in it (so we can use the same optimizations
> before linking and after). I was hoping to get a patch series out soon
> for discussion, and I've got an experimental i965 fs backend to try it
> out. It should be able to replace Mesa IR too, but that's not the
> primary goal - it's mostly to be able to do SSA-based optimizations in
> a backend-independent way. You can find a branch here:
> 
> https://urldefense.proofpoint.com/v1/url?u=https://github.com/cwabbott0/mesa/tree/nir&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=F4msKE2WxRzA%2BwN%2B25muztFm5TSPwE8HKJfWfR2NgfY%3D%0A&m=rN8iMoHhewcWeH%2BBeepDoWVV3%2FFTRoPueNUNlnWNdFo%3D%0A&s=f208c68fe0200b7ddf4ebd782ea2b2256635d7da9a884294991d66b538c37af0
> 
> but I'd like to wait on discussing it until I put out some patches.
> 
>>
>> It's more of a question of which gallium hardware drivers are going to
>> support it. I don't think there will be any eager candidates.
> 
> AFAIK almost every HW out there supports predication in one form or
> another - why wouldn't it make sense for a higher level part of the
> compiler to do e.g. if-conversion based on cost estimates provided by
> the driver, similar to how LLVM handles vectorization? That way, it
> can take advantage of the fact that things are predicated by being
> more aggressive with optimizations like code motion, CSE, etc. -
> that's why I originally added support for predication to NIR. Also,
> I'm sure that drivers that don't support control flow (i.e. vc4) will
> like having the frontend do if-conversion for them and pass along the
> predicated code - Eric?
> 
> I'm not sure how predication in Gallium works - if it's old and crufty
> compared to how drivers do things, then that's OK but I still think
> it's useful to do some things with predication outside the driver.

Well predication in gallium is kind of awkward just like it was in d3d9
sm3. sm3 in particular had somewhat weird control flow you could do either
if bool (taking a boolean constant reg, static control flow)
if_lt (comparing one component of a reg to another)
if_pred (using a predicate register)

Also, all ordinary instructions (not including control flow which have
their own pred versions as seen above) could use a predicate register
(actually "the" predicate register as there was just one with 4
channels) to mask output channels (note that such usage actually counted
as an additional instruction towards shader limits, so at least some
hardware probably couldn't do this natively).
But this all went away with sm4 (and if you don't count some extensions,
gl never had it), using a somewhat more "normal" control flow model.
Thus, all drivers (if they want to support glsl) are required to
implement if conversion on their own to whatever they need to do it. Of
course modern hw still has kind of always-on predication (based on
current execution mask) but this doesn't look like it would be too
useful to expose in the IR I think - if you do have some "if" a driver
might well do a comparison (changing the execution mask) plus also do
some jump (if the resulting mask is empty can skip the if block),
whatever the driver thinks is fastest (llvmpipe in particular will
actually never skip a conditional block, though at some point it
probably should...).
Being able to do if-conversion to predication in the frontend also
assumes this works mostly the same for all chips which need it.

Roland




>>
>> The D3D9 state tracker already converts predicates to IFs.
>>
>> Marek
>>
>> On Thu, Aug 7, 2014 at 2:25 AM, Matt Turner <mattst88 at gmail.com> wrote:
>>> On Wed, Aug 6, 2014 at 5:10 PM, Marek Olšák <maraeo at gmail.com> wrote:
>>>> From: Marek Olšák <marek.olsak at amd.com>
>>>>
>>>> Neved used.
>>>> ---
>>>
>>> Connor's new IR has predication. You may not want to remove this quite yet.
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> https://urldefense.proofpoint.com/v1/url?u=http://lists.freedesktop.org/mailman/listinfo/mesa-dev&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=F4msKE2WxRzA%2BwN%2B25muztFm5TSPwE8HKJfWfR2NgfY%3D%0A&m=rN8iMoHhewcWeH%2BBeepDoWVV3%2FFTRoPueNUNlnWNdFo%3D%0A&s=a43243c5465bc07ddadcf7d9885606726f8d353ac5ca234cf5f20a52cece8304
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://urldefense.proofpoint.com/v1/url?u=http://lists.freedesktop.org/mailman/listinfo/mesa-dev&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=F4msKE2WxRzA%2BwN%2B25muztFm5TSPwE8HKJfWfR2NgfY%3D%0A&m=rN8iMoHhewcWeH%2BBeepDoWVV3%2FFTRoPueNUNlnWNdFo%3D%0A&s=a43243c5465bc07ddadcf7d9885606726f8d353ac5ca234cf5f20a52cece8304
> 



More information about the mesa-dev mailing list