[Piglit] [PATCH 2/2] Add generated tests for AMD_shader_trinary_minmax.

Kenneth Graunke kenneth at whitecape.org
Fri Jan 24 16:21:48 PST 2014


On 01/24/2014 02:56 PM, Ian Romanick wrote:
> On 01/24/2014 01:59 PM, Kenneth Graunke wrote:
>> ---
>>  generated_tests/builtin_function.py | 26 ++++++++++++++++++++++++++
>>  1 file changed, 26 insertions(+)
>>
>> diff --git a/generated_tests/builtin_function.py b/generated_tests/builtin_function.py
>> index d2fdf41..30f5897 100644
>> --- a/generated_tests/builtin_function.py
>> +++ b/generated_tests/builtin_function.py
>> @@ -444,6 +444,8 @@ def _clamp(x, minVal, maxVal):
>>          return None
>>      return min(max(x, minVal), maxVal)
>>  
>> +def _mid3(x, y, z):
>> +    return max(min(x, y), max(min(x, z), min(y, z)))
> 
> I think this is correct, but I'd rather not have to think about it...
> especially since I believe this is the same algorithm Mesa uses, and
> that's what we're trying to test. :)
> 
> Could we do this as a sort, then pick the middle element?
> 
>     # Inefficient, but obvious
>     def _mid3(x, y, z):
>         return np.sort([x, y, z])[1]

I like that better - it's nice to have a different implementation in the
test case.  I've replaced the Mesa algorithm with your obvious one.
There's no change in behavior, so the old code was correct.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20140124/4f40972c/attachment.pgp>


More information about the Piglit mailing list