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.

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Piglit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to