Mesa (master): nv50: avoid segfault with enabled but unbound vertex attrib

2015-07-08 Thread Samuel Pitoiset
Module: Mesa
Branch: master
Commit: adc816a1e41812e6489a5bc388f80de65504be5b
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=adc816a1e41812e6489a5bc388f80de65504be5b

Author: Samuel Pitoiset 
Date:   Mon Jul  6 23:34:23 2015 +0200

nv50: avoid segfault with enabled but unbound vertex attrib

Before validating vertex arrays we need to check if a VBO is present.
Checking if vb->buffer is not NULL fixes the issue.

Fixes the following piglit test:
  gl-3.1-vao-broken-attrib

Signed-off-by: Samuel Pitoiset 
Reviewed-by: Ilia Mirkin 

---

 src/gallium/drivers/nouveau/nv50/nv50_vbo.c |5 +
 1 file changed, 5 insertions(+)

diff --git a/src/gallium/drivers/nouveau/nv50/nv50_vbo.c 
b/src/gallium/drivers/nouveau/nv50/nv50_vbo.c
index 1fd33b8..3d200bd 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_vbo.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_vbo.c
@@ -382,6 +382,11 @@ nv50_vertex_arrays_validate(struct nv50_context *nv50)
   if (nv50->vbo_user & (1 << b)) {
  address = addrs[b] + ve->pipe.src_offset;
  limit = addrs[b] + limits[b];
+  } else
+  if (!vb->buffer) {
+ BEGIN_NV04(push, NV50_3D(VERTEX_ARRAY_FETCH(i)), 1);
+ PUSH_DATA (push, 0);
+ continue;
   } else {
  struct nv04_resource *buf = nv04_resource(vb->buffer);
  if (!(refd & (1 << b))) {

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


Mesa (master): nvc0: fix wrong use of BLIT_SRC_Y_INT for 2D texture copy

2015-07-08 Thread Samuel Pitoiset
Module: Mesa
Branch: master
Commit: ec151e2f72bd4a239573770aea563d47d0268708
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ec151e2f72bd4a239573770aea563d47d0268708

Author: Samuel Pitoiset 
Date:   Mon Jul  6 22:06:08 2015 +0200

nvc0: fix wrong use of BLIT_SRC_Y_INT for 2D texture copy

According to nv50, this should be src->ms_y instead of src->ms_x. This
code is here since 2012, so it's probably a typo error which has never
been detected since a long time. I didn't do a full piglit run to check
if it fixes some other weird issues.

Signed-off-by: Samuel Pitoiset 
Reviewed-by: Ilia Mirkin 

---

 src/gallium/drivers/nouveau/nvc0/nvc0_surface.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_surface.c 
b/src/gallium/drivers/nouveau/nvc0/nvc0_surface.c
index ac4dd25..3c17f16 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_surface.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_surface.c
@@ -189,7 +189,7 @@ nvc0_2d_texture_do_copy(struct nouveau_pushbuf *push,
PUSH_DATA (push, 0);
PUSH_DATA (push, sx << src->ms_x);
PUSH_DATA (push, 0);
-   PUSH_DATA (push, sy << src->ms_x);
+   PUSH_DATA (push, sy << src->ms_y);
 
return 0;
 }

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


Mesa (master): nir: Fix comment above nir_convert_from_ssa() prototype.

2015-07-08 Thread Kenneth Graunke
Module: Mesa
Branch: master
Commit: efb36271a92b44ee0e35c4f833610dbea776badd
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=efb36271a92b44ee0e35c4f833610dbea776badd

Author: Kenneth Graunke 
Date:   Wed Jul  8 01:57:00 2015 -0700

nir: Fix comment above nir_convert_from_ssa() prototype.

Connor renamed the parameter, inverting the sense.
Update the comment accordingly.

Signed-off-by: Kenneth Graunke 
Reviewed-by: Connor Abbott 

---

 src/glsl/nir/nir.h |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
index 4cb7d2f..9e2a281 100644
--- a/src/glsl/nir/nir.h
+++ b/src/glsl/nir/nir.h
@@ -1659,9 +1659,9 @@ bool nir_ssa_defs_interfere(nir_ssa_def *a, nir_ssa_def 
*b);
 void nir_convert_to_ssa_impl(nir_function_impl *impl);
 void nir_convert_to_ssa(nir_shader *shader);
 
-/* If convert_everything is true, convert all values (even those not involved
- * in a phi node) to registers. If false, only convert SSA values involved in
- * phi nodes to registers.
+/* If phi_webs_only is true, only convert SSA values involved in phi nodes to
+ * registers.  If false, convert all values (even those not involved in a phi
+ * node) to registers.
  */
 void nir_convert_from_ssa(nir_shader *shader, bool phi_webs_only);
 

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


Mesa (master): egl: use unix defines on osx with clang

2015-07-08 Thread Emil Velikov
Module: Mesa
Branch: master
Commit: 7d642442d9339e5b65c30802c44091816cdf18be
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7d642442d9339e5b65c30802c44091816cdf18be

Author: Julien Isorce 
Date:   Thu Jul  2 23:10:38 2015 +0100

egl: use unix defines on osx with clang

I also created an bug in Khronos 's bugzilla as you suggested:
https://www.khronos.org/bugzilla/show_bug.cgi?id=1356
I'll let you know if I get feedback from this bug or else where.

Patch with updated error messages:

[PATCH] eglplatform: treat __APPLE__ the same way as __unix__ to handle X11 
types

  CC   eglapi.lo
./egldisplay.h:258:19: error: unknown type name 'Display'
_eglGetX11Display(Display *native_display, const EGLint *attrib_list);
eglapi.c:290:4: error: array size is negative
   STATIC_ASSERT(sizeof(void*) == sizeof(nativeDisplay));
eglapi.c:291:25: warning: cast to 'void *' from smaller integer type
   'EGLNativeDisplayType' (aka 'int') [-Wint-to-void-pointer-cast]
   native_display_ptr = (void*) nativeDisplay;
eglapi.c:307:32: error: use of undeclared identifier 'Display'
  dpy = _eglGetX11Display((Display*) native_display, attrib_list);
eglapi.c:776:35: error: use of undeclared identifier 'Window'
  native_window = (void*) (* (Window*) native_window);
eglapi.c:847:35: error: use of undeclared identifier 'Pixmap'
  native_pixmap = (void*) (* (Pixmap*) native_pixmap);

Bugzilla Mesa: https://bugs.freedesktop.org/show_bug.cgi?id=90249
Bugzilla Khronos: https://www.khronos.org/bugzilla/show_bug.cgi?id=1356
Signed-off-by: Julien Isorce 
Reviewed-by: Emil Velikov 

---

 include/EGL/eglplatform.h |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/EGL/eglplatform.h b/include/EGL/eglplatform.h
index 7802542..b376e64 100644
--- a/include/EGL/eglplatform.h
+++ b/include/EGL/eglplatform.h
@@ -77,7 +77,7 @@ typedef HDC EGLNativeDisplayType;
 typedef HBITMAP EGLNativePixmapType;
 typedef HWNDEGLNativeWindowType;
 
-#elif defined(__APPLE__) || defined(__WINSCW__) || defined(__SYMBIAN32__)  /* 
Symbian */
+#elif defined(__WINSCW__) || defined(__SYMBIAN32__)  /* Symbian */
 
 typedef int   EGLNativeDisplayType;
 typedef void *EGLNativeWindowType;
@@ -105,7 +105,7 @@ typedef struct ANativeWindow*   EGLNativeWindowType;
 typedef struct egl_native_pixmap_t* EGLNativePixmapType;
 typedef void*   EGLNativeDisplayType;
 
-#elif defined(__unix__)
+#elif defined(__unix__) || defined(__APPLE__)
 
 #if defined(MESA_EGL_NO_X11_HEADERS)
 

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


Mesa (master): darwin: Suppress type conversion warnings for GLhandleARB

2015-07-08 Thread Emil Velikov
Module: Mesa
Branch: master
Commit: c7f3657450683827446072ad6b1e8fce04078162
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=c7f3657450683827446072ad6b1e8fce04078162

Author: Julien Isorce 
Date:   Wed Jul  1 00:33:14 2015 +0100

darwin: Suppress type conversion warnings for GLhandleARB

This patch and its description are inspired from Jose Fonseca
explanations and suggestions.

With this patch the following logic applies and only if __APPLE__:

When building mesa, GLhandleARB is defined as unsigned long and
at some point casted to GLuint in gl fuction implementations.
These exact points are where these errors and warnings appear.

When building an application GLhandleARB is defined as void*.
Later when calling a gl function, for example glBindAttribLocationARB,
it will be dispatched to _mesa_BindAttribLocation. So internally
void* will be treated as unsigned long which has the same size.
So the same truncation happens when casting it to GLuint.

Same when GLhandleARB appears as return value.
For mesa it will be GLuint -> unsigned long.
For an application it will be GLuint -> unsigned long -> void*.
Note that the value will be preserved when casting back to GLuint.

When GLhandleARB appears as a pointer there are also separate
entry-points, i.e. _mesa_FuncNameARB. So the same logic can
be applied.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=66346
Signed-off-by: Julien Isorce 
Reviewed-by: Jose Fonseca 
Reviewed-by: Emil Velikov 

---

 configure.ac   |2 +-
 include/GL/glext.h |5 +
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index d240c06..d819bef 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1354,7 +1354,7 @@ if test "x$enable_dri" = xyes; then
 fi
 ;;
 darwin*)
-DEFINES="$DEFINES -DGLX_ALIAS_UNSUPPORTED"
+DEFINES="$DEFINES -DGLX_ALIAS_UNSUPPORTED -DBUILDING_MESA"
 if test "x$with_dri_drivers" = "xyes"; then
 with_dri_drivers="swrast"
 fi
diff --git a/include/GL/glext.h b/include/GL/glext.h
index a3873a6..e5f1d89 100644
--- a/include/GL/glext.h
+++ b/include/GL/glext.h
@@ -3879,7 +3879,12 @@ GLAPI void APIENTRY glMinSampleShadingARB (GLfloat 
value);
 #ifndef GL_ARB_shader_objects
 #define GL_ARB_shader_objects 1
 #ifdef __APPLE__
+#ifdef BUILDING_MESA
+/* Avoid uint <-> void* warnings */
+typedef unsigned long GLhandleARB;
+#else
 typedef void *GLhandleARB;
+#endif
 #else
 typedef unsigned int GLhandleARB;
 #endif

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


Mesa (master): android: freedreno: add missing components to the build

2015-07-08 Thread Emil Velikov
Module: Mesa
Branch: master
Commit: 64cb014037551c4b7bbed1cf2ca8f1126c970146
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=64cb014037551c4b7bbed1cf2ca8f1126c970146

Author: Varad Gautam 
Date:   Sat Jun 27 11:50:26 2015 +0530

android: freedreno: add missing components to the build

Freedreno requires {a4xx,ir3}_SOURCES and NIR to build.

Signed-off-by: Varad Gautam 
Reviewed-by: Emil Velikov 

---

 src/gallium/drivers/freedreno/Android.mk |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/freedreno/Android.mk 
b/src/gallium/drivers/freedreno/Android.mk
index a6712b2..ed51835 100644
--- a/src/gallium/drivers/freedreno/Android.mk
+++ b/src/gallium/drivers/freedreno/Android.mk
@@ -28,7 +28,9 @@ include $(CLEAR_VARS)
 LOCAL_SRC_FILES := \
$(C_SOURCES) \
$(a2xx_SOURCES) \
-   $(a3xx_SOURCES)
+   $(a3xx_SOURCES) \
+   $(a4xx_SOURCES) \
+   $(ir3_SOURCES)
 
 LOCAL_CFLAGS := \
-Wno-packed-bitfield-compat
@@ -37,6 +39,7 @@ LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/ir3
 
 LOCAL_SHARED_LIBRARIES := libdrm libdrm_freedreno
+LOCAL_STATIC_LIBRARIES := libmesa_glsl
 LOCAL_MODULE := libmesa_pipe_freedreno
 
 include $(GALLIUM_COMMON_MK)

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


Mesa (master): egl/dri2: load libglapi.0.dylib on osx

2015-07-08 Thread Emil Velikov
Module: Mesa
Branch: master
Commit: e27ea996444743b8cbdca096a4aab47dd405ebf9
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e27ea996444743b8cbdca096a4aab47dd405ebf9

Author: Julien Isorce 
Date:   Thu Jun 18 06:53:52 2015 +0100

egl/dri2: load libglapi.0.dylib on osx

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90903
Signed-off-by: Julien Isorce 
Reviewed-by: Emil Velikov 

---

 src/egl/drivers/dri2/egl_dri2.c |2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 400ee63..65194cb 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -2368,6 +2368,8 @@ dri2_load(_EGLDriver *drv)
 #ifdef HAVE_SHARED_GLAPI
 #ifdef HAVE_ANDROID_PLATFORM
const char *libname = "libglapi.so";
+#elif defined(__APPLE__)
+   const char *libname = "libglapi.0.dylib";
 #else
const char *libname = "libglapi.so.0";
 #endif

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


Mesa (master): i965: Move pipecontrol workaround bo to brw_pipe_control

2015-07-08 Thread Chris Wilson
Module: Mesa
Branch: master
Commit: f1d08c4f75794add30d1714a4cd9ce2bf335148d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f1d08c4f75794add30d1714a4cd9ce2bf335148d

Author: Chris Wilson 
Date:   Fri May  1 11:25:20 2015 +0100

i965: Move pipecontrol workaround bo to brw_pipe_control

With the exception of gen8, the sole user of the workaround bo are for
emitting pipe controls. Move it out of the purview of the batchbuffer
and into the pipecontrol.

Signed-off-by: Chris Wilson 
Reviewed-by: Kenneth Graunke 
Reviewed-by: Martin Peres 

---

 src/mesa/drivers/dri/i965/brw_context.c   |7 +
 src/mesa/drivers/dri/i965/brw_context.h   |   12 +---
 src/mesa/drivers/dri/i965/brw_pipe_control.c  |   40 +
 src/mesa/drivers/dri/i965/gen8_depth_state.c  |2 +-
 src/mesa/drivers/dri/i965/intel_batchbuffer.c |   12 
 src/mesa/drivers/dri/i965/intel_extensions.c  |   28 -
 6 files changed, 64 insertions(+), 37 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.c 
b/src/mesa/drivers/dri/i965/brw_context.c
index 4b51fe5..8150b94 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -819,6 +819,12 @@ brwCreateContext(gl_api api,
   }
}
 
+   if (brw_init_pipe_control(brw, devinfo)) {
+  *dri_ctx_error = __DRI_CTX_ERROR_NO_MEMORY;
+  intelDestroyContext(driContextPriv);
+  return false;
+   }
+
brw_init_state(brw);
 
intelInitExtensions(ctx);
@@ -942,6 +948,7 @@ intelDestroyContext(__DRIcontext * driContextPriv)
if (ctx->swrast_context)
   _swrast_DestroyContext(&brw->ctx);
 
+   brw_fini_pipe_control(brw);
intel_batchbuffer_free(brw);
 
drm_intel_bo_unreference(brw->throttle_batch[1]);
diff --git a/src/mesa/drivers/dri/i965/brw_context.h 
b/src/mesa/drivers/dri/i965/brw_context.h
index 7596139..65f34c3 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -869,8 +869,6 @@ struct intel_batchbuffer {
drm_intel_bo *bo;
/** Last BO submitted to the hardware.  Used for glFinish(). */
drm_intel_bo *last_bo;
-   /** BO for post-sync nonzero writes for gen6 workaround. */
-   drm_intel_bo *workaround_bo;
 
uint16_t emit, total;
uint16_t used, reserved_space;
@@ -882,8 +880,6 @@ struct intel_batchbuffer {
enum brw_gpu_ring ring;
bool needs_sol_reset;
 
-   uint8_t pipe_controls_since_last_cs_stall;
-
struct {
   uint16_t used;
   int reloc_count;
@@ -1035,6 +1031,10 @@ struct brw_context
 
drm_intel_context *hw_ctx;
 
+   /** BO for post-sync nonzero writes for gen6 workaround. */
+   drm_intel_bo *workaround_bo;
+   uint8_t pipe_controls_since_last_cs_stall;
+
/**
 * Set of drm_intel_bo * that have been rendered to within this batchbuffer
 * and would need flushing before being used from another cache domain that
@@ -2001,6 +2001,10 @@ gen9_use_linear_1d_layout(const struct brw_context *brw,
   const struct intel_mipmap_tree *mt);
 
 /* brw_pipe_control.c */
+int brw_init_pipe_control(struct brw_context *brw,
+ const struct brw_device_info *info);
+void brw_fini_pipe_control(struct brw_context *brw);
+
 void brw_emit_pipe_control_flush(struct brw_context *brw, uint32_t flags);
 void brw_emit_pipe_control_write(struct brw_context *brw, uint32_t flags,
  drm_intel_bo *bo, uint32_t offset,
diff --git a/src/mesa/drivers/dri/i965/brw_pipe_control.c 
b/src/mesa/drivers/dri/i965/brw_pipe_control.c
index b4c86b9..7ee3cb6 100644
--- a/src/mesa/drivers/dri/i965/brw_pipe_control.c
+++ b/src/mesa/drivers/dri/i965/brw_pipe_control.c
@@ -72,13 +72,13 @@ gen7_cs_stall_every_four_pipe_controls(struct brw_context 
*brw, uint32_t flags)
if (brw->gen == 7 && !brw->is_haswell) {
   if (flags & PIPE_CONTROL_CS_STALL) {
  /* If we're doing a CS stall, reset the counter and carry on. */
- brw->batch.pipe_controls_since_last_cs_stall = 0;
+ brw->pipe_controls_since_last_cs_stall = 0;
  return 0;
   }
 
   /* If this is the fourth pipe control without a CS stall, do one now. */
-  if (++brw->batch.pipe_controls_since_last_cs_stall == 4) {
- brw->batch.pipe_controls_since_last_cs_stall = 0;
+  if (++brw->pipe_controls_since_last_cs_stall == 4) {
+ brw->pipe_controls_since_last_cs_stall = 0;
  return PIPE_CONTROL_CS_STALL;
   }
}
@@ -213,7 +213,7 @@ gen7_emit_vs_workaround_flush(struct brw_context *brw)
brw_emit_pipe_control_write(brw,
PIPE_CONTROL_WRITE_IMMEDIATE
| PIPE_CONTROL_DEPTH_STALL,
-   brw->batch.workaround_bo, 0,
+   brw->workaround_bo, 0,
0, 0);
 }
 
@@ -227,7 +227,7 @@ gen7_emit_cs_stall_flush(struct brw_context *brw)
brw_emit_pipe_contr

Mesa (master): loader: Look for any version of currently linked libudev.so

2015-07-08 Thread Chris Wilson
Module: Mesa
Branch: master
Commit: f2413457937f8f4a92e11379569be69e508d7477
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f2413457937f8f4a92e11379569be69e508d7477

Author: Chris Wilson 
Date:   Wed Jun 10 08:28:13 2015 +0100

loader: Look for any version of currently linked libudev.so

Since there was an ABI break and linking twice against libudev.so.0 and
libudev.so.1 causes the application to quickly crash, we first check if
the application is currently linked against libudev before dlopening a
local handle. However for backwards/forwards compatability, we need to
inspect the application for current linkage against all known versions
first. Not doing so causes a crash when both libraries are present and
so mesa chooses libudev.so.1 but the application was linked against
libudev.so.0.

Signed-off-by: Chris Wilson 

Emil Velikov:

I'm ever so slightly conserned that RTLD_NOLOAD is not part of the POSIX
standard, thus it's missing on some platforms (*BSD seems ok, while
Solaris, MacOS are not).

Reviewed-by: Emil Velikov 
Cc: mesa-sta...@lists.freedesktop.org

---

 src/loader/loader.c |   46 --
 1 file changed, 28 insertions(+), 18 deletions(-)

diff --git a/src/loader/loader.c b/src/loader/loader.c
index 8452cd3..8780587 100644
--- a/src/loader/loader.c
+++ b/src/loader/loader.c
@@ -128,26 +128,36 @@ static void *udev_handle = NULL;
 static void *
 udev_dlopen_handle(void)
 {
-   if (!udev_handle) {
-  udev_handle = dlopen("libudev.so.1", RTLD_LOCAL | RTLD_LAZY);
-
-  if (!udev_handle) {
- /* libudev.so.1 changed the return types of the two unref functions
-  * from voids to pointers.  We don't use those return values, and the
-  * only ABI I've heard that cares about this kind of change (calling
-  * a function with a void * return that actually only returns void)
-  * might be ia64.
-  */
- udev_handle = dlopen("libudev.so.0", RTLD_LOCAL | RTLD_LAZY);
-
- if (!udev_handle) {
-log_(_LOADER_WARNING, "Couldn't dlopen libudev.so.1 or "
- "libudev.so.0, driver detection may be broken.\n");
- }
+   char name[80];
+   unsigned flags = RTLD_NOLOAD | RTLD_LOCAL | RTLD_LAZY;
+   int version;
+
+   /* libudev.so.1 changed the return types of the two unref functions
+* from voids to pointers.  We don't use those return values, and the
+* only ABI I've heard that cares about this kind of change (calling
+* a function with a void * return that actually only returns void)
+* might be ia64.
+*/
+
+   /* First try opening an already linked libudev, then try loading one */
+   do {
+  for (version = 1; version >= 0; version--) {
+ snprintf(name, sizeof(name), "libudev.so.%d", version);
+ udev_handle = dlopen(name, flags);
+ if (udev_handle)
+return udev_handle;
   }
-   }
 
-   return udev_handle;
+  if ((flags & RTLD_NOLOAD) == 0)
+ break;
+
+  flags &= ~RTLD_NOLOAD;
+   } while (1);
+
+   log_(_LOADER_WARNING,
+"Couldn't dlopen libudev.so.1 or "
+"libudev.so.0, driver detection may be broken.\n");
+   return NULL;
 }
 
 static int dlsym_failed = 0;

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


Mesa (master): i965: Query whether we have kernel support for the TIMESTAMP register once

2015-07-08 Thread Chris Wilson
Module: Mesa
Branch: master
Commit: c8d3ebaffc0d7d915c1c19d54dba61fd1e57b338
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=c8d3ebaffc0d7d915c1c19d54dba61fd1e57b338

Author: Chris Wilson 
Date:   Wed Apr 29 13:32:38 2015 +0100

i965: Query whether we have kernel support for the TIMESTAMP register once

Move the query for the TIMESTAMP register from context init to the
screen, so that it is only queried once for all contexts.

On 32bit systems, some old kernels trigger a hw bug resulting in the
TIMESTAMP register being shifted and the low 32bits always zero. Detect
this by repeating the read a few times and check the register is
incrementing every 80ns as expected and not stuck on zero (as would be
the case with the buggy kernel/hw.).

Signed-off-by: Chris Wilson 
Cc: Martin Peres 
Reviewed-by: Martin Peres 
Reviewed-by: Kenneth Graunke 

---

 src/mesa/drivers/dri/i965/intel_extensions.c |6 +-
 src/mesa/drivers/dri/i965/intel_screen.c |   22 ++
 src/mesa/drivers/dri/i965/intel_screen.h |2 ++
 3 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/intel_extensions.c 
b/src/mesa/drivers/dri/i965/intel_extensions.c
index 3423190..740ac81 100644
--- a/src/mesa/drivers/dri/i965/intel_extensions.c
+++ b/src/mesa/drivers/dri/i965/intel_extensions.c
@@ -282,8 +282,6 @@ intelInitExtensions(struct gl_context *ctx)
}
 
if (brw->gen >= 6) {
-  uint64_t dummy;
-
   ctx->Extensions.ARB_blend_func_extended =
  !driQueryOptionb(&brw->optionCache, "disable_blend_func_extended");
   ctx->Extensions.ARB_conditional_render_inverted = true;
@@ -307,9 +305,7 @@ intelInitExtensions(struct gl_context *ctx)
   ctx->Extensions.EXT_transform_feedback = true;
   ctx->Extensions.OES_depth_texture_cube_map = true;
 
-  /* Test if the kernel has the ioctl. */
-  if (drm_intel_reg_read(brw->bufmgr, TIMESTAMP, &dummy) == 0)
- ctx->Extensions.ARB_timer_query = true;
+  ctx->Extensions.ARB_timer_query = brw->intelScreen->hw_has_timestamp;
 
   /* Only enable this in core profile because other parts of Mesa behave
* slightly differently when the extension is enabled.
diff --git a/src/mesa/drivers/dri/i965/intel_screen.c 
b/src/mesa/drivers/dri/i965/intel_screen.c
index f9398d7..c0f5c92 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -1123,6 +1123,27 @@ intel_detect_swizzling(struct intel_screen *screen)
   return true;
 }
 
+static bool
+intel_detect_timestamp(struct intel_screen *screen)
+{
+   uint64_t dummy = 0;
+   int loop = 10;
+
+   /*
+* On 32bit systems, some old kernels trigger a hw bug resulting in the
+* TIMESTAMP register being shifted and the low 32bits always zero. Detect
+* this by repeating the read a few times and check the register is
+* incrementing every 80ns as expected and not stuck on zero (as would be
+* the case with the buggy kernel/hw.).
+*/
+   do {
+  if (drm_intel_reg_read(screen->bufmgr, TIMESTAMP, &dummy))
+return false;
+   } while ((dummy & 0x) == 0 && --loop);
+
+   return loop > 0;
+}
+
 /**
  * Return array of MSAA modes supported by the hardware. The array is
  * zero-terminated and sorted in decreasing order.
@@ -1378,6 +1399,7 @@ __DRIconfig **intelInitScreen2(__DRIscreen *psp)
intelScreen->hw_must_use_separate_stencil = intelScreen->devinfo->gen >= 7;
 
intelScreen->hw_has_swizzling = intel_detect_swizzling(intelScreen);
+   intelScreen->hw_has_timestamp = intel_detect_timestamp(intelScreen);
 
const char *force_msaa = getenv("INTEL_FORCE_MSAA");
if (force_msaa) {
diff --git a/src/mesa/drivers/dri/i965/intel_screen.h 
b/src/mesa/drivers/dri/i965/intel_screen.h
index 742b3d3..941e0fc 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.h
+++ b/src/mesa/drivers/dri/i965/intel_screen.h
@@ -52,6 +52,8 @@ struct intel_screen
 
bool hw_has_swizzling;
 
+   bool hw_has_timestamp;
+
/**
 * Does the kernel support context reset notifications?
 */

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