[Mesa-dev] [PATCH] util: try to use SSE instructions with MSVC and 32-bit gcc

Brian Paul brianp at vmware.com
Wed Aug 17 18:20:28 UTC 2016


On 08/17/2016 12:08 PM, Matt Turner wrote:
> On Wed, Aug 17, 2016 at 10:59 AM, Brian Paul <brianp at vmware.com> wrote:
>> The lrint() and lrintf() functions are pretty slow and make some
>> texture transfers very inefficient.  This patch makes a better effort
>> at using those intrisics for 32-bit gcc and MSVC.
>>
>> Note, this patch doesn't address the use of SSE4.1 with MSVC.
>>
>> Reviewed-by: José Fonseca <jfonseca at vmware.com>
>> ---
>>   src/util/rounding.h | 11 ++++++++---
>>   1 file changed, 8 insertions(+), 3 deletions(-)
>>
>> diff --git a/src/util/rounding.h b/src/util/rounding.h
>> index afb38fb..ab55ebb 100644
>> --- a/src/util/rounding.h
>> +++ b/src/util/rounding.h
>> @@ -29,9 +29,11 @@
>>   #include <limits.h>
>>   #include <stdint.h>
>>
>> -#ifdef __x86_64__
>> +#if defined(__SSE__) || defined(_MSC_VER)
>> +/* MSVC always has SSE nowadays */
>>   #include <xmmintrin.h>
>>   #include <emmintrin.h>
>> +#define ROUND_WITH_SSE 1
>
> I wonder why not replace the ifdef __x86_64__ with SSE || _MSC_VER
> like you did above.

I was thinking of also having a ROUND_WITH_SSE_4_1 at some point for the 
other two functions (since checking for that may be more complicated). 
But since those aren't used for texture transfers I probably won't 
bother afterall.


>
> Either way,
>
> Reviewed-by: Matt Turner <mattst88 at gmail.com>
>
> Also, -fno-math-errno and -fno-trapping-math make various rounding
> functions compile to single or very few instructions with gcc. If MSVC
> has similar flags, it might be worth enabling them.

Thanks.

-Brian



More information about the mesa-dev mailing list