Re: [Mesa-dev] [PATCH] mesa: Ensure stack is realigned on x86.

2014-12-02 Thread Jose Fonseca

On 02/12/14 21:10, Brian Paul wrote:

On 12/02/2014 01:27 PM, Jose Fonseca wrote:

From: José Fonseca 

Nowadays GCC assumes stack pointer is 16-byte aligned even on 32-bits,
but that is an assumption OpenGL drivers (or any dynamic library for
that matter) can affort to make as there are many closed- and open-


can or cannot?


Oops. "cannot".



affort -> afford


Thanks.





source application binaries out there that only assume 4-byte stack
alignment.

This fix uses force_align_arg_pointer GCC attribute, and is only a
stop-gap measure.

The right fix would be to pass -mstackrealign or
-mincoming-stack-boundary=2 to all source fails that use any -msse*
option, as there is no way to guarantee if/when GCC will decide to spill
SSE registers to the stack.

https://bugs.freedesktop.org/show_bug.cgi?id=86788
---
  src/mesa/main/sse_minmax.c | 3 +++
  1 file changed, 3 insertions(+)

diff --git a/src/mesa/main/sse_minmax.c b/src/mesa/main/sse_minmax.c
index 222ac14..93cf2a6 100644
--- a/src/mesa/main/sse_minmax.c
+++ b/src/mesa/main/sse_minmax.c
@@ -31,6 +31,9 @@
  #include 

  void
+#if !defined(__x86_64__)
+   __attribute__((force_align_arg_pointer))
+#endif
  _mesa_uint_array_min_max(const unsigned *ui_indices, unsigned
*min_index,
   unsigned *max_index, const unsigned count)
  {



I don't remember if this code is compiled with MSVC.  If so, do you also
need a gcc check for the __attribute__ part?


No, it doesn't compile on MSVC yet -- there are a few non-standard GCC 
"__attribute__" below already, plus MSVC doesn't define __SSE4_1__, so 
the whole thing would be no-oped.


Getting this to compile on MSVC/MinGW is something I rather leave to 
another time, as it will involve updating scons to set -msse4.1 
correctly, and port a few defines from 
src/gallium/include/pipe/p_config.h and 
src/gallium/auxiliary/util/u_sse.h for portability.



Jose

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] mesa: Ensure stack is realigned on x86.

2014-12-02 Thread Brian Paul

On 12/02/2014 01:27 PM, Jose Fonseca wrote:

From: José Fonseca 

Nowadays GCC assumes stack pointer is 16-byte aligned even on 32-bits,
but that is an assumption OpenGL drivers (or any dynamic library for
that matter) can affort to make as there are many closed- and open-


can or cannot?

affort -> afford



source application binaries out there that only assume 4-byte stack
alignment.

This fix uses force_align_arg_pointer GCC attribute, and is only a
stop-gap measure.

The right fix would be to pass -mstackrealign or
-mincoming-stack-boundary=2 to all source fails that use any -msse*
option, as there is no way to guarantee if/when GCC will decide to spill
SSE registers to the stack.

https://bugs.freedesktop.org/show_bug.cgi?id=86788
---
  src/mesa/main/sse_minmax.c | 3 +++
  1 file changed, 3 insertions(+)

diff --git a/src/mesa/main/sse_minmax.c b/src/mesa/main/sse_minmax.c
index 222ac14..93cf2a6 100644
--- a/src/mesa/main/sse_minmax.c
+++ b/src/mesa/main/sse_minmax.c
@@ -31,6 +31,9 @@
  #include 

  void
+#if !defined(__x86_64__)
+   __attribute__((force_align_arg_pointer))
+#endif
  _mesa_uint_array_min_max(const unsigned *ui_indices, unsigned *min_index,
   unsigned *max_index, const unsigned count)
  {



I don't remember if this code is compiled with MSVC.  If so, do you also 
need a gcc check for the __attribute__ part?


-Brian

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] mesa: Ensure stack is realigned on x86.

2014-12-02 Thread Jose Fonseca
From: José Fonseca 

Nowadays GCC assumes stack pointer is 16-byte aligned even on 32-bits,
but that is an assumption OpenGL drivers (or any dynamic library for
that matter) can affort to make as there are many closed- and open-
source application binaries out there that only assume 4-byte stack
alignment.

This fix uses force_align_arg_pointer GCC attribute, and is only a
stop-gap measure.

The right fix would be to pass -mstackrealign or
-mincoming-stack-boundary=2 to all source fails that use any -msse*
option, as there is no way to guarantee if/when GCC will decide to spill
SSE registers to the stack.

https://bugs.freedesktop.org/show_bug.cgi?id=86788
---
 src/mesa/main/sse_minmax.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/mesa/main/sse_minmax.c b/src/mesa/main/sse_minmax.c
index 222ac14..93cf2a6 100644
--- a/src/mesa/main/sse_minmax.c
+++ b/src/mesa/main/sse_minmax.c
@@ -31,6 +31,9 @@
 #include 
 
 void
+#if !defined(__x86_64__)
+   __attribute__((force_align_arg_pointer))
+#endif
 _mesa_uint_array_min_max(const unsigned *ui_indices, unsigned *min_index,
  unsigned *max_index, const unsigned count)
 {
-- 
2.1.3

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev