[Mesa-dev] [PATCH 7/8] gallium: remove TGSI opcode SCS
Jose Fonseca
jfonseca at vmware.com
Tue Aug 22 11:10:20 UTC 2017
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.
Jose
More information about the mesa-dev
mailing list