[Mesa-dev] [PATCH 1/5] gallium: add SQRT shader opcode

Brian Paul brianp at vmware.com
Fri Feb 1 10:58:21 PST 2013


On 02/01/2013 11:44 AM, Christoph Bumiller wrote:
> On 01.02.2013 19:29, Brian Paul wrote:
>> The glsl-to-tgsi translater will emit SQRT to implement GLSL's sqrt()
>> and distance() functions if the PIPE_SHADER_CAP_TGSI_SQRT_SUPPORTED
>> query says it's supported by the driver.
>>
>> Otherwise, sqrt(x) is implemented with x*rsq(x).  The problem with
>> this is sqrt(0) must be handled specially because rsq(0) might be
>> Inf/NaN/undefined (and then 0*rsq(0) is Inf/Nan/undefined).  In the
> That's why we do rcp(rsq(x)), that works correctly.
> I'm not sure we really need a cap for this though ... except to avoid
> modifying drivers ;)
>
> I'll advertise the cap anyway, I prefer to be able to handle it internally.
> But I like this change, lowering SQRT (or not) is device specific and
> shouldn't be done unconditionally just because the API can't represent it.

If/when all the drivers get updated, I'd be happy to remove the CAP query.

-Brian


More information about the mesa-dev mailing list