[Mesa-dev] [PATCH 7/8] gallium: remove TGSI opcode SCS

Marek Olšák maraeo at gmail.com
Tue Aug 22 11:28:57 UTC 2017


On Tue, Aug 22, 2017 at 1:10 PM, Jose Fonseca <jfonseca at vmware.com> wrote:
> On 20/08/17 01:49, Marek Olšák wrote:
>>
>> From: Marek Olšák <marek.olsak at amd.com>
>>
>> use COS+SIN instead.
>
>
> I don't know if any existing gallium driver leverages that, but it's a basic
> trigonometric principle that one can easily extract the sin from cos or
> vice-versa.  It requires some extra care for getting the right sign.  But
> the fact is that it should be considerably cheaper to comput both
> simultaneously than indepdently.
>
> Unfortunately GLSL/SPIR-V doesn't allow to express that.  D3D9/D3D11 and
> Metal all do.  And from what I've seen from D3D9/D3D11 apps, 99% of the
> times the shader wants both SIN/COS at the same time.
>
> If we want one opcode to rule them all, then a combined SIN+COS seems a
> better choice IMO.  On SM4 the sincos has two outputs:
> https://msdn.microsoft.com/en-us/library/windows/desktop/hh447234.aspx but
> they are both optional to use.  I don't know if there's a precedent for
> that.  I recall we had similar discussions about UMUL/UMUL_HI, and I suspect
> we chose not to go that route.
>
>
> Don't GPUs allow to express the computation of both sin/cos with a single
> opcode?  If nothing else there would be a non-negligible impact of
> leveraging this in llvmpipe at some point.  On the other hand, is possible
> that LLVM common-subexpression elimination optimization passes already do
> that, so we gain nothing.
>
>
> In short, not big deal either way, but I think it's worth give it a 2nd
> thought here.

R300 doesn't have trigonometric functions. R500, R600 and later VLIW
chips, and GCN all only have separate sin and cos.

svga is the only driver that has sincos. No gallium hardware driver has that.

Marek


More information about the mesa-dev mailing list