[Mesa-dev] [PATCH] i965: Work around SIN/COS output range problem.

Kenneth Graunke kenneth at whitecape.org
Tue Mar 22 22:18:59 UTC 2016


On Tuesday, March 22, 2016 2:31:42 PM PDT Ian Romanick wrote:
> On 03/17/2016 09:18 AM, Martin Peres wrote:
> > On 16/03/16 19:33, Kenneth Graunke wrote:
> >> The SIN and COS instructions on Intel hardware can produce values
> >> slightly outside of the [-1.0, 1.0] range for a small set of values.
> >> Obviously, this can break everyone's expectations about trig functions.
> >>
> >> According to an internal presentation, the COS instruction can produce
> >> a value up to 1.000027 for inputs in the range (0.08296, 0.09888).  One
> >> suggested workaround is to multiply by 0.99997, scaling down the
> >> amplitude slightly.  Apparently this also minimizes the error function,
> >> reducing the maximum error from 0.00006 to about 0.00003.
> >>
> >> I chose to apply this only when not saturating, as saturate already
> >> clamps to 1.0.  This may or may not be a good idea.
> >>
> >> Fixes 16 dEQP precision tests
> >>
> >>     dEQP-GLES31.functional.shaders.builtin_functions.precision.
> >>     {cos,sin}.{highp,mediump}_compute.{scalar,vec2,vec4,vec4}.
> >>
> >> at the cost of making every sin and cos call more expensive.
> >>
> >> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
> >> ---
> >>   src/mesa/drivers/dri/i965/brw_fs_nir.cpp   | 26
> >> ++++++++++++++++++++------
> >>   src/mesa/drivers/dri/i965/brw_vec4_nir.cpp | 26
> >> ++++++++++++++++++++------
> >>   2 files changed, 40 insertions(+), 12 deletions(-)
> >>
> >> This has been in the Vulkan tree for a while - we needed it to pass the
> >> Vulkan CTS, as it contains these same dEQP tests.
> >>
> >> I haven't run shader-db yet, but I don't expect we'll like the results.
> >>
> >> The patch is pretty sketchy, too.  I'm sort of tempted to hide it behind
> >> an INTEL_STRICT_CONFORMANCE=1 option, like we had way back in the day...
> > 
> > FYI, a quick run on hsw_gt2 shows -10.45% on Gputest:voplosion.
> 
> Can you explain this result?  -10.45% of what?  Instructions?  FPS?  And
> this is comparing what to what?  Before this patch to after?

I think FPS goes down by 10.45% when applying this patch.  Pretty dire.

--Ken
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160322/376a2b26/attachment.sig>


More information about the mesa-dev mailing list