[Mesa-dev] [PATCH] r600g-llvm: Crude fix for a race in initialization of the llvm backend

2012-08-15 Thread Mathias Fröhlich

Hi,

This change adds application global locking around compiling an r600 llvm 
shader. This fixes a race condition/crash that I observe when shaders are 
concurrently compiled from different contexts in different threads.
The fix is crude as it just guards the whole compile with a global mutex, but 
up to now I did not have enough time to understand the real reason that must 
be somewhere in the way r600g initializes the llvm backend. And since we have 
a pending public release we will better have a curde fix than a known bug.
Better solutions welcome!

I will post a piglit test in the next minutes that exercises this problem with 
a high probability at least here on my test machine.

Please review

MathiasFrom 6501efdb1ef9f52b584a709c4d24e095b67fc91d Mon Sep 17 00:00:00 2001
Message-Id: 6501efdb1ef9f52b584a709c4d24e095b67fc91d.1345008604.git.mathias.froehl...@gmx.net
From: =?UTF-8?q?Mathias=20Fr=C3=B6hlich?= mathias.froehl...@gmx.net
Date: Fri, 10 Aug 2012 22:20:06 +0200
Subject: [PATCH] radeon_llvm: Introduce global lock on llvm.

No clue what is really racing here, but this fixes
sporadic crashes running osgviewer with multiple
windows together with the r600 llvm shader compiler.

Signed-off-by: Mathias Froehlich mathias.froehl...@web.de
---
 src/gallium/drivers/radeon/radeon_llvm.h   | 10 
 src/gallium/drivers/radeon/radeon_llvm_emit.cpp| 14 +--
 .../drivers/radeon/radeon_setup_tgsi_llvm.c| 28 ++
 3 files changed, 50 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/radeon/radeon_llvm.h b/src/gallium/drivers/radeon/radeon_llvm.h
index 7a32bb0..d1b6d17 100644
--- a/src/gallium/drivers/radeon/radeon_llvm.h
+++ b/src/gallium/drivers/radeon/radeon_llvm.h
@@ -142,6 +142,16 @@ static inline LLVMValueRef bitcast(
 		return value;
 }
 
+#ifdef __cplusplus
+extern C {
+#endif
+
+void radeon_llvm_lock(void);
+void radeon_llvm_unlock(void);
+
+#ifdef __cplusplus
+}
+#endif
 
 void radeon_llvm_context_init(struct radeon_llvm_context * ctx);
 
diff --git a/src/gallium/drivers/radeon/radeon_llvm_emit.cpp b/src/gallium/drivers/radeon/radeon_llvm_emit.cpp
index 89130b3..39b4640 100644
--- a/src/gallium/drivers/radeon/radeon_llvm_emit.cpp
+++ b/src/gallium/drivers/radeon/radeon_llvm_emit.cpp
@@ -48,15 +48,19 @@
 
 using namespace llvm;
 
-#ifndef EXTERNAL_LLVM
 extern C {
 
+#ifndef EXTERNAL_LLVM
 void LLVMInitializeAMDGPUTargetMC(void);
 void LLVMInitializeAMDGPUTarget(void);
 void LLVMInitializeAMDGPUTargetInfo(void);
-}
 #endif
 
+void radeon_llvm_lock();
+void radeon_llvm_unlock();
+
+}
+
 /**
  * Compile an LLVM module to machine code.
  *
@@ -68,6 +72,8 @@ radeon_llvm_compile(LLVMModuleRef M, unsigned char ** bytes,
  unsigned * byte_count, const char * gpu_family,
  unsigned dump) {
 
+   radeon_llvm_lock();
+
Triple AMDGPUTriple(sys::getDefaultTargetTriple());
 
 #ifdef EXTERNAL_LLVM
@@ -82,6 +88,7 @@ radeon_llvm_compile(LLVMModuleRef M, unsigned char ** bytes,
std::string err;
const Target * AMDGPUTarget = TargetRegistry::lookupTarget(r600, err);
if(!AMDGPUTarget) {
+  radeon_llvm_unlock();
   fprintf(stderr, Can't find target: %s\n, err.c_str());
   return 1;
}
@@ -119,6 +126,7 @@ radeon_llvm_compile(LLVMModuleRef M, unsigned char ** bytes,
/* Optional extra paramater true / false to disable verify */
if (AMDGPUTargetMachine.addPassesToEmitFile(PM, out, TargetMachine::CGFT_AssemblyFile,
true)){
+  radeon_llvm_unlock();
   fprintf(stderr, AddingPasses failed.\n);
   return 1;
}
@@ -131,5 +139,7 @@ radeon_llvm_compile(LLVMModuleRef M, unsigned char ** bytes,
memcpy(*bytes, data.c_str(), data.length() * sizeof(unsigned char));
*byte_count = data.length();
 
+   radeon_llvm_unlock();
+
return 0;
 }
diff --git a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
index 641d277..95dd419 100644
--- a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
+++ b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
@@ -36,10 +36,26 @@
 #include util/u_math.h
 #include util/u_memory.h
 #include util/u_debug.h
+#include os/os_thread.h
 
 #include llvm-c/Core.h
 #include llvm-c/Transforms/Scalar.h
 
+/** llvm with its magnitudes of global variables and factories
+ *  appears not to be thread safe. Until then, we sadly need a mutex.
+ */
+pipe_static_mutex(llvm_mutex);
+
+void radeon_llvm_lock()
+{
+	pipe_mutex_lock(llvm_mutex);
+}
+
+void radeon_llvm_unlock()
+{
+	pipe_mutex_unlock(llvm_mutex);
+}
+
 static struct radeon_llvm_loop * get_current_loop(struct radeon_llvm_context * ctx)
 {
 	return ctx-loop_depth  0 ? ctx-loop + (ctx-loop_depth - 1) : NULL;
@@ -989,6 +1005,8 @@ void radeon_llvm_context_init(struct radeon_llvm_context * ctx)
 	LLVMTypeRef main_fn_type;
 	LLVMBasicBlockRef main_fn_body;
 
+	radeon_llvm_lock();
+
 	/* Initialize the gallivm 

Re: [Mesa-dev] [QUESTION] If shared dricode/glapi is enabled by default, why it isn't used by gallium

2012-08-15 Thread Michel Dänzer
On Mit, 2012-08-15 at 04:51 +0300, Maxim Levitsky wrote: 
 I noticed that recently in addition to nouveau_dri.so, I also get
 installed libdricore.so and libglsl.so.

I assume you mean libglapi.so instead of libglsl.so, the latter is no
longer built as a separate shared object.

 But two later files aren't linked to anything and can be deleted.
 Obviously nouveau_dri.so statically links its code.
 
 Quick glance over Makefiles makes me thing that same issue exists
 in other Gallium drivers.

I get libdricore linked by r600_dri.so and libglapi linked by libGL.


 Any while at it, why not to move mesa state tracker
 (src/mesa/state_tracker) to gallium for consistency, as anyway
 the (src/gallium/state_trackers) long ago isn't just
 'This directory is a placeholder for incubating state-trackers.'
 
 In fact wrapper for all DRI gallium drivers, lives there.
 Its just confusing this way in my opinion.

The current location is indeed a historical accident and may be
confusing. It might be better to move it to src/mesa/drivers/ though, so
it's less likely to be overlooked when making changes in src/mesa/
affecting it.


-- 
Earthling Michel Dänzer   |   http://www.amd.com
Libre software enthusiast |  Debian, X and DRI developer
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] gallium/st: Use driver name to access driconf

2012-08-15 Thread Michel Dänzer
On Mit, 2012-08-15 at 03:45 +0300, Maxim Levitsky wrote: 
 This fixes fetching driconf options from the gallium drivers.
 
 Patch written by, Carl-Philip Haensch
 (http://lists.freedesktop.org/archives/mesa-dev/2011-May/007743.html)

This should be reflected in the Git authorship directly.


 @@ -103,8 +104,8 @@ dri_create_context(gl_api api, const struct gl_config * 
 visual,
 ctx-cPriv = cPriv;
 ctx-sPriv = sPriv;
  
 -   driParseConfigFiles(ctx-optionCache,
 -screen-optionCache, sPriv-myNum, dri);
 +   driParseConfigFiles(ctx-optionCache, screen-optionCache,
 +sPriv-myNum, driver_descriptor.name);

Unfortunately, this breaks the src/gallium/targets/dri-swrast build:

swrast_dri.so.tmp: undefined reference to `driver_descriptor'
collect2: error: ld returned 1 exit status
make[3]: *** [swrast_dri.so] Error 1
make[3]: Leaving directory 
`/home/daenzer/src/mesa-git/mesa/src/gallium/targets/dri-swrast'


-- 
Earthling Michel Dänzer   |   http://www.amd.com
Libre software enthusiast |  Debian, X and DRI developer
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 53513] src/gallium/state_trackers/egl/common/egl_g3d_api.c:56:18: error: ‘_EGLContext’ has no member named ‘ClientVersion’

2012-08-15 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=53513

--- Comment #1 from Andreas Boll andreas.boll@gmail.com 2012-08-15 
08:50:39 UTC ---
Created attachment 65593
  -- https://bugs.freedesktop.org/attachment.cgi?id=65593
proposed patch

Could you test the attached patch.
I can't test it myself right now.

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 53513] src/gallium/state_trackers/egl/common/egl_g3d_api.c:56:18: error: ‘_EGLContext’ has no member named ‘ClientVersion’

2012-08-15 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=53513

Michel Dänzer mic...@daenzer.net changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED

--- Comment #2 from Michel Dänzer mic...@daenzer.net 2012-08-15 09:03:02 UTC 
---
Sorry Andreas, didn't see your patch in time.

Commit: 538085c5d423df4fed3c3b2c473c3684f7b08db6
URL:   
http://cgit.freedesktop.org/mesa/mesa/commit/?id=538085c5d423df4fed3c3b2c473c3684f7b08db6

Author: Michel Dänzer michel.daen...@amd.com
Date:   Wed Aug 15 10:49:22 2012 +0200

st/egl: Fix up for ClientVersion - ClientMajorVersion rename.

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/3] build: Require X11 pkg-config files

2012-08-15 Thread Andreas Boll
2012/8/14 Matt Turner matts...@gmail.com:
 Cc: Jeremy Huddleston jerem...@apple.com
 ---
 Jeremy, does OS X ship the pkg-config files?

  configure.ac |   85 
 +++---
  1 files changed, 16 insertions(+), 69 deletions(-)

 diff --git a/configure.ac b/configure.ac
 index 2ecedaf..e1c8818 100644
 --- a/configure.ac
 +++ b/configure.ac
 @@ -153,8 +153,6 @@ AC_SUBST([EXTRA_LIB_PATH])

  dnl Cache CPPFLAGS so we can add *_INCLUDES and restore it later
  _SAVE_CPPFLAGS=$CPPFLAGS
 -AC_ARG_VAR([X11_INCLUDES],[Extra -I paths for X11 headers])
 -AC_SUBST([X11_INCLUDES])

  dnl Compiler macros
  DEFINES=
 @@ -878,32 +876,8 @@ if test x$enable_dri = xyes; then
  fi
  fi

 -dnl
 -dnl Find out if X is available. The variable have_x is set if libX11 is
 -dnl found to mimic AC_PATH_XTRA.
 -dnl
 -if test -n $PKG_CONFIG; then
 -AC_MSG_CHECKING([pkg-config files for X11 are available])
 -PKG_CHECK_EXISTS([x11],[
 -x11_pkgconfig=yes
 -have_x=yes
 -],[
 -x11_pkgconfig=no
 -])
 -AC_MSG_RESULT([$x11_pkgconfig])
 -else
 -x11_pkgconfig=no
 -fi
 -dnl Use the autoconf macro if no pkg-config files
 -if test $x11_pkgconfig = yes; then
 -PKG_CHECK_MODULES([X11], [x11])
 -else
 -AC_PATH_XTRA
 -test -z $X11_CFLAGS  X11_CFLAGS=$X_CFLAGS
 -test -z $X11_LIBS  X11_LIBS=$X_LIBS -lX11
 -AC_SUBST([X11_CFLAGS])
 -AC_SUBST([X11_LIBS])
 -fi
 +dnl Find out if X is available.
 +PKG_CHECK_MODULES([X11], [x11])

  dnl Try to tell the user that the --x-* options are only used when
  dnl pkg-config is not available. This must be right after AC_PATH_XTRA.
 @@ -947,18 +921,10 @@ dnl
  case x$enable_glx$enable_xlib_glx in
  xyesyes)
  # Xlib-based GLX
 -if test $x11_pkgconfig = yes; then
 -PKG_CHECK_MODULES([XLIBGL], [x11 xext])
 -GL_PC_REQ_PRIV=x11 xext
 -X11_INCLUDES=$X11_INCLUDES $XLIBGL_CFLAGS
 -GL_LIB_DEPS=$XLIBGL_LIBS
 -else
 -# should check these...
 -X11_INCLUDES=$X11_INCLUDES $X_CFLAGS
 -GL_LIB_DEPS=$X_LIBS -lX11 -lXext
 -GL_PC_LIB_PRIV=$GL_LIB_DEPS
 -GL_PC_CFLAGS=$X11_INCLUDES
 -fi
 +PKG_CHECK_MODULES([XLIBGL], [x11 xext])
 +GL_PC_REQ_PRIV=x11 xext
 +X11_INCLUDES=$X11_INCLUDES $XLIBGL_CFLAGS
 +GL_LIB_DEPS=$XLIBGL_LIBS
  GL_LIB_DEPS=$GL_LIB_DEPS $SELINUX_LIBS -lm -lpthread $DLOPEN_LIBS
  GL_PC_LIB_PRIV=$GL_PC_LIB_PRIV $SELINUX_LIBS -lm -lpthread
  ;;
 @@ -975,38 +941,19 @@ xyesno)
  fi

  # find the DRI deps for libGL
 -if test $x11_pkgconfig = yes; then
 -PKG_CHECK_MODULES([XCB],[x11-xcb xcb-glx = 1.8.1])

Don't we need to check against xcb-glx = 1.8.1?

 -dri_modules=x11 xext xdamage xfixes x11-xcb xcb-glx
 -
 -# add xf86vidmode if available
 -PKG_CHECK_MODULES([XF86VIDMODE], [xxf86vm], HAVE_XF86VIDMODE=yes, 
 HAVE_XF86VIDMODE=no)
 -if test $HAVE_XF86VIDMODE = yes ; then
 -dri_modules=$dri_modules xxf86vm
 -fi
 +dri_modules=x11 xext xdamage xfixes x11-xcb xcb-glx

 -PKG_CHECK_MODULES([DRIGL], [$dri_modules])
 -GL_PC_REQ_PRIV=$GL_PC_REQ_PRIV $dri_modules
 -X11_INCLUDES=$X11_INCLUDES $DRIGL_CFLAGS
 -GL_LIB_DEPS=$DRIGL_LIBS
 -else
 -# should check these...
 -X11_INCLUDES=$X11_INCLUDES $X_CFLAGS
 -if test x$HAVE_XF86VIDMODE == xyes; then
 -   GL_LIB_DEPS=$X_LIBS -lX11 -lXext -lXxf86vm -lXdamage -lXfixes
 -   else
 -   GL_LIB_DEPS=$X_LIBS -lX11 -lXext -lXdamage -lXfixes
 -   fi
 -GL_PC_LIB_PRIV=$GL_LIB_DEPS
 -GL_PC_CFLAGS=$X11_INCLUDES
 -
 -# XCB can only be used from pkg-config
 -PKG_CHECK_MODULES([XCB],[x11-xcb xcb-glx = 1.8.1])
 -GL_PC_REQ_PRIV=$GL_PC_REQ_PRIV x11-xcb xcb-glx
 -X11_INCLUDES=$X11_INCLUDES $XCB_CFLAGS
 -GL_LIB_DEPS=$GL_LIB_DEPS $XCB_LIBS
 +# add xf86vidmode if available
 +PKG_CHECK_MODULES([XF86VIDMODE], [xxf86vm], HAVE_XF86VIDMODE=yes, 
 HAVE_XF86VIDMODE=no)
 +if test $HAVE_XF86VIDMODE = yes ; then
 +dri_modules=$dri_modules xxf86vm
  fi

 +PKG_CHECK_MODULES([DRIGL], [$dri_modules])
 +GL_PC_REQ_PRIV=$GL_PC_REQ_PRIV $dri_modules
 +X11_INCLUDES=$X11_INCLUDES $DRIGL_CFLAGS
 +GL_LIB_DEPS=$DRIGL_LIBS
 +
  # need DRM libs, -lpthread, etc.
  GL_LIB_DEPS=$GL_LIB_DEPS $LIBDRM_LIBS -lm -lpthread $DLOPEN_LIBS
  GL_PC_LIB_PRIV=-lm -lpthread $DLOPEN_LIBS
 --
 1.7.8.6

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


Re: [Mesa-dev] [PATCH] gallium/st: Use driver name to access driconf

2012-08-15 Thread Maxim Levitsky
On Wed, 2012-08-15 at 10:48 +0200, Michel Dänzer wrote: 
 On Mit, 2012-08-15 at 03:45 +0300, Maxim Levitsky wrote: 
  This fixes fetching driconf options from the gallium drivers.
  
  Patch written by, Carl-Philip Haensch
  (http://lists.freedesktop.org/archives/mesa-dev/2011-May/007743.html)
 
 This should be reflected in the Git authorship directly.
Don't know how to do this. 
 
 
  @@ -103,8 +104,8 @@ dri_create_context(gl_api api, const struct gl_config * 
  visual,
  ctx-cPriv = cPriv;
  ctx-sPriv = sPriv;
   
  -   driParseConfigFiles(ctx-optionCache,
  -  screen-optionCache, sPriv-myNum, dri);
  +   driParseConfigFiles(ctx-optionCache, screen-optionCache,
  +sPriv-myNum, driver_descriptor.name);
 
 Unfortunately, this breaks the src/gallium/targets/dri-swrast build:
And stupid me tried to compile swrast today, and I wonder why it didn't
compile..
I see what I could do.

Best regards,
Maxim Levitsky

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


Re: [Mesa-dev] [PATCH] gallium/st: Use driver name to access driconf

2012-08-15 Thread Michel Dänzer
On Mit, 2012-08-15 at 12:29 +0300, Maxim Levitsky wrote: 
 On Wed, 2012-08-15 at 10:48 +0200, Michel Dänzer wrote: 
  On Mit, 2012-08-15 at 03:45 +0300, Maxim Levitsky wrote: 
   This fixes fetching driconf options from the gallium drivers.
   
   Patch written by, Carl-Philip Haensch
   (http://lists.freedesktop.org/archives/mesa-dev/2011-May/007743.html)
  
  This should be reflected in the Git authorship directly.
 Don't know how to do this. 

git commit --author


-- 
Earthling Michel Dänzer   |   http://www.amd.com
Libre software enthusiast |  Debian, X and DRI developer
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] gallium/st: Use driver name to access driconf

2012-08-15 Thread Maxim Levitsky
On Wed, 2012-08-15 at 11:32 +0200, Michel Dänzer wrote: 
 On Mit, 2012-08-15 at 12:29 +0300, Maxim Levitsky wrote: 
  On Wed, 2012-08-15 at 10:48 +0200, Michel Dänzer wrote: 
   On Mit, 2012-08-15 at 03:45 +0300, Maxim Levitsky wrote: 
This fixes fetching driconf options from the gallium drivers.

Patch written by, Carl-Philip Haensch
(http://lists.freedesktop.org/archives/mesa-dev/2011-May/007743.html)
   
   This should be reflected in the Git authorship directly.
  Don't know how to do this. 
 
 git commit --author

Ah, thanks!

-- 
Best regards,
Maxim Levitsky


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


[Mesa-dev] [PATCH 1/6] st/dri: Support width and height getters

2012-08-15 Thread Jakob Bornecrantz
Signed-off-by: Jakob Bornecrantz ja...@vmware.com
---
 src/gallium/state_trackers/dri/drm/dri2.c |6 ++
 1 file changed, 6 insertions(+)

diff --git a/src/gallium/state_trackers/dri/drm/dri2.c 
b/src/gallium/state_trackers/dri/drm/dri2.c
index d0be710..d5a98a2 100644
--- a/src/gallium/state_trackers/dri/drm/dri2.c
+++ b/src/gallium/state_trackers/dri/drm/dri2.c
@@ -603,6 +603,12 @@ dri2_query_image(__DRIimage *image, int attrib, int *value)
case __DRI_IMAGE_ATTRIB_FORMAT:
   *value = image-dri_format;
   return GL_TRUE;
+   case __DRI_IMAGE_ATTRIB_WIDTH:
+  *value = image-texture-width0;
+  return GL_TRUE;
+   case __DRI_IMAGE_ATTRIB_HEIGHT:
+  *value = image-texture-height0;
+  return GL_TRUE;
default:
   return GL_FALSE;
}
-- 
1.7.9.5

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


[Mesa-dev] [PATCH 3/6] gbm: Add shared usage on images created

2012-08-15 Thread Jakob Bornecrantz
Signed-off-by: Jakob Bornecrantz ja...@vmware.com
---
 src/gbm/backends/dri/gbm_dri.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
index f09f6ef..5c332d4 100644
--- a/src/gbm/backends/dri/gbm_dri.c
+++ b/src/gbm/backends/dri/gbm_dri.c
@@ -483,6 +483,9 @@ gbm_dri_bo_create(struct gbm_device *gbm,
if (usage  GBM_BO_USE_WRITE)
   dri_use |= __DRI_IMAGE_USE_WRITE;
 
+   /* Gallium drivers requires shared in order to get the handle/stride */
+   dri_use |= __DRI_IMAGE_USE_SHARE;
+
bo-image =
   dri-image-createImage(dri-screen,
   width, height,
-- 
1.7.9.5

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


[Mesa-dev] [PATCH 4/6] gbm: Use libkms to replace DRI cursor images

2012-08-15 Thread Jakob Bornecrantz
Uses libkms instead of dri image cursor. Since this is the only user of the
DRI cursor and write interface we can remove cursor surfaces entirely from
the DRI interface and as a consequence also from the Gallium interface as
well. Tho to make everybody happy with this it would probably should add a
kms_bo_write function, but that is probably wise in anyways.

The only downside is that it adds a dependancy on libkms, this could how ever
be replaced with the dumb_bo drm ioctl interface.

Signed-off-by: Jakob Bornecrantz ja...@vmware.com
---
 configure.ac  |2 ++
 src/egl/drivers/dri2/Makefile.am  |1 +
 src/gbm/Makefile.am   |3 ++-
 src/gbm/backends/dri/gbm_dri.c|   52 -
 src/gbm/backends/dri/gbm_driint.h |8 ++
 5 files changed, 59 insertions(+), 7 deletions(-)

diff --git a/configure.ac b/configure.ac
index 2ecedaf..f5836d6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1355,6 +1355,8 @@ if test x$enable_gbm = xyes; then
 if test $SHARED_GLAPI -eq 0; then
 AC_MSG_ERROR([gbm_dri requires --enable-shared-glapi])
 fi
+PKG_CHECK_MODULES([LIBKMS], [libkms], [],
+  AC_MSG_ERROR([gbm needs libkms]))
 fi
 fi
 GBM_PC_REQ_PRIV=libudev
diff --git a/src/egl/drivers/dri2/Makefile.am b/src/egl/drivers/dri2/Makefile.am
index 49ec06b..45f7dfa 100644
--- a/src/egl/drivers/dri2/Makefile.am
+++ b/src/egl/drivers/dri2/Makefile.am
@@ -30,6 +30,7 @@ AM_CFLAGS = \
$(DEFINES) \
$(LIBDRM_CFLAGS) \
$(LIBUDEV_CFLAGS) \
+   $(LIBKMS_CFLAGS) \
-DDEFAULT_DRIVER_DIR=\$(DRI_DRIVER_SEARCH_DIR)\
 
 noinst_LTLIBRARIES = libegl_dri2.la
diff --git a/src/gbm/Makefile.am b/src/gbm/Makefile.am
index f079da1..e22c55c 100644
--- a/src/gbm/Makefile.am
+++ b/src/gbm/Makefile.am
@@ -7,6 +7,7 @@ AM_CFLAGS = \
-I$(top_srcdir)/include \
-I$(top_srcdir)/src/gbm/main \
$(LIBUDEV_CFLAGS) \
+   $(LIBKMS_CFLAGS) \
$(DLOPEN_CFLAGS) \
$(DEFINES)
 
@@ -18,7 +19,7 @@ libgbm_la_SOURCES = \
main/backend.c \
main/common.c
 libgbm_la_LDFLAGS = -version-info 1:0
-libgbm_la_LIBADD = $(LIBUDEV_LIBS) $(DLOPEN_LIBS)
+libgbm_la_LIBADD = $(LIBUDEV_LIBS) $(LIBKMS_LIBS) $(DLOPEN_LIBS)
 
 if HAVE_EGL_PLATFORM_WAYLAND
 AM_CPPFLAGS = -DHAVE_WAYLAND_PLATFORM
diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
index 5c332d4..15a7622 100644
--- a/src/gbm/backends/dri/gbm_dri.c
+++ b/src/gbm/backends/dri/gbm_dri.c
@@ -301,11 +301,20 @@ gbm_dri_bo_write(struct gbm_bo *_bo, const void *buf, 
size_t count)
 {
struct gbm_dri_device *dri = gbm_dri_device(_bo-gbm);
struct gbm_dri_bo *bo = gbm_dri_bo(_bo);
+   void *ptr;
+   int ret;
+
+   if (bo-bo == NULL)
+  return -1;
 
-   if (dri-image-base.version  4)
+   ret = kms_bo_map(bo-bo, ptr);
+   if (ret  0)
   return -1;
 
-   return dri-image-write(bo-image, buf, count);
+   memcpy(ptr, buf, count);
+
+   kms_bo_unmap(bo-bo);
+   return 0;
 }
 
 static void
@@ -314,7 +323,10 @@ gbm_dri_bo_destroy(struct gbm_bo *_bo)
struct gbm_dri_device *dri = gbm_dri_device(_bo-gbm);
struct gbm_dri_bo *bo = gbm_dri_bo(_bo);
 
-   dri-image-destroyImage(bo-image);
+   if (bo-image != NULL)
+  dri-image-destroyImage(bo-image);
+   if (bo-bo != NULL)
+  kms_bo_destroy(bo-bo);
free(bo);
 }
 
@@ -446,9 +458,6 @@ gbm_dri_bo_create(struct gbm_device *gbm,
int dri_format;
unsigned dri_use = 0;
 
-   if (dri-image-base.version  4  (usage  GBM_BO_USE_WRITE))
-  return NULL;
-
bo = calloc(1, sizeof *bo);
if (bo == NULL)
   return NULL;
@@ -457,6 +466,33 @@ gbm_dri_bo_create(struct gbm_device *gbm,
bo-base.base.width = width;
bo-base.base.height = height;
 
+   if (usage  GBM_BO_USE_WRITE) {
+  int ret;
+  unsigned attrs[7] = {
+ KMS_WIDTH, 64,
+ KMS_HEIGHT, 64,
+ KMS_BO_TYPE, KMS_BO_TYPE_SCANOUT_X8R8G8B8,
+ KMS_TERMINATE_PROP_LIST,
+  };
+
+  if (!(usage  GBM_BO_USE_CURSOR_64X64))
+ return NULL;
+
+  if (dri-kms == NULL)
+ return NULL;
+
+  ret = kms_bo_create(dri-kms, attrs, bo-bo);
+  if (ret  0) {
+ free(bo);
+ return NULL;
+  }
+
+  kms_bo_get_prop(bo-bo, KMS_PITCH, bo-base.base.stride);
+  kms_bo_get_prop(bo-bo, KMS_HANDLE, (unsigned*)bo-base.base.handle);
+
+  return bo-base.base;
+   }
+
switch (format) {
case GBM_FORMAT_RGB565:
   dri_format =__DRI_IMAGE_FORMAT_RGB565;
@@ -570,6 +606,10 @@ dri_device_create(int fd)
   return NULL;
}
 
+   if (dri-image-base.version  4) {
+  kms_create(fd, dri-kms);
+   }
+
return dri-base.base;
 }
 
diff --git a/src/gbm/backends/dri/gbm_driint.h 
b/src/gbm/backends/dri/gbm_driint.h
index f404368..4b619a0 100644
--- a/src/gbm/backends/dri/gbm_driint.h
+++ b/src/gbm/backends/dri/gbm_driint.h
@@ -30,6 +30,8 @@
 
 #include gbmint.h
 
+#include libkms.h
+

[Mesa-dev] [PATCH 5/6] dri: Remove image write function

2012-08-15 Thread Jakob Bornecrantz
Since its not used by anything anymore and no release has gone out
where it was being used.

Signed-off-by: Jakob Bornecrantz ja...@vmware.com
---
 include/GL/internal/dri_interface.h|   10 +-
 src/gbm/backends/dri/gbm_dri.c |2 --
 src/mesa/drivers/dri/intel/intel_regions.h |1 -
 src/mesa/drivers/dri/intel/intel_screen.c  |   28 
 4 files changed, 1 insertion(+), 40 deletions(-)

diff --git a/include/GL/internal/dri_interface.h 
b/include/GL/internal/dri_interface.h
index 97e1a1a..e766226 100644
--- a/include/GL/internal/dri_interface.h
+++ b/include/GL/internal/dri_interface.h
@@ -935,8 +935,7 @@ struct __DRIdri2ExtensionRec {
 
 #define __DRI_IMAGE_USE_SHARE  0x0001
 #define __DRI_IMAGE_USE_SCANOUT0x0002
-#define __DRI_IMAGE_USE_CURSOR 0x0004
-#define __DRI_IMAGE_USE_WRITE  0x0008
+#define __DRI_IMAGE_USE_CURSOR 0x0004 /* Depricated */
 
 /**
  * queryImage attributes
@@ -985,13 +984,6 @@ struct __DRIimageExtensionRec {
GLboolean (*validateUsage)(__DRIimage *image, unsigned int use);
 
/**
-* Write data into image.
-*
-* \since 4
-*/
-   int (*write)(__DRIimage *image, const void *buf, size_t count);
-
-   /**
 * Create an image out of a sub-region of a parent image.  This
 * entry point lets us create individual __DRIimages for different
 * planes in a planar buffer (typically yuv), for example.  While a
diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
index 15a7622..1731e4a 100644
--- a/src/gbm/backends/dri/gbm_dri.c
+++ b/src/gbm/backends/dri/gbm_dri.c
@@ -516,8 +516,6 @@ gbm_dri_bo_create(struct gbm_device *gbm,
   dri_use |= __DRI_IMAGE_USE_SCANOUT;
if (usage  GBM_BO_USE_CURSOR_64X64)
   dri_use |= __DRI_IMAGE_USE_CURSOR;
-   if (usage  GBM_BO_USE_WRITE)
-  dri_use |= __DRI_IMAGE_USE_WRITE;
 
/* Gallium drivers requires shared in order to get the handle/stride */
dri_use |= __DRI_IMAGE_USE_SHARE;
diff --git a/src/mesa/drivers/dri/intel/intel_regions.h 
b/src/mesa/drivers/dri/intel/intel_regions.h
index 782d669..4ff0efe 100644
--- a/src/mesa/drivers/dri/intel/intel_regions.h
+++ b/src/mesa/drivers/dri/intel/intel_regions.h
@@ -144,7 +144,6 @@ intel_region_get_aligned_offset(struct intel_region 
*region, uint32_t x,
 struct __DRIimageRec {
struct intel_region *region;
GLenum internal_format;
-   uint32_t usage;
uint32_t dri_format;
GLuint format;
uint32_t offset;
diff --git a/src/mesa/drivers/dri/intel/intel_screen.c 
b/src/mesa/drivers/dri/intel/intel_screen.c
index f4c1602..103fcd2 100644
--- a/src/mesa/drivers/dri/intel/intel_screen.c
+++ b/src/mesa/drivers/dri/intel/intel_screen.c
@@ -339,13 +339,7 @@ intel_create_image(__DRIscreen *screen,
   tiling = I915_TILING_NONE;
}
 
-   /* We only support write for cursor drm images */
-   if ((use  __DRI_IMAGE_USE_WRITE) 
-   use != (__DRI_IMAGE_USE_WRITE | __DRI_IMAGE_USE_CURSOR))
-  return NULL;
-
image = intel_allocate_image(format, loaderPrivate);
-   image-usage = use;
cpp = _mesa_get_format_bytes(image-format);
image-region =
   intel_region_alloc(intelScreen, tiling, cpp, width, height, true);
@@ -399,7 +393,6 @@ intel_dup_image(__DRIimage *orig_image, void *loaderPrivate)
}
 
image-internal_format = orig_image-internal_format;
-   image-usage   = orig_image-usage;
image-dri_format  = orig_image-dri_format;
image-format  = orig_image-format;
image-offset  = orig_image-offset;
@@ -416,29 +409,9 @@ intel_validate_usage(__DRIimage *image, unsigned int use)
 return GL_FALSE;
}
 
-   /* We only support write for cursor drm images */
-   if ((use  __DRI_IMAGE_USE_WRITE) 
-   use != (__DRI_IMAGE_USE_WRITE | __DRI_IMAGE_USE_CURSOR))
-  return GL_FALSE;
-
return GL_TRUE;
 }
 
-static int
-intel_image_write(__DRIimage *image, const void *buf, size_t count)
-{
-   if (image-region-map_refcount)
-  return -1;
-   if (!(image-usage  __DRI_IMAGE_USE_WRITE))
-  return -1;
-
-   drm_intel_bo_map(image-region-bo, true);
-   memcpy(image-region-bo-virtual, buf, count);
-   drm_intel_bo_unmap(image-region-bo);
-
-   return 0;
-}
-
 static __DRIimage *
 intel_create_sub_image(__DRIimage *parent,
int width, int height, int dri_format,
@@ -490,7 +463,6 @@ static struct __DRIimageExtensionRec intelImageExtension = {
 intel_query_image,
 intel_dup_image,
 intel_validate_usage,
-intel_image_write,
 intel_create_sub_image
 };
 
-- 
1.7.9.5

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


[Mesa-dev] [PATCH 6/6] egl_dri2: Avoid using createSubImage when not neccassery

2012-08-15 Thread Jakob Bornecrantz
Makes it possible to run Wayland on Gallium drivers.

Signed-off-by: Jakob Bornecrantz ja...@vmware.com
---
 src/egl/drivers/dri2/egl_dri2.c |   22 --
 src/gbm/backends/dri/gbm_dri.c  |   10 ++
 2 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 423d18d..d714dc9 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1197,9 +1197,13 @@ dri2_create_image_wayland_wl_buffer(_EGLDisplay *disp, 
_EGLContext *ctx,
offset = buffer-offset[index];
stride = buffer-stride[index];
 
-   dri_image = dri2_dpy-image-createSubImage(buffer-driver_buffer,
-   width, height, format,
-   offset, stride / cpp, NULL);
+   if (f-nplanes == 1) {
+  dri_image = dri2_dpy-image-dupImage(buffer-driver_buffer, NULL);
+   } else {
+  dri_image = dri2_dpy-image-createSubImage(buffer-driver_buffer,
+  width, height, format,
+  offset, stride / cpp, NULL);
+   }
 
return dri2_create_image(disp, dri_image);
 }
@@ -1360,11 +1364,17 @@ dri2_wl_reference_buffer(void *user_data, uint32_t name,
 {
_EGLDisplay *disp = user_data;
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
-   int i;
+   const struct wl_drm_format_descriptor *f;
+   int i, format = 0;
 
for (i = 0; i  ARRAY_SIZE(wl_drm_formats); i++)
   if (wl_drm_formats[i].wl_format == buffer-format) {
- buffer-driver_format = wl_drm_formats[i];
+ f = wl_drm_formats[i];
+ buffer-driver_format = f;
+ if (f-nplanes == 1)
+format = f-planes[0].dri_format;
+ else
+format = __DRI_IMAGE_FORMAT_NONE;
  break;
   }
 
@@ -1375,7 +1385,7 @@ dri2_wl_reference_buffer(void *user_data, uint32_t name,
   dri2_dpy-image-createImageFromName(dri2_dpy-dri_screen,
buffer-buffer.width,
buffer-buffer.height, 
-   __DRI_IMAGE_FORMAT_NONE, name,
+   format, name,
buffer-stride[0] / 4,
NULL);
 }
diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
index 1731e4a..dfa5d39 100644
--- a/src/gbm/backends/dri/gbm_dri.c
+++ b/src/gbm/backends/dri/gbm_dri.c
@@ -422,10 +422,12 @@ gbm_dri_bo_import(struct gbm_device *gbm,
dri-image-queryImage(image, __DRI_IMAGE_ATTRIB_WIDTH, width);
dri-image-queryImage(image, __DRI_IMAGE_ATTRIB_HEIGHT, height);
 
-   bo-image = dri-image-createSubImage(image,
-  width, height, dri_format,
-  offset, stride / cpp, NULL);
-
+   if (dri-image-version  5)
+  bo-image = dri-image-dupImage(image, NULL);
+   else
+  bo-image = dri-image-createSubImage(image,
+ width, height, dri_format,
+ offset, stride / cpp, NULL);
 
if (usage  GBM_BO_USE_SCANOUT)
   dri_use |= __DRI_IMAGE_USE_SCANOUT;
-- 
1.7.9.5

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


Re: [Mesa-dev] [PATCH] r600g-llvm: Crude fix for a race in initialization of the llvm backend

2012-08-15 Thread Tom Stellard
cc'ing the list this time.

On Wed, Aug 15, 2012 at 07:51:46AM +0200, Mathias Fröhlich wrote:
 
 Hi,
 
 This change adds application global locking around compiling an r600 llvm 
 shader. This fixes a race condition/crash that I observe when shaders are 
 concurrently compiled from different contexts in different threads.
 The fix is crude as it just guards the whole compile with a global mutex, but 
 up to now I did not have enough time to understand the real reason that must 
 be somewhere in the way r600g initializes the llvm backend. And since we have 
 a pending public release we will better have a curde fix than a known bug.
 Better solutions welcome!
 
 I will post a piglit test in the next minutes that exercises this problem 
 with 
 a high probability at least here on my test machine.
 
 Please review
 
 Mathias

This is likely caused by the fact that the same LLVM Context is used
for all threads.  Take a look at the comment starting at
src/gallium/auxilary/gallivm/lp_bld_init.c:314

You should be able to reproduce this error on llvmpipe as well.
Creating a new LLVM Context for each thread should fix this.

-Tom

 From 6501efdb1ef9f52b584a709c4d24e095b67fc91d Mon Sep 17 00:00:00 2001
 Message-Id: 
 6501efdb1ef9f52b584a709c4d24e095b67fc91d.1345008604.git.mathias.froehl...@gmx.net
 From: =?UTF-8?q?Mathias=20Fr=C3=B6hlich?= mathias.froehl...@gmx.net
 Date: Fri, 10 Aug 2012 22:20:06 +0200
 Subject: [PATCH] radeon_llvm: Introduce global lock on llvm.
 
 No clue what is really racing here, but this fixes
 sporadic crashes running osgviewer with multiple
 windows together with the r600 llvm shader compiler.
 
 Signed-off-by: Mathias Froehlich mathias.froehl...@web.de
 ---
  src/gallium/drivers/radeon/radeon_llvm.h   | 10 
  src/gallium/drivers/radeon/radeon_llvm_emit.cpp| 14 +--
  .../drivers/radeon/radeon_setup_tgsi_llvm.c| 28 
 ++
  3 files changed, 50 insertions(+), 2 deletions(-)
 
 diff --git a/src/gallium/drivers/radeon/radeon_llvm.h 
 b/src/gallium/drivers/radeon/radeon_llvm.h
 index 7a32bb0..d1b6d17 100644
 --- a/src/gallium/drivers/radeon/radeon_llvm.h
 +++ b/src/gallium/drivers/radeon/radeon_llvm.h
 @@ -142,6 +142,16 @@ static inline LLVMValueRef bitcast(
   return value;
  }
  
 +#ifdef __cplusplus
 +extern C {
 +#endif
 +
 +void radeon_llvm_lock(void);
 +void radeon_llvm_unlock(void);
 +
 +#ifdef __cplusplus
 +}
 +#endif
  
  void radeon_llvm_context_init(struct radeon_llvm_context * ctx);
  
 diff --git a/src/gallium/drivers/radeon/radeon_llvm_emit.cpp 
 b/src/gallium/drivers/radeon/radeon_llvm_emit.cpp
 index 89130b3..39b4640 100644
 --- a/src/gallium/drivers/radeon/radeon_llvm_emit.cpp
 +++ b/src/gallium/drivers/radeon/radeon_llvm_emit.cpp
 @@ -48,15 +48,19 @@
  
  using namespace llvm;
  
 -#ifndef EXTERNAL_LLVM
  extern C {
  
 +#ifndef EXTERNAL_LLVM
  void LLVMInitializeAMDGPUTargetMC(void);
  void LLVMInitializeAMDGPUTarget(void);
  void LLVMInitializeAMDGPUTargetInfo(void);
 -}
  #endif
  
 +void radeon_llvm_lock();
 +void radeon_llvm_unlock();
 +
 +}
 +
  /**
   * Compile an LLVM module to machine code.
   *
 @@ -68,6 +72,8 @@ radeon_llvm_compile(LLVMModuleRef M, unsigned char ** bytes,
   unsigned * byte_count, const char * gpu_family,
   unsigned dump) {
  
 +   radeon_llvm_lock();
 +
 Triple AMDGPUTriple(sys::getDefaultTargetTriple());
  
  #ifdef EXTERNAL_LLVM
 @@ -82,6 +88,7 @@ radeon_llvm_compile(LLVMModuleRef M, unsigned char ** bytes,
 std::string err;
 const Target * AMDGPUTarget = TargetRegistry::lookupTarget(r600, err);
 if(!AMDGPUTarget) {
 +  radeon_llvm_unlock();
fprintf(stderr, Can't find target: %s\n, err.c_str());
return 1;
 }
 @@ -119,6 +126,7 @@ radeon_llvm_compile(LLVMModuleRef M, unsigned char ** 
 bytes,
 /* Optional extra paramater true / false to disable verify */
 if (AMDGPUTargetMachine.addPassesToEmitFile(PM, out, 
 TargetMachine::CGFT_AssemblyFile,
 true)){
 +  radeon_llvm_unlock();
fprintf(stderr, AddingPasses failed.\n);
return 1;
 }
 @@ -131,5 +139,7 @@ radeon_llvm_compile(LLVMModuleRef M, unsigned char ** 
 bytes,
 memcpy(*bytes, data.c_str(), data.length() * sizeof(unsigned char));
 *byte_count = data.length();
  
 +   radeon_llvm_unlock();
 +
 return 0;
  }
 diff --git a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c 
 b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
 index 641d277..95dd419 100644
 --- a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
 +++ b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
 @@ -36,10 +36,26 @@
  #include util/u_math.h
  #include util/u_memory.h
  #include util/u_debug.h
 +#include os/os_thread.h
  
  #include llvm-c/Core.h
  #include llvm-c/Transforms/Scalar.h
  
 +/** llvm with its magnitudes of global variables and factories
 + *  appears not to be thread safe. Until 

Re: [Mesa-dev] (no subject)

2012-08-15 Thread Alex Deucher
On Tue, Aug 14, 2012 at 8:45 PM, Maxim Levitsky maximlevit...@gmail.com wrote:

 Hi, I have this backported patch here for more that an year, and forgot all 
 about it.
 It just makes gallium drivers use driver name instread of 'dri' in driconf
 parser, thus making it compatable with 'driconf' GUI.

Sounds reasonable.  Can you post it?

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


[Mesa-dev] [PATCH 2/7] gallium/radeon: Merge holes when freeing virtual address space.

2012-08-15 Thread Michel Dänzer
From: Michel Dänzer michel.daen...@amd.com

Otherwise we'll likely end up with an ever increasing amount of ever smaller
holes.

Requires keeping the list ordered wrt offsets.

Signed-off-by: Michel Dänzer michel.daen...@amd.com
---
 src/gallium/winsys/radeon/drm/radeon_drm_bo.c |   43 +
 1 file changed, 36 insertions(+), 7 deletions(-)

diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c 
b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
index 4c89901..e1d1e55 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
@@ -226,7 +226,7 @@ static uint64_t radeon_bomgr_find_va(struct radeon_bomgr 
*mgr, uint64_t size, ui
 n = CALLOC_STRUCT(radeon_bo_va_hole);
 n-size = waste;
 n-offset = hole-offset;
-list_add(n-list, mgr-va_holes);
+list_add(n-list, hole-list);
 }
 hole-size -= (size + waste);
 hole-offset += size + waste;
@@ -286,18 +286,47 @@ static void radeon_bomgr_free_va(struct radeon_bomgr 
*mgr, uint64_t va, uint64_t
 if ((va + size) == mgr-va_offset) {
 mgr-va_offset = va;
 } else {
-struct radeon_bo_va_hole *hole;
+struct radeon_bo_va_hole *hole, *next;
+
+hole = container_of(mgr-va_holes, hole, list);
+LIST_FOR_EACH_ENTRY(next, mgr-va_holes, list) {
+   if (next-offset  va)
+   break;
+hole = next;
+}
+
+if (hole-list != mgr-va_holes) {
+/* Grow upper hole if it's adjacent */
+if (hole-offset == (va + size)) {
+hole-offset = va;
+hole-size += size;
+/* Merge lower hole if it's adjacent */
+if (next != hole  (next-offset + next-size) == va) {
+next-size += hole-size;
+list_del(hole-list);
+FREE(hole);
+}
+goto out;
+}
+}
+
+/* Grow lower hole if it's adjacent */
+if (next != hole  (next-offset + next-size) == va) {
+next-size += size;
+goto out;
+}
 
 /* FIXME on allocation failure we just lose virtual address space
  * maybe print a warning
  */
-hole = CALLOC_STRUCT(radeon_bo_va_hole);
-if (hole) {
-hole-size = size;
-hole-offset = va;
-list_add(hole-list, mgr-va_holes);
+next = CALLOC_STRUCT(radeon_bo_va_hole);
+if (next) {
+next-size = size;
+next-offset = va;
+list_add(next-list, hole-list);
 }
 }
+out:
 pipe_mutex_unlock(mgr-bo_va_mutex);
 }
 
-- 
1.7.10.4

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


[Mesa-dev] [PATCH 1/7] gallium/radeon: Make va_offset 64 bits wide.

2012-08-15 Thread Michel Dänzer
From: Michel Dänzer michel.daen...@amd.com

Otherwise we'd wrap around after 32 bits. The kernel currently limits GPU
virtual address space to 4GB anyway, but that will probably change sooner or
later, and this would result in confusing error messages when running out of
virtual address space even now.

Signed-off-by: Michel Dänzer michel.daen...@amd.com
---
 src/gallium/winsys/radeon/drm/radeon_drm_bo.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c 
b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
index 464842c..4c89901 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
@@ -120,7 +120,7 @@ struct radeon_bomgr {
 
 /* is virtual address supported */
 bool va;
-unsigned va_offset;
+uint64_t va_offset;
 struct list_head va_holes;
 };
 
-- 
1.7.10.4

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


[Mesa-dev] [PATCH 0/7] gallium/radeon: Misc GPU virtual address space fixes.

2012-08-15 Thread Michel Dänzer
I found some of these problems a while ago inspired by
https://bugs.freedesktop.org/show_bug.cgi?id=45018 . Found some more recently,
now it seems to be working much better with the radeonsi driver.

[PATCH 1/7] gallium/radeon: Make va_offset 64 bits wide.
[PATCH 2/7] gallium/radeon: Merge holes when freeing virtual address
[PATCH 3/7] gallium/radeon: Fix losing holes when allocating virtual
[PATCH 4/7] gallium/radeon: Delete uppermost virtual address space
[PATCH 5/7] gallium/radeon: Fix potential address space loss in
[PATCH 6/7] gallium/radeon: Create hole for waste when allocating
[PATCH 7/7] gallium/radeon: Don't assign virtual address space for
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 3/7] gallium/radeon: Fix losing holes when allocating virtual address space.

2012-08-15 Thread Michel Dänzer
From: Michel Dänzer michel.daen...@amd.com

If a hole exactly matches the allocated size plus alignment, we would fail to
preserve the alignment as a hole. This would result in never being able to use
the alignment area for an allocation again.

Signed-off-by: Michel Dänzer michel.daen...@amd.com
---
 src/gallium/winsys/radeon/drm/radeon_drm_bo.c |7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c 
b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
index e1d1e55..43fa7b2 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
@@ -221,7 +221,7 @@ static uint64_t radeon_bomgr_find_va(struct radeon_bomgr 
*mgr, uint64_t size, ui
 pipe_mutex_unlock(mgr-bo_va_mutex);
 return offset;
 }
-if ((hole-size - waste) = size) {
+if ((hole-size - waste)  size) {
 if (waste) {
 n = CALLOC_STRUCT(radeon_bo_va_hole);
 n-size = waste;
@@ -233,6 +233,11 @@ static uint64_t radeon_bomgr_find_va(struct radeon_bomgr 
*mgr, uint64_t size, ui
 pipe_mutex_unlock(mgr-bo_va_mutex);
 return offset;
 }
+if ((hole-size - waste) == size) {
+hole-size = waste;
+pipe_mutex_unlock(mgr-bo_va_mutex);
+return offset;
+}
 }
 
 offset = mgr-va_offset;
-- 
1.7.10.4

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


[Mesa-dev] [PATCH 4/7] gallium/radeon: Delete uppermost virtual address space hole if it's at the top.

2012-08-15 Thread Michel Dänzer
From: Michel Dänzer michel.daen...@amd.com

Signed-off-by: Michel Dänzer michel.daen...@amd.com
---
 src/gallium/winsys/radeon/drm/radeon_drm_bo.c |   13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c 
b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
index 43fa7b2..998dcd8 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
@@ -287,11 +287,22 @@ static void radeon_bomgr_force_va(struct radeon_bomgr 
*mgr, uint64_t va, uint64_
 
 static void radeon_bomgr_free_va(struct radeon_bomgr *mgr, uint64_t va, 
uint64_t size)
 {
+struct radeon_bo_va_hole *hole;
+
 pipe_mutex_lock(mgr-bo_va_mutex);
 if ((va + size) == mgr-va_offset) {
 mgr-va_offset = va;
+/* Delete uppermost hole if it reaches the new top */
+LIST_FOR_EACH_ENTRY_FROM(hole, mgr-va_holes.next,
+ mgr-va_holes.next-next, list) {
+if ((hole-offset + hole-size) == va) {
+mgr-va_offset = hole-offset;
+list_del(hole-list);
+FREE(hole);
+}
+}
 } else {
-struct radeon_bo_va_hole *hole, *next;
+struct radeon_bo_va_hole *next;
 
 hole = container_of(mgr-va_holes, hole, list);
 LIST_FOR_EACH_ENTRY(next, mgr-va_holes, list) {
-- 
1.7.10.4

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


[Mesa-dev] [PATCH 6/7] gallium/radeon: Create hole for waste when allocating from va_offset.

2012-08-15 Thread Michel Dänzer
From: Michel Dänzer michel.daen...@amd.com

Otherwise, the wasted area could never be used for an allocation again.

Signed-off-by: Michel Dänzer michel.daen...@amd.com
---
 src/gallium/winsys/radeon/drm/radeon_drm_bo.c |6 ++
 1 file changed, 6 insertions(+)

diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c 
b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
index 731183a..25b346b 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
@@ -246,6 +246,12 @@ static uint64_t radeon_bomgr_find_va(struct radeon_bomgr 
*mgr, uint64_t size, ui
 waste = offset % alignment;
 waste = waste ? alignment - waste : 0;
 }
+if (waste) {
+n = CALLOC_STRUCT(radeon_bo_va_hole);
+n-size = waste;
+n-offset = offset;
+list_add(n-list, mgr-va_holes);
+}
 offset += waste;
 mgr-va_offset += size + waste;
 pipe_mutex_unlock(mgr-bo_va_mutex);
-- 
1.7.10.4

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


[Mesa-dev] [PATCH] wayland-drm: close fd after the display is uninitialized

2012-08-15 Thread Philipp Brüschweiler
This fixes a kernel rejected pushbuf: Bad file descriptor error on
wl_drm display destruction.
---
 src/gallium/state_trackers/egl/wayland/native_drm.c | 5 +++--
 1 Datei geändert, 3 Zeilen hinzugefügt(+), 2 Zeilen entfernt(-)

diff --git a/src/gallium/state_trackers/egl/wayland/native_drm.c 
b/src/gallium/state_trackers/egl/wayland/native_drm.c
index 006b3d5..c6f6197 100644
--- a/src/gallium/state_trackers/egl/wayland/native_drm.c
+++ b/src/gallium/state_trackers/egl/wayland/native_drm.c
@@ -71,8 +71,6 @@ wayland_drm_display_destroy(struct native_display *ndpy)
 {
struct wayland_drm_display *drmdpy = wayland_drm_display(ndpy);
 
-   if (drmdpy-fd)
-  close(drmdpy-fd);
if (drmdpy-wl_drm)
   wl_drm_destroy(drmdpy-wl_drm);
if (drmdpy-device_name)
@@ -84,6 +82,9 @@ wayland_drm_display_destroy(struct native_display *ndpy)
 
ndpy_uninit(ndpy);
 
+   if (drmdpy-fd)
+  close(drmdpy-fd);
+
FREE(drmdpy);
 }
 
-- 
1.7.11.4

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


Re: [Mesa-dev] [PATCH] Remove 3D registers from compute command stream

2012-08-15 Thread Matt Harvey
Hey, I'd be interested in testing this to make sure it works, but I have a
HD4200 running r600g, and I don't think that card has opencl support at the
moment. Do you know if that would still be useful for testing, and what I
would use for testing? Also, I was having trouble getting the proper
libraries installed for building from source last weekend, so it might take
me until after next weekend to get anything tested.
Does the mailing list think that would be useful?

Matt

On Mon, Aug 13, 2012 at 4:05 PM, archibald archib...@ethernull.org wrote:

 Hi list,

 Here is my attempt at solving the task Remove 3D registers from compute
 command stream on 
 http://dri.freedesktop.org/**wiki/R600ToDohttp://dri.freedesktop.org/wiki/R600ToDo.
 It's my
 first attempt at a patch for mesa, so I'd appreciate any comments or
 advice that people might have.

 I don't have a Cayman card, so I'm not able to test on that, so that part
 is officially untested.

 I ran the opencl-example programs to test the opencl aspect and there was
 no difference in the number of passed and failed tests (67:4) before and
 after the patch. OpenArena and my desktop session ran fine afterwards, but
 I'm having `fun' trying to get piglit to behave so I couldn't do a
 full regression test.

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


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


[Mesa-dev] [PATCH 2/3] radeonsi: Fix LLVM context leak.

2012-08-15 Thread Michel Dänzer
From: Michel Dänzer michel.daen...@amd.com

Signed-off-by: Michel Dänzer michel.daen...@amd.com
---
 src/gallium/drivers/radeonsi/radeonsi_shader.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/src/gallium/drivers/radeonsi/radeonsi_shader.c 
b/src/gallium/drivers/radeonsi/radeonsi_shader.c
index ae8c9a9..8e3e9ae 100644
--- a/src/gallium/drivers/radeonsi/radeonsi_shader.c
+++ b/src/gallium/drivers/radeonsi/radeonsi_shader.c
@@ -680,6 +680,7 @@ int si_pipe_shader_create(
shader-num_vgprs = util_le32_to_cpu(*(uint32_t*)(inst_bytes + 4));
shader-spi_ps_input_ena = util_le32_to_cpu(*(uint32_t*)(inst_bytes + 
8));
 
+   radeon_llvm_dispose(si_shader_ctx.radeon_bld);
tgsi_parse_free(si_shader_ctx.parse);
 
/* copy new shader */
-- 
1.7.10.4

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


[Mesa-dev] [PATCH 1/3] radeonsi: Fix a few more state BO leaks.

2012-08-15 Thread Michel Dänzer
From: Michel Dänzer michel.daen...@amd.com

Signed-off-by: Michel Dänzer michel.daen...@amd.com
---
 src/gallium/drivers/radeonsi/si_state.c  |2 ++
 src/gallium/drivers/radeonsi/si_state_draw.c |2 ++
 2 files changed, 4 insertions(+)

diff --git a/src/gallium/drivers/radeonsi/si_state.c 
b/src/gallium/drivers/radeonsi/si_state.c
index 1d6d214..db3ea25 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -2003,6 +2003,7 @@ static void si_set_ps_sampler_view(struct pipe_context 
*ctx, unsigned count,
si_pm4_set_reg(pm4, R_00B040_SPI_SHADER_USER_DATA_PS_4, va);
si_pm4_set_reg(pm4, R_00B044_SPI_SHADER_USER_DATA_PS_5, va  32);
 
+   si_resource_reference(bo, NULL);
 out:
si_pm4_set_state(rctx, ps_sampler_views, pm4);
rctx-have_depth_texture = has_depth;
@@ -2046,6 +2047,7 @@ static void si_bind_ps_sampler(struct pipe_context *ctx, 
unsigned count, void **
si_pm4_set_reg(pm4, R_00B038_SPI_SHADER_USER_DATA_PS_2, va);
si_pm4_set_reg(pm4, R_00B03C_SPI_SHADER_USER_DATA_PS_3, va  32);
 
+   si_resource_reference(bo, NULL);
 out:
si_pm4_set_state(rctx, ps_sampler, pm4);
rctx-ps_samplers.n_samplers = count;
diff --git a/src/gallium/drivers/radeonsi/si_state_draw.c 
b/src/gallium/drivers/radeonsi/si_state_draw.c
index 43644e5..8506933 100644
--- a/src/gallium/drivers/radeonsi/si_state_draw.c
+++ b/src/gallium/drivers/radeonsi/si_state_draw.c
@@ -458,6 +458,8 @@ static void si_vertex_buffer_update(struct r600_context 
*rctx)
si_pm4_set_reg(pm4, R_00B148_SPI_SHADER_USER_DATA_VS_6, va);
si_pm4_set_reg(pm4, R_00B14C_SPI_SHADER_USER_DATA_VS_7, va  32);
si_pm4_set_state(rctx, vertex_buffers, pm4);
+
+   si_resource_reference(t_list_buffer, NULL);
 }
 
 static void si_state_draw(struct r600_context *rctx,
-- 
1.7.10.4

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


[Mesa-dev] [PATCH 3/3] radeonsi: Fix memory leaks if returning early from some state functions.

2012-08-15 Thread Michel Dänzer
From: Michel Dänzer michel.daen...@amd.com

Signed-off-by: Michel Dänzer michel.daen...@amd.com
---
 src/gallium/drivers/radeonsi/r600_hw_context.c |3 ++-
 src/gallium/drivers/radeonsi/si_state.c|   23 ---
 2 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/r600_hw_context.c 
b/src/gallium/drivers/radeonsi/r600_hw_context.c
index 5480cb5..f8b1b38 100644
--- a/src/gallium/drivers/radeonsi/r600_hw_context.c
+++ b/src/gallium/drivers/radeonsi/r600_hw_context.c
@@ -155,11 +155,12 @@ void r600_need_cs_space(struct r600_context *ctx, 
unsigned num_dw,
 
 static void r600_flush_framebuffer(struct r600_context *ctx)
 {
-   struct si_pm4_state *pm4 = CALLOC_STRUCT(si_pm4_state);
+   struct si_pm4_state *pm4;
 
if (!(ctx-flags  R600_CONTEXT_DST_CACHES_DIRTY))
return;
 
+   pm4 = CALLOC_STRUCT(si_pm4_state);
si_cmd_surface_sync(pm4, S_0085F0_CB0_DEST_BASE_ENA(1) |
S_0085F0_CB1_DEST_BASE_ENA(1) |
S_0085F0_CB2_DEST_BASE_ENA(1) |
diff --git a/src/gallium/drivers/radeonsi/si_state.c 
b/src/gallium/drivers/radeonsi/si_state.c
index db3ea25..2b6a0aa 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -39,11 +39,15 @@
  */
 static void si_update_fb_blend_state(struct r600_context *rctx)
 {
-   struct si_pm4_state *pm4 = CALLOC_STRUCT(si_pm4_state);
+   struct si_pm4_state *pm4;
struct si_state_blend *blend = rctx-queued.named.blend;
uint32_t mask;
 
-   if (pm4 == NULL || blend == NULL)
+   if (blend == NULL)
+   return;
+
+   pm4 = CALLOC_STRUCT(si_pm4_state);
+   if (pm4 == NULL)
return;
 
mask = (1ULL  ((unsigned)rctx-framebuffer.nr_cbufs * 4)) - 1;
@@ -300,14 +304,12 @@ static void si_set_viewport_state(struct pipe_context 
*ctx,
 static void si_update_fb_rs_state(struct r600_context *rctx)
 {
struct si_state_rasterizer *rs = rctx-queued.named.rasterizer;
-   struct si_pm4_state *pm4 = CALLOC_STRUCT(si_pm4_state);
+   struct si_pm4_state *pm4;
unsigned offset_db_fmt_cntl = 0, depth;
float offset_units;
 
-   if (!rs || !rctx-framebuffer.zsbuf) {
-   FREE(pm4);
+   if (!rs || !rctx-framebuffer.zsbuf)
return;
-   }
 
offset_units = rctx-queued.named.rasterizer-offset_units;
switch (rctx-framebuffer.zsbuf-texture-format) {
@@ -330,6 +332,7 @@ static void si_update_fb_rs_state(struct r600_context *rctx)
return;
}
 
+   pm4 = CALLOC_STRUCT(si_pm4_state);
/* FIXME some of those reg can be computed with cso */
offset_db_fmt_cntl |= S_028B78_POLY_OFFSET_NEG_NUM_DB_BITS(depth);
si_pm4_set_reg(pm4, R_028B80_PA_SU_POLY_OFFSET_FRONT_SCALE,
@@ -2070,18 +2073,17 @@ static void si_set_constant_buffer(struct pipe_context 
*ctx, uint shader, uint i
 {
struct r600_context *rctx = (struct r600_context *)ctx;
struct si_resource *rbuffer = cb ? si_resource(cb-buffer) : NULL;
-   struct si_pm4_state *pm4 = CALLOC_STRUCT(si_pm4_state);
+   struct si_pm4_state *pm4;
uint64_t va_offset;
uint32_t offset;
 
/* Note that the state tracker can unbind constant buffers by
 * passing NULL here.
 */
-   if (cb == NULL) {
-   FREE(pm4);
+   if (cb == NULL)
return;
-   }
 
+   pm4 = CALLOC_STRUCT(si_pm4_state);
si_pm4_inval_shader_cache(pm4);
 
if (cb-user_buffer)
@@ -2108,7 +2110,6 @@ static void si_set_constant_buffer(struct pipe_context 
*ctx, uint shader, uint i
 
default:
R600_ERR(unsupported %d\n, shader);
-   return;
}
 
if (cb-buffer != rbuffer-b.b)
-- 
1.7.10.4

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


[Mesa-dev] [PATCH 1/2] r600g: set CB_COLOR_INFO to INVALID for disabled colorbuffers on r600-r700

2012-08-15 Thread Marek Olšák
---
 src/gallium/drivers/r600/r600_state.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/gallium/drivers/r600/r600_state.c 
b/src/gallium/drivers/r600/r600_state.c
index d2ef68e..e024907 100644
--- a/src/gallium/drivers/r600/r600_state.c
+++ b/src/gallium/drivers/r600/r600_state.c
@@ -1438,6 +1438,9 @@ static void r600_set_framebuffer_state(struct 
pipe_context *ctx,
   surf-cb_color_info, res, 
RADEON_USAGE_READWRITE);
i++;
}
+   for (; i  8 ; i++) {
+   r600_pipe_state_add_reg(rstate, R_0280A0_CB_COLOR0_INFO + i * 
4, 0);
+   }
 
/* Update alpha-test state dependencies.
 * Alpha-test is done on the first colorbuffer only. */
-- 
1.7.9.5

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


[Mesa-dev] [PATCH 2/2] r600g: make F2U trans-only on r600-r700

2012-08-15 Thread Marek Olšák
---
 src/gallium/drivers/r600/r600_shader.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/drivers/r600/r600_shader.c 
b/src/gallium/drivers/r600/r600_shader.c
index ccfb230..94cb8dc 100644
--- a/src/gallium/drivers/r600/r600_shader.c
+++ b/src/gallium/drivers/r600/r600_shader.c
@@ -5343,7 +5343,7 @@ static struct r600_shader_tgsi_instruction 
r600_shader_tgsi_instruction[] = {
{TGSI_OPCODE_ISGE,  0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE_INT, 
tgsi_op2},
{TGSI_OPCODE_ISHR,  0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ASHR_INT, 
tgsi_op2_trans},
{TGSI_OPCODE_ISLT,  0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT_INT, 
tgsi_op2_swap},
-   {TGSI_OPCODE_F2U,   0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_UINT, 
tgsi_op2},
+   {TGSI_OPCODE_F2U,   0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_UINT, 
tgsi_op2_trans},
{TGSI_OPCODE_U2F,   0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_UINT_TO_FLT, 
tgsi_op2_trans},
{TGSI_OPCODE_UADD,  0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD_INT, 
tgsi_op2},
{TGSI_OPCODE_UDIV,  0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, 
tgsi_udiv},
-- 
1.7.9.5

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


Re: [Mesa-dev] [PATCH 0/7] gallium/radeon: Misc GPU virtual address space fixes.

2012-08-15 Thread Alex Deucher
On Wed, Aug 15, 2012 at 11:40 AM, Michel Dänzer mic...@daenzer.net wrote:
 I found some of these problems a while ago inspired by
 https://bugs.freedesktop.org/show_bug.cgi?id=45018 . Found some more recently,
 now it seems to be working much better with the radeonsi driver.

 [PATCH 1/7] gallium/radeon: Make va_offset 64 bits wide.
 [PATCH 2/7] gallium/radeon: Merge holes when freeing virtual address
 [PATCH 3/7] gallium/radeon: Fix losing holes when allocating virtual
 [PATCH 4/7] gallium/radeon: Delete uppermost virtual address space
 [PATCH 5/7] gallium/radeon: Fix potential address space loss in
 [PATCH 6/7] gallium/radeon: Create hole for waste when allocating
 [PATCH 7/7] gallium/radeon: Don't assign virtual address space for

For the series:

Reviewed-by: Alex Deucher alexander.deuc...@amd.com
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/3] radeonsi: Fix a few more state BO leaks.

2012-08-15 Thread Alex Deucher
On Wed, Aug 15, 2012 at 12:37 PM, Michel Dänzer mic...@daenzer.net wrote:
 From: Michel Dänzer michel.daen...@amd.com

 Signed-off-by: Michel Dänzer michel.daen...@amd.com

For the series:

Reviewed-by: Alex Deucher alexander.deuc...@amd.com

 ---
  src/gallium/drivers/radeonsi/si_state.c  |2 ++
  src/gallium/drivers/radeonsi/si_state_draw.c |2 ++
  2 files changed, 4 insertions(+)

 diff --git a/src/gallium/drivers/radeonsi/si_state.c 
 b/src/gallium/drivers/radeonsi/si_state.c
 index 1d6d214..db3ea25 100644
 --- a/src/gallium/drivers/radeonsi/si_state.c
 +++ b/src/gallium/drivers/radeonsi/si_state.c
 @@ -2003,6 +2003,7 @@ static void si_set_ps_sampler_view(struct pipe_context 
 *ctx, unsigned count,
 si_pm4_set_reg(pm4, R_00B040_SPI_SHADER_USER_DATA_PS_4, va);
 si_pm4_set_reg(pm4, R_00B044_SPI_SHADER_USER_DATA_PS_5, va  32);

 +   si_resource_reference(bo, NULL);
  out:
 si_pm4_set_state(rctx, ps_sampler_views, pm4);
 rctx-have_depth_texture = has_depth;
 @@ -2046,6 +2047,7 @@ static void si_bind_ps_sampler(struct pipe_context 
 *ctx, unsigned count, void **
 si_pm4_set_reg(pm4, R_00B038_SPI_SHADER_USER_DATA_PS_2, va);
 si_pm4_set_reg(pm4, R_00B03C_SPI_SHADER_USER_DATA_PS_3, va  32);

 +   si_resource_reference(bo, NULL);
  out:
 si_pm4_set_state(rctx, ps_sampler, pm4);
 rctx-ps_samplers.n_samplers = count;
 diff --git a/src/gallium/drivers/radeonsi/si_state_draw.c 
 b/src/gallium/drivers/radeonsi/si_state_draw.c
 index 43644e5..8506933 100644
 --- a/src/gallium/drivers/radeonsi/si_state_draw.c
 +++ b/src/gallium/drivers/radeonsi/si_state_draw.c
 @@ -458,6 +458,8 @@ static void si_vertex_buffer_update(struct r600_context 
 *rctx)
 si_pm4_set_reg(pm4, R_00B148_SPI_SHADER_USER_DATA_VS_6, va);
 si_pm4_set_reg(pm4, R_00B14C_SPI_SHADER_USER_DATA_VS_7, va  32);
 si_pm4_set_state(rctx, vertex_buffers, pm4);
 +
 +   si_resource_reference(t_list_buffer, NULL);
  }

  static void si_state_draw(struct r600_context *rctx,
 --
 1.7.10.4

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


[Mesa-dev] [Bug 52140] Ubuntu Unity - Launcher and switcher icons disappeared

2012-08-15 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=52140

--- Comment #19 from Vasco Alves vascofal...@gmail.com 2012-08-15 22:10:01 
UTC ---
I can confirm this is fixed on Intel hardware (HD Graphics 3000).

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] R600g : rejected cs and etqw corruption with - implement wait-free buffer transfer for DISCARD_RANGE

2012-08-15 Thread Andy Furniss

Andy Furniss wrote:

Andy Furniss wrote:

Andy Furniss wrote:

Marek Olšák wrote:

Hi Andy,

this should be fixed by the commit:

commit c3c83af380d703cdc24475bd39baa1722c333b44
Author: Marek Olšák mar...@gmail.com
Date:   Wed Jul 18 18:33:37 2012 +0200

 r600g: setup streamout before calling last r600_need_cs_space
before drawing

Please let me know if you still have any issue.


That has fixed this issue - nice perf boost with your latest commits :-)

Unfortunately after running for a while I managed to trigger the issue I
previously reported.

It only took 10 mins - after the fix following the last report I ran for
an hour and then next day 45 mins without triggering it.

r600_pipe.h:743:r600_write_context_reg_seq: Assertion `cs-cdw+2+num =
(16 * 1024)' failed.


I can still 100% reproduce this - one thing I maybe didn't notice before
because I just checked dmesg (or maybe it just didn't happen) is that in
addition to the corruption followed by the above assert, there are
lots of

radeon: The kernel rejected CS, see dmesg for more information

But there is nothing in dmesg.


Testing with today's Mesa a slight difference in that it took a lot
longer than normal to assert after the corruption started and I see on
stderr in addition to kernel rejected CS

EE r600_pipe.c:79 r600_create_fence - r600: too many concurrent fences

still nothing in dmesg.


Looks like this is fixed with today's commits. I ran it for an hour.

Perf has gone down to where it used to be -20ish%.

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


[Mesa-dev] [PATCH] i965/fs: Fix INTEL_DEBUG=perf program key printing.

2012-08-15 Thread Kenneth Graunke
When dumping differences in program keys, it printed messages of the
format:

   [Name of thing that changed]  [new]-[old]

This was terribly confusing: the right arrow implies the value changed
from this to that, when in fact the message conveyed the opposite.

Except that some of the time, it didn't, since we accidentally swapped
the arguments to brw_debug_recompile_sampler_key.  With two swaps, it
would often come out in the expected format.

This patch fixes it to properly print:

   [Name of thing that changed]  [old]-[new]

Signed-off-by: Kenneth Graunke kenn...@whitecape.org
---
 src/mesa/drivers/dri/i965/brw_wm.c | 36 ++--
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_wm.c 
b/src/mesa/drivers/dri/i965/brw_wm.c
index 323eabd..32464f7 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.c
+++ b/src/mesa/drivers/dri/i965/brw_wm.c
@@ -366,18 +366,18 @@ brw_debug_recompile_sampler_key(const struct 
brw_sampler_prog_key_data *old_key,
 
for (unsigned int i = 0; i  BRW_MAX_TEX_UNIT; i++) {
   found |= key_debug(EXT_texture_swizzle or DEPTH_TEXTURE_MODE,
- key-swizzles[i], old_key-swizzles[i]);
+ old_key-swizzles[i], key-swizzles[i]);
}
found |= key_debug(GL_CLAMP enabled on any texture unit's 1st coordinate,
-  key-gl_clamp_mask[0], old_key-gl_clamp_mask[0]);
+  old_key-gl_clamp_mask[0], key-gl_clamp_mask[0]);
found |= key_debug(GL_CLAMP enabled on any texture unit's 2nd coordinate,
-  key-gl_clamp_mask[1], old_key-gl_clamp_mask[1]);
+  old_key-gl_clamp_mask[1], key-gl_clamp_mask[1]);
found |= key_debug(GL_CLAMP enabled on any texture unit's 3rd coordinate,
-  key-gl_clamp_mask[2], old_key-gl_clamp_mask[2]);
+  old_key-gl_clamp_mask[2], key-gl_clamp_mask[2]);
found |= key_debug(GL_MESA_ycbcr texturing\n,
-  key-yuvtex_mask, old_key-yuvtex_mask);
+  old_key-yuvtex_mask, key-yuvtex_mask);
found |= key_debug(GL_MESA_ycbcr UV swapping\n,
-  key-yuvtex_swap_mask, old_key-yuvtex_swap_mask);
+  old_key-yuvtex_swap_mask, key-yuvtex_swap_mask);
 
return found;
 }
@@ -413,18 +413,18 @@ brw_wm_debug_recompile(struct brw_context *brw,
}
 
found |= key_debug(alphatest, computed depth, depth test, or depth write,
-  key-iz_lookup, old_key-iz_lookup);
-   found |= key_debug(depth statistics, key-stats_wm, old_key-stats_wm);
-   found |= key_debug(flat shading, key-flat_shade, old_key-flat_shade);
-   found |= key_debug(number of color buffers, key-nr_color_regions, 
old_key-nr_color_regions);
-   found |= key_debug(rendering to FBO, key-render_to_fbo, 
old_key-render_to_fbo);
-   found |= key_debug(fragment color clamping, key-clamp_fragment_color, 
old_key-clamp_fragment_color);
-   found |= key_debug(line smoothing, key-line_aa, old_key-line_aa);
-   found |= key_debug(proj_attrib_mask, key-proj_attrib_mask, 
old_key-proj_attrib_mask);
-   found |= key_debug(renderbuffer height, key-drawable_height, 
old_key-drawable_height);
-   found |= key_debug(vertex shader outputs, key-vp_outputs_written, 
old_key-vp_outputs_written);
-
-   found |= brw_debug_recompile_sampler_key(key-tex, old_key-tex);
+  old_key-iz_lookup, key-iz_lookup);
+   found |= key_debug(depth statistics, old_key-stats_wm, key-stats_wm);
+   found |= key_debug(flat shading, old_key-flat_shade, key-flat_shade);
+   found |= key_debug(number of color buffers, old_key-nr_color_regions, 
key-nr_color_regions);
+   found |= key_debug(rendering to FBO, old_key-render_to_fbo, 
key-render_to_fbo);
+   found |= key_debug(fragment color clamping, 
old_key-clamp_fragment_color, key-clamp_fragment_color);
+   found |= key_debug(line smoothing, old_key-line_aa, key-line_aa);
+   found |= key_debug(proj_attrib_mask, old_key-proj_attrib_mask, 
key-proj_attrib_mask);
+   found |= key_debug(renderbuffer height, old_key-drawable_height, 
key-drawable_height);
+   found |= key_debug(vertex shader outputs, old_key-vp_outputs_written, 
key-vp_outputs_written);
+
+   found |= brw_debug_recompile_sampler_key(old_key-tex, key-tex);
 
if (!found) {
   perf_debug(  Something else\n);
-- 
1.7.11.4

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


[Mesa-dev] [PATCH] i965/fs: Don't try 16-wide if 8-wide uses more than half the registers.

2012-08-15 Thread Kenneth Graunke
16-wide programs use roughly twice as many registers as 8-wide, and we
don't support spilling in 16-wide.  So if an 8-wide program uses more
than half the available GRFs, the 16-wide one almost certainly will fail
to compile during register allocation.

Not only that, but attempting to compiling such shaders is expensive:
programs that use a lot of registers tend to be quite complex, meaning
that we spend more time than usual generating and optimizing code.  If
we fail at register allocation, we've failed at the last step, after
needlessly burning through a lot of CPU time.

To make things worse, such shader compilation typically happens at the
first draw call using the shader, so it can cause the GPU to stall.

With all that in mind, it makes sense to short-circuit the 16-wide
attempt if the 8-wide program uses too many registers.  I've chosen 75
to be conservative---if we /can/ compile a SIMD16 program, we want to.

Reduces the number of GPU stalls due to fragment shader recompiles
in Left 4 Dead 2 by about 20%, and reduces the duration of many of the
remaining stalls by about half.

Signed-off-by: Kenneth Graunke kenn...@whitecape.org
---
 src/mesa/drivers/dri/i965/brw_fs.cpp | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp 
b/src/mesa/drivers/dri/i965/brw_fs.cpp
index e2dafdc..a113105 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -2100,7 +2100,10 @@ brw_wm_fs_emit(struct brw_context *brw, struct 
brw_wm_compile *c,
   return false;
}
 
-   if (intel-gen = 5  c-prog_data.nr_pull_params == 0) {
+   if (v.grf_used = 75) {
+  perf_debug(Too many registers to attempt compiling a 16-wide shader; 
+ falling back to 8-wide at a 10-20%% performance cost.\n);
+   } else if (intel-gen = 5  c-prog_data.nr_pull_params == 0) {
   c-dispatch_width = 16;
   fs_visitor v2(c, prog, shader);
   v2.import_uniforms(v);
-- 
1.7.11.4

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