[Mesa-dev] SpvOpSelect w/ float operands

Ian Romanick idr at freedesktop.org
Tue Nov 17 18:49:26 UTC 2020


On 11/17/20 9:25 AM, Brian Paul wrote:
> 
> Using the Intel Vulkan driver, we've found some cases where SpvOpSelect
> is returning -0.0 (negative zeros) instead of normal 0.0 depending on
> the arguments.

Do you have a specific test case that fails?

It seems like on some platforms there was an errata about the version of
the SEL instruction that is used for min or max that can return the
wrong signed zero in some cases.

It's also possible that some optimizations are causing problems.  I
don't remember exactly how it works in SPIR-V, but does marking those
SPIR-V instructions as precise (that's what it was in GLSL) make a
difference?

> I'm wondering if "SpvOpSelect x, a, b" for floats is being implemented
> with something like "a*x + b*(1-x)" ?  That might explain where the
> negative zeros are coming from.
> 
> Our work-around is to implement selection with bitwise operations: (a &
> x) | (b & ~x)
> 
> It seems to me that SpvOpSelect shouldn't interpret the bits and just
> return an exact copy of the argument.
> 
> -Brian
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev



More information about the mesa-dev mailing list