From 8a2a35f7ff928053cfc424f2155c67e0fac4308f Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sat, 27 Apr 2013 17:29:43 +1000 Subject: [PATCH] rebase to Mesa 9.1.1 + fixes from git --- .gitignore | 1 + mesa-9.0-19-g895a587.patch | 1889 ---------------------------- mesa-9.0.1-22-gd0a9ab2.patch | 1834 --------------------------- mesa-9.1-53-gd0ccb5b.patch | 1974 ------------------------------ mesa-9.1.1-53-g3cff41c.patch | 2242 ++++++++++++++++++++++++++++++++++ mesa.spec | 9 +- sources | 2 +- 7 files changed, 2250 insertions(+), 5701 deletions(-) delete mode 100644 mesa-9.0-19-g895a587.patch delete mode 100644 mesa-9.0.1-22-gd0a9ab2.patch delete mode 100644 mesa-9.1-53-gd0ccb5b.patch create mode 100644 mesa-9.1.1-53-g3cff41c.patch diff --git a/.gitignore b/.gitignore index b475cc4..78b25bc 100644 --- a/.gitignore +++ b/.gitignore @@ -46,3 +46,4 @@ mesa-20100720.tar.bz2 /MesaLib-9.0.1.tar.bz2 /mesa-20130213.tar.xz /MesaLib-9.1.tar.bz2 +/MesaLib-9.1.1.tar.bz2 diff --git a/mesa-9.0-19-g895a587.patch b/mesa-9.0-19-g895a587.patch deleted file mode 100644 index c907bd7..0000000 --- a/mesa-9.0-19-g895a587.patch +++ /dev/null @@ -1,1889 +0,0 @@ -diff --git a/Makefile.am b/Makefile.am -index 9a0c1dd..3caa121 100644 ---- a/Makefile.am -+++ b/Makefile.am -@@ -61,6 +61,7 @@ PACKAGE_NAME = MesaLib-$(PACKAGE_VERSION) - EXTRA_FILES = \ - aclocal.m4 \ - configure \ -+ bin/install-sh \ - src/glsl/glsl_parser.cc \ - src/glsl/glsl_parser.h \ - src/glsl/glsl_lexer.cc \ -diff --git a/bin/get-pick-list.sh b/bin/get-pick-list.sh -new file mode 100755 -index 0000000..7288090 ---- /dev/null -+++ b/bin/get-pick-list.sh -@@ -0,0 +1,29 @@ -+#!/bin/sh -+ -+# Script for generating a list of candidates for cherry-picking to a stable branch -+ -+# Grep for commits with "cherry picked from commit" in the commit message. -+git log --reverse --grep="cherry picked from commit" origin/master..HEAD |\ -+ grep "cherry picked from commit" |\ -+ sed -e 's/^[[:space:]]*(cherry picked from commit[[:space:]]*//' -e 's/)//' > already_picked -+ -+# Grep for commits that were marked as a candidate for the stable tree. -+git log --reverse --pretty=%H -i --grep='^[[:space:]]*NOTE: This is a candidate' HEAD..origin/master |\ -+while read sha -+do -+ # Check to see whether the patch is on the ignore list. -+ if [ -f .git/cherry-ignore ] ; then -+ if grep -q ^$sha .git/cherry-ignore ; then -+ continue -+ fi -+ fi -+ -+ # Check to see if it has already been picked over. -+ if grep -q ^$sha already_picked ; then -+ continue -+ fi -+ -+ git log -n1 --pretty=oneline $sha | cat -+done -+ -+rm -f already_picked -diff --git a/configure.ac b/configure.ac -index 2d922f6..e7a7241 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -160,13 +160,13 @@ DEFINES="" - AC_SUBST([DEFINES]) - case "$host_os" in - linux*|*-gnu*|gnu*) -- DEFINES="$DEFINES -D_GNU_SOURCE" -+ DEFINES="$DEFINES -D_GNU_SOURCE -DHAVE_PTHREAD" - ;; - solaris*) -- DEFINES="$DEFINES -DSVR4" -+ DEFINES="$DEFINES -DHAVE_PTHREAD -DSVR4" - ;; - cygwin*) -- DEFINES="$DEFINES" -+ DEFINES="$DEFINES -DHAVE_PTHREAD" - ;; - esac - -@@ -946,7 +946,7 @@ AC_ARG_ENABLE([glx-tls], - AC_SUBST(GLX_TLS, ${GLX_USE_TLS}) - - AS_IF([test "x$GLX_USE_TLS" = xyes -a "x$ax_pthread_ok" = xyes], -- [DEFINES="${DEFINES} -DGLX_USE_TLS"]) -+ [DEFINES="${DEFINES} -DGLX_USE_TLS -DHAVE_PTHREAD"]) - - dnl - dnl More DRI setup -@@ -1030,7 +1030,7 @@ if test "x$enable_dri" = xyes; then - esac - ;; - freebsd* | dragonfly* | *netbsd*) -- DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1" -+ DEFINES="$DEFINES -DHAVE_PTHREAD -DUSE_EXTERNAL_DXTN_LIB=1" - DEFINES="$DEFINES -DIN_DRI_DRIVER -DHAVE_ALIAS" - - if test "x$DRI_DIRS" = "xyes"; then -@@ -1222,8 +1222,6 @@ if test "x$enable_gbm" = xyes; then - if test "x$enable_shared_glapi" = xno; 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" -@@ -1518,7 +1516,7 @@ for plat in $egl_platforms; do - ;; - - wayland) -- PKG_CHECK_MODULES([WAYLAND], [wayland-client wayland-server],, \ -+ PKG_CHECK_MODULES([WAYLAND], [wayland-client >= 0.99.0 wayland-server >= 0.99.0],, \ - [AC_MSG_ERROR([cannot find libwayland-client])]) - GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS sw/wayland" - -diff --git a/docs/news.html b/docs/news.html -index 541bde6..26e648b 100644 ---- a/docs/news.html -+++ b/docs/news.html -@@ -9,6 +9,16 @@ - -

News

- -+

October 8, 2012

-+ -+

-+Mesa 9.0 is released. -+This is the first version of Mesa to support OpenGL 3.1 and GLSL 1.40 -+(with the i965 driver). -+See the release notes for more information about the release. -+

-+ -+ -

July 10, 2012

- -

-diff --git a/docs/relnotes-9.0.html b/docs/relnotes-9.0.html -index d72c5bb..02b7324 100644 ---- a/docs/relnotes-9.0.html -+++ b/docs/relnotes-9.0.html -@@ -26,7 +26,9 @@ because GL_ARB_compatibility is not supported. - -

MD5 checksums

-
--tbd
-+be4cd34c6599a7cb9d254b05c48bdb1f  MesaLib-9.0.tar.gz
-+60e557ce407be3732711da484ab3db6c  MesaLib-9.0.tar.bz2
-+16b128544cd3f7e237927bb9f8aab7ce  MesaLib-9.0.zip
- 
- - -diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h -index 81c1354..3c42338 100644 ---- a/src/egl/drivers/dri2/egl_dri2.h -+++ b/src/egl/drivers/dri2/egl_dri2.h -@@ -122,8 +122,10 @@ struct dri2_egl_display - - #ifdef HAVE_WAYLAND_PLATFORM - struct wl_display *wl_dpy; -+ struct wl_registry *wl_registry; - struct wl_drm *wl_server_drm; - struct wl_drm *wl_drm; -+ struct wl_event_queue *wl_queue; - int authenticated; - int formats; - #endif -@@ -174,7 +176,7 @@ struct dri2_egl_surface - __DRIbuffer *dri_buffers[__DRI_BUFFER_COUNT]; - __DRIbuffer *third_buffer; - __DRIbuffer *pending_buffer; -- EGLBoolean block_swap_buffers; -+ struct wl_callback *frame_callback; - int format; - #endif - -diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c -index d291f0f..dcf3601 100644 ---- a/src/egl/drivers/dri2/platform_wayland.c -+++ b/src/egl/drivers/dri2/platform_wayland.c -@@ -46,6 +46,34 @@ enum wl_drm_format_flags { - }; - - static void -+sync_callback(void *data, struct wl_callback *callback, uint32_t serial) -+{ -+ int *done = data; -+ -+ *done = 1; -+ wl_callback_destroy(callback); -+} -+ -+static const struct wl_callback_listener sync_listener = { -+ sync_callback -+}; -+ -+static int -+roundtrip(struct dri2_egl_display *dri2_dpy) -+{ -+ struct wl_callback *callback; -+ int done = 0, ret = 0; -+ -+ callback = wl_display_sync(dri2_dpy->wl_dpy); -+ wl_callback_add_listener(callback, &sync_listener, &done); -+ wl_proxy_set_queue((struct wl_proxy *) callback, dri2_dpy->wl_queue); -+ while (ret != -1 && !done) -+ ret = wl_display_dispatch_queue(dri2_dpy->wl_dpy, dri2_dpy->wl_queue); -+ -+ return ret; -+} -+ -+static void - wl_buffer_release(void *data, struct wl_buffer *buffer) - { - struct dri2_egl_surface *dri2_surf = data; -@@ -80,7 +108,6 @@ dri2_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type, - struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); - struct dri2_egl_config *dri2_conf = dri2_egl_config(conf); - struct dri2_egl_surface *dri2_surf; -- struct dri2_egl_buffer *dri2_buf; - int i; - - (void) drv; -@@ -104,7 +131,7 @@ dri2_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type, - - dri2_surf->pending_buffer = NULL; - dri2_surf->third_buffer = NULL; -- dri2_surf->block_swap_buffers = EGL_FALSE; -+ dri2_surf->frame_callback = NULL; - - if (conf->AlphaSize == 0) - dri2_surf->format = WL_DRM_FORMAT_XRGB8888; -@@ -118,17 +145,6 @@ dri2_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type, - dri2_surf->base.Width = -1; - dri2_surf->base.Height = -1; - break; -- case EGL_PIXMAP_BIT: -- dri2_surf->wl_pix = (struct wl_egl_pixmap *) window; -- -- dri2_surf->base.Width = dri2_surf->wl_pix->width; -- dri2_surf->base.Height = dri2_surf->wl_pix->height; -- -- if (dri2_surf->wl_pix->driver_private) { -- dri2_buf = dri2_surf->wl_pix->driver_private; -- dri2_surf->dri_buffers[__DRI_BUFFER_FRONT_LEFT] = dri2_buf->dri_buffer; -- } -- break; - default: - goto cleanup_surf; - } -@@ -166,15 +182,6 @@ dri2_create_window_surface(_EGLDriver *drv, _EGLDisplay *disp, - window, attrib_list); - } - --static _EGLSurface * --dri2_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *disp, -- _EGLConfig *conf, EGLNativePixmapType pixmap, -- const EGLint *attrib_list) --{ -- return dri2_create_surface(drv, disp, EGL_PIXMAP_BIT, conf, -- pixmap, attrib_list); --} -- - /** - * Called via eglDestroySurface(), drv->API.DestroySurface(). - */ -@@ -197,8 +204,7 @@ dri2_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf) - wl_buffer_destroy(dri2_surf->wl_drm_buffer[i]); - - for (i = 0; i < __DRI_BUFFER_COUNT; ++i) -- if (dri2_surf->dri_buffers[i] && !(i == __DRI_BUFFER_FRONT_LEFT && -- dri2_surf->base.Type == EGL_PIXMAP_BIT)) -+ if (dri2_surf->dri_buffers[i]) - dri2_dpy->dri2->releaseBuffer(dri2_dpy->dri_screen, - dri2_surf->dri_buffers[i]); - -@@ -212,22 +218,6 @@ dri2_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf) - return EGL_TRUE; - } - --static void --dri2_wl_egl_pixmap_destroy(struct wl_egl_pixmap *egl_pixmap) --{ -- struct dri2_egl_buffer *dri2_buf = egl_pixmap->driver_private; -- -- assert(dri2_buf); -- -- dri2_buf->dri2_dpy->dri2->releaseBuffer(dri2_buf->dri2_dpy->dri_screen, -- dri2_buf->dri_buffer); -- -- free(dri2_buf); -- -- egl_pixmap->driver_private = NULL; -- egl_pixmap->destroy = NULL; --} -- - static struct wl_buffer * - wayland_create_buffer(struct dri2_egl_surface *dri2_surf, - __DRIbuffer *buffer) -@@ -268,30 +258,6 @@ dri2_process_back_buffer(struct dri2_egl_surface *dri2_surf, unsigned format) - } - - static void --dri2_process_front_buffer(struct dri2_egl_surface *dri2_surf, unsigned format) --{ -- struct dri2_egl_display *dri2_dpy = -- dri2_egl_display(dri2_surf->base.Resource.Display); -- struct dri2_egl_buffer *dri2_buf; -- -- switch (dri2_surf->base.Type) { -- case EGL_PIXMAP_BIT: -- dri2_buf = malloc(sizeof *dri2_buf); -- if (!dri2_buf) -- return; -- -- dri2_buf->dri_buffer = dri2_surf->dri_buffers[__DRI_BUFFER_FRONT_LEFT]; -- dri2_buf->dri2_dpy = dri2_dpy; -- -- dri2_surf->wl_pix->driver_private = dri2_buf; -- dri2_surf->wl_pix->destroy = dri2_wl_egl_pixmap_destroy; -- break; -- default: -- break; -- } --} -- --static void - dri2_release_pending_buffer(void *data, - struct wl_callback *callback, uint32_t time) - { -@@ -333,11 +299,13 @@ dri2_release_buffers(struct dri2_egl_surface *dri2_surf) - switch (i) { - case __DRI_BUFFER_FRONT_LEFT: - if (dri2_surf->pending_buffer) -- wl_display_roundtrip(dri2_dpy->wl_dpy); -+ roundtrip(dri2_dpy); - dri2_surf->pending_buffer = dri2_surf->dri_buffers[i]; - callback = wl_display_sync(dri2_dpy->wl_dpy); - wl_callback_add_listener(callback, - &release_buffer_listener, dri2_surf); -+ wl_proxy_set_queue((struct wl_proxy *) callback, -+ dri2_dpy->wl_queue); - break; - default: - dri2_dpy->dri2->releaseBuffer(dri2_dpy->dri_screen, -@@ -466,9 +434,7 @@ dri2_get_buffers_with_format(__DRIdrawable * driDrawable, - if (!dri2_surf->dri_buffers[attachments[i]]) - continue; - -- if (attachments[i] == __DRI_BUFFER_FRONT_LEFT) -- dri2_process_front_buffer(dri2_surf, attachments[i+1]); -- else if (attachments[i] == __DRI_BUFFER_BACK_LEFT) -+ if (attachments[i] == __DRI_BUFFER_BACK_LEFT) - dri2_process_back_buffer(dri2_surf, attachments[i+1]); - } - -@@ -479,13 +445,7 @@ dri2_get_buffers_with_format(__DRIdrawable * driDrawable, - dri2_surf->buffer_count++; - } - -- assert(dri2_surf->base.Type == EGL_PIXMAP_BIT || -- dri2_surf->dri_buffers[__DRI_BUFFER_BACK_LEFT]); -- -- if (dri2_surf->base.Type == EGL_PIXMAP_BIT && !dri2_surf->wl_pix->buffer) -- dri2_surf->wl_pix->buffer = -- wayland_create_buffer(dri2_surf, -- dri2_surf->dri_buffers[__DRI_BUFFER_FRONT_LEFT]); -+ assert(dri2_surf->dri_buffers[__DRI_BUFFER_BACK_LEFT]); - - *out_count = dri2_surf->buffer_count; - if (dri2_surf->buffer_count == 0) -@@ -552,7 +512,7 @@ wayland_frame_callback(void *data, struct wl_callback *callback, uint32_t time) - { - struct dri2_egl_surface *dri2_surf = data; - -- dri2_surf->block_swap_buffers = EGL_FALSE; -+ dri2_surf->frame_callback = NULL; - wl_callback_destroy(callback); - } - -@@ -569,17 +529,18 @@ dri2_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw) - struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); - struct dri2_egl_surface *dri2_surf = dri2_egl_surface(draw); - struct dri2_egl_driver *dri2_drv = dri2_egl_driver(drv); -- struct wl_callback *callback; -+ int ret = 0; - -- if (dri2_surf->block_swap_buffers) { -- wl_display_flush(dri2_dpy->wl_dpy); -- while (dri2_surf->block_swap_buffers) -- wl_display_iterate(dri2_dpy->wl_dpy, WL_DISPLAY_READABLE); -- } -+ while (dri2_surf->frame_callback && ret != -1) -+ ret = wl_display_dispatch_queue(dri2_dpy->wl_dpy, dri2_dpy->wl_queue); -+ if (ret < 0) -+ return EGL_FALSE; - -- dri2_surf->block_swap_buffers = EGL_TRUE; -- callback = wl_surface_frame(dri2_surf->wl_win->surface); -- wl_callback_add_listener(callback, &frame_listener, dri2_surf); -+ dri2_surf->frame_callback = wl_surface_frame(dri2_surf->wl_win->surface); -+ wl_callback_add_listener(dri2_surf->frame_callback, -+ &frame_listener, dri2_surf); -+ wl_proxy_set_queue((struct wl_proxy *) dri2_surf->frame_callback, -+ dri2_dpy->wl_queue); - - if (dri2_surf->base.Type == EGL_WINDOW_BIT) { - pointer_swap( -@@ -611,6 +572,8 @@ dri2_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw) - - wl_surface_damage(dri2_surf->wl_win->surface, 0, 0, - dri2_surf->base.Width, dri2_surf->base.Height); -+ -+ wl_surface_commit(dri2_surf->wl_win->surface); - } - - _EGLContext *ctx; -@@ -626,71 +589,6 @@ dri2_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw) - return EGL_TRUE; - } - --/** -- * Called via eglCreateImageKHR(), drv->API.CreateImageKHR(). -- */ --static _EGLImage * --dri2_create_image_khr_pixmap(_EGLDisplay *disp, _EGLContext *ctx, -- EGLClientBuffer buffer, const EGLint *attr_list) --{ -- struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); -- struct wl_egl_pixmap *wl_egl_pixmap = (struct wl_egl_pixmap *) buffer; -- struct dri2_egl_buffer *dri2_buf; -- EGLint wl_attr_list[] = { -- EGL_WIDTH, 0, -- EGL_HEIGHT, 0, -- EGL_DRM_BUFFER_STRIDE_MESA, 0, -- EGL_DRM_BUFFER_FORMAT_MESA, EGL_DRM_BUFFER_FORMAT_ARGB32_MESA, -- EGL_NONE -- }; -- -- dri2_buf = malloc(sizeof *dri2_buf); -- if (!dri2_buf) -- return NULL; -- -- dri2_buf->dri2_dpy = dri2_dpy; -- dri2_buf->dri_buffer = -- dri2_dpy->dri2->allocateBuffer(dri2_dpy->dri_screen, -- __DRI_BUFFER_FRONT_LEFT, 32, -- wl_egl_pixmap->width, -- wl_egl_pixmap->height); -- -- wl_egl_pixmap->destroy = dri2_wl_egl_pixmap_destroy; -- wl_egl_pixmap->driver_private = dri2_buf; -- -- /* FIXME: Get buffer format from attr_list somehow... or from the -- wl_egl_piaxmap. */ -- wl_egl_pixmap->buffer = -- wl_drm_create_buffer(dri2_dpy->wl_drm, -- dri2_buf->dri_buffer->name, -- wl_egl_pixmap->width, -- wl_egl_pixmap->height, -- dri2_buf->dri_buffer->pitch, -- WL_DRM_FORMAT_ARGB8888); -- -- wl_attr_list[1] = wl_egl_pixmap->width; -- wl_attr_list[3] = wl_egl_pixmap->height; -- wl_attr_list[5] = dri2_buf->dri_buffer->pitch / 4; -- -- return dri2_create_image_khr(disp->Driver, disp, ctx, EGL_DRM_BUFFER_MESA, -- (EGLClientBuffer)(intptr_t) dri2_buf->dri_buffer->name, wl_attr_list); --} -- --static _EGLImage * --dri2_wayland_create_image_khr(_EGLDriver *drv, _EGLDisplay *disp, -- _EGLContext *ctx, EGLenum target, -- EGLClientBuffer buffer, const EGLint *attr_list) --{ -- (void) drv; -- -- switch (target) { -- case EGL_NATIVE_PIXMAP_KHR: -- return dri2_create_image_khr_pixmap(disp, ctx, buffer, attr_list); -- default: -- return dri2_create_image_khr(drv, disp, ctx, target, buffer, attr_list); -- } --} -- - static int - dri2_wayland_authenticate(_EGLDisplay *disp, uint32_t id) - { -@@ -700,7 +598,8 @@ dri2_wayland_authenticate(_EGLDisplay *disp, uint32_t id) - dri2_dpy->authenticated = 0; - - wl_drm_authenticate(dri2_dpy->wl_drm, id); -- wl_display_roundtrip(dri2_dpy->wl_dpy); -+ if (roundtrip(dri2_dpy) < 0) -+ ret = -1; - - if (!dri2_dpy->authenticated) - ret = -1; -@@ -795,22 +694,37 @@ static const struct wl_drm_listener drm_listener = { - drm_handle_authenticated - }; - -+static void -+registry_handle_global(void *data, struct wl_registry *registry, uint32_t name, -+ const char *interface, uint32_t version) -+{ -+ struct dri2_egl_display *dri2_dpy = data; -+ -+ if (strcmp(interface, "wl_drm") == 0) { -+ dri2_dpy->wl_drm = -+ wl_registry_bind(registry, name, &wl_drm_interface, 1); -+ wl_drm_add_listener(dri2_dpy->wl_drm, &drm_listener, dri2_dpy); -+ } -+} -+ -+static const struct wl_registry_listener registry_listener = { -+ registry_handle_global -+}; -+ - EGLBoolean - dri2_initialize_wayland(_EGLDriver *drv, _EGLDisplay *disp) - { - struct dri2_egl_display *dri2_dpy; - const __DRIconfig *config; -- uint32_t id, types; -+ uint32_t types; - int i; - static const unsigned int argb_masks[4] = - { 0xff0000, 0xff00, 0xff, 0xff000000 }; - static const unsigned int rgb_masks[4] = { 0xff0000, 0xff00, 0xff, 0 }; - - drv->API.CreateWindowSurface = dri2_create_window_surface; -- drv->API.CreatePixmapSurface = dri2_create_pixmap_surface; - drv->API.DestroySurface = dri2_destroy_surface; - drv->API.SwapBuffers = dri2_swap_buffers; -- drv->API.CreateImageKHR = dri2_wayland_create_image_khr; - drv->API.Terminate = dri2_terminate; - - dri2_dpy = malloc(sizeof *dri2_dpy); -@@ -829,22 +743,19 @@ dri2_initialize_wayland(_EGLDriver *drv, _EGLDisplay *disp) - dri2_dpy->wl_dpy = disp->PlatformDisplay; - } - -- id = wl_display_get_global(dri2_dpy->wl_dpy, "wl_drm", 1); -- if (id == 0) -- wl_display_roundtrip(dri2_dpy->wl_dpy); -- id = wl_display_get_global(dri2_dpy->wl_dpy, "wl_drm", 1); -- if (id == 0) -+ dri2_dpy->wl_queue = wl_display_create_queue(dri2_dpy->wl_dpy); -+ dri2_dpy->wl_registry = wl_display_get_registry(dri2_dpy->wl_dpy); -+ wl_proxy_set_queue((struct wl_proxy *) dri2_dpy->wl_registry, -+ dri2_dpy->wl_queue); -+ wl_registry_add_listener(dri2_dpy->wl_registry, -+ ®istry_listener, dri2_dpy); -+ if (roundtrip(dri2_dpy) < 0 || dri2_dpy->wl_drm == NULL) - goto cleanup_dpy; -- dri2_dpy->wl_drm = wl_display_bind(dri2_dpy->wl_dpy, id, &wl_drm_interface); -- if (!dri2_dpy->wl_drm) -- goto cleanup_dpy; -- wl_drm_add_listener(dri2_dpy->wl_drm, &drm_listener, dri2_dpy); -- wl_display_roundtrip(dri2_dpy->wl_dpy); -- if (dri2_dpy->fd == -1) -+ -+ if (roundtrip(dri2_dpy) < 0 || dri2_dpy->fd == -1) - goto cleanup_drm; - -- wl_display_roundtrip(dri2_dpy->wl_dpy); -- if (!dri2_dpy->authenticated) -+ if (roundtrip(dri2_dpy) < 0 || !dri2_dpy->authenticated) - goto cleanup_fd; - - dri2_dpy->driver_name = dri2_get_driver_for_fd(dri2_dpy->fd); -@@ -871,7 +782,7 @@ dri2_initialize_wayland(_EGLDriver *drv, _EGLDisplay *disp) - if (!dri2_create_screen(disp)) - goto cleanup_driver; - -- types = EGL_WINDOW_BIT | EGL_PIXMAP_BIT; -+ types = EGL_WINDOW_BIT; - for (i = 0; dri2_dpy->driver_configs[i]; i++) { - config = dri2_dpy->driver_configs[i]; - if (dri2_dpy->formats & HAS_XRGB8888) -@@ -880,8 +791,6 @@ dri2_initialize_wayland(_EGLDriver *drv, _EGLDisplay *disp) - dri2_add_config(disp, config, i + 1, 0, types, NULL, argb_masks); - } - -- disp->Extensions.KHR_image_pixmap = EGL_TRUE; -- - disp->Extensions.WL_bind_wayland_display = EGL_TRUE; - dri2_dpy->authenticate = dri2_wayland_authenticate; - -diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c -index 71eca6f..4efb76b 100644 ---- a/src/egl/main/eglcontext.c -+++ b/src/egl/main/eglcontext.c -@@ -229,17 +229,14 @@ _eglParseContextAttribList(_EGLContext *ctx, _EGLDisplay *dpy, - * - * "* If an OpenGL context is requested, the requested version - * is greater than 3.2, and the value for attribute -- * EGL_CONTEXT_PROFILE_MASK_KHR has no bits set; has any -- * bits set other than EGL_CONTEXT_CORE_PROFILE_BIT_KHR and -- * EGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_KHR; has more than -- * one of these bits set; or if the implementation does not -- * support the requested profile, then an -- * EGL_BAD_PROFILE_KHR error is generated." -- * -- * However, it does not define EGL_BAD_PROFILE_KHR. For now use -- * EGL_BAD_ATTRIBUTE. -+ * EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR has no bits set; has -+ * any bits set other than EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR -+ * and EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR; has -+ * more than one of these bits set; or if the implementation does -+ * not support the requested profile, then an EGL_BAD_MATCH error -+ * is generated." - */ -- err = EGL_BAD_ATTRIBUTE; -+ err = EGL_BAD_MATCH; - break; - } - } -diff --git a/src/egl/wayland/wayland-drm/wayland-drm.c b/src/egl/wayland/wayland-drm/wayland-drm.c -index 45b307f..d02aab6 100644 ---- a/src/egl/wayland/wayland-drm/wayland-drm.c -+++ b/src/egl/wayland/wayland-drm/wayland-drm.c -@@ -36,17 +36,6 @@ - #include "wayland-drm.h" - #include "wayland-drm-server-protocol.h" - --/* Git master of Wayland is moving towards a stable version of the -- * protocol, but breaking from 0.85 in the process. For the time -- * being, it's convenient to be able to build Mesa against both master -- * and 0.85.x of Wayland. To make this work we'll do a compile-time -- * version check and work around the difference in API and protocol */ --#if defined (WAYLAND_VERSION_MAJOR) && \ -- WAYLAND_VERSION_MAJOR == 0 && \ -- WAYLAND_VERSION_MINOR == 85 --#define HAS_WAYLAND_0_85 --#endif -- - struct wl_drm { - struct wl_display *display; - -@@ -69,25 +58,10 @@ destroy_buffer(struct wl_resource *resource) - static void - buffer_destroy(struct wl_client *client, struct wl_resource *resource) - { --#ifdef HAS_WAYLAND_0_85 -- wl_resource_destroy(resource, 0); --#else - wl_resource_destroy(resource); --#endif --} -- --#ifdef HAS_WAYLAND_0_85 --static void --buffer_damage(struct wl_client *client, struct wl_resource *buffer, -- int32_t x, int32_t y, int32_t width, int32_t height) --{ - } --#endif - - const static struct wl_buffer_interface drm_buffer_interface = { --#ifdef HAS_WAYLAND_0_85 -- buffer_damage, --#endif - buffer_destroy - }; - -diff --git a/src/egl/wayland/wayland-egl/wayland-egl-priv.h b/src/egl/wayland/wayland-egl/wayland-egl-priv.h -index accd2dd..bdbf32a 100644 ---- a/src/egl/wayland/wayland-egl/wayland-egl-priv.h -+++ b/src/egl/wayland/wayland-egl/wayland-egl-priv.h -@@ -26,17 +26,6 @@ struct wl_egl_window { - int attached_height; - }; - --struct wl_egl_pixmap { -- struct wl_buffer *buffer; -- -- int width; -- int height; -- -- void (*destroy) (struct wl_egl_pixmap *egl_pixmap); -- -- void *driver_private; --}; -- - #ifdef __cplusplus - } - #endif -diff --git a/src/egl/wayland/wayland-egl/wayland-egl.c b/src/egl/wayland/wayland-egl/wayland-egl.c -index e950b4a..c61fb4f 100644 ---- a/src/egl/wayland/wayland-egl/wayland-egl.c -+++ b/src/egl/wayland/wayland-egl/wayland-egl.c -@@ -48,36 +48,3 @@ wl_egl_window_get_attached_size(struct wl_egl_window *egl_window, - if (height) - *height = egl_window->attached_height; - } -- --WL_EGL_EXPORT struct wl_egl_pixmap * --wl_egl_pixmap_create(int width, int height, uint32_t flags) --{ -- struct wl_egl_pixmap *egl_pixmap; -- -- egl_pixmap = malloc(sizeof *egl_pixmap); -- if (egl_pixmap == NULL) -- return NULL; -- -- egl_pixmap->width = width; -- egl_pixmap->height = height; -- -- egl_pixmap->destroy = NULL; -- egl_pixmap->buffer = NULL; -- egl_pixmap->driver_private = NULL; -- -- return egl_pixmap; --} -- --WL_EGL_EXPORT void --wl_egl_pixmap_destroy(struct wl_egl_pixmap *egl_pixmap) --{ -- if (egl_pixmap->destroy) -- egl_pixmap->destroy(egl_pixmap); -- free(egl_pixmap); --} -- --WL_EGL_EXPORT struct wl_buffer * --wl_egl_pixmap_create_buffer(struct wl_egl_pixmap *egl_pixmap) --{ -- return egl_pixmap->buffer; --} -diff --git a/src/gallium/drivers/nv30/nv30_miptree.c b/src/gallium/drivers/nv30/nv30_miptree.c -index 7e67729..18e40e1 100644 ---- a/src/gallium/drivers/nv30/nv30_miptree.c -+++ b/src/gallium/drivers/nv30/nv30_miptree.c -@@ -56,8 +56,7 @@ nv30_miptree_get_handle(struct pipe_screen *pscreen, - if (!mt || !mt->base.bo) - return FALSE; - -- stride = util_format_get_stride(mt->base.base.format, -- mt->base.base.width0); -+ stride = mt->level[0].pitch; - - return nouveau_screen_bo_get_handle(pscreen, mt->base.bo, stride, handle); - } -diff --git a/src/gallium/drivers/nv50/nv50_miptree.c b/src/gallium/drivers/nv50/nv50_miptree.c -index 7b8dfb8..70e8c77 100644 ---- a/src/gallium/drivers/nv50/nv50_miptree.c -+++ b/src/gallium/drivers/nv50/nv50_miptree.c -@@ -133,8 +133,7 @@ nv50_miptree_get_handle(struct pipe_screen *pscreen, - if (!mt || !mt->base.bo) - return FALSE; - -- stride = util_format_get_stride(mt->base.base.format, -- mt->base.base.width0); -+ stride = mt->level[0].pitch; - - return nouveau_screen_bo_get_handle(pscreen, - mt->base.bo, -diff --git a/src/gallium/state_trackers/egl/wayland/native_drm.c b/src/gallium/state_trackers/egl/wayland/native_drm.c -index c6f6197..4671e33 100644 ---- a/src/gallium/state_trackers/egl/wayland/native_drm.c -+++ b/src/gallium/state_trackers/egl/wayland/native_drm.c -@@ -182,35 +182,43 @@ static const struct wl_drm_listener drm_listener = { - drm_handle_authenticated - }; - -+static void -+registry_handle_global(void *data, struct wl_registry *registry, uint32_t name, -+ const char *interface, uint32_t version) -+{ -+ struct wayland_drm_display *drmdpy = data; -+ -+ if (strcmp(interface, "wl_drm") == 0) { -+ drmdpy->wl_drm = wl_registry_bind(registry, name, &wl_drm_interface, 1); -+ wl_drm_add_listener(drmdpy->wl_drm, &drm_listener, drmdpy); -+ } -+} -+ -+static const struct wl_registry_listener registry_listener = { -+ registry_handle_global -+}; -+ - static boolean - wayland_drm_display_init_screen(struct native_display *ndpy) - { - struct wayland_drm_display *drmdpy = wayland_drm_display(ndpy); -- uint32_t id; -- -- id = wl_display_get_global(drmdpy->base.dpy, "wl_drm", 1); -- if (id == 0) -- wl_display_roundtrip(drmdpy->base.dpy); -- id = wl_display_get_global(drmdpy->base.dpy, "wl_drm", 1); -- if (id == 0) -- return FALSE; - -- drmdpy->wl_drm = wl_display_bind(drmdpy->base.dpy, id, &wl_drm_interface); -- if (!drmdpy->wl_drm) -+ drmdpy->base.queue = wl_display_create_queue(drmdpy->base.dpy); -+ drmdpy->base.registry = wl_display_get_registry(drmdpy->base.dpy); -+ wl_proxy_set_queue((struct wl_proxy *) drmdpy->base.registry, -+ drmdpy->base.queue); -+ wl_registry_add_listener(drmdpy->base.registry, ®istry_listener, drmdpy); -+ if (wayland_roundtrip(&drmdpy->base) < 0 || drmdpy->wl_drm == NULL) - return FALSE; - - wl_drm_add_listener(drmdpy->wl_drm, &drm_listener, drmdpy); -- wl_display_roundtrip(drmdpy->base.dpy); -- if (drmdpy->fd == -1) -+ if (wayland_roundtrip(&drmdpy->base) < 0 || drmdpy->fd == -1) - return FALSE; - -- wl_display_roundtrip(drmdpy->base.dpy); -- if (!drmdpy->authenticated) -+ if (wayland_roundtrip(&drmdpy->base) < 0 || !drmdpy->authenticated) - return FALSE; - - if (drmdpy->base.formats == 0) -- wl_display_roundtrip(drmdpy->base.dpy); -- if (drmdpy->base.formats == 0) - return FALSE; - - drmdpy->base.base.screen = -diff --git a/src/gallium/state_trackers/egl/wayland/native_shm.c b/src/gallium/state_trackers/egl/wayland/native_shm.c -index 574ffce..5ffe485 100644 ---- a/src/gallium/state_trackers/egl/wayland/native_shm.c -+++ b/src/gallium/state_trackers/egl/wayland/native_shm.c -@@ -133,26 +133,36 @@ static const struct wl_shm_listener shm_listener = { - shm_handle_format - }; - -+static void -+registry_handle_global(void *data, struct wl_registry *registry, uint32_t name, -+ const char *interface, uint32_t version) -+{ -+ struct wayland_shm_display *shmdpy = data; -+ -+ if (strcmp(interface, "wl_shm") == 0) { -+ shmdpy->wl_shm = wl_registry_bind(registry, name, &wl_shm_interface, 1); -+ wl_shm_add_listener(shmdpy->wl_shm, &shm_listener, shmdpy); -+ } -+} -+ -+static const struct wl_registry_listener registry_listener = { -+ registry_handle_global -+}; -+ - static boolean - wayland_shm_display_init_screen(struct native_display *ndpy) - { - struct wayland_shm_display *shmdpy = wayland_shm_display(ndpy); - struct sw_winsys *winsys = NULL; -- uint32_t id; - -- id = wl_display_get_global(shmdpy->base.dpy, "wl_shm", 1); -- if (id == 0) -- wl_display_iterate(shmdpy->base.dpy, WL_DISPLAY_READABLE); -- id = wl_display_get_global(shmdpy->base.dpy, "wl_shm", 1); -- if (id == 0) -+ shmdpy->base.queue = wl_display_create_queue(shmdpy->base.dpy); -+ shmdpy->base.registry = wl_display_get_registry(shmdpy->base.dpy); -+ wl_proxy_set_queue((struct wl_proxy *) shmdpy->base.registry, -+ shmdpy->base.queue); -+ wl_registry_add_listener(shmdpy->base.registry, ®istry_listener, shmdpy); -+ if (wayland_roundtrip(&shmdpy->base) < 0 || shmdpy->wl_shm == NULL) - return FALSE; - -- shmdpy->wl_shm = wl_display_bind(shmdpy->base.dpy, id, &wl_shm_interface); -- if (!shmdpy->wl_shm) -- return FALSE; -- -- wl_shm_add_listener(shmdpy->wl_shm, &shm_listener, shmdpy); -- - if (shmdpy->base.formats == 0) - wl_display_roundtrip(shmdpy->base.dpy); - if (shmdpy->base.formats == 0) -diff --git a/src/gallium/state_trackers/egl/wayland/native_wayland.c b/src/gallium/state_trackers/egl/wayland/native_wayland.c -index a7f9cb7..62c87f3 100644 ---- a/src/gallium/state_trackers/egl/wayland/native_wayland.c -+++ b/src/gallium/state_trackers/egl/wayland/native_wayland.c -@@ -35,6 +35,34 @@ - - #include "native_wayland.h" - -+static void -+sync_callback(void *data, struct wl_callback *callback, uint32_t serial) -+{ -+ int *done = data; -+ -+ *done = 1; -+ wl_callback_destroy(callback); -+} -+ -+static const struct wl_callback_listener sync_listener = { -+ sync_callback -+}; -+ -+int -+wayland_roundtrip(struct wayland_display *display) -+{ -+ struct wl_callback *callback; -+ int done = 0, ret = 0; -+ -+ callback = wl_display_sync(display->dpy); -+ wl_callback_add_listener(callback, &sync_listener, &done); -+ wl_proxy_set_queue((struct wl_proxy *) callback, display->queue); -+ while (ret == 0 && !done) -+ ret = wl_display_dispatch_queue(display->dpy, display->queue); -+ -+ return ret; -+} -+ - static const struct native_event_handler *wayland_event_handler; - - const static struct { -@@ -71,7 +99,6 @@ wayland_display_get_configs(struct native_display *ndpy, int *num_configs) - (1 << NATIVE_ATTACHMENT_BACK_LEFT); - - nconf->window_bit = TRUE; -- nconf->pixmap_bit = TRUE; - - nconf->color_format = wayland_formats[i].format; - display->num_configs++; -@@ -93,7 +120,6 @@ static int - wayland_display_get_param(struct native_display *ndpy, - enum native_param_type param) - { -- struct wayland_display *display = wayland_display(ndpy); - int val; - - switch (param) { -@@ -111,49 +137,6 @@ wayland_display_get_param(struct native_display *ndpy, - return val; - } - --static boolean --wayland_display_get_pixmap_format(struct native_display *ndpy, -- EGLNativePixmapType pix, -- enum pipe_format *format) --{ -- /* all wl_egl_pixmaps are supported */ -- *format = PIPE_FORMAT_NONE; -- -- return TRUE; --} -- --static void --wayland_pixmap_destroy(struct wl_egl_pixmap *egl_pixmap) --{ -- struct pipe_resource *resource = egl_pixmap->driver_private; -- -- assert(resource); -- -- pipe_resource_reference(&resource, NULL); -- if (egl_pixmap->buffer) { -- wl_buffer_destroy(egl_pixmap->buffer); -- egl_pixmap->buffer = NULL; -- } -- -- egl_pixmap->driver_private = NULL; -- egl_pixmap->destroy = NULL; --} -- --static void --wayland_pixmap_surface_initialize(struct wayland_surface *surface) --{ -- struct wayland_display *display = wayland_display(&surface->display->base); -- const enum native_attachment front_natt = NATIVE_ATTACHMENT_FRONT_LEFT; -- -- if (surface->pix->buffer != NULL) -- return; -- -- surface->pix->buffer = display->create_buffer(display, surface, front_natt); -- surface->pix->destroy = wayland_pixmap_destroy; -- surface->pix->driver_private = -- resource_surface_get_single_resource(surface->rsurf, front_natt); --} -- - static void - wayland_release_pending_resource(void *data, - struct wl_callback *callback, -@@ -188,7 +171,7 @@ wayland_window_surface_handle_resize(struct wayland_surface *surface) - surface->win->width, surface->win->height)) { - - if (surface->pending_resource) -- wl_display_roundtrip(display->dpy); -+ wayland_roundtrip(display); - - if (front_resource) { - struct wl_callback *callback; -@@ -198,6 +181,7 @@ wayland_window_surface_handle_resize(struct wayland_surface *surface) - - callback = wl_display_sync(display->dpy); - wl_callback_add_listener(callback, &release_buffer_listener, surface); -+ wl_proxy_set_queue((struct wl_proxy *) callback, display->queue); - } - - for (i = 0; i < WL_BUFFER_COUNT; ++i) { -@@ -234,9 +218,6 @@ wayland_surface_validate(struct native_surface *nsurf, uint attachment_mask, - - resource_surface_get_size(surface->rsurf, (uint *) width, (uint *) height); - -- if (surface->type == WL_PIXMAP_SURFACE) -- wayland_pixmap_surface_initialize(surface); -- - return TRUE; - } - -@@ -245,7 +226,7 @@ wayland_frame_callback(void *data, struct wl_callback *callback, uint32_t time) - { - struct wayland_surface *surface = data; - -- surface->block_swap_buffers = FALSE; -+ surface->frame_callback = NULL; - - wl_callback_destroy(callback); - } -@@ -269,15 +250,17 @@ wayland_surface_swap_buffers(struct native_surface *nsurf) - { - struct wayland_surface *surface = wayland_surface(nsurf); - struct wayland_display *display = surface->display; -- struct wl_callback *callback; -+ int ret = 0; - -- while (surface->block_swap_buffers) -- wl_display_iterate(display->dpy, WL_DISPLAY_READABLE); -+ while (surface->frame_callback && ret != -1) -+ ret = wl_display_dispatch_queue(display->dpy, display->queue); -+ if (ret == -1) -+ return EGL_FALSE; - -- surface->block_swap_buffers = TRUE; -- -- callback = wl_surface_frame(surface->win->surface); -- wl_callback_add_listener(callback, &frame_listener, surface); -+ surface->frame_callback = wl_surface_frame(surface->win->surface); -+ wl_callback_add_listener(surface->frame_callback, &frame_listener, surface); -+ wl_proxy_set_queue((struct wl_proxy *) surface->frame_callback, -+ display->queue); - - if (surface->type == WL_WINDOW_SURFACE) { - resource_surface_swap_buffers(surface->rsurf, -@@ -349,6 +332,7 @@ wayland_surface_present(struct native_surface *nsurf, - if (surface->type == WL_WINDOW_SURFACE) { - resource_surface_get_size(surface->rsurf, &width, &height); - wl_surface_damage(surface->win->surface, 0, 0, width, height); -+ wl_surface_commit(surface->win->surface); - } - - return ret; -@@ -376,61 +360,6 @@ wayland_surface_destroy(struct native_surface *nsurf) - } - - -- --static struct native_surface * --wayland_create_pixmap_surface(struct native_display *ndpy, -- EGLNativePixmapType pix, -- const struct native_config *nconf) --{ -- struct wayland_display *display = wayland_display(ndpy); -- struct wayland_surface *surface; -- struct wl_egl_pixmap *egl_pixmap = (struct wl_egl_pixmap *) pix; -- enum native_attachment natt = NATIVE_ATTACHMENT_FRONT_LEFT; -- uint bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW | -- PIPE_BIND_DISPLAY_TARGET | PIPE_BIND_SCANOUT; -- -- surface = CALLOC_STRUCT(wayland_surface); -- if (!surface) -- return NULL; -- -- surface->display = display; -- -- surface->pending_resource = NULL; -- surface->type = WL_PIXMAP_SURFACE; -- surface->pix = egl_pixmap; -- -- if (nconf) -- surface->color_format = nconf->color_format; -- else /* FIXME: derive format from wl_visual */ -- surface->color_format = PIPE_FORMAT_B8G8R8A8_UNORM; -- -- surface->attachment_mask = (1 << NATIVE_ATTACHMENT_FRONT_LEFT); -- -- surface->rsurf = resource_surface_create(display->base.screen, -- surface->color_format, bind); -- -- if (!surface->rsurf) { -- FREE(surface); -- return NULL; -- } -- -- resource_surface_set_size(surface->rsurf, -- egl_pixmap->width, egl_pixmap->height); -- -- /* the pixmap is already allocated, so import it */ -- if (surface->pix->buffer != NULL) -- resource_surface_import_resource(surface->rsurf, natt, -- surface->pix->driver_private); -- -- surface->base.destroy = wayland_surface_destroy; -- surface->base.present = wayland_surface_present; -- surface->base.validate = wayland_surface_validate; -- surface->base.wait = wayland_surface_wait; -- -- return &surface->base; --} -- -- - static struct native_surface * - wayland_create_window_surface(struct native_display *ndpy, - EGLNativeWindowType win, -@@ -452,7 +381,7 @@ wayland_create_window_surface(struct native_display *ndpy, - surface->win = (struct wl_egl_window *) win; - - surface->pending_resource = NULL; -- surface->block_swap_buffers = FALSE; -+ surface->frame_callback = NULL; - surface->type = WL_WINDOW_SURFACE; - - surface->buffer[WL_BUFFER_FRONT] = NULL; -@@ -505,10 +434,7 @@ native_create_display(void *dpy, boolean use_sw) - - display->base.get_param = wayland_display_get_param; - display->base.get_configs = wayland_display_get_configs; -- display->base.get_pixmap_format = wayland_display_get_pixmap_format; -- display->base.copy_to_pixmap = native_display_copy_to_pixmap; - display->base.create_window_surface = wayland_create_window_surface; -- display->base.create_pixmap_surface = wayland_create_pixmap_surface; - - display->own_dpy = own_dpy; - -diff --git a/src/gallium/state_trackers/egl/wayland/native_wayland.h b/src/gallium/state_trackers/egl/wayland/native_wayland.h -index e6a914f..b623fee 100644 ---- a/src/gallium/state_trackers/egl/wayland/native_wayland.h -+++ b/src/gallium/state_trackers/egl/wayland/native_wayland.h -@@ -45,6 +45,8 @@ struct wayland_display { - struct native_display base; - - struct wl_display *dpy; -+ struct wl_event_queue *queue; -+ struct wl_registry *registry; - boolean own_dpy; - /* supported formats */ - uint32_t formats; -@@ -65,7 +67,6 @@ enum wayland_buffer_type { - - enum wayland_surface_type { - WL_WINDOW_SURFACE, -- WL_PIXMAP_SURFACE, - WL_PBUFFER_SURFACE - }; - -@@ -74,7 +75,6 @@ struct wayland_surface { - struct wayland_display *display; - - struct wl_egl_window *win; -- struct wl_egl_pixmap *pix; - enum wayland_surface_type type; - int dx, dy; - struct resource_surface *rsurf; -@@ -85,7 +85,7 @@ struct wayland_surface { - struct wl_buffer *buffer[WL_BUFFER_COUNT]; - unsigned int attachment_mask; - -- boolean block_swap_buffers; -+ struct wl_callback *frame_callback; - boolean premultiplied_alpha; - }; - -@@ -119,4 +119,7 @@ struct wayland_display * - wayland_create_drm_display(struct wl_display *display, - const struct native_event_handler *event_handler); - -+int -+wayland_roundtrip(struct wayland_display *drmdpy); -+ - #endif /* _NATIVE_WAYLAND_H_ */ -diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c -index d8b1cc7..519929e 100644 ---- a/src/gbm/backends/dri/gbm_dri.c -+++ b/src/gbm/backends/dri/gbm_dri.c -@@ -33,8 +33,10 @@ - #include - - #include -+#include - #include - #include -+#include - - #include /* dri_interface needs GL types */ - #include -@@ -300,19 +302,12 @@ static int - gbm_dri_bo_write(struct gbm_bo *_bo, const void *buf, size_t count) - { - struct gbm_dri_bo *bo = gbm_dri_bo(_bo); -- void *ptr; -- int ret; -- -- if (bo->bo == NULL) -- return -1; - -- ret = kms_bo_map(bo->bo, &ptr); -- if (ret < 0) -+ if (bo->image != NULL) - return -1; - -- memcpy(ptr, buf, count); -+ memcpy(bo->map, buf, count); - -- kms_bo_unmap(bo->bo); - return 0; - } - -@@ -321,11 +316,17 @@ 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); -+ struct drm_mode_destroy_dumb arg; - -- if (bo->image != NULL) -+ if (bo->image != NULL) { - dri->image->destroyImage(bo->image); -- if (bo->bo != NULL) -- kms_bo_destroy(&bo->bo); -+ } else { -+ munmap(bo->map, bo->size); -+ memset(&arg, 0, sizeof(arg)); -+ arg.handle = bo->handle; -+ drmIoctl(dri->base.base.fd, DRM_IOCTL_MODE_DESTROY_DUMB, &arg); -+ } -+ - free(bo); - } - -@@ -375,6 +376,9 @@ gbm_dri_bo_import(struct gbm_device *gbm, - { - struct wl_drm_buffer *wb = (struct wl_drm_buffer *) buffer; - -+ if (!wayland_buffer_is_drm(buffer)) -+ return NULL; -+ - image = wb->driver_buffer; - - switch (wb->format) { -@@ -445,49 +449,86 @@ gbm_dri_bo_import(struct gbm_device *gbm, - } - - static struct gbm_bo * --gbm_dri_bo_create(struct gbm_device *gbm, -+create_dumb(struct gbm_device *gbm, - uint32_t width, uint32_t height, - uint32_t format, uint32_t usage) - { - struct gbm_dri_device *dri = gbm_dri_device(gbm); -+ struct drm_mode_create_dumb create_arg; -+ struct drm_mode_map_dumb map_arg; - struct gbm_dri_bo *bo; -- int dri_format; -- unsigned dri_use = 0; -+ struct drm_mode_destroy_dumb destroy_arg; -+ int ret; -+ -+ if (!(usage & GBM_BO_USE_CURSOR_64X64)) -+ return NULL; -+ if (format != GBM_FORMAT_ARGB8888) -+ return NULL; - - bo = calloc(1, sizeof *bo); - if (bo == NULL) - return NULL; - -+ create_arg.bpp = 32; -+ create_arg.width = width; -+ create_arg.height = height; -+ -+ ret = drmIoctl(dri->base.base.fd, DRM_IOCTL_MODE_CREATE_DUMB, &create_arg); -+ if (ret) -+ goto free_bo; -+ - bo->base.base.gbm = gbm; - bo->base.base.width = width; - bo->base.base.height = height; -+ bo->base.base.stride = create_arg.pitch; -+ bo->base.base.handle.u32 = create_arg.handle; -+ bo->handle = create_arg.handle; -+ bo->size = create_arg.size; - -- 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, -- }; -+ memset(&map_arg, 0, sizeof(map_arg)); -+ map_arg.handle = bo->handle; - -- if (!(usage & GBM_BO_USE_CURSOR_64X64)) -- return NULL; -+ ret = drmIoctl(dri->base.base.fd, DRM_IOCTL_MODE_MAP_DUMB, &map_arg); -+ if (ret) -+ goto destroy_dumb; - -- if (dri->kms == NULL) -- return NULL; -+ bo->map = mmap(0, bo->size, PROT_WRITE, -+ MAP_SHARED, dri->base.base.fd, map_arg.offset); -+ if (bo->map == MAP_FAILED) -+ goto destroy_dumb; - -- ret = kms_bo_create(dri->kms, attrs, &bo->bo); -- if (ret < 0) { -- free(bo); -- return NULL; -- } -+ return &bo->base.base; - -- 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); -+destroy_dumb: -+ memset(&destroy_arg, 0, sizeof destroy_arg); -+ destroy_arg.handle = create_arg.handle; -+ drmIoctl(dri->base.base.fd, DRM_IOCTL_MODE_DESTROY_DUMB, &destroy_arg); -+free_bo: -+ free(bo); - -- return &bo->base.base; -- } -+ return NULL; -+} -+ -+static struct gbm_bo * -+gbm_dri_bo_create(struct gbm_device *gbm, -+ uint32_t width, uint32_t height, -+ uint32_t format, uint32_t usage) -+{ -+ struct gbm_dri_device *dri = gbm_dri_device(gbm); -+ struct gbm_dri_bo *bo; -+ int dri_format; -+ unsigned dri_use = 0; -+ -+ if (usage & GBM_BO_USE_WRITE) -+ return create_dumb(gbm, width, height, format, usage); -+ -+ bo = calloc(1, sizeof *bo); -+ if (bo == NULL) -+ return NULL; -+ -+ bo->base.base.gbm = gbm; -+ bo->base.base.width = width; -+ bo->base.base.height = height; - - switch (format) { - case GBM_FORMAT_RGB565: -@@ -594,10 +635,6 @@ dri_device_create(int fd) - dri->base.type = GBM_DRM_DRIVER_TYPE_DRI; - dri->base.base.name = "drm"; - -- kms_create(fd, &dri->kms); -- if (dri->kms == NULL) -- goto err_kms; -- - ret = dri_screen_create(dri); - if (ret) - goto err_dri; -@@ -605,9 +642,8 @@ dri_device_create(int fd) - return &dri->base.base; - - err_dri: -- kms_destroy(&dri->kms); --err_kms: - free(dri); -+ - return NULL; - } - -diff --git a/src/gbm/backends/dri/gbm_driint.h b/src/gbm/backends/dri/gbm_driint.h -index 4b619a0..18fc3c0 100644 ---- a/src/gbm/backends/dri/gbm_driint.h -+++ b/src/gbm/backends/dri/gbm_driint.h -@@ -30,8 +30,6 @@ - - #include "gbmint.h" - --#include "libkms.h" -- - #include "common.h" - #include "common_drm.h" - -@@ -43,9 +41,6 @@ struct gbm_dri_surface; - struct gbm_dri_device { - struct gbm_drm_device base; - -- /* Only used for cursors */ -- struct kms_driver *kms; -- - void *driver; - - __DRIscreen *screen; -@@ -79,7 +74,8 @@ struct gbm_dri_bo { - __DRIimage *image; - - /* Only used for cursors */ -- struct kms_bo *bo; -+ uint32_t handle, size; -+ void *map; - }; - - struct gbm_dri_surface { -diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp -index 34ce133..86371b5 100644 ---- a/src/glsl/linker.cpp -+++ b/src/glsl/linker.cpp -@@ -882,6 +882,7 @@ move_non_declarations(exec_list *instructions, exec_node *last, - - assert(inst->as_assignment() - || inst->as_call() -+ || inst->as_if() /* for initializers with the ?: operator */ - || ((var != NULL) && (var->mode == ir_var_temporary))); - - if (make_copies) { -diff --git a/src/glsl/ralloc.c b/src/glsl/ralloc.c -index 3da09b5..59e71c4 100644 ---- a/src/glsl/ralloc.c -+++ b/src/glsl/ralloc.c -@@ -41,14 +41,6 @@ _CRTIMP int _vscprintf(const char *format, va_list argptr); - - #include "ralloc.h" - --#ifdef __GNUC__ --#define likely(x) __builtin_expect(!!(x),1) --#define unlikely(x) __builtin_expect(!!(x),0) --#else --#define likely(x) !!(x) --#define unlikely(x) !!(x) --#endif -- - #ifndef va_copy - #ifdef __va_copy - #define va_copy(dest, src) __va_copy((dest), (src)) -diff --git a/src/glsl/ralloc.h b/src/glsl/ralloc.h -index 86306b1..67eb938 100644 ---- a/src/glsl/ralloc.h -+++ b/src/glsl/ralloc.h -@@ -54,6 +54,7 @@ extern "C" { - #include - #include - #include -+#include "main/compiler.h" - - /** - * \def ralloc(ctx, type) -@@ -301,7 +302,7 @@ bool ralloc_strncat(char **dest, const char *str, size_t n); - * - * \return The newly allocated string. - */ --char *ralloc_asprintf (const void *ctx, const char *fmt, ...); -+char *ralloc_asprintf (const void *ctx, const char *fmt, ...) PRINTFLIKE(2, 3); - - /** - * Print to a string, given a va_list. -@@ -334,7 +335,8 @@ char *ralloc_vasprintf(const void *ctx, const char *fmt, va_list args); - * \return True unless allocation failed. - */ - bool ralloc_asprintf_rewrite_tail(char **str, size_t *start, -- const char *fmt, ...); -+ const char *fmt, ...) -+ PRINTFLIKE(3, 4); - - /** - * Rewrite the tail of an existing string, starting at a given index. -@@ -376,7 +378,8 @@ bool ralloc_vasprintf_rewrite_tail(char **str, size_t *start, const char *fmt, - * - * \return True unless allocation failed. - */ --bool ralloc_asprintf_append (char **str, const char *fmt, ...); -+bool ralloc_asprintf_append (char **str, const char *fmt, ...) -+ PRINTFLIKE(2, 3); - - /** - * Append formatted text to the supplied string, given a va_list. -diff --git a/src/glsl/tests/Makefile.am b/src/glsl/tests/Makefile.am -index ee3cef6..957bb55 100644 ---- a/src/glsl/tests/Makefile.am -+++ b/src/glsl/tests/Makefile.am -@@ -1,12 +1,9 @@ --INC = \ -+AM_CPPFLAGS = \ - -I$(top_builddir)/src/gtest/include \ - -I$(top_builddir)/src/mesa \ - -I$(top_builddir)/src/mapi \ - -I$(top_builddir)/src/glsl - --AM_CFLAGS = $(INC) --AM_CXXFLAGS = $(INC) -- - TESTS_ENVIRONMENT= \ - export PYTHON2=$(PYTHON2); \ - export PYTHON_FLAGS=$(PYTHON_FLAGS); -diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c -index 4e8b351..15f590e 100644 ---- a/src/glx/dri2_glx.c -+++ b/src/glx/dri2_glx.c -@@ -961,7 +961,7 @@ dri2BindExtensions(struct dri2_screen *psc, const __DRIextension **extensions) - __glXEnableDirectExtension(&psc->base, "GLX_SGI_make_current_read"); - - /* FIXME: if DRI2 version supports it... */ -- __glXEnableDirectExtension(&psc->base, "INTEL_swap_event"); -+ __glXEnableDirectExtension(&psc->base, "GLX_INTEL_swap_event"); - - if (psc->dri2->base.version >= 3) { - const unsigned mask = psc->dri2->getAPIMask(psc->driScreen); -diff --git a/src/glx/glxext.c b/src/glx/glxext.c -index a4e76c1..420e677 100644 ---- a/src/glx/glxext.c -+++ b/src/glx/glxext.c -@@ -83,6 +83,7 @@ static /* const */ char *error_list[] = { - "GLXBadPbuffer", - "GLXBadCurrentDrawable", - "GLXBadWindow", -+ "GLXBadProfileARB", - }; - - #ifdef GLX_USE_APPLEGL -@@ -404,6 +405,8 @@ __glXInitializeVisualConfigFromTags(struct glx_config * config, int count, - #endif - } - -+ config->sRGBCapable = GL_FALSE; -+ - /* - ** Additional properties may be in a list at the end - ** of the reply. They are in pairs of property type -diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml -index 751a18f..f83a7a7 100644 ---- a/src/mapi/glapi/gen/gl_API.xml -+++ b/src/mapi/glapi/gen/gl_API.xml -@@ -2981,7 +2981,6 @@ - - - -- - - - -@@ -8089,6 +8088,8 @@ - - - -+ -+ - - - -diff --git a/src/mesa/drivers/dri/i965/brw_misc_state.c b/src/mesa/drivers/dri/i965/brw_misc_state.c -index 6dfa08e..4799af2 100644 ---- a/src/mesa/drivers/dri/i965/brw_misc_state.c -+++ b/src/mesa/drivers/dri/i965/brw_misc_state.c -@@ -413,8 +413,10 @@ static void emit_depthbuffer(struct brw_context *brw) - * tile_x and tile_y to 0. This is a temporary workaround until we come - * up with a better solution. - */ -- tile_x &= ~7; -- tile_y &= ~7; -+ if (intel->gen >= 6) { -+ tile_x &= ~7; -+ tile_y &= ~7; -+ } - - BEGIN_BATCH(len); - OUT_BATCH(_3DSTATE_DEPTH_BUFFER << 16 | (len - 2)); -diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c -index f96583c..00a1b01 100644 ---- a/src/mesa/drivers/dri/intel/intel_screen.c -+++ b/src/mesa/drivers/dri/intel/intel_screen.c -@@ -26,6 +26,7 @@ - **************************************************************************/ - - #include -+#include - #include "main/glheader.h" - #include "main/context.h" - #include "main/framebuffer.h" -diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c -index c0e6bc7..a21ae10 100644 ---- a/src/mesa/main/context.c -+++ b/src/mesa/main/context.c -@@ -404,9 +404,6 @@ one_time_init( struct gl_context *ctx ) - - _mesa_get_cpu_features(); - -- /* context dependence is never a one-time thing... */ -- _mesa_init_get_hash(ctx); -- - for (i = 0; i < 256; i++) { - _mesa_ubyte_to_float_color_tab[i] = (float) i / 255.0F; - } -@@ -425,6 +422,8 @@ one_time_init( struct gl_context *ctx ) - - /* per-API one-time init */ - if (!(api_init_mask & (1 << ctx->API))) { -+ _mesa_init_get_hash(ctx); -+ - /* - * This is fine as ES does not use the remap table, but it may not be - * future-proof. We cannot always initialize the remap table because -diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c -index fe1035b..e2ccc29 100644 ---- a/src/mesa/main/get.c -+++ b/src/mesa/main/get.c -@@ -538,6 +538,11 @@ static const struct value_desc values[] = { - /* GL_{APPLE,ARB,OES}_vertex_array_object */ - { GL_VERTEX_ARRAY_BINDING_APPLE, ARRAY_INT(Name), NO_EXTRA }, - -+ /* GL_EXT_texture_filter_anisotropic */ -+ { GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, -+ CONTEXT_FLOAT(Const.MaxTextureMaxAnisotropy), -+ extra_EXT_texture_filter_anisotropic }, -+ - #if FEATURE_GL || FEATURE_ES1 - /* Enums in OpenGL and GLES1 */ - { 0, 0, TYPE_API_MASK, API_OPENGL_BIT | API_OPENGLES_BIT | API_OPENGL_CORE_BIT, NO_EXTRA }, -@@ -687,11 +692,6 @@ static const struct value_desc values[] = { - /* GL_EXT_texture_lod_bias */ - { GL_MAX_TEXTURE_LOD_BIAS_EXT, CONTEXT_FLOAT(Const.MaxTextureLodBias), - NO_EXTRA }, -- -- /* GL_EXT_texture_filter_anisotropic */ -- { GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, -- CONTEXT_FLOAT(Const.MaxTextureMaxAnisotropy), -- extra_EXT_texture_filter_anisotropic }, - #endif /* FEATURE_GL || FEATURE_ES1 */ - - #if FEATURE_ES1 -@@ -791,6 +791,15 @@ static const struct value_desc values[] = { - - #endif /* FEATURE_GL || FEATURE_ES2 */ - -+#if FEATURE_ES1 || FEATURE_ES2 -+ { 0, 0, TYPE_API_MASK, API_OPENGLES | API_OPENGLES2_BIT, NO_EXTRA }, -+ /* GL_OES_EGL_image_external */ -+ { GL_TEXTURE_BINDING_EXTERNAL_OES, LOC_CUSTOM, -+ TYPE_INT, TEXTURE_EXTERNAL_INDEX, extra_OES_EGL_image_external }, -+ { GL_TEXTURE_EXTERNAL_OES, LOC_CUSTOM, -+ TYPE_BOOLEAN, 0, extra_OES_EGL_image_external }, -+#endif -+ - #if FEATURE_ES2 - /* Enums unique to OpenGL ES 2.0 */ - { 0, 0, TYPE_API_MASK, API_OPENGLES2_BIT, NO_EXTRA }, -@@ -803,12 +812,6 @@ static const struct value_desc values[] = { - { GL_SHADER_BINARY_FORMATS, CONST(0), NO_EXTRA }, - #endif /* FEATURE_ES2 */ - -- /* GL_OES_EGL_image_external */ -- { GL_TEXTURE_BINDING_EXTERNAL_OES, LOC_CUSTOM, -- TYPE_INT, TEXTURE_EXTERNAL_INDEX, extra_OES_EGL_image_external }, -- { GL_TEXTURE_EXTERNAL_OES, LOC_CUSTOM, -- TYPE_BOOLEAN, 0, extra_OES_EGL_image_external }, -- - #if FEATURE_GL - /* Remaining enums are only in OpenGL */ - { 0, 0, TYPE_API_MASK, API_OPENGL_BIT | API_OPENGL_CORE_BIT, NO_EXTRA }, -@@ -1384,45 +1387,54 @@ static const struct value_desc values[] = { - * collisions for any enum (typical numbers). And the code is very - * simple, even though it feels a little magic. */ - --static unsigned short table[1024]; -+static unsigned short table[API_LAST + 1][1024]; - static const int prime_factor = 89, prime_step = 281; - - #ifdef GET_DEBUG - static void --print_table_stats(void) -+print_table_stats(int api) - { - int i, j, collisions[11], count, hash, mask; - const struct value_desc *d; -- -+ const char *api_names[] = { -+ [API_OPENGL] = "GL", -+ [API_OPENGL_CORE] = "GL_CORE", -+ [API_OPENGLES] = "GLES", -+ [API_OPENGLES2] = "GLES2", -+ }; -+ const char *api_name; -+ -+ api_name = api < Elements(api_names) ? api_names[api] : "N/A"; - count = 0; -- mask = Elements(table) - 1; -+ mask = Elements(table[api]) - 1; - memset(collisions, 0, sizeof collisions); - -- for (i = 0; i < Elements(table); i++) { -- if (!table[i]) -- continue; -+ for (i = 0; i < Elements(table[api]); i++) { -+ if (!table[api][i]) -+ continue; - count++; -- d = &values[table[i]]; -+ d = &values[table[api][i]]; - hash = (d->pname * prime_factor); - j = 0; - while (1) { -- if (values[table[hash & mask]].pname == d->pname) -- break; -- hash += prime_step; -- j++; -+ if (values[table[api][hash & mask]].pname == d->pname) -+ break; -+ hash += prime_step; -+ j++; - } - - if (j < 10) -- collisions[j]++; -+ collisions[j]++; - else -- collisions[10]++; -+ collisions[10]++; - } - -- printf("number of enums: %d (total %d)\n", count, Elements(values)); -+ printf("number of enums for %s: %d (total %ld)\n", -+ api_name, count, Elements(values)); - for (i = 0; i < Elements(collisions) - 1; i++) - if (collisions[i] > 0) -- printf(" %d enums with %d %scollisions\n", -- collisions[i], i, i == 10 ? "or more " : ""); -+ printf(" %d enums with %d %scollisions\n", -+ collisions[i], i, i == 10 ? "or more " : ""); - } - #endif - -@@ -1437,27 +1449,30 @@ print_table_stats(void) - void _mesa_init_get_hash(struct gl_context *ctx) - { - int i, hash, index, mask; -+ int api; - int api_mask = 0, api_bit; - -- mask = Elements(table) - 1; -- api_bit = 1 << ctx->API; -+ api = ctx->API; -+ -+ mask = Elements(table[api]) - 1; -+ api_bit = 1 << api; - - for (i = 0; i < Elements(values); i++) { - if (values[i].type == TYPE_API_MASK) { -- api_mask = values[i].offset; -- continue; -+ api_mask = values[i].offset; -+ continue; - } - if (!(api_mask & api_bit)) -- continue; -+ continue; - - hash = (values[i].pname * prime_factor) & mask; - while (1) { -- index = hash & mask; -- if (!table[index]) { -- table[index] = i; -- break; -- } -- hash += prime_step; -+ index = hash & mask; -+ if (!table[api][index]) { -+ table[api][index] = i; -+ break; -+ } -+ hash += prime_step; - } - } - -@@ -1985,22 +2000,24 @@ find_value(const char *func, GLenum pname, void **p, union value *v) - struct gl_texture_unit *unit; - int mask, hash; - const struct value_desc *d; -+ int api; - -- mask = Elements(table) - 1; -+ api = ctx->API; -+ mask = Elements(table[api]) - 1; - hash = (pname * prime_factor); - while (1) { -- d = &values[table[hash & mask]]; -+ d = &values[table[api][hash & mask]]; - - /* If the enum isn't valid, the hash walk ends with index 0, - * which is the API mask entry at the beginning of values[]. */ - if (unlikely(d->type == TYPE_API_MASK)) { -- _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=%s)", func, -- _mesa_lookup_enum_by_nr(pname)); -- return &error_value; -+ _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=%s)", func, -+ _mesa_lookup_enum_by_nr(pname)); -+ return &error_value; - } - - if (likely(d->pname == pname)) -- break; -+ break; - - hash += prime_step; - } -diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h -index ba43e57..f185ffd 100644 ---- a/src/mesa/main/mtypes.h -+++ b/src/mesa/main/mtypes.h -@@ -3340,6 +3340,8 @@ typedef enum - API_OPENGLES, - API_OPENGLES2, - API_OPENGL_CORE, -+ -+ API_LAST = API_OPENGL_CORE, - } gl_api; - - /** -diff --git a/src/mesa/main/tests/enum_strings.cpp b/src/mesa/main/tests/enum_strings.cpp -index 7d46080..f4f424d 100644 ---- a/src/mesa/main/tests/enum_strings.cpp -+++ b/src/mesa/main/tests/enum_strings.cpp -@@ -563,7 +563,7 @@ const struct enum_info everything[] = { - { 0x8036, "GL_UNSIGNED_INT_10_10_10_2" }, - { 0x8037, "GL_POLYGON_OFFSET_FILL" }, - { 0x8038, "GL_POLYGON_OFFSET_FACTOR" }, -- { 0x8039, "GL_POLYGON_OFFSET_BIAS" }, -+ { 0x8039, "GL_POLYGON_OFFSET_BIAS_EXT" }, - { 0x803A, "GL_RESCALE_NORMAL" }, - { 0x803B, "GL_ALPHA4" }, - { 0x803C, "GL_ALPHA8" }, -diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c -index 21646cc..38fa9fa 100644 ---- a/src/mesa/main/teximage.c -+++ b/src/mesa/main/teximage.c -@@ -3034,13 +3034,15 @@ teximage(struct gl_context *ctx, GLboolean compressed, GLuint dims, - border, internalFormat, texFormat); - - /* Give the texture to the driver. may be null. */ -- if (compressed) { -- ctx->Driver.CompressedTexImage(ctx, dims, texImage, -- imageSize, pixels); -- } -- else { -- ctx->Driver.TexImage(ctx, dims, texImage, format, -- type, pixels, unpack); -+ if (width > 0 && height > 0 && depth > 0) { -+ if (compressed) { -+ ctx->Driver.CompressedTexImage(ctx, dims, texImage, -+ imageSize, pixels); -+ } -+ else { -+ ctx->Driver.TexImage(ctx, dims, texImage, format, -+ type, pixels, unpack); -+ } - } - - check_gen_mipmap(ctx, target, texObj, level); -@@ -3596,10 +3598,10 @@ compressed_subtexture_error_check(struct gl_context *ctx, GLint dimensions, - if (!_mesa_is_compressed_format(ctx, format)) - return GL_INVALID_ENUM; - -- if (width < 1 || width > maxTextureSize) -+ if (width < 0 || width > maxTextureSize) - return GL_INVALID_VALUE; - -- if ((height < 1 || height > maxTextureSize) -+ if ((height < 0 || height > maxTextureSize) - && dimensions > 1) - return GL_INVALID_VALUE; - -diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c -index ed3bbc7..b8e2538 100644 ---- a/src/mesa/state_tracker/st_cb_texture.c -+++ b/src/mesa/state_tracker/st_cb_texture.c -@@ -1130,11 +1130,18 @@ copy_image_data_to_texture(struct st_context *st, - /* Copy potentially with the blitter: - */ - GLuint src_level; -- if (stImage->pt != stObj->pt) -+ if (stImage->pt->last_level == 0) - src_level = 0; - else - src_level = stImage->base.Level; - -+ assert(src_level <= stImage->pt->last_level); -+ assert(u_minify(stImage->pt->width0, src_level) == stImage->base.Width); -+ assert(stImage->pt->target == PIPE_TEXTURE_1D_ARRAY || -+ u_minify(stImage->pt->height0, src_level) == stImage->base.Height); -+ assert(stImage->pt->target == PIPE_TEXTURE_2D_ARRAY || -+ u_minify(stImage->pt->depth0, src_level) == stImage->base.Depth); -+ - st_texture_image_copy(st->pipe, - stObj->pt, dstLevel, /* dest texture, level */ - stImage->pt, src_level, /* src texture, level */ diff --git a/mesa-9.0.1-22-gd0a9ab2.patch b/mesa-9.0.1-22-gd0a9ab2.patch deleted file mode 100644 index fb10a04..0000000 --- a/mesa-9.0.1-22-gd0a9ab2.patch +++ /dev/null @@ -1,1834 +0,0 @@ -diff --git a/configs/current.in b/configs/current.in -index 1802271..62edfa5 100644 ---- a/configs/current.in -+++ b/configs/current.in -@@ -144,7 +144,7 @@ GLAPI_LIB_DEPS = @GLAPI_LIB_DEPS@ - DRI_LIB_DEPS = @DRI_LIB_DEPS@ - GALLIUM_DRI_LIB_DEPS = @GALLIUM_DRI_LIB_DEPS@ - LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ --LIBDRM_LIB = @LIBDRM_LIBS@ -+LIBDRM_LIBS = @LIBDRM_LIBS@ - DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ - GLPROTO_CFLAGS = @GLPROTO_CFLAGS@ - EXPAT_INCLUDES = @EXPAT_INCLUDES@ -diff --git a/docs/GL3.txt b/docs/GL3.txt -index 24b70a1..9035779 100644 ---- a/docs/GL3.txt -+++ b/docs/GL3.txt -@@ -34,8 +34,7 @@ sRGB framebuffer format (GL_EXT_framebuffer_sRGB) DONE (i965, r600) - glClearBuffer commands DONE - glGetStringi command DONE - glTexParameterI, glGetTexParameterI commands DONE --glVertexAttribI commands ~50% done (converts int -- values to floats) -+glVertexAttribI commands DONE - Depth format cube textures DONE - GLX_ARB_create_context (GLX 1.4 is required) DONE - -diff --git a/docs/news.html b/docs/news.html -index 26e648b..399a537 100644 ---- a/docs/news.html -+++ b/docs/news.html -@@ -9,6 +9,14 @@ - -

News

- -+

November 16, 2012

-+ -+

-+Mesa 9.0.1 is released. -+This is a bug fix release. -+

-+ -+ -

October 8, 2012

- -

-diff --git a/docs/relnotes-9.0.1.html b/docs/relnotes-9.0.1.html -index 8a354b0..ed8f1a7 100644 ---- a/docs/relnotes-9.0.1.html -+++ b/docs/relnotes-9.0.1.html -@@ -7,7 +7,7 @@ - - - --

Mesa 9.0.1 Release Notes / November 14th, 2012

-+

Mesa 9.0.1 Release Notes / November 16th, 2012

- -

- Mesa 9.0.1 is a bug fix release which fixes bugs found since the 9.0 release. -@@ -23,7 +23,9 @@ because GL_ARB_compatibility is not supported. - -

MD5 checksums

-
--TBD.
-+97d6554c05ea7449398afe3a0ede7018  MesaLib-9.0.1.tar.bz2
-+fd0fd5a6e56bc3dd210c80e42baef975  MesaLib-9.0.1.tar.gz
-+c2683d957acd530a00f747f50317186f  MesaLib-9.0.1.zip
- 
- -

New features

-diff --git a/src/gallium/auxiliary/draw/draw_vertex.h b/src/gallium/auxiliary/draw/draw_vertex.h -index e63cf5f..c87c3d8 100644 ---- a/src/gallium/auxiliary/draw/draw_vertex.h -+++ b/src/gallium/auxiliary/draw/draw_vertex.h -@@ -42,6 +42,7 @@ - #include "pipe/p_compiler.h" - #include "pipe/p_state.h" - #include "util/u_debug.h" -+#include "util/u_memory.h" - - - /** -@@ -87,7 +88,7 @@ struct vertex_info - unsigned interp_mode:4; /**< INTERP_x */ - unsigned emit:4; /**< EMIT_x */ - unsigned src_index:8; /**< map to post-xform attribs */ -- } attrib[PIPE_MAX_SHADER_INPUTS]; -+ } attrib[PIPE_MAX_SHADER_OUTPUTS]; - }; - - static INLINE size_t -@@ -127,7 +128,7 @@ draw_emit_vertex_attr(struct vertex_info *vinfo, - uint src_index) - { - const uint n = vinfo->num_attribs; -- assert(n < PIPE_MAX_SHADER_INPUTS); -+ assert(n < Elements(vinfo->attrib)); - vinfo->attrib[n].emit = emit; - vinfo->attrib[n].interp_mode = interp; - vinfo->attrib[n].src_index = src_index; -diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c -index 3fe78e0..3c2a923 100644 ---- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c -+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c -@@ -73,7 +73,7 @@ struct ureg_tokens { - - #define UREG_MAX_INPUT PIPE_MAX_ATTRIBS - #define UREG_MAX_SYSTEM_VALUE PIPE_MAX_ATTRIBS --#define UREG_MAX_OUTPUT PIPE_MAX_ATTRIBS -+#define UREG_MAX_OUTPUT PIPE_MAX_SHADER_OUTPUTS - #define UREG_MAX_CONSTANT_RANGE 32 - #define UREG_MAX_IMMEDIATE 256 - #define UREG_MAX_ADDR 2 -diff --git a/src/gallium/drivers/nv50/codegen/nv50_ir_from_tgsi.cpp b/src/gallium/drivers/nv50/codegen/nv50_ir_from_tgsi.cpp -index 071674b..e73c804 100644 ---- a/src/gallium/drivers/nv50/codegen/nv50_ir_from_tgsi.cpp -+++ b/src/gallium/drivers/nv50/codegen/nv50_ir_from_tgsi.cpp -@@ -257,7 +257,7 @@ unsigned int Instruction::srcMask(unsigned int s) const - mask &= 0x9; - break; - case TGSI_TEXTURE_SHADOW1D: -- mask &= 0x5; -+ mask &= 0xd; - break; - case TGSI_TEXTURE_1D_ARRAY: - case TGSI_TEXTURE_2D: -diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c -index 3d510ea..982948e 100644 ---- a/src/gallium/drivers/nv50/nv50_screen.c -+++ b/src/gallium/drivers/nv50/nv50_screen.c -@@ -454,6 +454,18 @@ nv50_screen_init_hwctx(struct nv50_screen *screen) - PUSH_DATA (push, (NV50_CB_AUX << 12) | 0xf21); - PUSH_DATA (push, (NV50_CB_AUX << 12) | 0xf31); - -+ /* return { 0.0, 0.0, 0.0, 0.0 } on out-of-bounds vtxbuf access */ -+ BEGIN_NV04(push, NV50_3D(CB_ADDR), 1); -+ PUSH_DATA (push, ((1 << 9) << 6) | NV50_CB_AUX); -+ BEGIN_NI04(push, NV50_3D(CB_DATA(0)), 4); -+ PUSH_DATAf(push, 0.0f); -+ PUSH_DATAf(push, 0.0f); -+ PUSH_DATAf(push, 0.0f); -+ PUSH_DATAf(push, 0.0f); -+ BEGIN_NV04(push, NV50_3D(VERTEX_RUNOUT_ADDRESS_HIGH), 2); -+ PUSH_DATAh(push, screen->uniforms->offset + (3 << 16) + (1 << 9)); -+ PUSH_DATA (push, screen->uniforms->offset + (3 << 16) + (1 << 9)); -+ - /* max TIC (bits 4:8) & TSC bindings, per program type */ - for (i = 0; i < 3; ++i) { - BEGIN_NV04(push, NV50_3D(TEX_LIMITS(i)), 1); -diff --git a/src/gallium/drivers/nvc0/nvc0_context.c b/src/gallium/drivers/nvc0/nvc0_context.c -index b021f2e..9c43ae6 100644 ---- a/src/gallium/drivers/nvc0/nvc0_context.c -+++ b/src/gallium/drivers/nvc0/nvc0_context.c -@@ -183,6 +183,7 @@ nvc0_create(struct pipe_screen *pscreen, void *priv) - BCTX_REFN_bo(nvc0->bufctx_3d, SCREEN, flags, screen->text); - BCTX_REFN_bo(nvc0->bufctx_3d, SCREEN, flags, screen->uniform_bo); - BCTX_REFN_bo(nvc0->bufctx_3d, SCREEN, flags, screen->txc); -+ BCTX_REFN_bo(nvc0->bufctx_3d, SCREEN, flags, screen->poly_cache); - - flags = NOUVEAU_BO_GART | NOUVEAU_BO_WR; - -diff --git a/src/gallium/drivers/nvc0/nvc0_screen.c b/src/gallium/drivers/nvc0/nvc0_screen.c -index eb74e95..8bb9ff6 100644 ---- a/src/gallium/drivers/nvc0/nvc0_screen.c -+++ b/src/gallium/drivers/nvc0/nvc0_screen.c -@@ -589,7 +589,7 @@ nvc0_screen_create(struct nouveau_device *dev) - - for (i = 0; i < 5; ++i) { - /* TIC and TSC entries for each unit (nve4+ only) */ -- /* auxiliary constants (6 user clip planes, base instance id */ -+ /* auxiliary constants (6 user clip planes, base instance id) */ - BEGIN_NVC0(push, NVC0_3D(CB_SIZE), 3); - PUSH_DATA (push, 512); - PUSH_DATAh(push, screen->uniform_bo->offset + (5 << 16) + (i << 9)); -@@ -610,6 +610,21 @@ nvc0_screen_create(struct nouveau_device *dev) - BEGIN_NVC0(push, NVC0_3D(LINKED_TSC), 1); - PUSH_DATA (push, 0); - -+ /* return { 0.0, 0.0, 0.0, 0.0 } for out-of-bounds vtxbuf access */ -+ BEGIN_NVC0(push, NVC0_3D(CB_SIZE), 3); -+ PUSH_DATA (push, 256); -+ PUSH_DATAh(push, screen->uniform_bo->offset + (5 << 16) + (6 << 9)); -+ PUSH_DATA (push, screen->uniform_bo->offset + (5 << 16) + (6 << 9)); -+ BEGIN_1IC0(push, NVC0_3D(CB_POS), 5); -+ PUSH_DATA (push, 0); -+ PUSH_DATAf(push, 0.0f); -+ PUSH_DATAf(push, 0.0f); -+ PUSH_DATAf(push, 0.0f); -+ PUSH_DATAf(push, 0.0f); -+ BEGIN_NVC0(push, NVC0_3D(VERTEX_RUNOUT_ADDRESS_HIGH), 2); -+ PUSH_DATAh(push, screen->uniform_bo->offset + (5 << 16) + (6 << 9)); -+ PUSH_DATA (push, screen->uniform_bo->offset + (5 << 16) + (6 << 9)); -+ - /* max MPs * max warps per MP (TODO: ask kernel) */ - if (screen->eng3d->oclass >= NVE4_3D_CLASS) - screen->tls_size = 8 * 64; -@@ -734,10 +749,6 @@ nvc0_screen_create(struct nouveau_device *dev) - - IMMED_NVC0(push, NVC0_3D(EDGEFLAG), 1); - -- BEGIN_NVC0(push, NVC0_3D(VERTEX_RUNOUT_ADDRESS_HIGH), 2); -- PUSH_DATA (push, 0xab); -- PUSH_DATA (push, 0x00000000); -- - PUSH_KICK (push); - - screen->tic.entries = CALLOC(4096, sizeof(void *)); -diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c -index 940179c..3ccf396 100644 ---- a/src/gallium/drivers/r300/r300_state_derived.c -+++ b/src/gallium/drivers/r300/r300_state_derived.c -@@ -655,6 +655,12 @@ static uint32_t r300_get_border_color(enum pipe_format format, - case PIPE_FORMAT_LATC2_UNORM: - util_pack_color(border_swizzled, PIPE_FORMAT_R8G8B8A8_UNORM, &uc); - return uc.ui; -+ case PIPE_FORMAT_DXT1_SRGB: -+ case PIPE_FORMAT_DXT1_SRGBA: -+ case PIPE_FORMAT_DXT3_SRGBA: -+ case PIPE_FORMAT_DXT5_SRGBA: -+ util_pack_color(border_swizzled, PIPE_FORMAT_B8G8R8A8_SRGB, &uc); -+ return uc.ui; - default: - util_pack_color(border_swizzled, PIPE_FORMAT_B8G8R8A8_UNORM, &uc); - return uc.ui; -@@ -685,10 +691,18 @@ static uint32_t r300_get_border_color(enum pipe_format format, - - default: - case 8: -- if (desc->channel[0].type == UTIL_FORMAT_TYPE_SIGNED) -- util_pack_color(border_swizzled, PIPE_FORMAT_R8G8B8A8_SNORM, &uc); -- else -- util_pack_color(border_swizzled, PIPE_FORMAT_R8G8B8A8_UNORM, &uc); -+ if (desc->channel[0].type == UTIL_FORMAT_TYPE_SIGNED) { -+ util_pack_color(border_swizzled, PIPE_FORMAT_R8G8B8A8_SNORM, &uc); -+ } else if (desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB) { -+ if (desc->nr_channels == 2) { -+ border_swizzled[3] = border_swizzled[1]; -+ util_pack_color(border_swizzled, PIPE_FORMAT_L8A8_SRGB, &uc); -+ } else { -+ util_pack_color(border_swizzled, PIPE_FORMAT_R8G8B8A8_SRGB, &uc); -+ } -+ } else { -+ util_pack_color(border_swizzled, PIPE_FORMAT_R8G8B8A8_UNORM, &uc); -+ } - break; - - case 10: -diff --git a/src/gallium/drivers/r600/r600_hw_context.c b/src/gallium/drivers/r600/r600_hw_context.c -index 7b7b6b1..af27fd9 100644 ---- a/src/gallium/drivers/r600/r600_hw_context.c -+++ b/src/gallium/drivers/r600/r600_hw_context.c -@@ -1080,13 +1080,14 @@ void r600_context_streamout_begin(struct r600_context *ctx) - unsigned *stride_in_dw = ctx->vs_shader->so.stride; - unsigned buffer_en, i, update_flags = 0; - uint64_t va; -+ unsigned num_cs_dw_streamout_end; - - buffer_en = (ctx->num_so_targets >= 1 && t[0] ? 1 : 0) | - (ctx->num_so_targets >= 2 && t[1] ? 2 : 0) | - (ctx->num_so_targets >= 3 && t[2] ? 4 : 0) | - (ctx->num_so_targets >= 4 && t[3] ? 8 : 0); - -- ctx->num_cs_dw_streamout_end = -+ num_cs_dw_streamout_end = - 12 + /* flush_vgt_streamout */ - util_bitcount(buffer_en) * 8 + /* STRMOUT_BUFFER_UPDATE */ - 3 /* set_streamout_enable(0) */; -@@ -1095,11 +1096,15 @@ void r600_context_streamout_begin(struct r600_context *ctx) - 12 + /* flush_vgt_streamout */ - 6 + /* set_streamout_enable */ - util_bitcount(buffer_en) * 7 + /* SET_CONTEXT_REG */ -- (ctx->chip_class == R700 ? util_bitcount(buffer_en) * 5 : 0) + /* STRMOUT_BASE_UPDATE */ -+ (ctx->family >= CHIP_RS780 && -+ ctx->family <= CHIP_RV740 ? util_bitcount(buffer_en) * 5 : 0) + /* STRMOUT_BASE_UPDATE */ - util_bitcount(buffer_en & ctx->streamout_append_bitmask) * 8 + /* STRMOUT_BUFFER_UPDATE */ - util_bitcount(buffer_en & ~ctx->streamout_append_bitmask) * 6 + /* STRMOUT_BUFFER_UPDATE */ -- (ctx->family > CHIP_R600 && ctx->family < CHIP_RV770 ? 2 : 0) + /* SURFACE_BASE_UPDATE */ -- ctx->num_cs_dw_streamout_end, TRUE); -+ (ctx->family > CHIP_R600 && ctx->family < CHIP_RS780 ? 2 : 0) + /* SURFACE_BASE_UPDATE */ -+ num_cs_dw_streamout_end, TRUE); -+ -+ /* This must be set after r600_need_cs_space. */ -+ ctx->num_cs_dw_streamout_end = num_cs_dw_streamout_end; - - if (ctx->chip_class >= EVERGREEN) { - evergreen_flush_vgt_streamout(ctx); -@@ -1133,7 +1138,7 @@ void r600_context_streamout_begin(struct r600_context *ctx) - - /* R7xx requires this packet after updating BUFFER_BASE. - * Without this, R7xx locks up. */ -- if (ctx->chip_class == R700) { -+ if (ctx->family >= CHIP_RS780 && ctx->family <= CHIP_RV740) { - cs->buf[cs->cdw++] = PKT3(PKT3_STRMOUT_BASE_UPDATE, 1, 0); - cs->buf[cs->cdw++] = i; - cs->buf[cs->cdw++] = va >> 8; -@@ -1173,7 +1178,7 @@ void r600_context_streamout_begin(struct r600_context *ctx) - } - } - -- if (ctx->family > CHIP_R600 && ctx->family < CHIP_RV770) { -+ if (ctx->family > CHIP_R600 && ctx->family < CHIP_RS780) { - cs->buf[cs->cdw++] = PKT3(PKT3_SURFACE_BASE_UPDATE, 0, 0); - cs->buf[cs->cdw++] = update_flags; - } -diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c -index 286c676..be30c7e 100644 ---- a/src/gallium/drivers/r600/r600_pipe.c -+++ b/src/gallium/drivers/r600/r600_pipe.c -@@ -443,7 +443,7 @@ static int r600_get_param(struct pipe_screen* pscreen, enum pipe_cap param) - return rscreen->has_streamout ? 1 : 0; - case PIPE_CAP_MAX_STREAM_OUTPUT_SEPARATE_COMPONENTS: - case PIPE_CAP_MAX_STREAM_OUTPUT_INTERLEAVED_COMPONENTS: -- return 16*4; -+ return 32*4; - - /* Texturing. */ - case PIPE_CAP_MAX_TEXTURE_2D_LEVELS: -@@ -933,13 +933,19 @@ struct pipe_screen *r600_screen_create(struct radeon_winsys *ws) - /* Figure out streamout kernel support. */ - switch (rscreen->chip_class) { - case R600: -- case EVERGREEN: -- case CAYMAN: -- rscreen->has_streamout = rscreen->info.drm_minor >= 14; -+ if (rscreen->family < CHIP_RS780) { -+ rscreen->has_streamout = rscreen->info.drm_minor >= 14; -+ } else { -+ rscreen->has_streamout = rscreen->info.drm_minor >= 23; -+ } - break; - case R700: - rscreen->has_streamout = rscreen->info.drm_minor >= 17; - break; -+ case EVERGREEN: -+ case CAYMAN: -+ rscreen->has_streamout = rscreen->info.drm_minor >= 14; -+ break; - } - - if (r600_init_tiling(rscreen)) { -diff --git a/src/gallium/drivers/r600/r600_shader.c b/src/gallium/drivers/r600/r600_shader.c -index 21019b7..1f8ab2b 100644 ---- a/src/gallium/drivers/r600/r600_shader.c -+++ b/src/gallium/drivers/r600/r600_shader.c -@@ -4012,6 +4012,23 @@ static int tgsi_tex(struct r600_shader_ctx *ctx) - if (r) - return r; - } -+ -+ /* for cube forms of lod and bias we need to route the lod -+ value into Z */ -+ if (inst->Instruction.Opcode == TGSI_OPCODE_TXB || -+ inst->Instruction.Opcode == TGSI_OPCODE_TXL) { -+ memset(&alu, 0, sizeof(struct r600_bytecode_alu)); -+ alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV); -+ r600_bytecode_src(&alu.src[0], &ctx->src[0], 3); -+ alu.dst.sel = ctx->temp_reg; -+ alu.dst.chan = 2; -+ alu.last = 1; -+ alu.dst.write = 1; -+ r = r600_bytecode_add_alu(ctx->bc, &alu); -+ if (r) -+ return r; -+ } -+ - src_loaded = TRUE; - src_gpr = ctx->temp_reg; - } -@@ -4087,17 +4104,12 @@ static int tgsi_tex(struct r600_shader_ctx *ctx) - tex.src_rel = ctx->src[0].rel; - } - -- if (inst->Texture.Texture == TGSI_TEXTURE_CUBE) { -- tex.src_sel_x = 1; -- tex.src_sel_y = 0; -- tex.src_sel_z = 3; -- tex.src_sel_w = 1; -- } -- if (inst->Texture.Texture == TGSI_TEXTURE_SHADOWCUBE) { -+ if (inst->Texture.Texture == TGSI_TEXTURE_CUBE || -+ inst->Texture.Texture == TGSI_TEXTURE_SHADOWCUBE) { - tex.src_sel_x = 1; - tex.src_sel_y = 0; - tex.src_sel_z = 3; -- tex.src_sel_w = 2; /* route Z compare value into W */ -+ tex.src_sel_w = 2; /* route Z compare or Lod value into W */ - } - - if (inst->Texture.Texture != TGSI_TEXTURE_RECT && -diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h -index 9ea9c0e..a67c43e 100644 ---- a/src/gallium/include/pipe/p_state.h -+++ b/src/gallium/include/pipe/p_state.h -@@ -59,7 +59,7 @@ extern "C" { - #define PIPE_MAX_CONSTANT_BUFFERS 32 - #define PIPE_MAX_SAMPLERS 16 - #define PIPE_MAX_SHADER_INPUTS 32 --#define PIPE_MAX_SHADER_OUTPUTS 32 -+#define PIPE_MAX_SHADER_OUTPUTS 48 /* 32 GENERICs + POS, PSIZE, FOG, etc. */ - #define PIPE_MAX_SHADER_SAMPLER_VIEWS 32 - #define PIPE_MAX_SHADER_RESOURCES 32 - #define PIPE_MAX_TEXTURE_LEVELS 16 -@@ -145,7 +145,7 @@ struct pipe_rasterizer_state - unsigned line_stipple_factor:8; /**< [1..256] actually */ - unsigned line_stipple_pattern:16; - -- unsigned sprite_coord_enable:PIPE_MAX_SHADER_OUTPUTS; -+ unsigned sprite_coord_enable; /* bitfield referring to 32 GENERIC inputs */ - - float line_width; - float point_size; /**< used when no per-vertex size */ -diff --git a/src/gallium/targets/dri-i915/Makefile b/src/gallium/targets/dri-i915/Makefile -index ddebff2..a835ee7 100644 ---- a/src/gallium/targets/dri-i915/Makefile -+++ b/src/gallium/targets/dri-i915/Makefile -@@ -28,6 +28,6 @@ endif - - include ../Makefile.dri - --GALLIUM_DRI_LIB_DEPS += -ldrm_intel -+GALLIUM_DRI_LIB_DEPS += $(INTEL_LIBS) - - symlinks: -diff --git a/src/gallium/targets/dri-r300/Makefile b/src/gallium/targets/dri-r300/Makefile -index 256aa23..63a2956 100644 ---- a/src/gallium/targets/dri-r300/Makefile -+++ b/src/gallium/targets/dri-r300/Makefile -@@ -21,6 +21,6 @@ DRIVER_DEFINES = \ - - include ../Makefile.dri - --GALLIUM_DRI_LIB_DEPS += -ldrm_radeon -+GALLIUM_DRI_LIB_DEPS += $(RADEON_LIBS) - - symlinks: -diff --git a/src/gallium/targets/dri-r600/Makefile b/src/gallium/targets/dri-r600/Makefile -index 7402750..2499ede 100644 ---- a/src/gallium/targets/dri-r600/Makefile -+++ b/src/gallium/targets/dri-r600/Makefile -@@ -21,6 +21,6 @@ DRIVER_DEFINES = \ - - include ../Makefile.dri - --GALLIUM_DRI_LIB_DEPS += -ldrm_radeon -+GALLIUM_DRI_LIB_DEPS += $(RADEON_LIBS) - - symlinks: -diff --git a/src/gallium/targets/dri-radeonsi/Makefile b/src/gallium/targets/dri-radeonsi/Makefile -index b45f243..588946e 100644 ---- a/src/gallium/targets/dri-radeonsi/Makefile -+++ b/src/gallium/targets/dri-radeonsi/Makefile -@@ -21,6 +21,6 @@ DRIVER_DEFINES = \ - - include ../Makefile.dri - --GALLIUM_DRI_LIB_DEPS += -ldrm_radeon -+GALLIUM_DRI_LIB_DEPS += $(RADEON_LIBS) - - symlinks: -diff --git a/src/gallium/targets/egl-static/Makefile b/src/gallium/targets/egl-static/Makefile -index f05c81d..08626a9 100644 ---- a/src/gallium/targets/egl-static/Makefile -+++ b/src/gallium/targets/egl-static/Makefile -@@ -48,17 +48,17 @@ egl_SYS += $(LIBUDEV_LIBS) $(DLOPEN_LIBS) -lEGL -lm -lpthread - ifneq ($(findstring x11, $(EGL_PLATFORMS)),) - egl_CPPFLAGS += $(LIBDRM_CFLAGS) - egl_LIBS += $(TOP)/src/gallium/winsys/sw/xlib/libws_xlib.a --egl_SYS += -lX11 -lXext -lXfixes $(LIBDRM_LIB) -+egl_SYS += -lX11 -lXext -lXfixes $(LIBDRM_LIBS) - endif - ifneq ($(findstring wayland, $(EGL_PLATFORMS)),) - egl_CPPFLAGS += $(LIBDRM_CFLAGS) - egl_LIBS += $(TOP)/src/gallium/winsys/sw/wayland/libws_wayland.a - egl_LIBS += $(TOP)/src/egl/wayland/wayland-drm/.libs/libwayland-drm.a --egl_SYS += $(LIBDRM_LIB) $(WAYLAND_LIBS) -+egl_SYS += $(LIBDRM_LIBS) $(WAYLAND_LIBS) - endif - ifneq ($(findstring drm, $(EGL_PLATFORMS)),) - egl_CPPFLAGS += $(LIBDRM_CFLAGS) --egl_SYS += $(LIBDRM_LIB) -lgbm -+egl_SYS += $(LIBDRM_LIBS) -lgbm - endif - ifneq ($(findstring fbdev, $(EGL_PLATFORMS)),) - egl_LIBS += $(TOP)/src/gallium/winsys/sw/fbdev/libfbdev.a -@@ -93,7 +93,7 @@ egl_CPPFLAGS += -D_EGL_PIPE_I915=1 - egl_LIBS += \ - $(TOP)/src/gallium/winsys/i915/drm/libi915drm.a \ - $(TOP)/src/gallium/drivers/i915/libi915.a --egl_SYS += -ldrm_intel -+egl_SYS += $(INTEL_LIBS) - endif - - # nouveau -@@ -105,7 +105,7 @@ egl_LIBS += \ - $(TOP)/src/gallium/drivers/nv50/libnv50.a \ - $(TOP)/src/gallium/drivers/nvc0/libnvc0.a \ - $(TOP)/src/gallium/drivers/nouveau/libnouveau.a --egl_SYS += -ldrm_nouveau -+egl_SYS += $(NOUVEAU_LIBS) - endif - - # r300 -@@ -115,7 +115,7 @@ egl_CPPFLAGS += -D_EGL_PIPE_R300=1 - egl_LIBS += \ - $(TOP)/src/gallium/winsys/radeon/drm/libradeonwinsys.a \ - $(TOP)/src/gallium/drivers/r300/libr300.a --egl_SYS += -ldrm_radeon -+egl_SYS += $(RADEON_LIBS) - endif - endif - -@@ -126,7 +126,7 @@ egl_CPPFLAGS += -D_EGL_PIPE_R600=1 - egl_LIBS += \ - $(TOP)/src/gallium/winsys/radeon/drm/libradeonwinsys.a \ - $(TOP)/src/gallium/drivers/r600/libr600.a --egl_SYS += -ldrm_radeon -+egl_SYS += $(RADEON_LIBS) - endif - endif - -@@ -137,7 +137,7 @@ egl_CPPFLAGS += -D_EGL_PIPE_RADEONSI=1 - egl_LIBS += \ - $(TOP)/src/gallium/winsys/radeon/drm/libradeonwinsys.a \ - $(TOP)/src/gallium/drivers/radeonsi/libradeonsi.a --egl_SYS += -ldrm_radeon -+egl_SYS += $(RADEON_LIBS) - endif - endif - -diff --git a/src/gallium/targets/gbm/Makefile b/src/gallium/targets/gbm/Makefile -index 423debf..17d5648 100644 ---- a/src/gallium/targets/gbm/Makefile -+++ b/src/gallium/targets/gbm/Makefile -@@ -14,7 +14,7 @@ GBM_INCLUDES = \ - -I$(TOP)/src/gallium/winsys \ - -I$(TOP)/src/gallium/include - --GBM_LIBS = $(LIBUDEV_LIBS) $(LIBDRM_LIB) -lm \ -+GBM_LIBS = $(LIBUDEV_LIBS) $(LIBDRM_LIBS) -lm \ - $(TOP)/src/gallium/state_trackers/gbm/libgbm.a \ - $(GALLIUM_PIPE_LOADER_LIBS) $(GALLIUM_AUXILIARIES) - -diff --git a/src/gallium/targets/pipe-loader/Makefile b/src/gallium/targets/pipe-loader/Makefile -index 596539c..f15cd25 100644 ---- a/src/gallium/targets/pipe-loader/Makefile -+++ b/src/gallium/targets/pipe-loader/Makefile -@@ -24,7 +24,7 @@ PIPE_LIBS = \ - $(TOP)/src/gallium/drivers/rbug/librbug.a \ - $(GALLIUM_AUXILIARIES) - --PIPE_SYS = $(LIBDRM_LIB) -lm -lpthread $(DLOPEN_LIBS) -+PIPE_SYS = $(LIBDRM_LIBS) -lm -lpthread $(DLOPEN_LIBS) - - PIPE_CFLAGS = $(LIBDRM_CFLAGS) - -@@ -34,7 +34,7 @@ PIPE_LDFLAGS = -Wl,--no-undefined - i915_LIBS = \ - $(TOP)/src/gallium/winsys/i915/drm/libi915drm.a \ - $(TOP)/src/gallium/drivers/i915/libi915.a --i915_SYS = -ldrm_intel -+i915_SYS = $(INTEL_LIBS) - - # nouveau pipe driver - nouveau_LIBS = \ -@@ -43,25 +43,25 @@ nouveau_LIBS = \ - $(TOP)/src/gallium/drivers/nv50/libnv50.a \ - $(TOP)/src/gallium/drivers/nvc0/libnvc0.a \ - $(TOP)/src/gallium/drivers/nouveau/libnouveau.a --nouveau_SYS = -ldrm_nouveau -+nouveau_SYS = $(NOUVEAU_LIBS) - - # r300 pipe driver - r300_LIBS = \ - $(TOP)/src/gallium/winsys/radeon/drm/libradeonwinsys.a \ - $(TOP)/src/gallium/drivers/r300/libr300.a --r300_SYS += -ldrm_radeon -+r300_SYS += $(RADEON_LIBS) - - # r600 pipe driver - r600_LIBS = \ - $(TOP)/src/gallium/winsys/radeon/drm/libradeonwinsys.a \ - $(TOP)/src/gallium/drivers/r600/libr600.a --r600_SYS += -ldrm_radeon -+r600_SYS += $(RADEON_LIBS) - - # radeonsi pipe driver - radeonsi_LIBS = \ - $(TOP)/src/gallium/winsys/radeon/drm/libradeonwinsys.a \ - $(TOP)/src/gallium/drivers/radeonsi/libradeonsi.a --radeonsi_SYS += -ldrm_radeon -+radeonsi_SYS += $(RADEON_LIBS) - - # vmwgfx pipe driver - vmwgfx_LIBS = \ -diff --git a/src/gallium/targets/vdpau-r300/Makefile b/src/gallium/targets/vdpau-r300/Makefile -index 1ada550..e79c920 100644 ---- a/src/gallium/targets/vdpau-r300/Makefile -+++ b/src/gallium/targets/vdpau-r300/Makefile -@@ -21,7 +21,7 @@ C_SOURCES = \ - $(COMMON_GALLIUM_SOURCES) \ - $(DRIVER_SOURCES) - --DRIVER_LIBS = $(shell $(PKG_CONFIG) libdrm --libs) -lXfixes -ldrm_radeon -+DRIVER_LIBS = $(LIBDRM_LIBS) $(RADEON_LIBS) -lXfixes - - include ../Makefile.vdpau - -diff --git a/src/gallium/targets/vdpau-r600/Makefile b/src/gallium/targets/vdpau-r600/Makefile -index 05e0b4f..6ef7f90 100644 ---- a/src/gallium/targets/vdpau-r600/Makefile -+++ b/src/gallium/targets/vdpau-r600/Makefile -@@ -17,7 +17,7 @@ C_SOURCES = \ - $(COMMON_GALLIUM_SOURCES) \ - $(DRIVER_SOURCES) - --DRIVER_LIBS = $(shell $(PKG_CONFIG) libdrm --libs) -lXfixes -ldrm_radeon -+DRIVER_LIBS = $(LIBDRM_LIBS) $(RADEON_LIBS) -lXfixes - - include ../Makefile.vdpau - -diff --git a/src/gallium/targets/vdpau-radeonsi/Makefile b/src/gallium/targets/vdpau-radeonsi/Makefile -index 6dd2be9..4ff6743 100644 ---- a/src/gallium/targets/vdpau-radeonsi/Makefile -+++ b/src/gallium/targets/vdpau-radeonsi/Makefile -@@ -23,7 +23,7 @@ C_SOURCES = \ - DRIVER_DEFINES = \ - -DGALLIUM_RBUG -DGALLIUM_TRACE -DGALLIUM_NOOP - --DRIVER_LIBS = $(shell $(PKG_CONFIG) libdrm --libs) -lXfixes -ldrm_radeon -+DRIVER_LIBS = $(LIBDRM_LIBS) $(RADEON_LIBS) -lXfixes - - include ../Makefile.vdpau - -diff --git a/src/gallium/targets/xvmc-r300/Makefile b/src/gallium/targets/xvmc-r300/Makefile -index 800f8d5..d2ab488 100644 ---- a/src/gallium/targets/xvmc-r300/Makefile -+++ b/src/gallium/targets/xvmc-r300/Makefile -@@ -17,7 +17,7 @@ C_SOURCES = \ - $(COMMON_GALLIUM_SOURCES) \ - $(DRIVER_SOURCES) - --DRIVER_LIBS = $(shell $(PKG_CONFIG) libdrm --libs) -lXfixes -ldrm_radeon -+DRIVER_LIBS = $(LIBDRM_LIBS) $(RADEON_LIBS) -lXfixes - - include ../Makefile.xvmc - -diff --git a/src/gallium/targets/xvmc-r600/Makefile b/src/gallium/targets/xvmc-r600/Makefile -index d9ce72f..3ef5b1a 100644 ---- a/src/gallium/targets/xvmc-r600/Makefile -+++ b/src/gallium/targets/xvmc-r600/Makefile -@@ -17,7 +17,7 @@ C_SOURCES = \ - $(COMMON_GALLIUM_SOURCES) \ - $(DRIVER_SOURCES) - --DRIVER_LIBS = $(shell $(PKG_CONFIG) libdrm --libs) -lXfixes -ldrm_radeon -+DRIVER_LIBS = $(LIBDRM_LIBS) $(RADEON_LIBS) -lXfixes - - include ../Makefile.xvmc - -diff --git a/src/mesa/drivers/dri/nouveau/nouveau_texture.c b/src/mesa/drivers/dri/nouveau/nouveau_texture.c -index 37f7577..288b510 100644 ---- a/src/mesa/drivers/dri/nouveau/nouveau_texture.c -+++ b/src/mesa/drivers/dri/nouveau/nouveau_texture.c -@@ -369,7 +369,7 @@ get_last_level(struct gl_texture_object *t) - t->Sampler.MinFilter == GL_LINEAR || !base) - return t->BaseLevel; - else -- return MIN2(t->BaseLevel + base->MaxLog2, t->MaxLevel); -+ return MIN2(t->BaseLevel + base->MaxNumLevels - 1, t->MaxLevel); - } - - static void -diff --git a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c -index 8901090..f4fb3a5 100644 ---- a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c -+++ b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c -@@ -270,7 +270,7 @@ static void calculate_min_max_lod(struct gl_sampler_object *samp, struct gl_text - minLod = MIN2(minLod, tObj->MaxLevel); - maxLod = tObj->BaseLevel + (GLint)(samp->MaxLod + 0.5); - maxLod = MIN2(maxLod, tObj->MaxLevel); -- maxLod = MIN2(maxLod, tObj->Image[0][minLod]->MaxLog2 + minLod); -+ maxLod = MIN2(maxLod, tObj->Image[0][minLod]->MaxNumLevels - 1 + minLod); - maxLod = MAX2(maxLod, minLod); /* need at least one level */ - } - break; -@@ -329,7 +329,7 @@ static GLboolean radeon_miptree_matches_texture(radeon_mipmap_tree *mt, struct g - - mtBaseLevel = &mt->levels[texObj->BaseLevel - mt->baseLevel]; - firstImage = texObj->Image[0][texObj->BaseLevel]; -- numLevels = MIN2(texObj->_MaxLevel - texObj->BaseLevel + 1, firstImage->MaxLog2 + 1); -+ numLevels = MIN2(texObj->_MaxLevel - texObj->BaseLevel + 1, firstImage->MaxNumLevels); - - if (radeon_is_debug_enabled(RADEON_TEXTURE,RADEON_TRACE)) { - fprintf(stderr, "Checking if miptree %p matches texObj %p\n", mt, texObj); -@@ -378,7 +378,7 @@ void radeon_try_alloc_miptree(radeonContextPtr rmesa, radeonTexObj *t) - } - - -- numLevels = MIN2(texObj->MaxLevel - texObj->BaseLevel + 1, texImg->MaxLog2 + 1); -+ numLevels = MIN2(texObj->MaxLevel - texObj->BaseLevel + 1, texImg->MaxNumLevels); - - t->mt = radeon_miptree_create(rmesa, t->base.Target, - texImg->TexFormat, texObj->BaseLevel, -diff --git a/src/mesa/main/config.h b/src/mesa/main/config.h -index ead1d32..3572ae8 100644 ---- a/src/mesa/main/config.h -+++ b/src/mesa/main/config.h -@@ -187,7 +187,7 @@ - #define MAX_PROGRAM_CALL_DEPTH 8 - #define MAX_PROGRAM_TEMPS 256 - #define MAX_PROGRAM_ADDRESS_REGS 2 --#define MAX_VARYING 16 /**< number of float[4] vectors */ -+#define MAX_VARYING 32 /**< number of float[4] vectors */ - #define MAX_SAMPLERS MAX_TEXTURE_IMAGE_UNITS - #define MAX_PROGRAM_INPUTS 32 - #define MAX_PROGRAM_OUTPUTS 64 -diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c -index a21ae10..de385cd 100644 ---- a/src/mesa/main/context.c -+++ b/src/mesa/main/context.c -@@ -624,7 +624,7 @@ _mesa_init_constants(struct gl_context *ctx) - #if FEATURE_ARB_vertex_shader - ctx->Const.MaxVertexTextureImageUnits = MAX_VERTEX_TEXTURE_IMAGE_UNITS; - ctx->Const.MaxCombinedTextureImageUnits = MAX_COMBINED_TEXTURE_IMAGE_UNITS; -- ctx->Const.MaxVarying = MAX_VARYING; -+ ctx->Const.MaxVarying = 16; /* old limit not to break tnl and swrast */ - #endif - #if FEATURE_ARB_geometry_shader4 - ctx->Const.MaxGeometryTextureImageUnits = MAX_GEOMETRY_TEXTURE_IMAGE_UNITS; -diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h -index 551aea7..4b74f70 100644 ---- a/src/mesa/main/imports.h -+++ b/src/mesa/main/imports.h -@@ -81,7 +81,7 @@ extern "C" { - * these casts generate warnings. - * The following union typedef is used to solve that. - */ --typedef union { GLfloat f; GLint i; } fi_type; -+typedef union { GLfloat f; GLint i; GLuint u; } fi_type; - - - -diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h -index 5af9487..e7ef877 100644 ---- a/src/mesa/main/macros.h -+++ b/src/mesa/main/macros.h -@@ -171,6 +171,20 @@ extern GLfloat _mesa_ubyte_to_float_color_tab[256]; - ub = ((GLubyte) F_TO_I((f) * 255.0F)) - #endif - -+static inline GLfloat INT_AS_FLT(GLint i) -+{ -+ fi_type tmp; -+ tmp.i = i; -+ return tmp.f; -+} -+ -+static inline GLfloat UINT_AS_FLT(GLuint u) -+{ -+ fi_type tmp; -+ tmp.u = u; -+ return tmp.f; -+} -+ - /*@}*/ - - -@@ -573,6 +587,31 @@ do { \ - - /*@}*/ - -+/** Copy \p sz elements into a homegeneous (4-element) vector, giving -+ * default values to the remaining components. -+ * The default values are chosen based on \p type. -+ */ -+static inline void -+COPY_CLEAN_4V_TYPE_AS_FLOAT(GLfloat dst[4], int sz, const GLfloat src[4], -+ GLenum type) -+{ -+ switch (type) { -+ case GL_FLOAT: -+ ASSIGN_4V(dst, 0, 0, 0, 1); -+ break; -+ case GL_INT: -+ ASSIGN_4V(dst, INT_AS_FLT(0), INT_AS_FLT(0), -+ INT_AS_FLT(0), INT_AS_FLT(1)); -+ break; -+ case GL_UNSIGNED_INT: -+ ASSIGN_4V(dst, UINT_AS_FLT(0), UINT_AS_FLT(0), -+ UINT_AS_FLT(0), UINT_AS_FLT(1)); -+ break; -+ default: -+ ASSERT(0); -+ } -+ COPY_SZ_4V(dst, sz, src); -+} - - /** \name Linear interpolation functions */ - /*@{*/ -diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h -index f185ffd..6fce70f 100644 ---- a/src/mesa/main/mtypes.h -+++ b/src/mesa/main/mtypes.h -@@ -1205,7 +1205,8 @@ struct gl_texture_image - GLuint WidthLog2; /**< = log2(Width2) */ - GLuint HeightLog2; /**< = log2(Height2) */ - GLuint DepthLog2; /**< = log2(Depth2) */ -- GLuint MaxLog2; /**< = MAX(WidthLog2, HeightLog2) */ -+ GLuint MaxNumLevels; /**< = maximum possible number of mipmap -+ levels, computed from the dimensions */ - - struct gl_texture_object *TexObject; /**< Pointer back to parent object */ - GLuint Level; /**< Which mipmap level am I? */ -diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c -index 38fa9fa..9edd4d8 100644 ---- a/src/mesa/main/teximage.c -+++ b/src/mesa/main/teximage.c -@@ -1002,6 +1002,43 @@ _mesa_get_texture_dimensions(GLenum target) - } - - -+/** -+ * Return the maximum number of mipmap levels for the given target -+ * and the dimensions. -+ * The dimensions are expected not to include the border. -+ */ -+GLsizei -+_mesa_get_tex_max_num_levels(GLenum target, GLsizei width, GLsizei height, -+ GLsizei depth) -+{ -+ GLsizei size; -+ -+ switch (target) { -+ case GL_TEXTURE_1D: -+ case GL_TEXTURE_1D_ARRAY: -+ size = width; -+ break; -+ case GL_TEXTURE_CUBE_MAP: -+ case GL_TEXTURE_CUBE_MAP_ARRAY: -+ ASSERT(width == height); -+ size = width; -+ break; -+ case GL_TEXTURE_2D: -+ case GL_TEXTURE_2D_ARRAY: -+ size = MAX2(width, height); -+ break; -+ case GL_TEXTURE_3D: -+ size = MAX3(width, height, depth); -+ break; -+ case GL_TEXTURE_RECTANGLE: -+ return 1; -+ default: -+ assert(0); -+ return 1; -+ } -+ -+ return _mesa_logbase2(size) + 1; -+} - - - #if 000 /* not used anymore */ -@@ -1187,7 +1224,9 @@ _mesa_init_teximage_fields(struct gl_context *ctx, - target); - } - -- img->MaxLog2 = MAX2(img->WidthLog2, img->HeightLog2); -+ img->MaxNumLevels = -+ _mesa_get_tex_max_num_levels(target, -+ img->Width2, img->Height2, img->Depth2); - img->TexFormat = format; - } - -diff --git a/src/mesa/main/teximage.h b/src/mesa/main/teximage.h -index 36fd1c2..a2565ec 100644 ---- a/src/mesa/main/teximage.h -+++ b/src/mesa/main/teximage.h -@@ -138,6 +138,10 @@ _mesa_tex_target_to_face(GLenum target); - extern GLint - _mesa_get_texture_dimensions(GLenum target); - -+extern GLsizei -+_mesa_get_tex_max_num_levels(GLenum target, GLsizei width, GLsizei height, -+ GLsizei depth); -+ - extern GLenum - _mesa_es_error_check_format_and_type(GLenum format, GLenum type, - unsigned dimensions); -diff --git a/src/mesa/main/texstorage.c b/src/mesa/main/texstorage.c -index f8a9397..b4dd13e 100644 ---- a/src/mesa/main/texstorage.c -+++ b/src/mesa/main/texstorage.c -@@ -244,7 +244,6 @@ tex_storage_error_check(struct gl_context *ctx, GLuint dims, GLenum target, - GLsizei width, GLsizei height, GLsizei depth) - { - struct gl_texture_object *texObj; -- GLuint maxDim; - GLboolean legalFormat; - - /* check internal format - note that only sized formats are allowed */ -@@ -324,8 +323,7 @@ tex_storage_error_check(struct gl_context *ctx, GLuint dims, GLenum target, - } - - /* check levels against width/height/depth */ -- maxDim = MAX3(width, height, depth); -- if (levels > _mesa_logbase2(maxDim) + 1) { -+ if (levels > _mesa_get_tex_max_num_levels(target, width, height, depth)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glTexStorage%uD(too many levels for max texture dimension)", - dims); -diff --git a/src/mesa/program/prog_print.c b/src/mesa/program/prog_print.c -index bc5dc58..887f020 100644 ---- a/src/mesa/program/prog_print.c -+++ b/src/mesa/program/prog_print.c -@@ -164,7 +164,23 @@ arb_input_attrib_string(GLint index, GLenum progType) - "fragment.varying[12]", - "fragment.varying[13]", - "fragment.varying[14]", -- "fragment.varying[15]" /* MAX_VARYING = 16 */ -+ "fragment.varying[15]", -+ "fragment.varying[16]", -+ "fragment.varying[17]", -+ "fragment.varying[18]", -+ "fragment.varying[19]", -+ "fragment.varying[20]", -+ "fragment.varying[21]", -+ "fragment.varying[22]", -+ "fragment.varying[23]", -+ "fragment.varying[24]", -+ "fragment.varying[25]", -+ "fragment.varying[26]", -+ "fragment.varying[27]", -+ "fragment.varying[28]", -+ "fragment.varying[29]", -+ "fragment.varying[30]", -+ "fragment.varying[31]", /* MAX_VARYING = 32 */ - }; - - /* sanity checks */ -@@ -268,7 +284,23 @@ arb_output_attrib_string(GLint index, GLenum progType) - "result.varying[12]", - "result.varying[13]", - "result.varying[14]", -- "result.varying[15]" /* MAX_VARYING = 16 */ -+ "result.varying[15]", -+ "result.varying[16]", -+ "result.varying[17]", -+ "result.varying[18]", -+ "result.varying[19]", -+ "result.varying[20]", -+ "result.varying[21]", -+ "result.varying[22]", -+ "result.varying[23]", -+ "result.varying[24]", -+ "result.varying[25]", -+ "result.varying[26]", -+ "result.varying[27]", -+ "result.varying[28]", -+ "result.varying[29]", -+ "result.varying[30]", -+ "result.varying[31]", /* MAX_VARYING = 32 */ - }; - static const char *const fragResults[] = { - "result.depth", /* FRAG_RESULT_DEPTH */ -diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c -index adcc7b5..3eba5b1 100644 ---- a/src/mesa/state_tracker/st_atom_sampler.c -+++ b/src/mesa/state_tracker/st_atom_sampler.c -@@ -34,6 +34,7 @@ - - #include "main/macros.h" - #include "main/mtypes.h" -+#include "main/glformats.h" - #include "main/samplerobj.h" - #include "main/texobj.h" - -@@ -172,12 +173,17 @@ convert_sampler(struct st_context *st, - msamp->BorderColor.ui[2] || - msamp->BorderColor.ui[3]) { - struct gl_texture_image *teximg; -+ GLboolean is_integer = GL_FALSE; - - teximg = texobj->Image[0][texobj->BaseLevel]; - -- st_translate_color(msamp->BorderColor.f, -- teximg ? teximg->_BaseFormat : GL_RGBA, -- sampler->border_color.f); -+ if (teximg) { -+ is_integer = _mesa_is_enum_format_integer(teximg->InternalFormat); -+ } -+ -+ st_translate_color(&msamp->BorderColor, -+ &sampler->border_color, -+ teximg ? teximg->_BaseFormat : GL_RGBA, is_integer); - } - - sampler->max_anisotropy = (msamp->MaxAnisotropy == 1.0 ? -diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c -index e731b6b..90eb0af 100644 ---- a/src/mesa/state_tracker/st_cb_clear.c -+++ b/src/mesa/state_tracker/st_cb_clear.c -@@ -37,6 +37,7 @@ - #include "main/accum.h" - #include "main/formats.h" - #include "main/macros.h" -+#include "main/glformats.h" - #include "program/prog_instruction.h" - #include "st_context.h" - #include "st_atom.h" -@@ -301,9 +302,13 @@ clear_with_quad(struct gl_context *ctx, - cso_set_geometry_shader_handle(st->cso_context, NULL); - - if (ctx->DrawBuffer->_ColorDrawBuffers[0]) { -- st_translate_color(ctx->Color.ClearColor.f, -- ctx->DrawBuffer->_ColorDrawBuffers[0]->_BaseFormat, -- clearColor.f); -+ struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0]; -+ GLboolean is_integer = _mesa_is_enum_format_integer(rb->InternalFormat); -+ -+ st_translate_color(&ctx->Color.ClearColor, -+ &clearColor, -+ ctx->DrawBuffer->_ColorDrawBuffers[0]->_BaseFormat, -+ is_integer); - } - - /* draw quad matching scissor rect */ -@@ -540,9 +545,13 @@ st_Clear(struct gl_context *ctx, GLbitfield mask) - clear_buffers |= PIPE_CLEAR_DEPTHSTENCIL; - - if (ctx->DrawBuffer->_ColorDrawBuffers[0]) { -- st_translate_color(ctx->Color.ClearColor.f, -+ struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0]; -+ GLboolean is_integer = _mesa_is_enum_format_integer(rb->InternalFormat); -+ -+ st_translate_color(&ctx->Color.ClearColor, -+ &clearColor, - ctx->DrawBuffer->_ColorDrawBuffers[0]->_BaseFormat, -- clearColor.f); -+ is_integer); - } - - st->pipe->clear(st->pipe, clear_buffers, &clearColor, -diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c -index b8e2538..923a8c9 100644 ---- a/src/mesa/state_tracker/st_cb_texture.c -+++ b/src/mesa/state_tracker/st_cb_texture.c -@@ -237,36 +237,6 @@ default_bindings(struct st_context *st, enum pipe_format format) - } - - --/** Return number of image dimensions (1, 2 or 3) for a texture target. */ --static GLuint --get_texture_dims(GLenum target) --{ -- switch (target) { -- case GL_TEXTURE_1D: -- case GL_TEXTURE_1D_ARRAY_EXT: -- case GL_TEXTURE_BUFFER: -- return 1; -- case GL_TEXTURE_2D: -- case GL_TEXTURE_CUBE_MAP_ARB: -- case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB: -- case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB: -- case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB: -- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB: -- case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB: -- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB: -- case GL_TEXTURE_RECTANGLE_NV: -- case GL_TEXTURE_2D_ARRAY_EXT: -- case GL_TEXTURE_EXTERNAL_OES: -- return 2; -- case GL_TEXTURE_3D: -- return 3; -- default: -- assert(0 && "invalid texture target in get_texture_dims()"); -- return 1; -- } --} -- -- - /** - * Given the size of a mipmap image, try to compute the size of the level=0 - * mipmap image. -@@ -281,32 +251,57 @@ guess_base_level_size(GLenum target, - GLuint width, GLuint height, GLuint depth, GLuint level, - GLuint *width0, GLuint *height0, GLuint *depth0) - { -- const GLuint dims = get_texture_dims(target); -- - assert(width >= 1); - assert(height >= 1); - assert(depth >= 1); - - if (level > 0) { -- /* Depending on the image's size, we can't always make a guess here */ -- if ((dims >= 1 && width == 1) || -- (dims >= 2 && height == 1) || -- (dims >= 3 && depth == 1)) { -- /* we can't determine the image size at level=0 */ -- return GL_FALSE; -- } -+ /* Guess the size of the base level. -+ * Depending on the image's size, we can't always make a guess here. -+ */ -+ switch (target) { -+ case GL_TEXTURE_1D: -+ case GL_TEXTURE_1D_ARRAY: -+ width <<= level; -+ break; -+ -+ case GL_TEXTURE_2D: -+ case GL_TEXTURE_2D_ARRAY: -+ /* We can't make a good guess here, because the base level dimensions -+ * can be non-square. -+ */ -+ if (width == 1 || height == 1) { -+ return GL_FALSE; -+ } -+ width <<= level; -+ height <<= level; -+ break; -+ -+ case GL_TEXTURE_CUBE_MAP: -+ case GL_TEXTURE_CUBE_MAP_ARRAY: -+ width <<= level; -+ height <<= level; -+ break; -+ -+ case GL_TEXTURE_3D: -+ /* We can't make a good guess here, because the base level dimensions -+ * can be non-cube. -+ */ -+ if (width == 1 || height == 1 || depth == 1) { -+ return GL_FALSE; -+ } -+ width <<= level; -+ height <<= level; -+ depth <<= level; -+ break; -+ -+ case GL_TEXTURE_RECTANGLE: -+ break; - -- /* grow the image size until we hit level = 0 */ -- while (level > 0) { -- if (width > 1) -- width <<= 1; -- if (height > 1) -- height <<= 1; -- if (depth > 1) -- depth <<= 1; -- level--; -+ default: -+ assert(0); - } -- } -+ } - - *width0 = width; - *height0 = height; -@@ -371,10 +366,8 @@ guess_and_alloc_texture(struct st_context *st, - } - else { - /* alloc space for a full mipmap */ -- GLuint l2width = util_logbase2(width); -- GLuint l2height = util_logbase2(height); -- GLuint l2depth = util_logbase2(depth); -- lastLevel = MAX2(MAX2(l2width, l2height), l2depth); -+ lastLevel = _mesa_get_tex_max_num_levels(stObj->base.Target, -+ width, height, depth) - 1; - } - - /* Save the level=0 dimensions */ -diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c -index 302b58c..75602e5 100644 ---- a/src/mesa/state_tracker/st_format.c -+++ b/src/mesa/state_tracker/st_format.c -@@ -1699,44 +1699,92 @@ st_sampler_compat_formats(enum pipe_format format1, enum pipe_format format2) - * Similarly for texture border colors. - */ - void --st_translate_color(const GLfloat colorIn[4], GLenum baseFormat, -- GLfloat colorOut[4]) -+st_translate_color(union gl_color_union *colorIn, -+ union pipe_color_union *colorOut, -+ GLenum baseFormat, GLboolean is_integer) - { -- switch (baseFormat) { -- case GL_RED: -- colorOut[0] = colorIn[0]; -- colorOut[1] = 0.0F; -- colorOut[2] = 0.0F; -- colorOut[3] = 1.0F; -- break; -- case GL_RG: -- colorOut[0] = colorIn[0]; -- colorOut[1] = colorIn[1]; -- colorOut[2] = 0.0F; -- colorOut[3] = 1.0F; -- break; -- case GL_RGB: -- colorOut[0] = colorIn[0]; -- colorOut[1] = colorIn[1]; -- colorOut[2] = colorIn[2]; -- colorOut[3] = 1.0F; -- break; -- case GL_ALPHA: -- colorOut[0] = colorOut[1] = colorOut[2] = 0.0; -- colorOut[3] = colorIn[3]; -- break; -- case GL_LUMINANCE: -- colorOut[0] = colorOut[1] = colorOut[2] = colorIn[0]; -- colorOut[3] = 1.0; -- break; -- case GL_LUMINANCE_ALPHA: -- colorOut[0] = colorOut[1] = colorOut[2] = colorIn[0]; -- colorOut[3] = colorIn[3]; -- break; -- case GL_INTENSITY: -- colorOut[0] = colorOut[1] = colorOut[2] = colorOut[3] = colorIn[0]; -- break; -- default: -- COPY_4V(colorOut, colorIn); -+ if (is_integer) { -+ int *in = colorIn->i; -+ int *out = colorOut->i; -+ -+ switch (baseFormat) { -+ case GL_RED: -+ out[0] = in[0]; -+ out[1] = 0; -+ out[2] = 0; -+ out[3] = 1; -+ break; -+ case GL_RG: -+ out[0] = in[0]; -+ out[1] = in[1]; -+ out[2] = 0; -+ out[3] = 1; -+ break; -+ case GL_RGB: -+ out[0] = in[0]; -+ out[1] = in[1]; -+ out[2] = in[2]; -+ out[3] = 1; -+ break; -+ case GL_ALPHA: -+ out[0] = out[1] = out[2] = 0; -+ out[3] = in[3]; -+ break; -+ case GL_LUMINANCE: -+ out[0] = out[1] = out[2] = in[0]; -+ out[3] = 1; -+ break; -+ case GL_LUMINANCE_ALPHA: -+ out[0] = out[1] = out[2] = in[0]; -+ out[3] = in[3]; -+ break; -+ case GL_INTENSITY: -+ out[0] = out[1] = out[2] = out[3] = in[0]; -+ break; -+ default: -+ COPY_4V(out, in); -+ } -+ } -+ else { -+ float *in = colorIn->f; -+ float *out = colorOut->f; -+ -+ switch (baseFormat) { -+ case GL_RED: -+ out[0] = in[0]; -+ out[1] = 0.0F; -+ out[2] = 0.0F; -+ out[3] = 1.0F; -+ break; -+ case GL_RG: -+ out[0] = in[0]; -+ out[1] = in[1]; -+ out[2] = 0.0F; -+ out[3] = 1.0F; -+ break; -+ case GL_RGB: -+ out[0] = in[0]; -+ out[1] = in[1]; -+ out[2] = in[2]; -+ out[3] = 1.0F; -+ break; -+ case GL_ALPHA: -+ out[0] = out[1] = out[2] = 0.0F; -+ out[3] = in[3]; -+ break; -+ case GL_LUMINANCE: -+ out[0] = out[1] = out[2] = in[0]; -+ out[3] = 1.0F; -+ break; -+ case GL_LUMINANCE_ALPHA: -+ out[0] = out[1] = out[2] = in[0]; -+ out[3] = in[3]; -+ break; -+ case GL_INTENSITY: -+ out[0] = out[1] = out[2] = out[3] = in[0]; -+ break; -+ default: -+ COPY_4V(out, in); -+ } - } - } -diff --git a/src/mesa/state_tracker/st_format.h b/src/mesa/state_tracker/st_format.h -index 2eef2c0..39397b1 100644 ---- a/src/mesa/state_tracker/st_format.h -+++ b/src/mesa/state_tracker/st_format.h -@@ -75,7 +75,8 @@ st_sampler_compat_formats(enum pipe_format format1, enum pipe_format format2); - - - extern void --st_translate_color(const GLfloat colorIn[4], GLenum baseFormat, -- GLfloat colorOut[4]); -+st_translate_color(union gl_color_union *colorIn, -+ union pipe_color_union *colorOut, -+ GLenum baseFormat, GLboolean is_integer); - - #endif /* ST_FORMAT_H */ -diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c -index 8892006..c092613 100644 ---- a/src/mesa/state_tracker/st_gen_mipmap.c -+++ b/src/mesa/state_tracker/st_gen_mipmap.c -@@ -121,30 +121,16 @@ compute_num_levels(struct gl_context *ctx, - struct gl_texture_object *texObj, - GLenum target) - { -- if (target == GL_TEXTURE_RECTANGLE_ARB) { -- return 1; -- } -- else { -- const struct gl_texture_image *baseImage = -- _mesa_get_tex_image(ctx, texObj, target, texObj->BaseLevel); -- GLuint size, numLevels; -+ const struct gl_texture_image *baseImage; -+ GLuint numLevels; - -- size = MAX2(baseImage->Width2, baseImage->Height2); -- size = MAX2(size, baseImage->Depth2); -+ baseImage = _mesa_get_tex_image(ctx, texObj, target, texObj->BaseLevel); - -- numLevels = texObj->BaseLevel; -- -- while (size > 0) { -- numLevels++; -- size >>= 1; -- } -+ numLevels = texObj->BaseLevel + baseImage->MaxNumLevels; -+ numLevels = MIN2(numLevels, texObj->MaxLevel + 1); -+ assert(numLevels >= 1); - -- numLevels = MIN2(numLevels, texObj->MaxLevel + 1); -- -- assert(numLevels >= 1); -- -- return numLevels; -- } -+ return numLevels; - } - - -diff --git a/src/mesa/vbo/vbo_attrib_tmp.h b/src/mesa/vbo/vbo_attrib_tmp.h -index d3fc77e..b4a6d73 100644 ---- a/src/mesa/vbo/vbo_attrib_tmp.h -+++ b/src/mesa/vbo/vbo_attrib_tmp.h -@@ -26,38 +26,46 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. - **************************************************************************/ - - /* float */ --#define ATTR1FV( A, V ) ATTR( A, 1, (V)[0], 0, 0, 1 ) --#define ATTR2FV( A, V ) ATTR( A, 2, (V)[0], (V)[1], 0, 1 ) --#define ATTR3FV( A, V ) ATTR( A, 3, (V)[0], (V)[1], (V)[2], 1 ) --#define ATTR4FV( A, V ) ATTR( A, 4, (V)[0], (V)[1], (V)[2], (V)[3] ) -+#define ATTR1FV( A, V ) ATTR( A, 1, GL_FLOAT, (V)[0], 0, 0, 1 ) -+#define ATTR2FV( A, V ) ATTR( A, 2, GL_FLOAT, (V)[0], (V)[1], 0, 1 ) -+#define ATTR3FV( A, V ) ATTR( A, 3, GL_FLOAT, (V)[0], (V)[1], (V)[2], 1 ) -+#define ATTR4FV( A, V ) ATTR( A, 4, GL_FLOAT, (V)[0], (V)[1], (V)[2], (V)[3] ) - --#define ATTR1F( A, X ) ATTR( A, 1, X, 0, 0, 1 ) --#define ATTR2F( A, X, Y ) ATTR( A, 2, X, Y, 0, 1 ) --#define ATTR3F( A, X, Y, Z ) ATTR( A, 3, X, Y, Z, 1 ) --#define ATTR4F( A, X, Y, Z, W ) ATTR( A, 4, X, Y, Z, W ) -+#define ATTR1F( A, X ) ATTR( A, 1, GL_FLOAT, X, 0, 0, 1 ) -+#define ATTR2F( A, X, Y ) ATTR( A, 2, GL_FLOAT, X, Y, 0, 1 ) -+#define ATTR3F( A, X, Y, Z ) ATTR( A, 3, GL_FLOAT, X, Y, Z, 1 ) -+#define ATTR4F( A, X, Y, Z, W ) ATTR( A, 4, GL_FLOAT, X, Y, Z, W ) - - /* int */ --#define ATTR2IV( A, V ) ATTR( A, 2, (V)[0], (V)[1], 0, 1 ) --#define ATTR3IV( A, V ) ATTR( A, 3, (V)[0], (V)[1], (V)[2], 1 ) --#define ATTR4IV( A, V ) ATTR( A, 4, (V)[0], (V)[1], (V)[2], (V)[3] ) -+#define ATTRI( A, N, X, Y, Z, W) ATTR( A, N, GL_INT, \ -+ INT_AS_FLT(X), INT_AS_FLT(Y), \ -+ INT_AS_FLT(Z), INT_AS_FLT(W) ) - --#define ATTR1I( A, X ) ATTR( A, 1, X, 0, 0, 1 ) --#define ATTR2I( A, X, Y ) ATTR( A, 2, X, Y, 0, 1 ) --#define ATTR3I( A, X, Y, Z ) ATTR( A, 3, X, Y, Z, 1 ) --#define ATTR4I( A, X, Y, Z, W ) ATTR( A, 4, X, Y, Z, W ) -+#define ATTR2IV( A, V ) ATTRI( A, 2, (V)[0], (V)[1], 0, 1 ) -+#define ATTR3IV( A, V ) ATTRI( A, 3, (V)[0], (V)[1], (V)[2], 1 ) -+#define ATTR4IV( A, V ) ATTRI( A, 4, (V)[0], (V)[1], (V)[2], (V)[3] ) -+ -+#define ATTR1I( A, X ) ATTRI( A, 1, X, 0, 0, 1 ) -+#define ATTR2I( A, X, Y ) ATTRI( A, 2, X, Y, 0, 1 ) -+#define ATTR3I( A, X, Y, Z ) ATTRI( A, 3, X, Y, Z, 1 ) -+#define ATTR4I( A, X, Y, Z, W ) ATTRI( A, 4, X, Y, Z, W ) - - - /* uint */ --#define ATTR2UIV( A, V ) ATTR( A, 2, (V)[0], (V)[1], 0, 1 ) --#define ATTR3UIV( A, V ) ATTR( A, 3, (V)[0], (V)[1], (V)[2], 1 ) --#define ATTR4UIV( A, V ) ATTR( A, 4, (V)[0], (V)[1], (V)[2], (V)[3] ) -+#define ATTRUI( A, N, X, Y, Z, W) ATTR( A, N, GL_UNSIGNED_INT, \ -+ UINT_AS_FLT(X), UINT_AS_FLT(Y), \ -+ UINT_AS_FLT(Z), UINT_AS_FLT(W) ) -+ -+#define ATTR2UIV( A, V ) ATTRUI( A, 2, (V)[0], (V)[1], 0, 1 ) -+#define ATTR3UIV( A, V ) ATTRUI( A, 3, (V)[0], (V)[1], (V)[2], 1 ) -+#define ATTR4UIV( A, V ) ATTRUI( A, 4, (V)[0], (V)[1], (V)[2], (V)[3] ) - --#define ATTR1UI( A, X ) ATTR( A, 1, X, 0, 0, 1 ) --#define ATTR2UI( A, X, Y ) ATTR( A, 2, X, Y, 0, 1 ) --#define ATTR3UI( A, X, Y, Z ) ATTR( A, 3, X, Y, Z, 1 ) --#define ATTR4UI( A, X, Y, Z, W ) ATTR( A, 4, X, Y, Z, W ) -+#define ATTR1UI( A, X ) ATTRUI( A, 1, X, 0, 0, 1 ) -+#define ATTR2UI( A, X, Y ) ATTRUI( A, 2, X, Y, 0, 1 ) -+#define ATTR3UI( A, X, Y, Z ) ATTRUI( A, 3, X, Y, Z, 1 ) -+#define ATTR4UI( A, X, Y, Z, W ) ATTRUI( A, 4, X, Y, Z, W ) - --#define MAT_ATTR( A, N, V ) ATTR( A, N, (V)[0], (V)[1], (V)[2], (V)[3] ) -+#define MAT_ATTR( A, N, V ) ATTR( A, N, GL_FLOAT, (V)[0], (V)[1], (V)[2], (V)[3] ) - - static inline float conv_ui10_to_norm_float(unsigned ui10) - { -@@ -69,20 +77,20 @@ static inline float conv_ui2_to_norm_float(unsigned ui2) - return (float)(ui2) / 3.0; - } - --#define ATTRUI10_1( A, UI ) ATTR( A, 1, (UI) & 0x3ff, 0, 0, 1 ) --#define ATTRUI10_2( A, UI ) ATTR( A, 2, (UI) & 0x3ff, ((UI) >> 10) & 0x3ff, 0, 1 ) --#define ATTRUI10_3( A, UI ) ATTR( A, 3, (UI) & 0x3ff, ((UI) >> 10) & 0x3ff, ((UI) >> 20) & 0x3ff, 1 ) --#define ATTRUI10_4( A, UI ) ATTR( A, 4, (UI) & 0x3ff, ((UI) >> 10) & 0x3ff, ((UI) >> 20) & 0x3ff, ((UI) >> 30) & 0x3 ) -+#define ATTRUI10_1( A, UI ) ATTR( A, 1, GL_FLOAT, (UI) & 0x3ff, 0, 0, 1 ) -+#define ATTRUI10_2( A, UI ) ATTR( A, 2, GL_FLOAT, (UI) & 0x3ff, ((UI) >> 10) & 0x3ff, 0, 1 ) -+#define ATTRUI10_3( A, UI ) ATTR( A, 3, GL_FLOAT, (UI) & 0x3ff, ((UI) >> 10) & 0x3ff, ((UI) >> 20) & 0x3ff, 1 ) -+#define ATTRUI10_4( A, UI ) ATTR( A, 4, GL_FLOAT, (UI) & 0x3ff, ((UI) >> 10) & 0x3ff, ((UI) >> 20) & 0x3ff, ((UI) >> 30) & 0x3 ) - --#define ATTRUI10N_1( A, UI ) ATTR( A, 1, conv_ui10_to_norm_float((UI) & 0x3ff), 0, 0, 1 ) --#define ATTRUI10N_2( A, UI ) ATTR( A, 2, \ -+#define ATTRUI10N_1( A, UI ) ATTR( A, 1, GL_FLOAT, conv_ui10_to_norm_float((UI) & 0x3ff), 0, 0, 1 ) -+#define ATTRUI10N_2( A, UI ) ATTR( A, 2, GL_FLOAT, \ - conv_ui10_to_norm_float((UI) & 0x3ff), \ - conv_ui10_to_norm_float(((UI) >> 10) & 0x3ff), 0, 1 ) --#define ATTRUI10N_3( A, UI ) ATTR( A, 3, \ -+#define ATTRUI10N_3( A, UI ) ATTR( A, 3, GL_FLOAT, \ - conv_ui10_to_norm_float((UI) & 0x3ff), \ - conv_ui10_to_norm_float(((UI) >> 10) & 0x3ff), \ - conv_ui10_to_norm_float(((UI) >> 20) & 0x3ff), 1 ) --#define ATTRUI10N_4( A, UI ) ATTR( A, 4, \ -+#define ATTRUI10N_4( A, UI ) ATTR( A, 4, GL_FLOAT, \ - conv_ui10_to_norm_float((UI) & 0x3ff), \ - conv_ui10_to_norm_float(((UI) >> 10) & 0x3ff), \ - conv_ui10_to_norm_float(((UI) >> 20) & 0x3ff), \ -@@ -119,30 +127,30 @@ static inline float conv_i2_to_norm_float(int i2) - return (float)val.x; - } - --#define ATTRI10_1( A, I10 ) ATTR( A, 1, conv_i10_to_i((I10) & 0x3ff), 0, 0, 1 ) --#define ATTRI10_2( A, I10 ) ATTR( A, 2, \ -+#define ATTRI10_1( A, I10 ) ATTR( A, 1, GL_FLOAT, conv_i10_to_i((I10) & 0x3ff), 0, 0, 1 ) -+#define ATTRI10_2( A, I10 ) ATTR( A, 2, GL_FLOAT, \ - conv_i10_to_i((I10) & 0x3ff), \ - conv_i10_to_i(((I10) >> 10) & 0x3ff), 0, 1 ) --#define ATTRI10_3( A, I10 ) ATTR( A, 3, \ -+#define ATTRI10_3( A, I10 ) ATTR( A, 3, GL_FLOAT, \ - conv_i10_to_i((I10) & 0x3ff), \ - conv_i10_to_i(((I10) >> 10) & 0x3ff), \ - conv_i10_to_i(((I10) >> 20) & 0x3ff), 1 ) --#define ATTRI10_4( A, I10 ) ATTR( A, 4, \ -+#define ATTRI10_4( A, I10 ) ATTR( A, 4, GL_FLOAT, \ - conv_i10_to_i((I10) & 0x3ff), \ - conv_i10_to_i(((I10) >> 10) & 0x3ff), \ - conv_i10_to_i(((I10) >> 20) & 0x3ff), \ - conv_i2_to_i(((I10) >> 30) & 0x3)) - - --#define ATTRI10N_1( A, I10 ) ATTR( A, 1, conv_i10_to_norm_float((I10) & 0x3ff), 0, 0, 1 ) --#define ATTRI10N_2( A, I10 ) ATTR( A, 2, \ -+#define ATTRI10N_1( A, I10 ) ATTR( A, 1, GL_FLOAT, conv_i10_to_norm_float((I10) & 0x3ff), 0, 0, 1 ) -+#define ATTRI10N_2( A, I10 ) ATTR( A, 2, GL_FLOAT, \ - conv_i10_to_norm_float((I10) & 0x3ff), \ - conv_i10_to_norm_float(((I10) >> 10) & 0x3ff), 0, 1 ) --#define ATTRI10N_3( A, I10 ) ATTR( A, 3, \ -+#define ATTRI10N_3( A, I10 ) ATTR( A, 3, GL_FLOAT, \ - conv_i10_to_norm_float((I10) & 0x3ff), \ - conv_i10_to_norm_float(((I10) >> 10) & 0x3ff), \ - conv_i10_to_norm_float(((I10) >> 20) & 0x3ff), 1 ) --#define ATTRI10N_4( A, I10 ) ATTR( A, 4, \ -+#define ATTRI10N_4( A, I10 ) ATTR( A, 4, GL_FLOAT, \ - conv_i10_to_norm_float((I10) & 0x3ff), \ - conv_i10_to_norm_float(((I10) >> 10) & 0x3ff), \ - conv_i10_to_norm_float(((I10) >> 20) & 0x3ff), \ -diff --git a/src/mesa/vbo/vbo_context.h b/src/mesa/vbo/vbo_context.h -index 1c49de0..6fcd47f 100644 ---- a/src/mesa/vbo/vbo_context.h -+++ b/src/mesa/vbo/vbo_context.h -@@ -151,4 +151,47 @@ vbo_draw_method(struct vbo_context *vbo, enum draw_method method) - } - } - -+/** -+ * Return if format is integer. The immediate mode commands only emit floats -+ * for non-integer types, thus everything else is integer. -+ */ -+static inline GLboolean -+vbo_attrtype_to_integer_flag(GLenum format) -+{ -+ switch (format) { -+ case GL_FLOAT: -+ return GL_FALSE; -+ case GL_INT: -+ case GL_UNSIGNED_INT: -+ return GL_TRUE; -+ default: -+ ASSERT(0); -+ return GL_FALSE; -+ } -+} -+ -+ -+/** -+ * Return default component values for the given format. -+ * The return type is an array of floats, because that's how we declare -+ * the vertex storage despite the fact we sometimes store integers in there. -+ */ -+static inline const GLfloat * -+vbo_get_default_vals_as_float(GLenum format) -+{ -+ static const GLfloat default_float[4] = { 0, 0, 0, 1 }; -+ static const GLint default_int[4] = { 0, 0, 0, 1 }; -+ -+ switch (format) { -+ case GL_FLOAT: -+ return default_float; -+ case GL_INT: -+ case GL_UNSIGNED_INT: -+ return (const GLfloat*)default_int; -+ default: -+ ASSERT(0); -+ return NULL; -+ } -+} -+ - #endif -diff --git a/src/mesa/vbo/vbo_exec.h b/src/mesa/vbo/vbo_exec.h -index 4ac7d16..34a6fe7 100644 ---- a/src/mesa/vbo/vbo_exec.h -+++ b/src/mesa/vbo/vbo_exec.h -@@ -102,6 +102,7 @@ struct vbo_exec_context - struct vbo_exec_copied_vtx copied; - - GLubyte attrsz[VBO_ATTRIB_MAX]; -+ GLenum attrtype[VBO_ATTRIB_MAX]; - GLubyte active_sz[VBO_ATTRIB_MAX]; - - GLfloat *attrptr[VBO_ATTRIB_MAX]; -diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c -index 781e360..64762c7 100644 ---- a/src/mesa/vbo/vbo_exec_api.c -+++ b/src/mesa/vbo/vbo_exec_api.c -@@ -157,11 +157,13 @@ static void vbo_exec_copy_to_current( struct vbo_exec_context *exec ) - GLfloat *current = (GLfloat *)vbo->currval[i].Ptr; - GLfloat tmp[4]; - -- COPY_CLEAN_4V(tmp, -- exec->vtx.attrsz[i], -- exec->vtx.attrptr[i]); -+ COPY_CLEAN_4V_TYPE_AS_FLOAT(tmp, -+ exec->vtx.attrsz[i], -+ exec->vtx.attrptr[i], -+ exec->vtx.attrtype[i]); - -- if (memcmp(current, tmp, sizeof(tmp)) != 0) { -+ if (exec->vtx.attrtype[i] != vbo->currval[i].Type || -+ memcmp(current, tmp, sizeof(tmp)) != 0) { - memcpy(current, tmp, sizeof(tmp)); - - /* Given that we explicitly state size here, there is no need -@@ -170,8 +172,10 @@ static void vbo_exec_copy_to_current( struct vbo_exec_context *exec ) - * directly. - */ - vbo->currval[i].Size = exec->vtx.attrsz[i]; -- assert(vbo->currval[i].Type == GL_FLOAT); - vbo->currval[i]._ElementSize = vbo->currval[i].Size * sizeof(GLfloat); -+ vbo->currval[i].Type = exec->vtx.attrtype[i]; -+ vbo->currval[i].Integer = -+ vbo_attrtype_to_integer_flag(exec->vtx.attrtype[i]); - - /* This triggers rather too much recalculation of Mesa state - * that doesn't get used (eg light positions). -@@ -324,7 +328,9 @@ vbo_exec_wrap_upgrade_vertex(struct vbo_exec_context *exec, - if (j == attr) { - if (oldSize) { - GLfloat tmp[4]; -- COPY_CLEAN_4V(tmp, oldSize, data + old_offset); -+ COPY_CLEAN_4V_TYPE_AS_FLOAT(tmp, oldSize, -+ data + old_offset, -+ exec->vtx.attrtype[j]); - COPY_SZ_4V(dest + new_offset, newSize, tmp); - } else { - GLfloat *current = (GLfloat *)vbo->currval[j].Ptr; -@@ -365,8 +371,9 @@ vbo_exec_fixup_vertex(struct gl_context *ctx, GLuint attr, GLuint newSize) - vbo_exec_wrap_upgrade_vertex( exec, attr, newSize ); - } - else if (newSize < exec->vtx.active_sz[attr]) { -- static const GLfloat id[4] = { 0, 0, 0, 1 }; - GLuint i; -+ const GLfloat *id = -+ vbo_get_default_vals_as_float(exec->vtx.attrtype[attr]); - - /* New size is smaller - just need to fill in some - * zeros. Don't need to flush or wrap. -@@ -390,7 +397,7 @@ vbo_exec_fixup_vertex(struct gl_context *ctx, GLuint attr, GLuint newSize) - * This macro is used to implement all the glVertex, glColor, glTexCoord, - * glVertexAttrib, etc functions. - */ --#define ATTR( A, N, V0, V1, V2, V3 ) \ -+#define ATTR( A, N, T, V0, V1, V2, V3 ) \ - do { \ - struct vbo_exec_context *exec = &vbo_context(ctx)->exec; \ - \ -@@ -406,6 +413,7 @@ do { \ - if (N>1) dest[1] = V1; \ - if (N>2) dest[2] = V2; \ - if (N>3) dest[3] = V3; \ -+ exec->vtx.attrtype[A] = T; \ - } \ - \ - if ((A) == 0) { \ -@@ -1192,6 +1200,8 @@ void vbo_exec_vtx_init( struct vbo_exec_context *exec ) - for (i = 0 ; i < VBO_ATTRIB_MAX ; i++) { - ASSERT(i < Elements(exec->vtx.attrsz)); - exec->vtx.attrsz[i] = 0; -+ ASSERT(i < Elements(exec->vtx.attrtype)); -+ exec->vtx.attrtype[i] = GL_FLOAT; - ASSERT(i < Elements(exec->vtx.active_sz)); - exec->vtx.active_sz[i] = 0; - } -@@ -1328,6 +1338,7 @@ static void reset_attrfv( struct vbo_exec_context *exec ) - - for (i = 0 ; i < VBO_ATTRIB_MAX ; i++) { - exec->vtx.attrsz[i] = 0; -+ exec->vtx.attrtype[i] = GL_FLOAT; - exec->vtx.active_sz[i] = 0; - } - -@@ -1382,7 +1393,7 @@ VertexAttrib4f_nopos(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) - { - GET_CURRENT_CONTEXT(ctx); - if (index < MAX_VERTEX_GENERIC_ATTRIBS) -- ATTR(VBO_ATTRIB_GENERIC0 + index, 4, x, y, z, w); -+ ATTR(VBO_ATTRIB_GENERIC0 + index, 4, GL_FLOAT, x, y, z, w); - else - ERROR(GL_INVALID_VALUE); - } -diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c -index 77db8ec..14d22ee 100644 ---- a/src/mesa/vbo/vbo_exec_draw.c -+++ b/src/mesa/vbo/vbo_exec_draw.c -@@ -215,9 +215,6 @@ vbo_exec_bind_arrays( struct gl_context *ctx ) - assert(0); - } - -- /* Make all active attributes (including edgeflag) available as -- * arrays of floats. -- */ - for (attr = 0; attr < VERT_ATTRIB_MAX ; attr++) { - const GLuint src = map[attr]; - -@@ -243,7 +240,9 @@ vbo_exec_bind_arrays( struct gl_context *ctx ) - arrays[attr].Size = exec->vtx.attrsz[src]; - arrays[attr].StrideB = exec->vtx.vertex_size * sizeof(GLfloat); - arrays[attr].Stride = exec->vtx.vertex_size * sizeof(GLfloat); -- arrays[attr].Type = GL_FLOAT; -+ arrays[attr].Type = exec->vtx.attrtype[src]; -+ arrays[attr].Integer = -+ vbo_attrtype_to_integer_flag(exec->vtx.attrtype[src]); - arrays[attr].Format = GL_RGBA; - arrays[attr].Enabled = 1; - arrays[attr]._ElementSize = arrays[attr].Size * sizeof(GLfloat); -diff --git a/src/mesa/vbo/vbo_save.h b/src/mesa/vbo/vbo_save.h -index 0b4d563..9aadde4 100644 ---- a/src/mesa/vbo/vbo_save.h -+++ b/src/mesa/vbo/vbo_save.h -@@ -63,6 +63,7 @@ struct vbo_save_copied_vtx { - */ - struct vbo_save_vertex_list { - GLubyte attrsz[VBO_ATTRIB_MAX]; -+ GLenum attrtype[VBO_ATTRIB_MAX]; - GLuint vertex_size; - - /* Copy of the final vertex from node->vertex_store->bufferobj. -@@ -127,6 +128,7 @@ struct vbo_save_context { - const struct gl_client_array *inputs[VBO_ATTRIB_MAX]; - - GLubyte attrsz[VBO_ATTRIB_MAX]; -+ GLenum attrtype[VBO_ATTRIB_MAX]; - GLubyte active_sz[VBO_ATTRIB_MAX]; - GLuint vertex_size; - -diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c -index a02a13d..1386d71 100644 ---- a/src/mesa/vbo/vbo_save_api.c -+++ b/src/mesa/vbo/vbo_save_api.c -@@ -327,6 +327,7 @@ _save_compile_vertex_list(struct gl_context *ctx) - /* Duplicate our template, increment refcounts to the storage structs: - */ - memcpy(node->attrsz, save->attrsz, sizeof(node->attrsz)); -+ memcpy(node->attrtype, save->attrtype, sizeof(node->attrtype)); - node->vertex_size = save->vertex_size; - node->buffer_offset = - (save->buffer - save->vertex_store->buffer) * sizeof(GLfloat); -@@ -513,7 +514,8 @@ _save_copy_to_current(struct gl_context *ctx) - for (i = VBO_ATTRIB_POS + 1; i < VBO_ATTRIB_MAX; i++) { - if (save->attrsz[i]) { - save->currentsz[i][0] = save->attrsz[i]; -- COPY_CLEAN_4V(save->current[i], save->attrsz[i], save->attrptr[i]); -+ COPY_CLEAN_4V_TYPE_AS_FLOAT(save->current[i], save->attrsz[i], -+ save->attrptr[i], save->attrtype[i]); - } - } - } -@@ -615,7 +617,8 @@ _save_upgrade_vertex(struct gl_context *ctx, GLuint attr, GLuint newsz) - if (save->attrsz[j]) { - if (j == attr) { - if (oldsz) { -- COPY_CLEAN_4V(dest, oldsz, data); -+ COPY_CLEAN_4V_TYPE_AS_FLOAT(dest, oldsz, data, -+ save->attrtype[j]); - data += oldsz; - dest += newsz; - } -@@ -652,8 +655,8 @@ save_fixup_vertex(struct gl_context *ctx, GLuint attr, GLuint sz) - _save_upgrade_vertex(ctx, attr, sz); - } - else if (sz < save->active_sz[attr]) { -- static GLfloat id[4] = { 0, 0, 0, 1 }; - GLuint i; -+ const GLfloat *id = vbo_get_default_vals_as_float(save->attrtype[attr]); - - /* New size is equal or smaller - just need to fill in some - * zeros. -@@ -691,7 +694,7 @@ _save_reset_vertex(struct gl_context *ctx) - * 3f version won't otherwise set color[3] to 1.0 -- this is the job - * of the chooser function when switching between Color4f and Color3f. - */ --#define ATTR(A, N, V0, V1, V2, V3) \ -+#define ATTR(A, N, T, V0, V1, V2, V3) \ - do { \ - struct vbo_save_context *save = &vbo_context(ctx)->save; \ - \ -@@ -704,6 +707,7 @@ do { \ - if (N>1) dest[1] = V1; \ - if (N>2) dest[2] = V2; \ - if (N>3) dest[3] = V3; \ -+ save->attrtype[A] = T; \ - } \ - \ - if ((A) == 0) { \ -diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c -index c6425ab..8e70dbd 100644 ---- a/src/mesa/vbo/vbo_save_draw.c -+++ b/src/mesa/vbo/vbo_save_draw.c -@@ -82,16 +82,20 @@ _playback_copy_to_current(struct gl_context *ctx, - GLfloat *current = (GLfloat *)vbo->currval[i].Ptr; - GLfloat tmp[4]; - -- COPY_CLEAN_4V(tmp, -- node->attrsz[i], -- data); -+ COPY_CLEAN_4V_TYPE_AS_FLOAT(tmp, -+ node->attrsz[i], -+ data, -+ node->attrtype[i]); - -- if (memcmp(current, tmp, 4 * sizeof(GLfloat)) != 0) { -+ if (node->attrtype[i] != vbo->currval[i].Type || -+ memcmp(current, tmp, 4 * sizeof(GLfloat)) != 0) { - memcpy(current, tmp, 4 * sizeof(GLfloat)); - - vbo->currval[i].Size = node->attrsz[i]; -- assert(vbo->currval[i].Type == GL_FLOAT); - vbo->currval[i]._ElementSize = vbo->currval[i].Size * sizeof(GLfloat); -+ vbo->currval[i].Type = node->attrtype[i]; -+ vbo->currval[i].Integer = -+ vbo_attrtype_to_integer_flag(node->attrtype[i]); - - if (i >= VBO_ATTRIB_FIRST_MATERIAL && - i <= VBO_ATTRIB_LAST_MATERIAL) -@@ -137,9 +141,11 @@ static void vbo_bind_vertex_list(struct gl_context *ctx, - const GLuint *map; - GLuint attr; - GLubyte node_attrsz[VBO_ATTRIB_MAX]; /* copy of node->attrsz[] */ -+ GLenum node_attrtype[VBO_ATTRIB_MAX]; /* copy of node->attrtype[] */ - GLbitfield64 varying_inputs = 0x0; - - memcpy(node_attrsz, node->attrsz, sizeof(node->attrsz)); -+ memcpy(node_attrtype, node->attrtype, sizeof(node->attrtype)); - - /* Install the default (ie Current) attributes first, then overlay - * all active ones. -@@ -178,6 +184,7 @@ static void vbo_bind_vertex_list(struct gl_context *ctx, - (ctx->VertexProgram._Current->Base.InputsRead & VERT_BIT_GENERIC0)) { - save->inputs[VERT_ATTRIB_GENERIC0] = save->inputs[0]; - node_attrsz[VERT_ATTRIB_GENERIC0] = node_attrsz[0]; -+ node_attrtype[VERT_ATTRIB_GENERIC0] = node_attrtype[0]; - node_attrsz[0] = 0; - } - break; -@@ -196,7 +203,9 @@ static void vbo_bind_vertex_list(struct gl_context *ctx, - arrays[attr].Size = node_attrsz[src]; - arrays[attr].StrideB = node->vertex_size * sizeof(GLfloat); - arrays[attr].Stride = node->vertex_size * sizeof(GLfloat); -- arrays[attr].Type = GL_FLOAT; -+ arrays[attr].Type = node_attrtype[src]; -+ arrays[attr].Integer = -+ vbo_attrtype_to_integer_flag(node_attrtype[src]); - arrays[attr].Format = GL_RGBA; - arrays[attr].Enabled = 1; - arrays[attr]._ElementSize = arrays[attr].Size * sizeof(GLfloat); diff --git a/mesa-9.1-53-gd0ccb5b.patch b/mesa-9.1-53-gd0ccb5b.patch deleted file mode 100644 index 66b13fc..0000000 --- a/mesa-9.1-53-gd0ccb5b.patch +++ /dev/null @@ -1,1974 +0,0 @@ -diff --git a/bin/get-pick-list.sh b/bin/get-pick-list.sh -index a141afe..d3ac511 100755 ---- a/bin/get-pick-list.sh -+++ b/bin/get-pick-list.sh -@@ -8,7 +8,7 @@ git log --reverse --grep="cherry picked from commit" origin/master..HEAD |\ - sed -e 's/^[[:space:]]*(cherry picked from commit[[:space:]]*//' -e 's/)//' > already_picked - - # Grep for commits that were marked as a candidate for the stable tree. --git log --reverse --pretty=%H -i --grep='^[[:space:]]*NOTE: This is a candidate' HEAD..origin/master |\ -+git log --reverse --pretty=%H -i --grep='^[[:space:]]*NOTE: .*[Cc]andidate' HEAD..origin/master |\ - while read sha - do - # Check to see whether the patch is on the ignore list. -diff --git a/common.py b/common.py -index 6ff9608..1d618e6 100644 ---- a/common.py -+++ b/common.py -@@ -100,4 +100,4 @@ def AddOptions(opts): - opts.Add(BoolOption('quiet', 'DEPRECATED: profile build', 'yes')) - opts.Add(BoolOption('texture_float', 'enable floating-point textures and renderbuffers', 'no')) - if host_platform == 'windows': -- opts.Add(EnumOption('MSVS_VERSION', 'MS Visual C++ version', None, allowed_values=('7.1', '8.0', '9.0'))) -+ opts.Add(EnumOption('MSVC_VERSION', 'MS Visual C++ version', None, allowed_values=('7.1', '8.0', '9.0', '10.0', '11.0'))) -diff --git a/configure.ac b/configure.ac -index 5701f8a..d75cf65 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -1682,6 +1682,9 @@ if test "x$enable_gallium_llvm" = xyes; then - if $LLVM_CONFIG --components | grep -q '\'; then - LLVM_COMPONENTS="${LLVM_COMPONENTS} mcjit" - fi -+ if $LLVM_CONFIG --components | grep -q '\'; then -+ LLVM_COMPONENTS="${LLVM_COMPONENTS} oprofilejit" -+ fi - - if test "x$enable_opencl" = xyes; then - LLVM_COMPONENTS="${LLVM_COMPONENTS} ipo linker instrumentation" -diff --git a/docs/index.html b/docs/index.html -index 5c92204..5d7229d 100644 ---- a/docs/index.html -+++ b/docs/index.html -@@ -16,6 +16,23 @@ - -

News

- -+

February 22, 2013

-+ -+

-+Mesa 9.1 is released. -+This is a new development release. -+See the release notes for more information about the release. -+

-+ -+ -+

February 21, 2013

-+ -+

-+Mesa 9.0.3 is released. -+This is a bug fix release. -+

-+ -+ -

January 22, 2013

- -

-diff --git a/docs/relnotes-9.1.html b/docs/relnotes-9.1.html -index 24ba9f9..8232ab8 100644 ---- a/docs/relnotes-9.1.html -+++ b/docs/relnotes-9.1.html -@@ -14,7 +14,7 @@ - -

- --

Mesa 9.1 Release Notes / date February 22, 2013

-+

Mesa 9.1 Release Notes / February 22, 2013

- -

- Mesa 9.1 is a new development release. -@@ -33,7 +33,9 @@ because GL_ARB_compatibility is not supported. - -

MD5 checksums

-
--tbd
-+86d40f3056f89949368764bf84aff55e  MesaLib-9.1.tar.gz
-+d3891e02215422e120271d976ff1947e  MesaLib-9.1.tar.bz2
-+01645f28f53351c23b0beb6c688911d8  MesaLib-9.1.zip
- 
- - -diff --git a/docs/relnotes.html b/docs/relnotes.html -index e373091..2e11bc4 100644 ---- a/docs/relnotes.html -+++ b/docs/relnotes.html -@@ -22,6 +22,7 @@ The release notes summarize what's new or changed in each Mesa release. - -
    -
  • 9.1 release notes -+
  • 9.0.3 release notes -
  • 9.0.2 release notes -
  • 9.0.1 release notes -
  • 9.0 release notes -diff --git a/include/pci_ids/i965_pci_ids.h b/include/pci_ids/i965_pci_ids.h -index 09dca5b..1e388f8 100644 ---- a/include/pci_ids/i965_pci_ids.h -+++ b/include/pci_ids/i965_pci_ids.h -@@ -53,12 +53,12 @@ CHIPSET(0x0A26, HASWELL_ULT_M_GT2_PLUS, hsw_gt2) - CHIPSET(0x0A0A, HASWELL_ULT_S_GT1, hsw_gt1) - CHIPSET(0x0A1A, HASWELL_ULT_S_GT2, hsw_gt2) - CHIPSET(0x0A2A, HASWELL_ULT_S_GT2_PLUS, hsw_gt2) --CHIPSET(0x0D12, HASWELL_CRW_GT1, hsw_gt1) --CHIPSET(0x0D22, HASWELL_CRW_GT2, hsw_gt2) --CHIPSET(0x0D32, HASWELL_CRW_GT2_PLUS, hsw_gt2) --CHIPSET(0x0D16, HASWELL_CRW_M_GT1, hsw_gt1) --CHIPSET(0x0D26, HASWELL_CRW_M_GT2, hsw_gt2) --CHIPSET(0x0D36, HASWELL_CRW_M_GT2_PLUS, hsw_gt2) --CHIPSET(0x0D1A, HASWELL_CRW_S_GT1, hsw_gt1) --CHIPSET(0x0D2A, HASWELL_CRW_S_GT2, hsw_gt2) --CHIPSET(0x0D3A, HASWELL_CRW_S_GT2_PLUS, hsw_gt2) -+CHIPSET(0x0D02, HASWELL_CRW_GT1, hsw_gt1) -+CHIPSET(0x0D12, HASWELL_CRW_GT2, hsw_gt2) -+CHIPSET(0x0D22, HASWELL_CRW_GT2_PLUS, hsw_gt2) -+CHIPSET(0x0D06, HASWELL_CRW_M_GT1, hsw_gt1) -+CHIPSET(0x0D16, HASWELL_CRW_M_GT2, hsw_gt2) -+CHIPSET(0x0D26, HASWELL_CRW_M_GT2_PLUS, hsw_gt2) -+CHIPSET(0x0D0A, HASWELL_CRW_S_GT1, hsw_gt1) -+CHIPSET(0x0D1A, HASWELL_CRW_S_GT2, hsw_gt2) -+CHIPSET(0x0D2A, HASWELL_CRW_S_GT2_PLUS, hsw_gt2) -diff --git a/include/pci_ids/r600_pci_ids.h b/include/pci_ids/r600_pci_ids.h -index 7ceb820..9c9bab2 100644 ---- a/include/pci_ids/r600_pci_ids.h -+++ b/include/pci_ids/r600_pci_ids.h -@@ -298,6 +298,10 @@ CHIPSET(0x9907, ARUBA_9907, ARUBA) - CHIPSET(0x9908, ARUBA_9908, ARUBA) - CHIPSET(0x9909, ARUBA_9909, ARUBA) - CHIPSET(0x990A, ARUBA_990A, ARUBA) -+CHIPSET(0x990B, ARUBA_990B, ARUBA) -+CHIPSET(0x990C, ARUBA_990C, ARUBA) -+CHIPSET(0x990D, ARUBA_990D, ARUBA) -+CHIPSET(0x990E, ARUBA_990E, ARUBA) - CHIPSET(0x990F, ARUBA_990F, ARUBA) - CHIPSET(0x9910, ARUBA_9910, ARUBA) - CHIPSET(0x9913, ARUBA_9913, ARUBA) -@@ -309,6 +313,13 @@ CHIPSET(0x9991, ARUBA_9991, ARUBA) - CHIPSET(0x9992, ARUBA_9992, ARUBA) - CHIPSET(0x9993, ARUBA_9993, ARUBA) - CHIPSET(0x9994, ARUBA_9994, ARUBA) -+CHIPSET(0x9995, ARUBA_9995, ARUBA) -+CHIPSET(0x9996, ARUBA_9996, ARUBA) -+CHIPSET(0x9997, ARUBA_9997, ARUBA) -+CHIPSET(0x9998, ARUBA_9998, ARUBA) -+CHIPSET(0x9999, ARUBA_9999, ARUBA) -+CHIPSET(0x999A, ARUBA_999A, ARUBA) -+CHIPSET(0x999B, ARUBA_999B, ARUBA) - CHIPSET(0x99A0, ARUBA_99A0, ARUBA) - CHIPSET(0x99A2, ARUBA_99A2, ARUBA) - CHIPSET(0x99A4, ARUBA_99A4, ARUBA) -diff --git a/scons/gallium.py b/scons/gallium.py -index 4b51b6e..b28be5d 100755 ---- a/scons/gallium.py -+++ b/scons/gallium.py -@@ -289,6 +289,7 @@ def generate(env): - '_CRT_SECURE_NO_DEPRECATE', - '_SCL_SECURE_NO_WARNINGS', - '_SCL_SECURE_NO_DEPRECATE', -+ '_ALLOW_KEYWORD_MACROS', - ] - if env['build'] in ('debug', 'checked'): - cppdefines += ['_DEBUG'] -@@ -401,6 +402,8 @@ def generate(env): - '/Oi', # enable intrinsic functions - ] - else: -+ if distutils.version.LooseVersion(env['MSVC_VERSION']) < distutils.version.LooseVersion('11.0'): -+ print 'scons: warning: Visual Studio versions prior to 2012 are known to produce incorrect code when optimizations are enabled ( https://bugs.freedesktop.org/show_bug.cgi?id=58718 )' - ccflags += [ - '/O2', # optimize for speed - ] -diff --git a/scons/llvm.py b/scons/llvm.py -index e1ed760..7f00c6c 100644 ---- a/scons/llvm.py -+++ b/scons/llvm.py -@@ -92,7 +92,19 @@ def generate(env): - 'HAVE_STDINT_H', - ]) - env.Prepend(LIBPATH = [os.path.join(llvm_dir, 'lib')]) -- if llvm_version >= distutils.version.LooseVersion('3.0'): -+ if llvm_version >= distutils.version.LooseVersion('3.2'): -+ # 3.2 -+ env.Prepend(LIBS = [ -+ 'LLVMBitWriter', 'LLVMX86Disassembler', 'LLVMX86AsmParser', -+ 'LLVMX86CodeGen', 'LLVMX86Desc', 'LLVMSelectionDAG', -+ 'LLVMAsmPrinter', 'LLVMMCParser', 'LLVMX86AsmPrinter', -+ 'LLVMX86Utils', 'LLVMX86Info', 'LLVMJIT', -+ 'LLVMExecutionEngine', 'LLVMCodeGen', 'LLVMScalarOpts', -+ 'LLVMInstCombine', 'LLVMTransformUtils', 'LLVMipa', -+ 'LLVMAnalysis', 'LLVMTarget', 'LLVMMC', 'LLVMCore', -+ 'LLVMSupport', 'LLVMRuntimeDyld', 'LLVMObject' -+ ]) -+ elif llvm_version >= distutils.version.LooseVersion('3.0'): - # 3.0 - env.Prepend(LIBS = [ - 'LLVMBitWriter', 'LLVMX86Disassembler', 'LLVMX86AsmParser', -diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c -index 351fbf4..e17d5be 100644 ---- a/src/egl/drivers/dri2/egl_dri2.c -+++ b/src/egl/drivers/dri2/egl_dri2.c -@@ -195,7 +195,14 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id, - for (i = 0; attr_list[i] != EGL_NONE; i += 2) - _eglSetConfigKey(&base, attr_list[i], attr_list[i+1]); - -- if (depth > 0 && depth != base.BufferSize) -+ /* Allow a 24-bit RGB visual to match a 32-bit RGBA EGLConfig. Otherwise -+ * it will only match a 32-bit RGBA visual. On a composited window manager -+ * on X11, this will make all of the EGLConfigs with destination alpha get -+ * blended by the compositor. This is probably not what the application -+ * wants... especially on drivers that only have 32-bit RGBA EGLConfigs! -+ */ -+ if (depth > 0 && depth != base.BufferSize -+ && !(depth == 24 && base.BufferSize == 32)) - return NULL; - - if (rgba_masks && memcmp(rgba_masks, dri_masks, sizeof(dri_masks))) -diff --git a/src/gallium/auxiliary/draw/draw_pipe_clip.c b/src/gallium/auxiliary/draw/draw_pipe_clip.c -index 7b879c4..3110809 100644 ---- a/src/gallium/auxiliary/draw/draw_pipe_clip.c -+++ b/src/gallium/auxiliary/draw/draw_pipe_clip.c -@@ -167,12 +167,17 @@ static void interp( const struct clip_stage *clip, - { - int k; - t_nopersp = t; -- for (k = 0; k < 2; k++) -+ /* find either in.x != out.x or in.y != out.y */ -+ for (k = 0; k < 2; k++) { - if (in->clip[k] != out->clip[k]) { -- t_nopersp = (dst->clip[k] - out->clip[k]) / -- (in->clip[k] - out->clip[k]); -+ /* do divide by W, then compute linear interpolation factor */ -+ float in_coord = in->clip[k] / in->clip[3]; -+ float out_coord = out->clip[k] / out->clip[3]; -+ float dst_coord = dst->clip[k] / dst->clip[3]; -+ t_nopersp = (dst_coord - out_coord) / (in_coord - out_coord); - break; - } -+ } - } - - /* Other attributes -diff --git a/src/gallium/auxiliary/draw/draw_pipe_offset.c b/src/gallium/auxiliary/draw/draw_pipe_offset.c -index 3da52b1..3578525 100644 ---- a/src/gallium/auxiliary/draw/draw_pipe_offset.c -+++ b/src/gallium/auxiliary/draw/draw_pipe_offset.c -@@ -127,10 +127,44 @@ static void offset_first_tri( struct draw_stage *stage, - struct prim_header *header ) - { - struct offset_stage *offset = offset_stage(stage); -+ const struct pipe_rasterizer_state *rast = stage->draw->rasterizer; -+ unsigned fill_mode = rast->fill_front; -+ boolean do_offset; -+ -+ if (rast->fill_back != rast->fill_front) { -+ /* Need to check for back-facing triangle */ -+ boolean ccw = header->det < 0.0f; -+ if (ccw != rast->front_ccw) -+ fill_mode = rast->fill_back; -+ } -+ -+ /* Now determine if we need to do offsetting for the point/line/fill mode */ -+ switch (fill_mode) { -+ case PIPE_POLYGON_MODE_FILL: -+ do_offset = rast->offset_tri; -+ break; -+ case PIPE_POLYGON_MODE_LINE: -+ do_offset = rast->offset_line; -+ break; -+ case PIPE_POLYGON_MODE_POINT: -+ do_offset = rast->offset_point; -+ break; -+ default: -+ assert(!"invalid fill_mode in offset_first_tri()"); -+ do_offset = rast->offset_tri; -+ } -+ -+ if (do_offset) { -+ offset->scale = rast->offset_scale; -+ offset->clamp = rast->offset_clamp; -+ offset->units = (float) (rast->offset_units * stage->draw->mrd); -+ } -+ else { -+ offset->scale = 0.0f; -+ offset->clamp = 0.0f; -+ offset->units = 0.0f; -+ } - -- offset->units = (float) (stage->draw->rasterizer->offset_units * stage->draw->mrd); -- offset->scale = stage->draw->rasterizer->offset_scale; -- offset->clamp = stage->draw->rasterizer->offset_clamp; - - stage->tri = offset_tri; - stage->tri( stage, header ); -diff --git a/src/gallium/auxiliary/util/u_range.h b/src/gallium/auxiliary/util/u_range.h -new file mode 100644 -index 0000000..4b1d0d1 ---- /dev/null -+++ b/src/gallium/auxiliary/util/u_range.h -@@ -0,0 +1,89 @@ -+/* -+ * Copyright 2013 Marek Olšák -+ * -+ * Permission is hereby granted, free of charge, to any person obtaining a -+ * copy of this software and associated documentation files (the "Software"), -+ * to deal in the Software without restriction, including without limitation -+ * on the rights to use, copy, modify, merge, publish, distribute, sub -+ * license, and/or sell copies of the Software, and to permit persons to whom -+ * the Software is furnished to do so, subject to the following conditions: -+ * -+ * The above copyright notice and this permission notice (including the next -+ * paragraph) shall be included in all copies or substantial portions of the -+ * Software. -+ * -+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL -+ * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, -+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -+ * USE OR OTHER DEALINGS IN THE SOFTWARE. */ -+ -+/** -+ * @file -+ * 1D integer range, capable of the union and intersection operations. -+ * -+ * It only maintains a single interval which is extended when the union is -+ * done. This implementation is partially thread-safe (readers are not -+ * protected by a lock). -+ * -+ * @author Marek Olšák -+ */ -+ -+#ifndef U_RANGE_H -+#define U_RANGE_H -+ -+#include "os/os_thread.h" -+ -+struct util_range { -+ unsigned start; /* inclusive */ -+ unsigned end; /* exclusive */ -+ -+ /* for the range to be consistent with multiple contexts: */ -+ pipe_mutex write_mutex; -+}; -+ -+ -+static INLINE void -+util_range_set_empty(struct util_range *range) -+{ -+ range->start = ~0; -+ range->end = 0; -+} -+ -+/* This is like a union of two sets. */ -+static INLINE void -+util_range_add(struct util_range *range, unsigned start, unsigned end) -+{ -+ if (start < range->start || end > range->end) { -+ pipe_mutex_lock(range->write_mutex); -+ range->start = MIN2(start, range->start); -+ range->end = MAX2(end, range->end); -+ pipe_mutex_unlock(range->write_mutex); -+ } -+} -+ -+static INLINE boolean -+util_ranges_intersect(struct util_range *range, unsigned start, unsigned end) -+{ -+ return MAX2(start, range->start) < MIN2(end, range->end); -+} -+ -+ -+/* Init/deinit */ -+ -+static INLINE void -+util_range_init(struct util_range *range) -+{ -+ pipe_mutex_init(range->write_mutex); -+ util_range_set_empty(range); -+} -+ -+static INLINE void -+util_range_destroy(struct util_range *range) -+{ -+ pipe_mutex_destroy(range->write_mutex); -+} -+ -+#endif -diff --git a/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c b/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c -index 40ccaf6..ca8df71 100644 ---- a/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c -+++ b/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c -@@ -46,6 +46,10 @@ clear_flags(struct pipe_rasterizer_state *rast) - { - rast->light_twoside = 0; - rast->offset_tri = 0; -+ rast->offset_line = 0; -+ rast->offset_point = 0; -+ rast->offset_units = 0.0f; -+ rast->offset_scale = 0.0f; - } - - -@@ -74,6 +78,8 @@ llvmpipe_create_rasterizer_state(struct pipe_context *pipe, - */ - need_pipeline = (rast->fill_front != PIPE_POLYGON_MODE_FILL || - rast->fill_back != PIPE_POLYGON_MODE_FILL || -+ rast->offset_point || -+ rast->offset_line || - rast->point_smooth || - rast->line_smooth || - rast->line_stipple_enable || -diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c -index 2e9c6bf..f17a04a 100644 ---- a/src/gallium/drivers/llvmpipe/lp_texture.c -+++ b/src/gallium/drivers/llvmpipe/lp_texture.c -@@ -295,7 +295,9 @@ llvmpipe_resource_create(struct pipe_screen *_screen, - /* assert(lpr->base.bind); */ - - if (resource_is_texture(&lpr->base)) { -- if (lpr->base.bind & PIPE_BIND_DISPLAY_TARGET) { -+ if (lpr->base.bind & (PIPE_BIND_DISPLAY_TARGET | -+ PIPE_BIND_SCANOUT | -+ PIPE_BIND_SHARED)) { - /* displayable surface */ - if (!llvmpipe_displaytarget_layout(screen, lpr)) - goto fail; -diff --git a/src/gallium/drivers/r600/evergreen_hw_context.c b/src/gallium/drivers/r600/evergreen_hw_context.c -index bb47530..bb43353 100644 ---- a/src/gallium/drivers/r600/evergreen_hw_context.c -+++ b/src/gallium/drivers/r600/evergreen_hw_context.c -@@ -283,4 +283,7 @@ void evergreen_dma_copy(struct r600_context *rctx, - src_offset += csize << shift; - size -= csize; - } -+ -+ util_range_add(&rdst->valid_buffer_range, dst_offset, -+ dst_offset + size); - } -diff --git a/src/gallium/drivers/r600/evergreen_state.c b/src/gallium/drivers/r600/evergreen_state.c -index 389ad3c..804c037 100644 ---- a/src/gallium/drivers/r600/evergreen_state.c -+++ b/src/gallium/drivers/r600/evergreen_state.c -@@ -808,6 +808,7 @@ static void *evergreen_create_dsa_state(struct pipe_context *ctx, - dsa->valuemask[1] = state->stencil[1].valuemask; - dsa->writemask[0] = state->stencil[0].writemask; - dsa->writemask[1] = state->stencil[1].writemask; -+ dsa->zwritemask = state->depth.writemask; - - db_depth_control = S_028800_Z_ENABLE(state->depth.enabled) | - S_028800_Z_WRITE_ENABLE(state->depth.writemask) | -@@ -1321,6 +1322,10 @@ void evergreen_init_color_surface_rat(struct r600_context *rctx, - * elements. */ - surf->cb_color_dim = pipe_buffer->width0; - -+ /* Set the buffer range the GPU will have access to: */ -+ util_range_add(&r600_resource(pipe_buffer)->valid_buffer_range, -+ 0, pipe_buffer->width0); -+ - surf->cb_color_cmask = surf->cb_color_base; - surf->cb_color_cmask_slice = 0; - surf->cb_color_fmask = surf->cb_color_base; -@@ -1405,10 +1410,15 @@ void evergreen_init_color_surface(struct r600_context *rctx, - S_028C74_NON_DISP_TILING_ORDER(non_disp_tiling) | - S_028C74_FMASK_BANK_HEIGHT(fmask_bankh); - -- if (rctx->chip_class == CAYMAN && rtex->resource.b.b.nr_samples > 1) { -- unsigned log_samples = util_logbase2(rtex->resource.b.b.nr_samples); -- color_attrib |= S_028C74_NUM_SAMPLES(log_samples) | -- S_028C74_NUM_FRAGMENTS(log_samples); -+ if (rctx->chip_class == CAYMAN) { -+ color_attrib |= S_028C74_FORCE_DST_ALPHA_1(desc->swizzle[3] == -+ UTIL_FORMAT_SWIZZLE_1); -+ -+ if (rtex->resource.b.b.nr_samples > 1) { -+ unsigned log_samples = util_logbase2(rtex->resource.b.b.nr_samples); -+ color_attrib |= S_028C74_NUM_SAMPLES(log_samples) | -+ S_028C74_NUM_FRAGMENTS(log_samples); -+ } - } - - ntype = V_028C70_NUMBER_UNORM; -@@ -1647,6 +1657,11 @@ static void evergreen_set_framebuffer_state(struct pipe_context *ctx, - } - if (rctx->framebuffer.state.zsbuf) { - rctx->flags |= R600_CONTEXT_WAIT_3D_IDLE | R600_CONTEXT_FLUSH_AND_INV; -+ -+ rtex = (struct r600_texture*)rctx->framebuffer.state.zsbuf->texture; -+ if (rtex->htile) { -+ rctx->flags |= R600_CONTEXT_FLUSH_AND_INV_DB_META; -+ } - } - - util_copy_framebuffer_state(&rctx->framebuffer.state, state); -@@ -2222,7 +2237,14 @@ static void evergreen_emit_db_misc_state(struct r600_context *rctx, struct r600_ - } - db_render_override |= S_02800C_NOOP_CULL_DISABLE(1); - } -- if (rctx->db_state.rsurf && rctx->db_state.rsurf->htile_enabled) { -+ /* FIXME we should be able to use hyperz even if we are not writing to -+ * zbuffer but somehow this trigger GPU lockup. See : -+ * -+ * https://bugs.freedesktop.org/show_bug.cgi?id=60848 -+ * -+ * Disable hyperz for now if not writing to zbuffer. -+ */ -+ if (rctx->db_state.rsurf && rctx->db_state.rsurf->htile_enabled && rctx->zwritemask) { - /* FORCE_OFF means HiZ/HiS are determined by DB_SHADER_CONTROL */ - db_render_override |= S_02800C_FORCE_HIZ_ENABLE(V_02800C_FORCE_OFF); - /* This is to fix a lockup when hyperz and alpha test are enabled at -@@ -3654,6 +3676,17 @@ boolean evergreen_dma_blit(struct pipe_context *ctx, - return FALSE; - } - -+ /* 128 bpp surfaces require non_disp_tiling for both -+ * tiled and linear buffers on cayman. However, async -+ * DMA only supports it on the tiled side. As such -+ * the tile order is backwards after a L2T/T2L packet. -+ */ -+ if ((rctx->chip_class == CAYMAN) && -+ (src_mode != dst_mode) && -+ (util_format_get_blocksize(src->format) >= 16)) { -+ return FALSE; -+ } -+ - if (src_mode == dst_mode) { - uint64_t dst_offset, src_offset; - /* simple dma blit would do NOTE code here assume : -diff --git a/src/gallium/drivers/r600/r600.h b/src/gallium/drivers/r600/r600.h -index 11dbb3b..0115293 100644 ---- a/src/gallium/drivers/r600/r600.h -+++ b/src/gallium/drivers/r600/r600.h -@@ -28,6 +28,7 @@ - - #include "../../winsys/radeon/drm/radeon_winsys.h" - #include "util/u_double_list.h" -+#include "util/u_range.h" - #include "util/u_transfer.h" - - #define R600_ERR(fmt, args...) \ -@@ -50,6 +51,16 @@ struct r600_resource { - - /* Resource state. */ - unsigned domains; -+ -+ /* The buffer range which is initialized (with a write transfer, -+ * streamout, DMA, or as a random access target). The rest of -+ * the buffer is considered invalid and can be mapped unsynchronized. -+ * -+ * This allows unsychronized mapping of a buffer range which hasn't -+ * been used yet. It's for applications which forget to use -+ * the unsynchronized map flag and expect the driver to figure it out. -+ */ -+ struct util_range valid_buffer_range; - }; - - #define R600_BLOCK_MAX_BO 32 -@@ -152,6 +163,7 @@ struct r600_so_target { - #define R600_CONTEXT_FLUSH_AND_INV (1 << 4) - #define R600_CONTEXT_FLUSH_AND_INV_CB_META (1 << 5) - #define R600_CONTEXT_PS_PARTIAL_FLUSH (1 << 6) -+#define R600_CONTEXT_FLUSH_AND_INV_DB_META (1 << 7) - - struct r600_context; - struct r600_screen; -diff --git a/src/gallium/drivers/r600/r600_asm.c b/src/gallium/drivers/r600/r600_asm.c -index f25c6aa..bda425c 100644 ---- a/src/gallium/drivers/r600/r600_asm.c -+++ b/src/gallium/drivers/r600/r600_asm.c -@@ -322,6 +322,7 @@ int r600_bytecode_add_output(struct r600_bytecode *bc, const struct r600_bytecod - output->swizzle_y == bc->cf_last->output.swizzle_y && - output->swizzle_z == bc->cf_last->output.swizzle_z && - output->swizzle_w == bc->cf_last->output.swizzle_w && -+ output->comp_mask == bc->cf_last->output.comp_mask && - (output->burst_count + bc->cf_last->output.burst_count) <= 16) { - - if ((output->gpr + output->burst_count) == bc->cf_last->output.gpr && -@@ -873,12 +874,6 @@ static int check_and_set_bank_swizzle(struct r600_bytecode *bc, - bank_swizzle[4] = SQ_ALU_SCL_210; - while(bank_swizzle[4] <= SQ_ALU_SCL_221) { - -- if (max_slots == 4) { -- for (i = 0; i < max_slots; i++) { -- if (bank_swizzle[i] == SQ_ALU_VEC_210) -- return -1; -- } -- } - init_bank_swizzle(&bs); - if (scalar_only == false) { - for (i = 0; i < 4; i++) { -@@ -910,8 +905,10 @@ static int check_and_set_bank_swizzle(struct r600_bytecode *bc, - bank_swizzle[i]++; - if (bank_swizzle[i] <= SQ_ALU_VEC_210) - break; -- else -+ else if (i < max_slots - 1) - bank_swizzle[i] = SQ_ALU_VEC_012; -+ else -+ return -1; - } - } - } -diff --git a/src/gallium/drivers/r600/r600_buffer.c b/src/gallium/drivers/r600/r600_buffer.c -index 6df0d91..bb85fc1 100644 ---- a/src/gallium/drivers/r600/r600_buffer.c -+++ b/src/gallium/drivers/r600/r600_buffer.c -@@ -34,6 +34,7 @@ static void r600_buffer_destroy(struct pipe_screen *screen, - { - struct r600_resource *rbuffer = r600_resource(buf); - -+ util_range_destroy(&rbuffer->valid_buffer_range); - pb_reference(&rbuffer->buf, NULL); - FREE(rbuffer); - } -@@ -98,6 +99,14 @@ static void *r600_buffer_transfer_map(struct pipe_context *ctx, - - assert(box->x + box->width <= resource->width0); - -+ /* See if the buffer range being mapped has never been initialized, -+ * in which case it can be mapped unsynchronized. */ -+ if (!(usage & PIPE_TRANSFER_UNSYNCHRONIZED) && -+ usage & PIPE_TRANSFER_WRITE && -+ !util_ranges_intersect(&rbuffer->valid_buffer_range, box->x, box->x + box->width)) { -+ usage |= PIPE_TRANSFER_UNSYNCHRONIZED; -+ } -+ - if (usage & PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE && - !(usage & PIPE_TRANSFER_UNSYNCHRONIZED)) { - assert(usage & PIPE_TRANSFER_WRITE); -@@ -178,6 +187,7 @@ static void r600_buffer_transfer_unmap(struct pipe_context *pipe, - { - struct r600_context *rctx = (struct r600_context*)pipe; - struct r600_transfer *rtransfer = (struct r600_transfer*)transfer; -+ struct r600_resource *rbuffer = r600_resource(transfer->resource); - - if (rtransfer->staging) { - struct pipe_resource *dst, *src; -@@ -189,7 +199,7 @@ static void r600_buffer_transfer_unmap(struct pipe_context *pipe, - doffset = transfer->box.x; - soffset = rtransfer->offset + transfer->box.x % R600_MAP_BUFFER_ALIGNMENT; - /* Copy the staging buffer into the original one. */ -- if (rctx->rings.dma.cs && !(size % 4) && !(doffset % 4) && !(soffset)) { -+ if (rctx->rings.dma.cs && !(size % 4) && !(doffset % 4) && !(soffset % 4)) { - if (rctx->screen->chip_class >= EVERGREEN) { - evergreen_dma_copy(rctx, dst, src, doffset, soffset, size); - } else { -@@ -203,6 +213,11 @@ static void r600_buffer_transfer_unmap(struct pipe_context *pipe, - } - pipe_resource_reference((struct pipe_resource**)&rtransfer->staging, NULL); - } -+ -+ if (transfer->usage & PIPE_TRANSFER_WRITE) { -+ util_range_add(&rbuffer->valid_buffer_range, transfer->box.x, -+ transfer->box.x + transfer->box.width); -+ } - util_slab_free(&rctx->pool_transfers, transfer); - } - -@@ -259,6 +274,7 @@ bool r600_init_resource(struct r600_screen *rscreen, - - res->cs_buf = rscreen->ws->buffer_get_cs_handle(res->buf); - res->domains = domains; -+ util_range_set_empty(&res->valid_buffer_range); - return true; - } - -@@ -275,6 +291,7 @@ struct pipe_resource *r600_buffer_create(struct pipe_screen *screen, - pipe_reference_init(&rbuffer->b.b.reference, 1); - rbuffer->b.b.screen = screen; - rbuffer->b.vtbl = &r600_buffer_vtbl; -+ util_range_init(&rbuffer->valid_buffer_range); - - if (!r600_init_resource(rscreen, rbuffer, templ->width0, alignment, TRUE, templ->usage)) { - FREE(rbuffer); -diff --git a/src/gallium/drivers/r600/r600_hw_context.c b/src/gallium/drivers/r600/r600_hw_context.c -index 9091ec0..322381a 100644 ---- a/src/gallium/drivers/r600/r600_hw_context.c -+++ b/src/gallium/drivers/r600/r600_hw_context.c -@@ -648,6 +648,12 @@ void r600_flush_emit(struct r600_context *rctx) - cs->buf[cs->cdw++] = EVENT_TYPE(EVENT_TYPE_FLUSH_AND_INV_CB_META) | EVENT_INDEX(0); - } - -+ if (rctx->chip_class >= R700 && -+ (rctx->flags & R600_CONTEXT_FLUSH_AND_INV_DB_META)) { -+ cs->buf[cs->cdw++] = PKT3(PKT3_EVENT_WRITE, 0, 0); -+ cs->buf[cs->cdw++] = EVENT_TYPE(EVENT_TYPE_FLUSH_AND_INV_DB_META) | EVENT_INDEX(0); -+ } -+ - if (rctx->flags & R600_CONTEXT_FLUSH_AND_INV) { - cs->buf[cs->cdw++] = PKT3(PKT3_EVENT_WRITE, 0, 0); - cs->buf[cs->cdw++] = EVENT_TYPE(EVENT_TYPE_CACHE_FLUSH_AND_INV_EVENT) | EVENT_INDEX(0); -@@ -742,6 +748,7 @@ void r600_context_flush(struct r600_context *ctx, unsigned flags) - */ - ctx->flags |= R600_CONTEXT_FLUSH_AND_INV | - R600_CONTEXT_FLUSH_AND_INV_CB_META | -+ R600_CONTEXT_FLUSH_AND_INV_DB_META | - R600_CONTEXT_WAIT_3D_IDLE | - R600_CONTEXT_WAIT_CP_DMA_IDLE; - -@@ -1119,6 +1126,7 @@ void r600_cp_dma_copy_buffer(struct r600_context *rctx, - rctx->flags |= R600_CONTEXT_INVAL_READ_CACHES | - R600_CONTEXT_FLUSH_AND_INV | - R600_CONTEXT_FLUSH_AND_INV_CB_META | -+ R600_CONTEXT_FLUSH_AND_INV_DB_META | - R600_CONTEXT_STREAMOUT_FLUSH | - R600_CONTEXT_WAIT_3D_IDLE; - -@@ -1164,6 +1172,9 @@ void r600_cp_dma_copy_buffer(struct r600_context *rctx, - - /* Invalidate the read caches. */ - rctx->flags |= R600_CONTEXT_INVAL_READ_CACHES; -+ -+ util_range_add(&r600_resource(dst)->valid_buffer_range, dst_offset, -+ dst_offset + size); - } - - void r600_need_dma_space(struct r600_context *ctx, unsigned num_dw) -@@ -1210,4 +1221,7 @@ void r600_dma_copy(struct r600_context *rctx, - src_offset += csize << shift; - size -= csize; - } -+ -+ util_range_add(&rdst->valid_buffer_range, dst_offset, -+ dst_offset + size); - } -diff --git a/src/gallium/drivers/r600/r600_hw_context_priv.h b/src/gallium/drivers/r600/r600_hw_context_priv.h -index 692e6ec..3b50f68 100644 ---- a/src/gallium/drivers/r600/r600_hw_context_priv.h -+++ b/src/gallium/drivers/r600/r600_hw_context_priv.h -@@ -29,7 +29,7 @@ - #include "r600_pipe.h" - - /* the number of CS dwords for flushing and drawing */ --#define R600_MAX_FLUSH_CS_DWORDS 12 -+#define R600_MAX_FLUSH_CS_DWORDS 16 - #define R600_MAX_DRAW_CS_DWORDS 34 - #define R600_TRACE_CS_DWORDS 7 - -diff --git a/src/gallium/drivers/r600/r600_llvm.c b/src/gallium/drivers/r600/r600_llvm.c -index fa66fcc..7a41688 100644 ---- a/src/gallium/drivers/r600/r600_llvm.c -+++ b/src/gallium/drivers/r600/r600_llvm.c -@@ -38,8 +38,12 @@ static LLVMValueRef llvm_fetch_const( - LLVMValueRef index = LLVMBuildLoad(bld_base->base.gallivm->builder, bld->addr[reg->Indirect.Index][reg->Indirect.SwizzleX], ""); - offset[1] = LLVMBuildAdd(bld_base->base.gallivm->builder, offset[1], index, ""); - } -+ unsigned ConstantAddressSpace = CONSTANT_BUFFER_0_ADDR_SPACE ; -+ if (reg->Register.Dimension) { -+ ConstantAddressSpace += reg->Dimension.Index; -+ } - LLVMTypeRef const_ptr_type = LLVMPointerType(LLVMArrayType(LLVMVectorType(bld_base->base.elem_type, 4), 1024), -- CONSTANT_BUFFER_0_ADDR_SPACE); -+ ConstantAddressSpace); - LLVMValueRef const_ptr = LLVMBuildIntToPtr(bld_base->base.gallivm->builder, lp_build_const_int32(bld_base->base.gallivm, 0), const_ptr_type, ""); - LLVMValueRef ptr = LLVMBuildGEP(bld_base->base.gallivm->builder, const_ptr, offset, 2, ""); - LLVMValueRef cvecval = LLVMBuildLoad(bld_base->base.gallivm->builder, ptr, ""); -diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c -index a59578d..a7973a5 100644 ---- a/src/gallium/drivers/r600/r600_pipe.c -+++ b/src/gallium/drivers/r600/r600_pipe.c -@@ -22,6 +22,7 @@ - */ - #include "r600_pipe.h" - #include "r600_public.h" -+#include "r600d.h" - - #include - #include "pipe/p_shader_tokens.h" -@@ -165,12 +166,23 @@ static void r600_flush_gfx_ring(void *ctx, unsigned flags) - static void r600_flush_dma_ring(void *ctx, unsigned flags) - { - struct r600_context *rctx = (struct r600_context *)ctx; -+ struct radeon_winsys_cs *cs = rctx->rings.dma.cs; -+ unsigned padding_dw, i; - -- if (!rctx->rings.dma.cs->cdw) { -+ if (!cs->cdw) { - return; - } -+ -+ /* Pad the DMA CS to a multiple of 8 dwords. */ -+ padding_dw = 8 - cs->cdw % 8; -+ if (padding_dw < 8) { -+ for (i = 0; i < padding_dw; i++) { -+ cs->buf[cs->cdw++] = DMA_PACKET(DMA_PACKET_NOP, 0, 0, 0); -+ } -+ } -+ - rctx->rings.dma.flushing = true; -- rctx->ws->cs_flush(rctx->rings.dma.cs, flags); -+ rctx->ws->cs_flush(cs, flags); - rctx->rings.dma.flushing = false; - } - -diff --git a/src/gallium/drivers/r600/r600_pipe.h b/src/gallium/drivers/r600/r600_pipe.h -index ec59c92..1be4321 100644 ---- a/src/gallium/drivers/r600/r600_pipe.h -+++ b/src/gallium/drivers/r600/r600_pipe.h -@@ -298,7 +298,8 @@ struct r600_dsa_state { - unsigned alpha_ref; - ubyte valuemask[2]; - ubyte writemask[2]; -- unsigned sx_alpha_test_control; -+ unsigned zwritemask; -+ unsigned sx_alpha_test_control; - }; - - struct r600_pipe_shader; -@@ -513,6 +514,7 @@ struct r600_context { - bool alpha_to_one; - bool force_blend_disable; - boolean dual_src_blend; -+ unsigned zwritemask; - - /* Index buffer. */ - struct pipe_index_buffer index_buffer; -diff --git a/src/gallium/drivers/r600/r600_state.c b/src/gallium/drivers/r600/r600_state.c -index 3f165f7..70232fd 100644 ---- a/src/gallium/drivers/r600/r600_state.c -+++ b/src/gallium/drivers/r600/r600_state.c -@@ -802,6 +802,7 @@ static void *r600_create_dsa_state(struct pipe_context *ctx, - dsa->valuemask[1] = state->stencil[1].valuemask; - dsa->writemask[0] = state->stencil[0].writemask; - dsa->writemask[1] = state->stencil[1].writemask; -+ dsa->zwritemask = state->depth.writemask; - - db_depth_control = S_028800_Z_ENABLE(state->depth.enabled) | - S_028800_Z_WRITE_ENABLE(state->depth.writemask) | -@@ -1515,6 +1516,11 @@ static void r600_set_framebuffer_state(struct pipe_context *ctx, - } - if (rctx->framebuffer.state.zsbuf) { - rctx->flags |= R600_CONTEXT_WAIT_3D_IDLE | R600_CONTEXT_FLUSH_AND_INV; -+ -+ rtex = (struct r600_texture*)rctx->framebuffer.state.zsbuf->texture; -+ if (rctx->chip_class >= R700 && rtex->htile) { -+ rctx->flags |= R600_CONTEXT_FLUSH_AND_INV_DB_META; -+ } - } - - /* Set the new state. */ -diff --git a/src/gallium/drivers/r600/r600_state_common.c b/src/gallium/drivers/r600/r600_state_common.c -index 88bb62b..f0e9de3 100644 ---- a/src/gallium/drivers/r600/r600_state_common.c -+++ b/src/gallium/drivers/r600/r600_state_common.c -@@ -284,6 +284,16 @@ static void r600_bind_dsa_state(struct pipe_context *ctx, void *state) - ref.valuemask[1] = dsa->valuemask[1]; - ref.writemask[0] = dsa->writemask[0]; - ref.writemask[1] = dsa->writemask[1]; -+ if (rctx->zwritemask != dsa->zwritemask) { -+ rctx->zwritemask = dsa->zwritemask; -+ if (rctx->chip_class >= EVERGREEN) { -+ /* work around some issue when not writting to zbuffer -+ * we are having lockup on evergreen so do not enable -+ * hyperz when not writting zbuffer -+ */ -+ rctx->db_misc_state.atom.dirty = true; -+ } -+ } - - r600_set_stencil_ref(ctx, &ref); - -@@ -972,6 +982,7 @@ r600_create_so_target(struct pipe_context *ctx, - { - struct r600_context *rctx = (struct r600_context *)ctx; - struct r600_so_target *t; -+ struct r600_resource *rbuffer = (struct r600_resource*)buffer; - - t = CALLOC_STRUCT(r600_so_target); - if (!t) { -@@ -991,6 +1002,9 @@ r600_create_so_target(struct pipe_context *ctx, - pipe_resource_reference(&t->b.buffer, buffer); - t->b.buffer_offset = buffer_offset; - t->b.buffer_size = buffer_size; -+ -+ util_range_add(&rbuffer->valid_buffer_range, buffer_offset, -+ buffer_offset + buffer_size); - return &t->b; - } - -diff --git a/src/gallium/drivers/r600/r600d.h b/src/gallium/drivers/r600/r600d.h -index 621e7a1..81e5a6c 100644 ---- a/src/gallium/drivers/r600/r600d.h -+++ b/src/gallium/drivers/r600/r600d.h -@@ -119,6 +119,7 @@ - #define EVENT_TYPE_CACHE_FLUSH_AND_INV_EVENT 0x16 - #define EVENT_TYPE_SO_VGTSTREAMOUT_FLUSH 0x1f - #define EVENT_TYPE_SAMPLE_STREAMOUTSTATS 0x20 -+#define EVENT_TYPE_FLUSH_AND_INV_DB_META 0x2c /* supported on r700+ */ - #define EVENT_TYPE_FLUSH_AND_INV_CB_META 46 /* supported on r700+ */ - #define EVENT_TYPE(x) ((x) << 0) - #define EVENT_INDEX(x) ((x) << 8) -diff --git a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c -index 0f90991..8902ae4 100644 ---- a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c -+++ b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c -@@ -766,6 +766,22 @@ static void emit_icmp( - emit_data->output[emit_data->chan] = v; - } - -+static void emit_ucmp( -+ const struct lp_build_tgsi_action * action, -+ struct lp_build_tgsi_context * bld_base, -+ struct lp_build_emit_data * emit_data) -+{ -+ unsigned pred; -+ LLVMBuilderRef builder = bld_base->base.gallivm->builder; -+ LLVMContextRef context = bld_base->base.gallivm->context; -+ -+ -+ LLVMValueRef v = LLVMBuildFCmp(builder, LLVMRealUGE, -+ emit_data->args[0], lp_build_const_float(bld_base->base.gallivm, 0.), ""); -+ -+ emit_data->output[emit_data->chan] = LLVMBuildSelect(builder, v, emit_data->args[2], emit_data->args[1], ""); -+} -+ - static void emit_cmp( - const struct lp_build_tgsi_action *action, - struct lp_build_tgsi_context * bld_base, -@@ -1241,6 +1257,7 @@ void radeon_llvm_context_init(struct radeon_llvm_context * ctx) - bld_base->op_actions[TGSI_OPCODE_USNE].emit = emit_icmp; - bld_base->op_actions[TGSI_OPCODE_U2F].emit = emit_u2f; - bld_base->op_actions[TGSI_OPCODE_XOR].emit = emit_xor; -+ bld_base->op_actions[TGSI_OPCODE_UCMP].emit = emit_ucmp; - - bld_base->rsq_action.emit = build_tgsi_intrinsic_nomem; - bld_base->rsq_action.intr_name = "llvm.AMDGPU.rsq"; -diff --git a/src/gallium/drivers/radeonsi/radeonsi_shader.c b/src/gallium/drivers/radeonsi/radeonsi_shader.c -index 2545634..7922928 100644 ---- a/src/gallium/drivers/radeonsi/radeonsi_shader.c -+++ b/src/gallium/drivers/radeonsi/radeonsi_shader.c -@@ -309,14 +309,8 @@ static void declare_input_fs( - /* XXX: Handle all possible interpolation modes */ - switch (decl->Interp.Interpolate) { - case TGSI_INTERPOLATE_COLOR: -- /* XXX: Flat shading hangs the GPU */ -- if (si_shader_ctx->rctx->queued.named.rasterizer && -- si_shader_ctx->rctx->queued.named.rasterizer->flatshade) { --#if 0 -+ if (si_shader_ctx->key.flatshade) { - intr_name = "llvm.SI.fs.interp.constant"; --#else -- intr_name = "llvm.SI.fs.interp.linear.center"; --#endif - } else { - if (decl->Interp.Centroid) - intr_name = "llvm.SI.fs.interp.persp.centroid"; -@@ -325,11 +319,8 @@ static void declare_input_fs( - } - break; - case TGSI_INTERPOLATE_CONSTANT: -- /* XXX: Flat shading hangs the GPU */ --#if 0 - intr_name = "llvm.SI.fs.interp.constant"; - break; --#endif - case TGSI_INTERPOLATE_LINEAR: - if (decl->Interp.Centroid) - intr_name = "llvm.SI.fs.interp.linear.centroid"; -diff --git a/src/gallium/drivers/radeonsi/radeonsi_shader.h b/src/gallium/drivers/radeonsi/radeonsi_shader.h -index 07b2f9f..f54f67c 100644 ---- a/src/gallium/drivers/radeonsi/radeonsi_shader.h -+++ b/src/gallium/drivers/radeonsi/radeonsi_shader.h -@@ -82,6 +82,7 @@ struct si_shader_key { - unsigned nr_cbufs:4; - unsigned color_two_side:1; - unsigned alpha_func:3; -+ unsigned flatshade:1; - float alpha_ref; - }; - -diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c -index a6b1983..39817fb 100644 ---- a/src/gallium/drivers/radeonsi/si_state.c -+++ b/src/gallium/drivers/radeonsi/si_state.c -@@ -421,8 +421,7 @@ static void *si_create_rs_state(struct pipe_context *ctx, - rs->offset_units = state->offset_units; - rs->offset_scale = state->offset_scale * 12.0f; - -- /* XXX: Flat shading hangs the GPU */ -- tmp = S_0286D4_FLAT_SHADE_ENA(0); -+ tmp = S_0286D4_FLAT_SHADE_ENA(1); - if (state->sprite_coord_enable) { - tmp |= S_0286D4_PNT_SPRITE_ENA(1) | - S_0286D4_PNT_SPRITE_OVRD_X(V_0286D4_SPI_PNT_SPRITE_SEL_S) | -@@ -1859,7 +1858,7 @@ static INLINE struct si_shader_key si_shader_selector_key(struct pipe_context *c - key.export_16bpc = rctx->export_16bpc; - if (rctx->queued.named.rasterizer) { - key.color_two_side = rctx->queued.named.rasterizer->two_side; -- /*key.flatshade = rctx->queued.named.rasterizer->flatshade;*/ -+ key.flatshade = rctx->queued.named.rasterizer->flatshade; - } - if (rctx->queued.named.dsa) { - key.alpha_func = rctx->queued.named.dsa->alpha_func; -diff --git a/src/gallium/drivers/radeonsi/si_state_draw.c b/src/gallium/drivers/radeonsi/si_state_draw.c -index 3704410..8c35625 100644 ---- a/src/gallium/drivers/radeonsi/si_state_draw.c -+++ b/src/gallium/drivers/radeonsi/si_state_draw.c -@@ -128,11 +128,6 @@ static void si_pipe_shader_ps(struct pipe_context *ctx, struct si_pipe_shader *s - continue; - } - -- /* XXX: Flat shading hangs the GPU */ -- if (shader->shader.input[i].interpolate == TGSI_INTERPOLATE_CONSTANT || -- (shader->shader.input[i].interpolate == TGSI_INTERPOLATE_COLOR && -- rctx->queued.named.rasterizer->flatshade)) -- have_linear = TRUE; - if (shader->shader.input[i].interpolate == TGSI_INTERPOLATE_LINEAR) - have_linear = TRUE; - if (shader->shader.input[i].interpolate == TGSI_INTERPOLATE_PERSPECTIVE) -@@ -327,15 +322,12 @@ static void si_update_spi_map(struct r600_context *rctx) - bcolor: - tmp = 0; - --#if 0 -- /* XXX: Flat shading hangs the GPU */ - if (name == TGSI_SEMANTIC_POSITION || - ps->input[i].interpolate == TGSI_INTERPOLATE_CONSTANT || - (ps->input[i].interpolate == TGSI_INTERPOLATE_COLOR && -- rctx->rasterizer && rctx->rasterizer->flatshade)) { -+ rctx->ps_shader->current->key.flatshade)) { - tmp |= S_028644_FLAT_SHADE(1); - } --#endif - - if (name == TGSI_SEMANTIC_GENERIC && - rctx->sprite_coord_enable & (1 << ps->input[i].sid)) { -@@ -453,8 +445,14 @@ static void si_vertex_buffer_update(struct r600_context *rctx) - si_pm4_sh_data_add(pm4, va & 0xFFFFFFFF); - si_pm4_sh_data_add(pm4, (S_008F04_BASE_ADDRESS_HI(va >> 32) | - S_008F04_STRIDE(vb->stride))); -- si_pm4_sh_data_add(pm4, (vb->buffer->width0 - vb->buffer_offset) / -- MAX2(vb->stride, 1)); -+ if (vb->stride) -+ /* Round up by rounding down and adding 1 */ -+ si_pm4_sh_data_add(pm4, -+ (vb->buffer->width0 - offset - -+ util_format_get_blocksize(ve->src_format)) / -+ vb->stride + 1); -+ else -+ si_pm4_sh_data_add(pm4, vb->buffer->width0 - offset); - si_pm4_sh_data_add(pm4, rctx->vertex_elements->rsrc_word3[i]); - - if (!bound[ve->vertex_buffer_index]) { -diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c -index 607584f..021175c 100644 ---- a/src/gallium/state_trackers/glx/xlib/xm_api.c -+++ b/src/gallium/state_trackers/glx/xlib/xm_api.c -@@ -438,7 +438,6 @@ create_xmesa_buffer(Drawable d, BufferType type, - { - XMesaDisplay xmdpy = xmesa_init_display(vis->display); - XMesaBuffer b; -- uint width, height; - - ASSERT(type == WINDOW || type == PIXMAP || type == PBUFFER); - -@@ -457,7 +456,7 @@ create_xmesa_buffer(Drawable d, BufferType type, - b->type = type; - b->cmap = cmap; - -- get_drawable_size(vis->display, d, &width, &height); -+ get_drawable_size(vis->display, d, &b->width, &b->height); - - /* - * Create framebuffer, but we'll plug in our own renderbuffers below. -diff --git a/src/gallium/targets/dri-vmwgfx/Makefile.am b/src/gallium/targets/dri-vmwgfx/Makefile.am -index 06ebf88..ca7df65 100644 ---- a/src/gallium/targets/dri-vmwgfx/Makefile.am -+++ b/src/gallium/targets/dri-vmwgfx/Makefile.am -@@ -58,17 +58,13 @@ vmwgfx_dri_la_LIBADD = \ - $(top_builddir)/src/gallium/drivers/svga/libsvga.la \ - $(GALLIUM_DRI_LIB_DEPS) - --if HAVE_MESA_LLVM - vmwgfx_dri_la_LINK = $(CXXLINK) $(vmwgfx_dri_la_LDFLAGS) - # Mention a dummy pure C++ file to trigger generation of the $(LINK) variable - nodist_EXTRA_vmwgfx_dri_la_SOURCES = dummy-cpp.cpp - -+if HAVE_MESA_LLVM - vmwgfx_dri_la_LDFLAGS += $(LLVM_LDFLAGS) - vmwgfx_dri_la_LIBADD += $(LLVM_LIBS) --else --vmwgfx_dri_la_LINK = $(LINK) $(vmwgfx_dri_la_LDFLAGS) --# Mention a dummy pure C file to trigger generation of the $(LINK) variable --nodist_EXTRA_vmwgfx_dri_la_SOURCES = dummy-c.c - endif - - # Provide compatibility with scripts for the old Mesa build system for -diff --git a/src/gallium/targets/vdpau-softpipe/Makefile.am b/src/gallium/targets/vdpau-softpipe/Makefile.am -index 3372b5c..7bde2f8 100644 ---- a/src/gallium/targets/vdpau-softpipe/Makefile.am -+++ b/src/gallium/targets/vdpau-softpipe/Makefile.am -@@ -35,7 +35,7 @@ vdpaudir = $(VDPAU_LIB_INSTALL_DIR) - vdpau_LTLIBRARIES = libvdpau_softpipe.la - - libvdpau_softpipe_la_SOURCES = \ -- $(top_srcdir)/src/gallium/auxiliary/vl/vl_winsys_dri.c -+ $(top_srcdir)/src/gallium/auxiliary/vl/vl_winsys_xsp.c - - libvdpau_softpipe_la_LDFLAGS = \ - -module \ -diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c -index 2d41c26..f4ac526 100644 ---- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c -+++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c -@@ -957,16 +957,16 @@ static boolean radeon_winsys_bo_get_handle(struct pb_buffer *buffer, - - bo->flinked = TRUE; - bo->flink = flink.name; -+ -+ pipe_mutex_lock(bo->mgr->bo_handles_mutex); -+ util_hash_table_set(bo->mgr->bo_handles, (void*)(uintptr_t)bo->flink, bo); -+ pipe_mutex_unlock(bo->mgr->bo_handles_mutex); - } - whandle->handle = bo->flink; - } else if (whandle->type == DRM_API_HANDLE_TYPE_KMS) { - whandle->handle = bo->handle; - } - -- pipe_mutex_lock(bo->mgr->bo_handles_mutex); -- util_hash_table_set(bo->mgr->bo_handles, (void*)(uintptr_t)whandle->handle, bo); -- pipe_mutex_unlock(bo->mgr->bo_handles_mutex); -- - whandle->stride = stride; - return TRUE; - } -diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c -index 519929e..a3a0530 100644 ---- a/src/gbm/backends/dri/gbm_dri.c -+++ b/src/gbm/backends/dri/gbm_dri.c -@@ -481,6 +481,7 @@ create_dumb(struct gbm_device *gbm, - bo->base.base.width = width; - bo->base.base.height = height; - bo->base.base.stride = create_arg.pitch; -+ bo->base.base.format = format; - bo->base.base.handle.u32 = create_arg.handle; - bo->handle = create_arg.handle; - bo->size = create_arg.size; -@@ -529,6 +530,7 @@ gbm_dri_bo_create(struct gbm_device *gbm, - bo->base.base.gbm = gbm; - bo->base.base.width = width; - bo->base.base.height = height; -+ bo->base.base.format = format; - - switch (format) { - case GBM_FORMAT_RGB565: -diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c -index 4e32b50..29a209e 100644 ---- a/src/mesa/drivers/common/meta.c -+++ b/src/mesa/drivers/common/meta.c -@@ -1910,6 +1910,14 @@ _mesa_meta_BlitFramebuffer(struct gl_context *ctx, - GLuint *tmp = malloc(srcW * srcH * sizeof(GLuint)); - - if (tmp) { -+ -+ newTex = alloc_texture(depthTex, srcW, srcH, GL_DEPTH_COMPONENT); -+ _mesa_ReadPixels(srcX, srcY, srcW, srcH, GL_DEPTH_COMPONENT, -+ GL_UNSIGNED_INT, tmp); -+ setup_drawpix_texture(ctx, depthTex, newTex, GL_DEPTH_COMPONENT, -+ srcW, srcH, GL_DEPTH_COMPONENT, -+ GL_UNSIGNED_INT, tmp); -+ - /* texcoords (after texture allocation!) */ - { - verts[0].s = 0.0F; -@@ -1928,15 +1936,6 @@ _mesa_meta_BlitFramebuffer(struct gl_context *ctx, - if (!blit->DepthFP) - init_blit_depth_pixels(ctx); - -- /* maybe change tex format here */ -- newTex = alloc_texture(depthTex, srcW, srcH, GL_DEPTH_COMPONENT); -- -- _mesa_ReadPixels(srcX, srcY, srcW, srcH, -- GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, tmp); -- -- setup_drawpix_texture(ctx, depthTex, newTex, GL_DEPTH_COMPONENT, srcW, srcH, -- GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, tmp); -- - _mesa_BindProgramARB(GL_FRAGMENT_PROGRAM_ARB, blit->DepthFP); - _mesa_set_enable(ctx, GL_FRAGMENT_PROGRAM_ARB, GL_TRUE); - _mesa_ColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); -diff --git a/src/mesa/drivers/dri/i965/Makefile.am b/src/mesa/drivers/dri/i965/Makefile.am -index dc140df..77670ef 100644 ---- a/src/mesa/drivers/dri/i965/Makefile.am -+++ b/src/mesa/drivers/dri/i965/Makefile.am -@@ -62,6 +62,7 @@ TEST_LIBS = \ - ../common/libdri_test_stubs.la - - i965_dri_la_SOURCES = -+nodist_EXTRA_i965_dri_la_SOURCES = dummy2.cpp - i965_dri_la_LIBADD = $(COMMON_LIBS) - i965_dri_la_LDFLAGS = -module -avoid-version -shared - -diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp -index 8dab431..f80219e 100644 ---- a/src/mesa/drivers/dri/i965/brw_fs.cpp -+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp -@@ -258,6 +258,26 @@ fs_visitor::VARYING_PULL_CONSTANT_LOAD(fs_reg dst, fs_reg surf_index, - return instructions; - } - -+/** -+ * A helper for MOV generation for fixing up broken hardware SEND dependency -+ * handling. -+ */ -+fs_inst * -+fs_visitor::DEP_RESOLVE_MOV(int grf) -+{ -+ fs_inst *inst = MOV(brw_null_reg(), fs_reg(GRF, grf, BRW_REGISTER_TYPE_F)); -+ -+ inst->ir = NULL; -+ inst->annotation = "send dependency resolve"; -+ -+ /* The caller always wants uncompressed to emit the minimal extra -+ * dependencies, and to avoid having to deal with aligning its regs to 2. -+ */ -+ inst->force_uncompressed = true; -+ -+ return inst; -+} -+ - bool - fs_inst::equals(fs_inst *inst) - { -@@ -1690,8 +1710,6 @@ fs_visitor::setup_pull_constants() - dst, index, offset); - pull->ir = inst->ir; - pull->annotation = inst->annotation; -- pull->base_mrf = 14; -- pull->mlen = 1; - - inst->insert_before(pull); - -@@ -1911,6 +1929,7 @@ fs_visitor::register_coalesce() - - bool has_source_modifiers = (inst->src[0].abs || - inst->src[0].negate || -+ inst->src[0].smear != -1 || - inst->src[0].file == UNIFORM); - - /* Found a move of a GRF to a GRF. Let's see if we can coalesce -@@ -2228,6 +2247,265 @@ fs_visitor::remove_duplicate_mrf_writes() - return progress; - } - -+static void -+clear_deps_for_inst_src(fs_inst *inst, int dispatch_width, bool *deps, -+ int first_grf, int grf_len) -+{ -+ bool inst_16wide = (dispatch_width > 8 && -+ !inst->force_uncompressed && -+ !inst->force_sechalf); -+ -+ /* Clear the flag for registers that actually got read (as expected). */ -+ for (int i = 0; i < 3; i++) { -+ int grf; -+ if (inst->src[i].file == GRF) { -+ grf = inst->src[i].reg; -+ } else if (inst->src[i].file == FIXED_HW_REG && -+ inst->src[i].fixed_hw_reg.file == BRW_GENERAL_REGISTER_FILE) { -+ grf = inst->src[i].fixed_hw_reg.nr; -+ } else { -+ continue; -+ } -+ -+ if (grf >= first_grf && -+ grf < first_grf + grf_len) { -+ deps[grf - first_grf] = false; -+ if (inst_16wide) -+ deps[grf - first_grf + 1] = false; -+ } -+ } -+} -+ -+/** -+ * Implements this workaround for the original 965: -+ * -+ * "[DevBW, DevCL] Implementation Restrictions: As the hardware does not -+ * check for post destination dependencies on this instruction, software -+ * must ensure that there is no destination hazard for the case of ‘write -+ * followed by a posted write’ shown in the following example. -+ * -+ * 1. mov r3 0 -+ * 2. send r3.xy -+ * 3. mov r2 r3 -+ * -+ * Due to no post-destination dependency check on the ‘send’, the above -+ * code sequence could have two instructions (1 and 2) in flight at the -+ * same time that both consider ‘r3’ as the target of their final writes. -+ */ -+void -+fs_visitor::insert_gen4_pre_send_dependency_workarounds(fs_inst *inst) -+{ -+ int write_len = inst->regs_written() * dispatch_width / 8; -+ int first_write_grf = inst->dst.reg; -+ bool needs_dep[BRW_MAX_MRF]; -+ assert(write_len < (int)sizeof(needs_dep) - 1); -+ -+ memset(needs_dep, false, sizeof(needs_dep)); -+ memset(needs_dep, true, write_len); -+ -+ clear_deps_for_inst_src(inst, dispatch_width, -+ needs_dep, first_write_grf, write_len); -+ -+ /* Walk backwards looking for writes to registers we're writing which -+ * aren't read since being written. If we hit the start of the program, -+ * we assume that there are no outstanding dependencies on entry to the -+ * program. -+ */ -+ for (fs_inst *scan_inst = (fs_inst *)inst->prev; -+ scan_inst != NULL; -+ scan_inst = (fs_inst *)scan_inst->prev) { -+ -+ /* If we hit control flow, assume that there *are* outstanding -+ * dependencies, and force their cleanup before our instruction. -+ */ -+ if (scan_inst->is_control_flow()) { -+ for (int i = 0; i < write_len; i++) { -+ if (needs_dep[i]) { -+ inst->insert_before(DEP_RESOLVE_MOV(first_write_grf + i)); -+ } -+ } -+ } -+ -+ bool scan_inst_16wide = (dispatch_width > 8 && -+ !scan_inst->force_uncompressed && -+ !scan_inst->force_sechalf); -+ -+ /* We insert our reads as late as possible on the assumption that any -+ * instruction but a MOV that might have left us an outstanding -+ * dependency has more latency than a MOV. -+ */ -+ if (scan_inst->dst.file == GRF && -+ scan_inst->dst.reg >= first_write_grf && -+ scan_inst->dst.reg < first_write_grf + write_len && -+ needs_dep[scan_inst->dst.reg - first_write_grf]) { -+ inst->insert_before(DEP_RESOLVE_MOV(scan_inst->dst.reg)); -+ needs_dep[scan_inst->dst.reg - first_write_grf] = false; -+ if (scan_inst_16wide) -+ needs_dep[scan_inst->dst.reg - first_write_grf + 1] = false; -+ } -+ -+ /* Clear the flag for registers that actually got read (as expected). */ -+ clear_deps_for_inst_src(scan_inst, dispatch_width, -+ needs_dep, first_write_grf, write_len); -+ -+ /* Continue the loop only if we haven't resolved all the dependencies */ -+ int i; -+ for (i = 0; i < write_len; i++) { -+ if (needs_dep[i]) -+ break; -+ } -+ if (i == write_len) -+ return; -+ } -+} -+ -+/** -+ * Implements this workaround for the original 965: -+ * -+ * "[DevBW, DevCL] Errata: A destination register from a send can not be -+ * used as a destination register until after it has been sourced by an -+ * instruction with a different destination register. -+ */ -+void -+fs_visitor::insert_gen4_post_send_dependency_workarounds(fs_inst *inst) -+{ -+ int write_len = inst->regs_written() * dispatch_width / 8; -+ int first_write_grf = inst->dst.reg; -+ bool needs_dep[BRW_MAX_MRF]; -+ assert(write_len < (int)sizeof(needs_dep) - 1); -+ -+ memset(needs_dep, false, sizeof(needs_dep)); -+ memset(needs_dep, true, write_len); -+ /* Walk forwards looking for writes to registers we're writing which aren't -+ * read before being written. -+ */ -+ for (fs_inst *scan_inst = (fs_inst *)inst->next; -+ !scan_inst->is_tail_sentinel(); -+ scan_inst = (fs_inst *)scan_inst->next) { -+ /* If we hit control flow, force resolve all remaining dependencies. */ -+ if (scan_inst->is_control_flow()) { -+ for (int i = 0; i < write_len; i++) { -+ if (needs_dep[i]) -+ scan_inst->insert_before(DEP_RESOLVE_MOV(first_write_grf + i)); -+ } -+ } -+ -+ /* Clear the flag for registers that actually got read (as expected). */ -+ clear_deps_for_inst_src(scan_inst, dispatch_width, -+ needs_dep, first_write_grf, write_len); -+ -+ /* We insert our reads as late as possible since they're reading the -+ * result of a SEND, which has massive latency. -+ */ -+ if (scan_inst->dst.file == GRF && -+ scan_inst->dst.reg >= first_write_grf && -+ scan_inst->dst.reg < first_write_grf + write_len && -+ needs_dep[scan_inst->dst.reg - first_write_grf]) { -+ scan_inst->insert_before(DEP_RESOLVE_MOV(scan_inst->dst.reg)); -+ needs_dep[scan_inst->dst.reg - first_write_grf] = false; -+ } -+ -+ /* Continue the loop only if we haven't resolved all the dependencies */ -+ int i; -+ for (i = 0; i < write_len; i++) { -+ if (needs_dep[i]) -+ break; -+ } -+ if (i == write_len) -+ return; -+ } -+ -+ /* If we hit the end of the program, resolve all remaining dependencies out -+ * of paranoia. -+ */ -+ fs_inst *last_inst = (fs_inst *)this->instructions.get_tail(); -+ assert(last_inst->eot); -+ for (int i = 0; i < write_len; i++) { -+ if (needs_dep[i]) -+ last_inst->insert_before(DEP_RESOLVE_MOV(first_write_grf + i)); -+ } -+} -+ -+void -+fs_visitor::insert_gen4_send_dependency_workarounds() -+{ -+ if (intel->gen != 4 || intel->is_g4x) -+ return; -+ -+ /* Note that we're done with register allocation, so GRF fs_regs always -+ * have a .reg_offset of 0. -+ */ -+ -+ foreach_list_safe(node, &this->instructions) { -+ fs_inst *inst = (fs_inst *)node; -+ -+ if (inst->mlen != 0 && inst->dst.file == GRF) { -+ insert_gen4_pre_send_dependency_workarounds(inst); -+ insert_gen4_post_send_dependency_workarounds(inst); -+ } -+ } -+} -+ -+/** -+ * Turns the generic expression-style uniform pull constant load instruction -+ * into a hardware-specific series of instructions for loading a pull -+ * constant. -+ * -+ * The expression style allows the CSE pass before this to optimize out -+ * repeated loads from the same offset, and gives the pre-register-allocation -+ * scheduling full flexibility, while the conversion to native instructions -+ * allows the post-register-allocation scheduler the best information -+ * possible. -+ */ -+void -+fs_visitor::lower_uniform_pull_constant_loads() -+{ -+ foreach_list(node, &this->instructions) { -+ fs_inst *inst = (fs_inst *)node; -+ -+ if (inst->opcode != FS_OPCODE_UNIFORM_PULL_CONSTANT_LOAD) -+ continue; -+ -+ if (intel->gen >= 7) { -+ fs_reg const_offset_reg = inst->src[1]; -+ assert(const_offset_reg.file == IMM && -+ const_offset_reg.type == BRW_REGISTER_TYPE_UD); -+ const_offset_reg.imm.u /= 16; -+ fs_reg payload = fs_reg(this, glsl_type::uint_type); -+ struct brw_reg g0 = retype(brw_vec8_grf(0, 0), -+ BRW_REGISTER_TYPE_UD); -+ -+ fs_inst *setup1 = MOV(payload, fs_reg(g0)); -+ setup1->force_writemask_all = true; -+ /* We don't need the second half of this vgrf to be filled with g1 -+ * in the 16-wide case, but if we use force_uncompressed then live -+ * variable analysis won't consider this a def! -+ */ -+ -+ fs_inst *setup2 = new(mem_ctx) fs_inst(FS_OPCODE_SET_GLOBAL_OFFSET, -+ payload, payload, -+ const_offset_reg); -+ -+ setup1->ir = inst->ir; -+ setup1->annotation = inst->annotation; -+ inst->insert_before(setup1); -+ setup2->ir = inst->ir; -+ setup2->annotation = inst->annotation; -+ inst->insert_before(setup2); -+ inst->opcode = FS_OPCODE_UNIFORM_PULL_CONSTANT_LOAD_GEN7; -+ inst->src[1] = payload; -+ } else { -+ /* Before register allocation, we didn't tell the scheduler about the -+ * MRF we use. We know it's safe to use this MRF because nothing -+ * else does except for register spill/unspill, which generates and -+ * uses its MRF within a single IR instruction. -+ */ -+ inst->base_mrf = 14; -+ inst->mlen = 1; -+ } -+ } -+} -+ - void - fs_visitor::dump_instruction(fs_inst *inst) - { -@@ -2500,6 +2778,8 @@ fs_visitor::run() - - schedule_instructions(false); - -+ lower_uniform_pull_constant_loads(); -+ - assign_curb_setup(); - assign_urb_setup(); - -@@ -2522,6 +2802,12 @@ fs_visitor::run() - assert(force_uncompressed_stack == 0); - assert(force_sechalf_stack == 0); - -+ /* This must come after all optimization and register allocation, since -+ * it inserts dead code that happens to have side effects, and it does -+ * so based on the actual physical registers in use. -+ */ -+ insert_gen4_send_dependency_workarounds(); -+ - if (failed) - return false; - -diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h -index 88fecb9..d1bb111 100644 ---- a/src/mesa/drivers/dri/i965/brw_fs.h -+++ b/src/mesa/drivers/dri/i965/brw_fs.h -@@ -285,6 +285,7 @@ public: - fs_inst *IF(fs_reg src0, fs_reg src1, uint32_t condition); - fs_inst *CMP(fs_reg dst, fs_reg src0, fs_reg src1, - uint32_t condition); -+ fs_inst *DEP_RESOLVE_MOV(int grf); - - int type_size(const struct glsl_type *type); - fs_inst *get_instruction_generating_reg(fs_inst *start, -@@ -329,7 +330,11 @@ public: - bool remove_duplicate_mrf_writes(); - bool virtual_grf_interferes(int a, int b); - void schedule_instructions(bool post_reg_alloc); -+ void insert_gen4_send_dependency_workarounds(); -+ void insert_gen4_pre_send_dependency_workarounds(fs_inst *inst); -+ void insert_gen4_post_send_dependency_workarounds(fs_inst *inst); - void fail(const char *msg, ...); -+ void lower_uniform_pull_constant_loads(); - - void push_force_uncompressed(); - void pop_force_uncompressed(); -diff --git a/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp b/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp -index c4ec1d9..194ed07 100644 ---- a/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp -+++ b/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp -@@ -223,7 +223,8 @@ fs_visitor::try_copy_propagate(fs_inst *inst, int arg, acp_entry *entry) - inst->src[arg].file = entry->src.file; - inst->src[arg].reg = entry->src.reg; - inst->src[arg].reg_offset = entry->src.reg_offset; -- inst->src[arg].smear = entry->src.smear; -+ if (entry->src.smear != -1) -+ inst->src[arg].smear = entry->src.smear; - - if (!inst->src[arg].abs) { - inst->src[arg].abs = entry->src.abs; -diff --git a/src/mesa/drivers/dri/i965/brw_fs_cse.cpp b/src/mesa/drivers/dri/i965/brw_fs_cse.cpp -index 70c143a..a13ca36 100644 ---- a/src/mesa/drivers/dri/i965/brw_fs_cse.cpp -+++ b/src/mesa/drivers/dri/i965/brw_fs_cse.cpp -@@ -105,7 +105,8 @@ fs_visitor::opt_cse_local(bblock_t *block, exec_list *aeb) - /* Match current instruction's expression against those in AEB. */ - if (inst->opcode == entry->generator->opcode && - inst->saturate == entry->generator->saturate && -- operands_match(entry->generator->src, inst->src)) { -+ inst->dst.type == entry->generator->dst.type && -+ operands_match(entry->generator->src, inst->src)) { - - found = true; - progress = true; -diff --git a/src/mesa/drivers/dri/i965/brw_fs_emit.cpp b/src/mesa/drivers/dri/i965/brw_fs_emit.cpp -index 45072da..365a2ec 100644 ---- a/src/mesa/drivers/dri/i965/brw_fs_emit.cpp -+++ b/src/mesa/drivers/dri/i965/brw_fs_emit.cpp -@@ -604,29 +604,8 @@ fs_generator::generate_unspill(fs_inst *inst, struct brw_reg dst) - { - assert(inst->mlen != 0); - -- /* Clear any post destination dependencies that would be ignored by -- * the block read. See the B-Spec for pre-gen5 send instruction. -- * -- * This could use a better solution, since texture sampling and -- * math reads could potentially run into it as well -- anywhere -- * that we have a SEND with a destination that is a register that -- * was written but not read within the last N instructions (what's -- * N? unsure). This is rare because of dead code elimination, but -- * not impossible. -- */ -- if (intel->gen == 4 && !intel->is_g4x) -- brw_MOV(p, brw_null_reg(), dst); -- - brw_oword_block_read_scratch(p, dst, brw_message_reg(inst->base_mrf), 1, - inst->offset); -- -- if (intel->gen == 4 && !intel->is_g4x) { -- /* gen4 errata: destination from a send can't be used as a -- * destination until it's been read. Just read it so we don't -- * have to worry. -- */ -- brw_MOV(p, brw_null_reg(), dst); -- } - } - - void -@@ -637,19 +616,6 @@ fs_generator::generate_uniform_pull_constant_load(fs_inst *inst, - { - assert(inst->mlen != 0); - -- /* Clear any post destination dependencies that would be ignored by -- * the block read. See the B-Spec for pre-gen5 send instruction. -- * -- * This could use a better solution, since texture sampling and -- * math reads could potentially run into it as well -- anywhere -- * that we have a SEND with a destination that is a register that -- * was written but not read within the last N instructions (what's -- * N? unsure). This is rare because of dead code elimination, but -- * not impossible. -- */ -- if (intel->gen == 4 && !intel->is_g4x) -- brw_MOV(p, brw_null_reg(), dst); -- - assert(index.file == BRW_IMMEDIATE_VALUE && - index.type == BRW_REGISTER_TYPE_UD); - uint32_t surf_index = index.dw1.ud; -@@ -660,14 +626,6 @@ fs_generator::generate_uniform_pull_constant_load(fs_inst *inst, - - brw_oword_block_read(p, dst, brw_message_reg(inst->base_mrf), - read_offset, surf_index); -- -- if (intel->gen == 4 && !intel->is_g4x) { -- /* gen4 errata: destination from a send can't be used as a -- * destination until it's been read. Just read it so we don't -- * have to worry. -- */ -- brw_MOV(p, brw_null_reg(), dst); -- } - } - - void -diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp -index d4f6fc9..573921c 100644 ---- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp -+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp -@@ -597,31 +597,9 @@ fs_visitor::visit(ir_expression *ir) - fs_reg packed_consts = fs_reg(this, glsl_type::float_type); - packed_consts.type = result.type; - -- if (intel->gen >= 7) { -- fs_reg const_offset_reg = fs_reg(const_offset->value.u[0] / 16); -- fs_reg payload = fs_reg(this, glsl_type::uint_type); -- struct brw_reg g0 = retype(brw_vec8_grf(0, 0), -- BRW_REGISTER_TYPE_UD); -- fs_inst *setup = emit(MOV(payload, fs_reg(g0))); -- setup->force_writemask_all = true; -- /* We don't need the second half of this vgrf to be filled with g1 -- * in the 16-wide case, but if we use force_uncompressed then live -- * variable analysis won't consider this a def! -- */ -- -- emit(FS_OPCODE_SET_GLOBAL_OFFSET, payload, -- payload, const_offset_reg); -- emit(FS_OPCODE_UNIFORM_PULL_CONSTANT_LOAD_GEN7, packed_consts, -- surf_index, payload); -- } else { -- fs_reg const_offset_reg = fs_reg(const_offset->value.u[0]); -- fs_inst *pull = emit(fs_inst(FS_OPCODE_UNIFORM_PULL_CONSTANT_LOAD, -- packed_consts, -- surf_index, -- const_offset_reg)); -- pull->base_mrf = 14; -- pull->mlen = 1; -- } -+ fs_reg const_offset_reg = fs_reg(const_offset->value.u[0] & ~15); -+ emit(fs_inst(FS_OPCODE_UNIFORM_PULL_CONSTANT_LOAD, -+ packed_consts, surf_index, const_offset_reg)); - - packed_consts.smear = const_offset->value.u[0] % 16 / 4; - for (int i = 0; i < ir->type->vector_elements; i++) { -diff --git a/src/mesa/drivers/dri/i965/brw_vs_constval.c b/src/mesa/drivers/dri/i965/brw_vs_constval.c -index 3d53843..48635c5 100644 ---- a/src/mesa/drivers/dri/i965/brw_vs_constval.c -+++ b/src/mesa/drivers/dri/i965/brw_vs_constval.c -@@ -238,6 +238,23 @@ static void calc_wm_input_sizes( struct brw_context *brw ) - - calc_sizes(&t); - -+ /* _NEW_POINT -+ * -+ * If the SF will be replacing the vertex output with a reference to -+ * gl_PointCoord, then tell the fragment shader that the value actually -+ * does vary. -+ */ -+ if (ctx->Point.PointSprite) { -+ for (int i = 0; i < 8; i++) { -+ if (ctx->Point.CoordReplace[i]) { -+ t.size_masks[4-1] |= FRAG_BIT_TEX(i); -+ t.size_masks[3-1] |= FRAG_BIT_TEX(i); -+ t.size_masks[2-1] |= FRAG_BIT_TEX(i); -+ t.size_masks[1-1] |= FRAG_BIT_TEX(i); -+ } -+ } -+ } -+ - if (memcmp(brw->wm.input_size_masks, t.size_masks, sizeof(t.size_masks)) != 0) { - memcpy(brw->wm.input_size_masks, t.size_masks, sizeof(t.size_masks)); - brw->state.dirty.brw |= BRW_NEW_WM_INPUT_DIMENSIONS; -@@ -246,7 +263,7 @@ static void calc_wm_input_sizes( struct brw_context *brw ) - - const struct brw_tracked_state brw_wm_input_sizes = { - .dirty = { -- .mesa = _NEW_LIGHT | _NEW_PROGRAM, -+ .mesa = _NEW_LIGHT | _NEW_PROGRAM | _NEW_POINT, - .brw = BRW_NEW_VERTEX_PROGRAM | BRW_NEW_INPUT_DIMENSIONS, - .cache = 0 - }, -diff --git a/src/mesa/drivers/dri/intel/intel_chipset.h b/src/mesa/drivers/dri/intel/intel_chipset.h -index 9c00ba8..885f6c2 100644 ---- a/src/mesa/drivers/dri/intel/intel_chipset.h -+++ b/src/mesa/drivers/dri/intel/intel_chipset.h -@@ -114,15 +114,15 @@ - #define PCI_CHIP_HASWELL_ULT_S_GT1 0x0A0A /* Server */ - #define PCI_CHIP_HASWELL_ULT_S_GT2 0x0A1A - #define PCI_CHIP_HASWELL_ULT_S_GT2_PLUS 0x0A2A --#define PCI_CHIP_HASWELL_CRW_GT1 0x0D12 /* Desktop */ --#define PCI_CHIP_HASWELL_CRW_GT2 0x0D22 --#define PCI_CHIP_HASWELL_CRW_GT2_PLUS 0x0D32 --#define PCI_CHIP_HASWELL_CRW_M_GT1 0x0D16 /* Mobile */ --#define PCI_CHIP_HASWELL_CRW_M_GT2 0x0D26 --#define PCI_CHIP_HASWELL_CRW_M_GT2_PLUS 0x0D36 --#define PCI_CHIP_HASWELL_CRW_S_GT1 0x0D1A /* Server */ --#define PCI_CHIP_HASWELL_CRW_S_GT2 0x0D2A --#define PCI_CHIP_HASWELL_CRW_S_GT2_PLUS 0x0D3A -+#define PCI_CHIP_HASWELL_CRW_GT1 0x0D02 /* Desktop */ -+#define PCI_CHIP_HASWELL_CRW_GT2 0x0D12 -+#define PCI_CHIP_HASWELL_CRW_GT2_PLUS 0x0D22 -+#define PCI_CHIP_HASWELL_CRW_M_GT1 0x0D06 /* Mobile */ -+#define PCI_CHIP_HASWELL_CRW_M_GT2 0x0D16 -+#define PCI_CHIP_HASWELL_CRW_M_GT2_PLUS 0x0D26 -+#define PCI_CHIP_HASWELL_CRW_S_GT1 0x0D0A /* Server */ -+#define PCI_CHIP_HASWELL_CRW_S_GT2 0x0D1A -+#define PCI_CHIP_HASWELL_CRW_S_GT2_PLUS 0x0D2A - - #define IS_MOBILE(devid) (devid == PCI_CHIP_I855_GM || \ - devid == PCI_CHIP_I915_GM || \ -diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c -index a951283..6d91534 100644 ---- a/src/mesa/main/attrib.c -+++ b/src/mesa/main/attrib.c -@@ -130,6 +130,9 @@ struct gl_enable_attrib - GLboolean VertexProgramPointSize; - GLboolean VertexProgramTwoSide; - -+ /* GL_ARB_fragment_program */ -+ GLboolean FragmentProgram; -+ - /* GL_ARB_point_sprite / GL_NV_point_sprite */ - GLboolean PointSprite; - GLboolean FragmentShaderATI; -@@ -316,6 +319,10 @@ _mesa_PushAttrib(GLbitfield mask) - attr->VertexProgram = ctx->VertexProgram.Enabled; - attr->VertexProgramPointSize = ctx->VertexProgram.PointSizeEnabled; - attr->VertexProgramTwoSide = ctx->VertexProgram.TwoSideEnabled; -+ -+ /* GL_ARB_fragment_program */ -+ attr->FragmentProgram = ctx->FragmentProgram.Enabled; -+ - save_attrib_data(&head, GL_ENABLE_BIT, attr); - - /* GL_ARB_framebuffer_sRGB / GL_EXT_framebuffer_sRGB */ -@@ -607,6 +614,11 @@ pop_enable_group(struct gl_context *ctx, const struct gl_enable_attrib *enable) - enable->VertexProgramTwoSide, - GL_VERTEX_PROGRAM_TWO_SIDE_ARB); - -+ /* GL_ARB_fragment_program */ -+ TEST_AND_UPDATE(ctx->FragmentProgram.Enabled, -+ enable->FragmentProgram, -+ GL_FRAGMENT_PROGRAM_ARB); -+ - /* GL_ARB_framebuffer_sRGB / GL_EXT_framebuffer_sRGB */ - TEST_AND_UPDATE(ctx->Color.sRGBEnabled, enable->sRGBEnabled, - GL_FRAMEBUFFER_SRGB); -diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c -index 5e9e539..df57b76 100644 ---- a/src/mesa/main/context.c -+++ b/src/mesa/main/context.c -@@ -1072,7 +1072,6 @@ _mesa_initialize_context(struct gl_context *ctx, - case API_OPENGLES2: - ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE; - ctx->VertexProgram._MaintainTnlProgram = GL_TRUE; -- ctx->Point.PointSprite = GL_TRUE; /* always on for ES 2.x */ - break; - } - -diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c -index 8728540..c1e1658 100644 ---- a/src/mesa/main/glformats.c -+++ b/src/mesa/main/glformats.c -@@ -917,7 +917,7 @@ _mesa_is_compressed_format(struct gl_context *ctx, GLenum format) - case GL_COMPRESSED_SIGNED_RG11_EAC: - case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: - case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: -- return _mesa_is_gles3(ctx); -+ return _mesa_is_gles3(ctx) || ctx->Extensions.ARB_ES3_compatibility; - case GL_PALETTE4_RGB8_OES: - case GL_PALETTE4_RGBA8_OES: - case GL_PALETTE4_R5_G6_B5_OES: -diff --git a/src/mesa/main/points.c b/src/mesa/main/points.c -index 1778640..c925d4c 100644 ---- a/src/mesa/main/points.c -+++ b/src/mesa/main/points.c -@@ -253,7 +253,8 @@ _mesa_init_point(struct gl_context *ctx) - * In a core context, the state will default to true, and the setters and - * getters are disabled. - */ -- ctx->Point.PointSprite = (ctx->API == API_OPENGL_CORE); -+ ctx->Point.PointSprite = (ctx->API == API_OPENGL_CORE || -+ ctx->API == API_OPENGLES2); - - ctx->Point.SpriteRMode = GL_ZERO; /* GL_NV_point_sprite (only!) */ - ctx->Point.SpriteOrigin = GL_UPPER_LEFT; /* GL_ARB_point_sprite */ -diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c -index d1723b8..1b9525b 100644 ---- a/src/mesa/main/teximage.c -+++ b/src/mesa/main/teximage.c -@@ -520,7 +520,7 @@ _mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat ) - } - } - -- if (_mesa_is_gles3(ctx)) { -+ if (_mesa_is_gles3(ctx) || ctx->Extensions.ARB_ES3_compatibility) { - switch (internalFormat) { - case GL_COMPRESSED_RGB8_ETC2: - case GL_COMPRESSED_SRGB8_ETC2: -@@ -3187,6 +3187,12 @@ _mesa_EGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image) - return; - } - -+ if (!image) { -+ _mesa_error(ctx, GL_INVALID_OPERATION, -+ "glEGLImageTargetTexture2D(image=%p)", image); -+ return; -+ } -+ - if (ctx->NewState & _NEW_PIXEL) - _mesa_update_state(ctx); - -diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c -index 52ede13..6f18ec6 100644 ---- a/src/mesa/main/texparam.c -+++ b/src/mesa/main/texparam.c -@@ -1432,6 +1432,12 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params ) - *params = (GLfloat) obj->Immutable; - break; - -+ case GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES: -+ if (!_mesa_is_gles(ctx) || !ctx->Extensions.OES_EGL_image_external) -+ goto invalid_pname; -+ *params = obj->RequiredTextureImageUnits; -+ break; -+ - case GL_TEXTURE_SRGB_DECODE_EXT: - if (!ctx->Extensions.EXT_texture_sRGB_decode) - goto invalid_pname; -diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c -index f20df9e..7fdfa72 100644 ---- a/src/mesa/state_tracker/st_atom_rasterizer.c -+++ b/src/mesa/state_tracker/st_atom_rasterizer.c -@@ -135,16 +135,12 @@ static void update_raster_state( struct st_context *st ) - - /* _NEW_POLYGON - */ -- if (ctx->Polygon.OffsetUnits != 0.0 || -- ctx->Polygon.OffsetFactor != 0.0) { -- raster->offset_point = ctx->Polygon.OffsetPoint; -- raster->offset_line = ctx->Polygon.OffsetLine; -- raster->offset_tri = ctx->Polygon.OffsetFill; -- } -- - if (ctx->Polygon.OffsetPoint || - ctx->Polygon.OffsetLine || - ctx->Polygon.OffsetFill) { -+ raster->offset_point = ctx->Polygon.OffsetPoint; -+ raster->offset_line = ctx->Polygon.OffsetLine; -+ raster->offset_tri = ctx->Polygon.OffsetFill; - raster->offset_units = ctx->Polygon.OffsetUnits; - raster->offset_scale = ctx->Polygon.OffsetFactor; - } -diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c -index 63dbdb2..36fffe9 100644 ---- a/src/mesa/state_tracker/st_cb_bitmap.c -+++ b/src/mesa/state_tracker/st_cb_bitmap.c -@@ -675,11 +675,12 @@ st_flush_bitmap_cache(struct st_context *st) - * \return GL_TRUE for success, GL_FALSE if bitmap is too large, etc. - */ - static GLboolean --accum_bitmap(struct st_context *st, -+accum_bitmap(struct gl_context *ctx, - GLint x, GLint y, GLsizei width, GLsizei height, - const struct gl_pixelstore_attrib *unpack, - const GLubyte *bitmap ) - { -+ struct st_context *st = ctx->st; - struct bitmap_cache *cache = st->bitmap.cache; - int px = -999, py = -999; - const GLfloat z = st->ctx->Current.RasterPos[2]; -@@ -729,9 +730,17 @@ accum_bitmap(struct st_context *st, - /* create the transfer if needed */ - create_cache_trans(st); - -+ /* PBO source... */ -+ bitmap = _mesa_map_pbo_source(ctx, unpack, bitmap); -+ if (!bitmap) { -+ return FALSE; -+ } -+ - unpack_bitmap(st, px, py, width, height, unpack, bitmap, - cache->buffer, BITMAP_CACHE_WIDTH); - -+ _mesa_unmap_pbo_source(ctx, unpack); -+ - return GL_TRUE; /* accumulated */ - } - -@@ -764,7 +773,7 @@ st_Bitmap(struct gl_context *ctx, GLint x, GLint y, - semantic_indexes); - } - -- if (UseBitmapCache && accum_bitmap(st, x, y, width, height, unpack, bitmap)) -+ if (UseBitmapCache && accum_bitmap(ctx, x, y, width, height, unpack, bitmap)) - return; - - pt = make_bitmap_texture(ctx, width, height, unpack, bitmap); -diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c -index de62264..bff8d9b 100644 ---- a/src/mesa/state_tracker/st_draw.c -+++ b/src/mesa/state_tracker/st_draw.c -@@ -283,7 +283,7 @@ st_draw_vbo(struct gl_context *ctx, - /* don't trim, restarts might be inside index list */ - cso_draw_vbo(st->cso_context, &info); - } -- else if (u_trim_pipe_prim(info.mode, &info.count)) -+ else if (u_trim_pipe_prim(prims[i].mode, &info.count)) - cso_draw_vbo(st->cso_context, &info); - } - -diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c -index a9111b5..f56f7cb 100644 ---- a/src/mesa/state_tracker/st_program.c -+++ b/src/mesa/state_tracker/st_program.c -@@ -1142,7 +1142,7 @@ st_print_shaders(struct gl_context *ctx) - static void - destroy_program_variants(struct st_context *st, struct gl_program *program) - { -- if (!program) -+ if (!program || program == &_mesa_DummyProgram) - return; - - switch (program->Target) { diff --git a/mesa-9.1.1-53-g3cff41c.patch b/mesa-9.1.1-53-g3cff41c.patch new file mode 100644 index 0000000..d6b302a --- /dev/null +++ b/mesa-9.1.1-53-g3cff41c.patch @@ -0,0 +1,2242 @@ +diff --git a/configure.ac b/configure.ac +index 4a98996..1c9d606 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -452,6 +452,9 @@ if test "x$enable_asm" = xyes; then + linux* | *freebsd* | dragonfly* | *netbsd*) + test "x$enable_64bit" = xyes && asm_arch=x86_64 || asm_arch=x86 + ;; ++ gnu*) ++ asm_arch=x86 ++ ;; + esac + ;; + x86_64) +@@ -826,20 +829,6 @@ if test "x$enable_dri" = xyes; then + fi + fi + +-dnl Find out if X is available. +-PKG_CHECK_MODULES([X11], [x11], [no_x=no], [no_x=yes]) +- +-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. +-m4_divert_once([HELP_BEGIN], +-[These options are only used when the X libraries cannot be found by the +-pkg-config utility.]) +- +-dnl We need X for xlib and dri, so bomb now if it's not found +-if test "x$enable_glx" = xyes -a "x$no_x" = xyes; then +- AC_MSG_ERROR([X11 development libraries needed for GLX]) +-fi +- + dnl Direct rendering or just indirect rendering + case "$host_os" in + gnu*) +diff --git a/docs/relnotes-9.1.1.html b/docs/relnotes-9.1.1.html +index 8921c8f..a73c974 100644 +--- a/docs/relnotes-9.1.1.html ++++ b/docs/relnotes-9.1.1.html +@@ -30,6 +30,9 @@ because GL_ARB_compatibility is not supported. + +

    MD5 checksums

    +
    ++6508d9882d8dce7106717f365632700c  MesaLib-9.1.1.tar.gz
    ++6ea2bdc3b7ecfb4257b39814b4182580  MesaLib-9.1.1.tar.bz2
    ++3434c0eb47849a08c53cd32833d10d13  MesaLib-9.1.1.zip
    + 
    + +

    New features

    +diff --git a/include/c99_compat.h b/include/c99_compat.h +new file mode 100644 +index 0000000..3a9f502 +--- /dev/null ++++ b/include/c99_compat.h +@@ -0,0 +1,147 @@ ++/************************************************************************** ++ * ++ * Copyright 2007-2013 VMware, Inc. ++ * All Rights Reserved. ++ * ++ * Permission is hereby granted, free of charge, to any person obtaining a ++ * copy of this software and associated documentation files (the ++ * "Software"), to deal in the Software without restriction, including ++ * without limitation the rights to use, copy, modify, merge, publish, ++ * distribute, sub license, and/or sell copies of the Software, and to ++ * permit persons to whom the Software is furnished to do so, subject to ++ * the following conditions: ++ * ++ * The above copyright notice and this permission notice (including the ++ * next paragraph) shall be included in all copies or substantial portions ++ * of the Software. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ++ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ++ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR ++ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, ++ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE ++ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ++ * ++ **************************************************************************/ ++ ++#ifndef _C99_COMPAT_H_ ++#define _C99_COMPAT_H_ ++ ++ ++/* ++ * MSVC hacks. ++ */ ++#if defined(_MSC_VER) ++ /* ++ * Visual Studio 2012 will complain if we define the `inline` keyword, but ++ * actually it only supports the keyword on C++. ++ * ++ * We could skip this check by defining _ALLOW_KEYWORD_MACROS, but there is ++ * probably value in checking this for other keywords. So simply include ++ * the checking before we define it below. ++ */ ++# if _MSC_VER >= 1700 ++# include ++# endif ++ ++ /* ++ * XXX: MSVC has a `__restrict` keyword, but it also has a ++ * `__declspec(restrict)` modifier, so it is impossible to define a ++ * `restrict` macro without interfering with the latter. Furthermore the ++ * MSVC standard library uses __declspec(restrict) under the _CRTRESTRICT ++ * macro. For now resolve this issue by redefining _CRTRESTRICT, but going ++ * forward we should probably should stop using restrict, especially ++ * considering that our code does not obbey strict aliasing rules any way. ++ */ ++# include ++# undef _CRTRESTRICT ++# define _CRTRESTRICT ++#endif ++ ++ ++/* ++ * C99 inline keyword ++ */ ++#ifndef inline ++# ifdef __cplusplus ++ /* C++ supports inline keyword */ ++# elif defined(__GNUC__) ++# define inline __inline__ ++# elif defined(_MSC_VER) ++# define inline __inline ++# elif defined(__ICL) ++# define inline __inline ++# elif defined(__INTEL_COMPILER) ++ /* Intel compiler supports inline keyword */ ++# elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100) ++# define inline __inline ++# elif defined(__SUNPRO_C) && defined(__C99FEATURES__) ++ /* C99 supports inline keyword */ ++# elif (__STDC_VERSION__ >= 199901L) ++ /* C99 supports inline keyword */ ++# else ++# define inline ++# endif ++#endif ++ ++ ++/* ++ * C99 restrict keyword ++ * ++ * See also: ++ * - http://cellperformance.beyond3d.com/articles/2006/05/demystifying-the-restrict-keyword.html ++ */ ++#ifndef restrict ++# if (__STDC_VERSION__ >= 199901L) ++ /* C99 */ ++# elif defined(__SUNPRO_C) && defined(__C99FEATURES__) ++ /* C99 */ ++# elif defined(__GNUC__) ++# define restrict __restrict__ ++# elif defined(_MSC_VER) ++# define restrict __restrict ++# else ++# define restrict /* */ ++# endif ++#endif ++ ++ ++/* ++ * C99 __func__ macro ++ */ ++#ifndef __func__ ++# if (__STDC_VERSION__ >= 199901L) ++ /* C99 */ ++# elif defined(__SUNPRO_C) && defined(__C99FEATURES__) ++ /* C99 */ ++# elif defined(__GNUC__) ++# if __GNUC__ >= 2 ++# define __func__ __FUNCTION__ ++# else ++# define __func__ "" ++# endif ++# elif defined(_MSC_VER) ++# if _MSC_VER >= 1300 ++# define __func__ __FUNCTION__ ++# else ++# define __func__ "" ++# endif ++# else ++# define __func__ "" ++# endif ++#endif ++ ++ ++/* Simple test case for debugging */ ++#if 0 ++static inline const char * ++test_c99_compat_h(const void * restrict a, ++ const void * restrict b) ++{ ++ return __func__; ++} ++#endif ++ ++ ++#endif /* _C99_COMPAT_H_ */ +diff --git a/src/egl/main/eglcompiler.h b/src/egl/main/eglcompiler.h +index 9823693..2499172 100644 +--- a/src/egl/main/eglcompiler.h ++++ b/src/egl/main/eglcompiler.h +@@ -31,6 +31,9 @@ + #define EGLCOMPILER_INCLUDED + + ++#include "c99_compat.h" /* inline, __func__, etc. */ ++ ++ + /** + * Get standard integer types + */ +@@ -62,30 +65,7 @@ + #endif + + +-/** +- * Function inlining +- */ +-#ifndef inline +-# ifdef __cplusplus +- /* C++ supports inline keyword */ +-# elif defined(__GNUC__) +-# define inline __inline__ +-# elif defined(_MSC_VER) +-# define inline __inline +-# elif defined(__ICL) +-# define inline __inline +-# elif defined(__INTEL_COMPILER) +- /* Intel compiler supports inline keyword */ +-# elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100) +-# define inline __inline +-# elif defined(__SUNPRO_C) && defined(__C99FEATURES__) +- /* C99 supports inline keyword */ +-# elif (__STDC_VERSION__ >= 199901L) +- /* C99 supports inline keyword */ +-# else +-# define inline +-# endif +-#endif ++/* XXX: Use standard `inline` keyword instead */ + #ifndef INLINE + # define INLINE inline + #endif +@@ -104,21 +84,9 @@ + # endif + #endif + +-/** +- * The __FUNCTION__ gcc variable is generally only used for debugging. +- * If we're not using gcc, define __FUNCTION__ as a cpp symbol here. +- * Don't define it if using a newer Windows compiler. +- */ ++/* XXX: Use standard `__func__` instead */ + #ifndef __FUNCTION__ +-# if (!defined __GNUC__) && (!defined __xlC__) && \ +- (!defined(_MSC_VER) || _MSC_VER < 1300) +-# if (__STDC_VERSION__ >= 199901L) /* C99 */ || \ +- (defined(__SUNPRO_C) && defined(__C99FEATURES__)) +-# define __FUNCTION__ __func__ +-# else +-# define __FUNCTION__ "" +-# endif +-# endif ++# define __FUNCTION__ __func__ + #endif + + #endif /* EGLCOMPILER_INCLUDED */ +diff --git a/src/gallium/auxiliary/Makefile.am b/src/gallium/auxiliary/Makefile.am +index a4eee47..f14279b 100644 +--- a/src/gallium/auxiliary/Makefile.am ++++ b/src/gallium/auxiliary/Makefile.am +@@ -7,7 +7,10 @@ noinst_LTLIBRARIES = libgallium.la + + AM_CFLAGS = \ + -I$(top_srcdir)/src/gallium/auxiliary/util \ +- $(GALLIUM_CFLAGS) ++ $(GALLIUM_CFLAGS) \ ++ $(VISIBILITY_CFLAGS) ++ ++AM_CXXFLAGS = $(VISIBILITY_CXXFLAGS) + + libgallium_la_SOURCES = \ + $(C_SOURCES) \ +@@ -18,7 +21,7 @@ if HAVE_MESA_LLVM + AM_CFLAGS += \ + $(LLVM_CFLAGS) + +-AM_CXXFLAGS = \ ++AM_CXXFLAGS += \ + $(GALLIUM_CFLAGS) \ + $(LLVM_CXXFLAGS) + +diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h +index 4898849..5fb4a11 100644 +--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h ++++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h +@@ -240,6 +240,7 @@ struct lp_exec_mask { + struct lp_build_context *bld; + + boolean has_mask; ++ boolean ret_in_main; + + LLVMTypeRef int_vec_type; + +diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +index 0621fb4..413a918 100644 +--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c ++++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +@@ -73,6 +73,7 @@ static void lp_exec_mask_init(struct lp_exec_mask *mask, struct lp_build_context + + mask->bld = bld; + mask->has_mask = FALSE; ++ mask->ret_in_main = FALSE; + mask->cond_stack_size = 0; + mask->loop_stack_size = 0; + mask->call_stack_size = 0; +@@ -108,7 +109,7 @@ static void lp_exec_mask_update(struct lp_exec_mask *mask) + } else + mask->exec_mask = mask->cond_mask; + +- if (mask->call_stack_size) { ++ if (mask->call_stack_size || mask->ret_in_main) { + mask->exec_mask = LLVMBuildAnd(builder, + mask->exec_mask, + mask->ret_mask, +@@ -117,7 +118,8 @@ static void lp_exec_mask_update(struct lp_exec_mask *mask) + + mask->has_mask = (mask->cond_stack_size > 0 || + mask->loop_stack_size > 0 || +- mask->call_stack_size > 0); ++ mask->call_stack_size > 0 || ++ mask->ret_in_main); + } + + static void lp_exec_mask_cond_push(struct lp_exec_mask *mask, +@@ -348,11 +350,23 @@ static void lp_exec_mask_ret(struct lp_exec_mask *mask, int *pc) + LLVMBuilderRef builder = mask->bld->gallivm->builder; + LLVMValueRef exec_mask; + +- if (mask->call_stack_size == 0) { ++ if (mask->cond_stack_size == 0 && ++ mask->loop_stack_size == 0 && ++ mask->call_stack_size == 0) { + /* returning from main() */ + *pc = -1; + return; + } ++ ++ if (mask->call_stack_size == 0) { ++ /* ++ * This requires special handling since we need to ensure ++ * we don't drop the mask even if we have no call stack ++ * (e.g. after a ret in a if clause after the endif) ++ */ ++ mask->ret_in_main = TRUE; ++ } ++ + exec_mask = LLVMBuildNot(builder, + mask->exec_mask, + "ret"); +diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c b/src/gallium/auxiliary/tgsi/tgsi_text.c +index 1267e79..dc3a5fb 100644 +--- a/src/gallium/auxiliary/tgsi/tgsi_text.c ++++ b/src/gallium/auxiliary/tgsi/tgsi_text.c +@@ -1569,7 +1569,7 @@ tgsi_text_translate( + struct tgsi_token *tokens, + uint num_tokens ) + { +- struct translate_ctx ctx; ++ struct translate_ctx ctx = {0}; + + ctx.text = text; + ctx.cur = text; +diff --git a/src/gallium/drivers/Makefile.am b/src/gallium/drivers/Makefile.am +index 25d9533..3477fee 100644 +--- a/src/gallium/drivers/Makefile.am ++++ b/src/gallium/drivers/Makefile.am +@@ -1,6 +1,7 @@ + AUTOMAKE_OPTIONS = subdir-objects + + AM_CPPFLAGS = \ ++ -I$(top_srcdir)/include \ + -I$(top_srcdir)/src/gallium/include \ + -I$(top_srcdir)/src/gallium/auxiliary \ + -I$(top_srcdir)/src/gallium/drivers \ +diff --git a/src/gallium/drivers/llvmpipe/lp_scene.c b/src/gallium/drivers/llvmpipe/lp_scene.c +index 328c0f7..e145391 100644 +--- a/src/gallium/drivers/llvmpipe/lp_scene.c ++++ b/src/gallium/drivers/llvmpipe/lp_scene.c +@@ -64,6 +64,28 @@ lp_scene_create( struct pipe_context *pipe ) + + pipe_mutex_init(scene->mutex); + ++#ifdef DEBUG ++ /* Do some scene limit sanity checks here */ ++ { ++ size_t maxBins = TILES_X * TILES_Y; ++ size_t maxCommandBytes = sizeof(struct cmd_block) * maxBins; ++ size_t maxCommandPlusData = maxCommandBytes + DATA_BLOCK_SIZE; ++ /* We'll need at least one command block per bin. Make sure that's ++ * less than the max allowed scene size. ++ */ ++ assert(maxCommandBytes < LP_SCENE_MAX_SIZE); ++ /* We'll also need space for at least one other data block */ ++ assert(maxCommandPlusData <= LP_SCENE_MAX_SIZE); ++ ++ /* Ideally, the size of a cmd_block object will be a power of two ++ * in order to avoid wasting space when we allocation them from ++ * data blocks (which are power of two also). ++ */ ++ assert(sizeof(struct cmd_block) == ++ util_next_power_of_two(sizeof(struct cmd_block))); ++ } ++#endif ++ + return scene; + } + +diff --git a/src/gallium/drivers/llvmpipe/lp_scene.h b/src/gallium/drivers/llvmpipe/lp_scene.h +index b1db61b..801829d 100644 +--- a/src/gallium/drivers/llvmpipe/lp_scene.h ++++ b/src/gallium/drivers/llvmpipe/lp_scene.h +@@ -49,12 +49,18 @@ struct lp_rast_state; + #define TILES_Y (LP_MAX_HEIGHT / TILE_SIZE) + + +-#define CMD_BLOCK_MAX 128 ++/* Commands per command block (ideally so sizeof(cmd_block) is a power of ++ * two in size.) ++ */ ++#define CMD_BLOCK_MAX 29 ++ ++/* Bytes per data block. ++ */ + #define DATA_BLOCK_SIZE (64 * 1024) + + /* Scene temporary storage is clamped to this size: + */ +-#define LP_SCENE_MAX_SIZE (4*1024*1024) ++#define LP_SCENE_MAX_SIZE (9*1024*1024) + + /* The maximum amount of texture storage referenced by a scene is + * clamped ot this size: +diff --git a/src/gallium/drivers/nv50/nv50_blit.h b/src/gallium/drivers/nv50/nv50_blit.h +index d409f21..bdd6a63 100644 +--- a/src/gallium/drivers/nv50/nv50_blit.h ++++ b/src/gallium/drivers/nv50/nv50_blit.h +@@ -180,4 +180,44 @@ nv50_blit_eng2d_get_mask(const struct pipe_blit_info *info) + return mask; + } + ++#if NOUVEAU_DRIVER == 0xc0 ++# define nv50_format_table nvc0_format_table ++#endif ++ ++/* return TRUE for formats that can be converted among each other by NVC0_2D */ ++static INLINE boolean ++nv50_2d_dst_format_faithful(enum pipe_format format) ++{ ++ const uint64_t mask = ++ NV50_ENG2D_SUPPORTED_FORMATS & ++ ~NV50_ENG2D_NOCONVERT_FORMATS; ++ uint8_t id = nv50_format_table[format].rt; ++ return (id >= 0xc0) && (mask & (1ULL << (id - 0xc0))); ++} ++static INLINE boolean ++nv50_2d_src_format_faithful(enum pipe_format format) ++{ ++ const uint64_t mask = ++ NV50_ENG2D_SUPPORTED_FORMATS & ++ ~(NV50_ENG2D_LUMINANCE_FORMATS | NV50_ENG2D_INTENSITY_FORMATS); ++ uint8_t id = nv50_format_table[format].rt; ++ return (id >= 0xc0) && (mask & (1ULL << (id - 0xc0))); ++} ++ ++static INLINE boolean ++nv50_2d_format_supported(enum pipe_format format) ++{ ++ uint8_t id = nv50_format_table[format].rt; ++ return (id >= 0xc0) && ++ (NV50_ENG2D_SUPPORTED_FORMATS & (1ULL << (id - 0xc0))); ++} ++ ++static INLINE boolean ++nv50_2d_dst_format_ops_supported(enum pipe_format format) ++{ ++ uint8_t id = nv50_format_table[format].rt; ++ return (id >= 0xc0) && ++ (NV50_ENG2D_OPERATION_FORMATS & (1ULL << (id - 0xc0))); ++} ++ + #endif /* __NV50_BLIT_H__ */ +diff --git a/src/gallium/drivers/nv50/nv50_state_validate.c b/src/gallium/drivers/nv50/nv50_state_validate.c +index a95e96d..f5e7b36 100644 +--- a/src/gallium/drivers/nv50/nv50_state_validate.c ++++ b/src/gallium/drivers/nv50/nv50_state_validate.c +@@ -9,6 +9,7 @@ nv50_validate_fb(struct nv50_context *nv50) + struct pipe_framebuffer_state *fb = &nv50->framebuffer; + unsigned i; + unsigned ms_mode = NV50_3D_MULTISAMPLE_MODE_MS1; ++ uint32_t array_size = 0xffff, array_mode = 0; + + nouveau_bufctx_reset(nv50->bufctx_3d, NV50_BIND_FB); + +@@ -23,6 +24,13 @@ nv50_validate_fb(struct nv50_context *nv50) + struct nv50_surface *sf = nv50_surface(fb->cbufs[i]); + struct nouveau_bo *bo = mt->base.bo; + ++ array_size = MIN2(array_size, sf->depth); ++ if (mt->layout_3d) ++ array_mode = NV50_3D_RT_ARRAY_MODE_MODE_3D; /* 1 << 16 */ ++ ++ /* can't mix 3D with ARRAY or have RTs of different depth/array_size */ ++ assert(mt->layout_3d || !array_mode || array_size == 1); ++ + BEGIN_NV04(push, NV50_3D(RT_ADDRESS_HIGH(i)), 5); + PUSH_DATAh(push, bo->offset + sf->offset); + PUSH_DATA (push, bo->offset + sf->offset); +@@ -34,7 +42,7 @@ nv50_validate_fb(struct nv50_context *nv50) + PUSH_DATA (push, sf->width); + PUSH_DATA (push, sf->height); + BEGIN_NV04(push, NV50_3D(RT_ARRAY_MODE), 1); +- PUSH_DATA (push, sf->depth); ++ PUSH_DATA (push, array_mode | array_size); + } else { + PUSH_DATA (push, 0); + PUSH_DATA (push, 0); +@@ -63,7 +71,7 @@ nv50_validate_fb(struct nv50_context *nv50) + struct nv50_miptree *mt = nv50_miptree(fb->zsbuf->texture); + struct nv50_surface *sf = nv50_surface(fb->zsbuf); + struct nouveau_bo *bo = mt->base.bo; +- int unk = mt->base.base.target == PIPE_TEXTURE_2D; ++ int unk = mt->base.base.target == PIPE_TEXTURE_3D || sf->depth == 1; + + BEGIN_NV04(push, NV50_3D(ZETA_ADDRESS_HIGH), 5); + PUSH_DATAh(push, bo->offset + sf->offset); +diff --git a/src/gallium/drivers/nv50/nv50_surface.c b/src/gallium/drivers/nv50/nv50_surface.c +index 7a0470c..3a780f6 100644 +--- a/src/gallium/drivers/nv50/nv50_surface.c ++++ b/src/gallium/drivers/nv50/nv50_surface.c +@@ -35,25 +35,22 @@ + + #include "nv50_context.h" + #include "nv50_resource.h" +-#include "nv50_blit.h" + + #include "nv50_defs.xml.h" + #include "nv50_texture.xml.h" + ++/* these are used in nv50_blit.h */ + #define NV50_ENG2D_SUPPORTED_FORMATS 0xff0843e080608409ULL ++#define NV50_ENG2D_NOCONVERT_FORMATS 0x0008402000000000ULL ++#define NV50_ENG2D_LUMINANCE_FORMATS 0x0008402000000000ULL ++#define NV50_ENG2D_INTENSITY_FORMATS 0x0000000000000000ULL ++#define NV50_ENG2D_OPERATION_FORMATS 0x060001c000608000ULL + +-/* return TRUE for formats that can be converted among each other by NV50_2D */ +-static INLINE boolean +-nv50_2d_format_faithful(enum pipe_format format) +-{ +- uint8_t id = nv50_format_table[format].rt; +- +- return (id >= 0xc0) && +- (NV50_ENG2D_SUPPORTED_FORMATS & (1ULL << (id - 0xc0))); +-} ++#define NOUVEAU_DRIVER 0x50 ++#include "nv50_blit.h" + + static INLINE uint8_t +-nv50_2d_format(enum pipe_format format) ++nv50_2d_format(enum pipe_format format, boolean dst, boolean dst_src_equal) + { + uint8_t id = nv50_format_table[format].rt; + +@@ -62,6 +59,7 @@ nv50_2d_format(enum pipe_format format) + */ + if ((id >= 0xc0) && (NV50_ENG2D_SUPPORTED_FORMATS & (1ULL << (id - 0xc0)))) + return id; ++ assert(dst_src_equal); + + switch (util_format_get_blocksize(format)) { + case 1: +@@ -78,7 +76,7 @@ nv50_2d_format(enum pipe_format format) + static int + nv50_2d_texture_set(struct nouveau_pushbuf *push, int dst, + struct nv50_miptree *mt, unsigned level, unsigned layer, +- enum pipe_format pformat) ++ enum pipe_format pformat, boolean dst_src_pformat_equal) + { + struct nouveau_bo *bo = mt->base.bo; + uint32_t width, height, depth; +@@ -86,7 +84,7 @@ nv50_2d_texture_set(struct nouveau_pushbuf *push, int dst, + uint32_t mthd = dst ? NV50_2D_DST_FORMAT : NV50_2D_SRC_FORMAT; + uint32_t offset = mt->level[level].offset; + +- format = nv50_2d_format(pformat); ++ format = nv50_2d_format(pformat, dst, dst_src_pformat_equal); + if (!format) { + NOUVEAU_ERR("invalid/unsupported surface format: %s\n", + util_format_name(pformat)); +@@ -155,15 +153,16 @@ nv50_2d_texture_do_copy(struct nouveau_pushbuf *push, + const enum pipe_format dfmt = dst->base.base.format; + const enum pipe_format sfmt = src->base.base.format; + int ret; ++ boolean eqfmt = dfmt == sfmt; + + if (!PUSH_SPACE(push, 2 * 16 + 32)) + return PIPE_ERROR; + +- ret = nv50_2d_texture_set(push, 1, dst, dst_level, dz, dfmt); ++ ret = nv50_2d_texture_set(push, 1, dst, dst_level, dz, dfmt, eqfmt); + if (ret) + return ret; + +- ret = nv50_2d_texture_set(push, 0, src, src_level, sz, sfmt); ++ ret = nv50_2d_texture_set(push, 0, src, src_level, sz, sfmt, eqfmt); + if (ret) + return ret; + +@@ -243,8 +242,8 @@ nv50_resource_copy_region(struct pipe_context *pipe, + } + + assert((src->format == dst->format) || +- (nv50_2d_format_faithful(src->format) && +- nv50_2d_format_faithful(dst->format))); ++ (nv50_2d_src_format_faithful(src->format) && ++ nv50_2d_dst_format_faithful(dst->format))); + + BCTX_REFN(nv50->bufctx, 2D, nv04_resource(src), RD); + BCTX_REFN(nv50->bufctx, 2D, nv04_resource(dst), WR); +@@ -936,7 +935,7 @@ nv50_blit_3d(struct nv50_context *nv50, const struct pipe_blit_info *info) + nv50_blit_select_fp(blit, info); + nv50_blitctx_pre_blit(blit); + +- nv50_blit_set_dst(blit, dst, info->dst.level, 0, info->dst.format); ++ nv50_blit_set_dst(blit, dst, info->dst.level, -1, info->dst.format); + nv50_blit_set_src(blit, src, info->src.level, -1, info->src.format, + blit->filter); + +@@ -977,6 +976,8 @@ nv50_blit_3d(struct nv50_context *nv50, const struct pipe_blit_info *info) + + BEGIN_NV04(push, NV50_3D(VIEWPORT_TRANSFORM_EN), 1); + PUSH_DATA (push, 0); ++ BEGIN_NV04(push, NV50_3D(VIEW_VOLUME_CLIP_CTRL), 1); ++ PUSH_DATA (push, 0x1); + + /* Draw a large triangle in screen coordinates covering the whole + * render target, with scissors defining the destination region. +@@ -1059,7 +1060,8 @@ nv50_blit_eng2d(struct nv50_context *nv50, const struct pipe_blit_info *info) + int64_t du_dx, dv_dy; + int i; + uint32_t mode; +- const uint32_t mask = nv50_blit_eng2d_get_mask(info); ++ uint32_t mask = nv50_blit_eng2d_get_mask(info); ++ boolean b; + + mode = nv50_blit_get_filter(info) ? + NV50_2D_BLIT_CONTROL_FILTER_BILINEAR : +@@ -1070,8 +1072,9 @@ nv50_blit_eng2d(struct nv50_context *nv50, const struct pipe_blit_info *info) + du_dx = ((int64_t)info->src.box.width << 32) / info->dst.box.width; + dv_dy = ((int64_t)info->src.box.height << 32) / info->dst.box.height; + +- nv50_2d_texture_set(push, 1, dst, info->dst.level, dz, info->dst.format); +- nv50_2d_texture_set(push, 0, src, info->src.level, sz, info->src.format); ++ b = info->dst.format == info->src.format; ++ nv50_2d_texture_set(push, 1, dst, info->dst.level, dz, info->dst.format, b); ++ nv50_2d_texture_set(push, 0, src, info->src.level, sz, info->src.format, b); + + if (info->scissor_enable) { + BEGIN_NV04(push, NV50_2D(CLIP_X), 5); +@@ -1094,6 +1097,17 @@ nv50_blit_eng2d(struct nv50_context *nv50, const struct pipe_blit_info *info) + PUSH_DATA (push, 0xffffffff); + BEGIN_NV04(push, NV50_2D(OPERATION), 1); + PUSH_DATA (push, NV50_2D_OPERATION_ROP); ++ } else ++ if (info->src.format != info->dst.format) { ++ if (info->src.format == PIPE_FORMAT_R8_UNORM || ++ info->src.format == PIPE_FORMAT_R16_UNORM || ++ info->src.format == PIPE_FORMAT_R16_FLOAT || ++ info->src.format == PIPE_FORMAT_R32_FLOAT) { ++ mask = 0xffff0000; /* also makes condition for OPERATION reset true */ ++ BEGIN_NV04(push, NV50_2D(BETA4), 2); ++ PUSH_DATA (push, mask); ++ PUSH_DATA (push, NV50_2D_OPERATION_SRCCOPY_PREMULT); ++ } + } + + if (src->ms_x > dst->ms_x || src->ms_y > dst->ms_y) { +@@ -1224,10 +1238,25 @@ nv50_blit(struct pipe_context *pipe, const struct pipe_blit_info *info) + debug_printf("blit: cannot filter array or cube textures in z direction"); + } + +- if (!eng3d && info->dst.format != info->src.format) +- if (!nv50_2d_format_faithful(info->dst.format) || +- !nv50_2d_format_faithful(info->src.format)) ++ if (!eng3d && info->dst.format != info->src.format) { ++ if (!nv50_2d_dst_format_faithful(info->dst.format) || ++ !nv50_2d_src_format_faithful(info->src.format)) { + eng3d = TRUE; ++ } else ++ if (!nv50_2d_src_format_faithful(info->src.format)) { ++ if (!util_format_is_luminance(info->src.format)) { ++ if (util_format_is_intensity(info->src.format)) ++ eng3d = TRUE; ++ else ++ if (!nv50_2d_dst_format_ops_supported(info->dst.format)) ++ eng3d = TRUE; ++ else ++ eng3d = !nv50_2d_format_supported(info->src.format); ++ } ++ } else ++ if (util_format_is_luminance_alpha(info->src.format)) ++ eng3d = TRUE; ++ } + + if (info->src.resource->nr_samples == 8 && + info->dst.resource->nr_samples <= 1) +diff --git a/src/gallium/drivers/nvc0/nvc0_3d.xml.h b/src/gallium/drivers/nvc0/nvc0_3d.xml.h +index 1cf1f96..bd3de58 100644 +--- a/src/gallium/drivers/nvc0/nvc0_3d.xml.h ++++ b/src/gallium/drivers/nvc0/nvc0_3d.xml.h +@@ -1041,7 +1041,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + #define NVC0_3D_VIEWPORT_TRANSFORM_EN 0x0000192c + + #define NVC0_3D_VIEW_VOLUME_CLIP_CTRL 0x0000193c +-#define NVC0_3D_VIEW_VOLUME_CLIP_CTRL_UNK0 0x00000001 ++#define NVC0_3D_VIEW_VOLUME_CLIP_CTRL_DEPTH_RANGE_0_1 0x00000001 + #define NVC0_3D_VIEW_VOLUME_CLIP_CTRL_UNK1__MASK 0x00000006 + #define NVC0_3D_VIEW_VOLUME_CLIP_CTRL_UNK1__SHIFT 1 + #define NVC0_3D_VIEW_VOLUME_CLIP_CTRL_UNK1_UNK0 0x00000000 +diff --git a/src/gallium/drivers/nvc0/nvc0_surface.c b/src/gallium/drivers/nvc0/nvc0_surface.c +index 281d740..66154a4 100644 +--- a/src/gallium/drivers/nvc0/nvc0_surface.c ++++ b/src/gallium/drivers/nvc0/nvc0_surface.c +@@ -36,29 +36,32 @@ + + #include "nv50/nv50_defs.xml.h" + #include "nv50/nv50_texture.xml.h" +-#include "nv50/nv50_blit.h" + +-#define NVC0_ENG2D_SUPPORTED_FORMATS 0xff9ccfe1cce3ccc9ULL ++/* these are used in nv50_blit.h */ ++#define NV50_ENG2D_SUPPORTED_FORMATS 0xff9ccfe1cce3ccc9ULL ++#define NV50_ENG2D_NOCONVERT_FORMATS 0x009cc02000000000ULL ++#define NV50_ENG2D_LUMINANCE_FORMATS 0x001cc02000000000ULL ++#define NV50_ENG2D_INTENSITY_FORMATS 0x0080000000000000ULL ++#define NV50_ENG2D_OPERATION_FORMATS 0x060001c000638000ULL + +-/* return TRUE for formats that can be converted among each other by NVC0_2D */ +-static INLINE boolean +-nvc0_2d_format_faithful(enum pipe_format format) +-{ +- uint8_t id = nvc0_format_table[format].rt; +- +- return (id >= 0xc0) && (NVC0_ENG2D_SUPPORTED_FORMATS & (1ULL << (id - 0xc0))); +-} ++#define NOUVEAU_DRIVER 0xc0 ++#include "nv50/nv50_blit.h" + + static INLINE uint8_t +-nvc0_2d_format(enum pipe_format format) ++nvc0_2d_format(enum pipe_format format, boolean dst, boolean dst_src_equal) + { + uint8_t id = nvc0_format_table[format].rt; + ++ /* A8_UNORM is treated as I8_UNORM as far as the 2D engine is concerned. */ ++ if (!dst && unlikely(format == PIPE_FORMAT_I8_UNORM) && !dst_src_equal) ++ return NV50_SURFACE_FORMAT_A8_UNORM; ++ + /* Hardware values for color formats range from 0xc0 to 0xff, + * but the 2D engine doesn't support all of them. + */ +- if (nvc0_2d_format_faithful(format)) ++ if (nv50_2d_format_supported(format)) + return id; ++ assert(dst_src_equal); + + switch (util_format_get_blocksize(format)) { + case 1: +@@ -72,6 +75,7 @@ nvc0_2d_format(enum pipe_format format) + case 16: + return NV50_SURFACE_FORMAT_RGBA32_FLOAT; + default: ++ assert(0); + return 0; + } + } +@@ -79,7 +83,7 @@ nvc0_2d_format(enum pipe_format format) + static int + nvc0_2d_texture_set(struct nouveau_pushbuf *push, boolean dst, + struct nv50_miptree *mt, unsigned level, unsigned layer, +- enum pipe_format pformat) ++ enum pipe_format pformat, boolean dst_src_pformat_equal) + { + struct nouveau_bo *bo = mt->base.bo; + uint32_t width, height, depth; +@@ -87,7 +91,7 @@ nvc0_2d_texture_set(struct nouveau_pushbuf *push, boolean dst, + uint32_t mthd = dst ? NVC0_2D_DST_FORMAT : NVC0_2D_SRC_FORMAT; + uint32_t offset = mt->level[level].offset; + +- format = nvc0_2d_format(pformat); ++ format = nvc0_2d_format(pformat, dst, dst_src_pformat_equal); + if (!format) { + NOUVEAU_ERR("invalid/unsupported surface format: %s\n", + util_format_name(pformat)); +@@ -157,15 +161,16 @@ nvc0_2d_texture_do_copy(struct nouveau_pushbuf *push, + const enum pipe_format dfmt = dst->base.base.format; + const enum pipe_format sfmt = src->base.base.format; + int ret; ++ boolean eqfmt = dfmt == sfmt; + + if (!PUSH_SPACE(push, 2 * 16 + 32)) + return PIPE_ERROR; + +- ret = nvc0_2d_texture_set(push, TRUE, dst, dst_level, dz, dfmt); ++ ret = nvc0_2d_texture_set(push, TRUE, dst, dst_level, dz, dfmt, eqfmt); + if (ret) + return ret; + +- ret = nvc0_2d_texture_set(push, FALSE, src, src_level, sz, sfmt); ++ ret = nvc0_2d_texture_set(push, FALSE, src, src_level, sz, sfmt, eqfmt); + if (ret) + return ret; + +@@ -243,8 +248,8 @@ nvc0_resource_copy_region(struct pipe_context *pipe, + return; + } + +- assert(nvc0_2d_format_faithful(src->format)); +- assert(nvc0_2d_format_faithful(dst->format)); ++ assert(nv50_2d_dst_format_faithful(dst->format)); ++ assert(nv50_2d_src_format_faithful(src->format)); + + BCTX_REFN(nvc0->bufctx, 2D, nv04_resource(src), RD); + BCTX_REFN(nvc0->bufctx, 2D, nv04_resource(dst), WR); +@@ -490,19 +495,19 @@ nvc0_blitter_make_vp(struct nvc0_blitter *blit) + { + static const uint32_t code_nvc0[] = + { +- 0xfff01c66, 0x06000080, /* vfetch b128 { $r0 $r1 $r2 $r3 } a[0x80] */ +- 0xfff11c26, 0x06000090, /* vfetch b96 { $r4 $r5 $r6 } a[0x90]*/ +- 0x03f01c66, 0x0a7e0070, /* export b128 o[0x70] { $r0 $r1 $r2 $r3 } */ +- 0x13f01c26, 0x0a7e0080, /* export b96 o[0x80] { $r4 $r5 $r6 } */ ++ 0xfff11c26, 0x06000080, /* vfetch b64 $r4:$r5 a[0x80] */ ++ 0xfff01c46, 0x06000090, /* vfetch b96 $r0:$r1:$r2 a[0x90] */ ++ 0x13f01c26, 0x0a7e0070, /* export b64 o[0x70] $r4:$r5 */ ++ 0x03f01c46, 0x0a7e0080, /* export b96 o[0x80] $r0:$r1:$r2 */ + 0x00001de7, 0x80000000, /* exit */ + }; + static const uint32_t code_nve4[] = + { + 0x00000007, 0x20000000, /* sched */ +- 0xfff01c66, 0x06000080, /* vfetch b128 { $r0 $r1 $r2 $r3 } a[0x80] */ +- 0xfff11c46, 0x06000090, /* vfetch b96 { $r4 $r5 $r6 } a[0x90]*/ +- 0x03f01c66, 0x0a7e0070, /* export b128 o[0x70] { $r0 $r1 $r2 $r3 } */ +- 0x13f01c46, 0x0a7e0080, /* export b96 o[0x80] { $r4 $r5 $r6 } */ ++ 0xfff11c26, 0x06000080, /* vfetch b64 $r4:$r5 a[0x80] */ ++ 0xfff01c46, 0x06000090, /* vfetch b96 $r0:$r1:$r2 a[0x90] */ ++ 0x13f01c26, 0x0a7e0070, /* export b64 o[0x70] $r4:$r5 */ ++ 0x03f01c46, 0x0a7e0080, /* export b96 o[0x80] $r0:$r1:$r2 */ + 0x00001de7, 0x80000000, /* exit */ + }; + +@@ -515,13 +520,13 @@ nvc0_blitter_make_vp(struct nvc0_blitter *blit) + blit->vp.code = (uint32_t *)code_nvc0; /* const_cast */ + blit->vp.code_size = sizeof(code_nvc0); + } +- blit->vp.max_gpr = 7; ++ blit->vp.max_gpr = 6; + blit->vp.vp.edgeflag = PIPE_MAX_ATTRIBS; + + blit->vp.hdr[0] = 0x00020461; /* vertprog magic */ + blit->vp.hdr[4] = 0x000ff000; /* no outputs read */ +- blit->vp.hdr[6] = 0x0000003f; /* a[0x80], a[0x90] */ +- blit->vp.hdr[13] = 0x0003f000; /* o[0x70], o[0x80] */ ++ blit->vp.hdr[6] = 0x00000073; /* a[0x80].xy, a[0x90].xyz */ ++ blit->vp.hdr[13] = 0x00073000; /* o[0x70].xy, o[0x80].xyz */ + } + + static void +@@ -820,7 +825,7 @@ nvc0_blit_3d(struct nvc0_context *nvc0, const struct pipe_blit_info *info) + nvc0_blit_select_fp(blit, info); + nvc0_blitctx_pre_blit(blit); + +- nvc0_blit_set_dst(blit, dst, info->dst.level, 0, info->dst.format); ++ nvc0_blit_set_dst(blit, dst, info->dst.level, -1, info->dst.format); + nvc0_blit_set_src(blit, src, info->src.level, -1, info->src.format, + blit->filter); + +@@ -859,6 +864,8 @@ nvc0_blit_3d(struct nvc0_context *nvc0, const struct pipe_blit_info *info) + z += 0.5f * dz; + + IMMED_NVC0(push, NVC0_3D(VIEWPORT_TRANSFORM_EN), 0); ++ IMMED_NVC0(push, NVC0_3D(VIEW_VOLUME_CLIP_CTRL), 0x2 | ++ NVC0_3D_VIEW_VOLUME_CLIP_CTRL_DEPTH_RANGE_0_1); + BEGIN_NVC0(push, NVC0_3D(VIEWPORT_HORIZ(0)), 2); + PUSH_DATA (push, nvc0->framebuffer.width << 16); + PUSH_DATA (push, nvc0->framebuffer.height << 16); +@@ -925,11 +932,14 @@ nvc0_blit_3d(struct nvc0_context *nvc0, const struct pipe_blit_info *info) + if (info->dst.box.z + info->dst.box.depth - 1) + IMMED_NVC0(push, NVC0_3D(LAYER), 0); + +- /* re-enable normally constant state */ ++ nvc0_blitctx_post_blit(blit); + +- IMMED_NVC0(push, NVC0_3D(VIEWPORT_TRANSFORM_EN), 1); ++ /* restore viewport */ + +- nvc0_blitctx_post_blit(blit); ++ BEGIN_NVC0(push, NVC0_3D(VIEWPORT_HORIZ(0)), 2); ++ PUSH_DATA (push, nvc0->framebuffer.width << 16); ++ PUSH_DATA (push, nvc0->framebuffer.height << 16); ++ IMMED_NVC0(push, NVC0_3D(VIEWPORT_TRANSFORM_EN), 1); + } + + static void +@@ -948,7 +958,8 @@ nvc0_blit_eng2d(struct nvc0_context *nvc0, const struct pipe_blit_info *info) + int64_t du_dx, dv_dy; + int i; + uint32_t mode; +- const uint32_t mask = nv50_blit_eng2d_get_mask(info); ++ uint32_t mask = nv50_blit_eng2d_get_mask(info); ++ boolean b; + + mode = nv50_blit_get_filter(info) ? + NVC0_2D_BLIT_CONTROL_FILTER_BILINEAR : +@@ -959,8 +970,9 @@ nvc0_blit_eng2d(struct nvc0_context *nvc0, const struct pipe_blit_info *info) + du_dx = ((int64_t)info->src.box.width << 32) / info->dst.box.width; + dv_dy = ((int64_t)info->src.box.height << 32) / info->dst.box.height; + +- nvc0_2d_texture_set(push, 1, dst, info->dst.level, dz, info->dst.format); +- nvc0_2d_texture_set(push, 0, src, info->src.level, sz, info->src.format); ++ b = info->dst.format == info->src.format; ++ nvc0_2d_texture_set(push, 1, dst, info->dst.level, dz, info->dst.format, b); ++ nvc0_2d_texture_set(push, 0, src, info->src.level, sz, info->src.format, b); + + if (info->scissor_enable) { + BEGIN_NVC0(push, NVC0_2D(CLIP_X), 5); +@@ -981,6 +993,25 @@ nvc0_blit_eng2d(struct nvc0_context *nvc0, const struct pipe_blit_info *info) + PUSH_DATA (push, 0xffffffff); + PUSH_DATA (push, 0xffffffff); + IMMED_NVC0(push, NVC0_2D(OPERATION), NVC0_2D_OPERATION_ROP); ++ } else ++ if (info->src.format != info->dst.format) { ++ if (info->src.format == PIPE_FORMAT_R8_UNORM || ++ info->src.format == PIPE_FORMAT_R8_SNORM || ++ info->src.format == PIPE_FORMAT_R16_UNORM || ++ info->src.format == PIPE_FORMAT_R16_SNORM || ++ info->src.format == PIPE_FORMAT_R16_FLOAT || ++ info->src.format == PIPE_FORMAT_R32_FLOAT) { ++ mask = 0xffff0000; /* also makes condition for OPERATION reset true */ ++ BEGIN_NVC0(push, NVC0_2D(BETA4), 2); ++ PUSH_DATA (push, mask); ++ PUSH_DATA (push, NVC0_2D_OPERATION_SRCCOPY_PREMULT); ++ } else ++ if (info->src.format == PIPE_FORMAT_A8_UNORM) { ++ mask = 0xff000000; ++ BEGIN_NVC0(push, NVC0_2D(BETA4), 2); ++ PUSH_DATA (push, mask); ++ PUSH_DATA (push, NVC0_2D_OPERATION_SRCCOPY_PREMULT); ++ } + } + + if (src->ms_x > dst->ms_x || src->ms_y > dst->ms_y) { +@@ -1106,10 +1137,24 @@ nvc0_blit(struct pipe_context *pipe, const struct pipe_blit_info *info) + debug_printf("blit: cannot filter array or cube textures in z direction"); + } + +- if (!eng3d && info->dst.format != info->src.format) +- if (!nvc0_2d_format_faithful(info->dst.format) || +- !nvc0_2d_format_faithful(info->src.format)) ++ if (!eng3d && info->dst.format != info->src.format) { ++ if (!nv50_2d_dst_format_faithful(info->dst.format)) { ++ eng3d = TRUE; ++ } else ++ if (!nv50_2d_src_format_faithful(info->src.format)) { ++ if (!util_format_is_luminance(info->src.format)) { ++ if (util_format_is_intensity(info->src.format)) ++ eng3d = info->src.format != PIPE_FORMAT_I8_UNORM; ++ else ++ if (!nv50_2d_dst_format_ops_supported(info->dst.format)) ++ eng3d = TRUE; ++ else ++ eng3d = !nv50_2d_format_supported(info->src.format); ++ } ++ } else ++ if (util_format_is_luminance_alpha(info->src.format)) + eng3d = TRUE; ++ } + + if (info->src.resource->nr_samples == 8 && + info->dst.resource->nr_samples <= 1) +diff --git a/src/gallium/drivers/r300/compiler/radeon_optimize.c b/src/gallium/drivers/r300/compiler/radeon_optimize.c +index 734c7f2..74afd6f 100644 +--- a/src/gallium/drivers/r300/compiler/radeon_optimize.c ++++ b/src/gallium/drivers/r300/compiler/radeon_optimize.c +@@ -708,6 +708,7 @@ static int peephole_mul_omod( + struct rc_list * writer_list; + struct rc_variable * var; + struct peephole_mul_cb_data cb_data; ++ unsigned writemask_sum; + + for (i = 0; i < 2; i++) { + unsigned int j; +@@ -815,10 +816,11 @@ static int peephole_mul_omod( + } + + /* Rewrite the instructions */ ++ writemask_sum = rc_variable_writemask_sum(writer_list->Item); + for (var = writer_list->Item; var; var = var->Friend) { + struct rc_variable * writer = var; + unsigned conversion_swizzle = rc_make_conversion_swizzle( +- writer->Inst->U.I.DstReg.WriteMask, ++ writemask_sum, + inst_mul->U.I.DstReg.WriteMask); + writer->Inst->U.I.Omod = omod_op; + writer->Inst->U.I.DstReg.File = inst_mul->U.I.DstReg.File; +diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c +index a7973a5..80b859f 100644 +--- a/src/gallium/drivers/r600/r600_pipe.c ++++ b/src/gallium/drivers/r600/r600_pipe.c +@@ -1157,7 +1157,7 @@ struct pipe_screen *r600_screen_create(struct radeon_winsys *ws) + * case were triggering lockup quickly such as : + * piglit/bin/depthstencil-render-miplevels 1024 d=s=z24_s8 + */ +- rscreen->use_hyperz = debug_get_bool_option("R600_HYPERZ", TRUE); ++ rscreen->use_hyperz = debug_get_bool_option("R600_HYPERZ", FALSE); + rscreen->use_hyperz = rscreen->info.drm_minor >= 26 ? rscreen->use_hyperz : FALSE; + + rscreen->global_pool = compute_memory_pool_new(rscreen); +diff --git a/src/gallium/drivers/r600/r600_query.c b/src/gallium/drivers/r600/r600_query.c +index 0335189..782ad26 100644 +--- a/src/gallium/drivers/r600/r600_query.c ++++ b/src/gallium/drivers/r600/r600_query.c +@@ -186,10 +186,11 @@ static void r600_emit_query_end(struct r600_context *ctx, struct r600_query *que + case PIPE_QUERY_PRIMITIVES_GENERATED: + case PIPE_QUERY_SO_STATISTICS: + case PIPE_QUERY_SO_OVERFLOW_PREDICATE: ++ va += query->buffer.results_end + query->result_size/2; + cs->buf[cs->cdw++] = PKT3(PKT3_EVENT_WRITE, 2, 0); + cs->buf[cs->cdw++] = EVENT_TYPE(EVENT_TYPE_SAMPLE_STREAMOUTSTATS) | EVENT_INDEX(3); +- cs->buf[cs->cdw++] = query->buffer.results_end + query->result_size/2; +- cs->buf[cs->cdw++] = 0; ++ cs->buf[cs->cdw++] = va; ++ cs->buf[cs->cdw++] = (va >> 32UL) & 0xFF; + break; + case PIPE_QUERY_TIME_ELAPSED: + va += query->buffer.results_end + query->result_size/2; +diff --git a/src/gallium/drivers/radeon/Makefile.am b/src/gallium/drivers/radeon/Makefile.am +index e6eb241..a3a7b74 100644 +--- a/src/gallium/drivers/radeon/Makefile.am ++++ b/src/gallium/drivers/radeon/Makefile.am +@@ -1,11 +1,14 @@ + include Makefile.sources + include $(top_srcdir)/src/gallium/Automake.inc + ++LIBGALLIUM_LIBS= ++ + if HAVE_GALLIUM_R600 + if HAVE_GALLIUM_RADEONSI + lib_LTLIBRARIES = libllvmradeon@VERSION@.la + libllvmradeon@VERSION@_la_LDFLAGS = -Wl, -shared -avoid-version \ + $(LLVM_LDFLAGS) ++LIBGALLIUM_LIBS += $(top_builddir)/src/gallium/auxiliary/libgallium.la + else + noinst_LTLIBRARIES = libllvmradeon@VERSION@.la + endif +@@ -26,5 +29,6 @@ libllvmradeon@VERSION@_la_SOURCES = \ + $(C_FILES) + + libllvmradeon@VERSION@_la_LIBADD = \ ++ $(LIBGALLIUM_LIBS) \ + $(CLOCK_LIB) \ + $(LLVM_LIBS) +diff --git a/src/gallium/drivers/radeonsi/si_state_draw.c b/src/gallium/drivers/radeonsi/si_state_draw.c +index 8c35625..93766a3 100644 +--- a/src/gallium/drivers/radeonsi/si_state_draw.c ++++ b/src/gallium/drivers/radeonsi/si_state_draw.c +@@ -401,6 +401,11 @@ static void si_update_derived_state(struct r600_context *rctx) + } + + if (si_pm4_state_changed(rctx, ps) || si_pm4_state_changed(rctx, vs)) { ++ /* XXX: Emitting the PS state even when only the VS changed ++ * fixes random failures with piglit glsl-max-varyings. ++ * Not sure why... ++ */ ++ rctx->emitted.named.ps = NULL; + si_update_spi_map(rctx); + } + } +diff --git a/src/gallium/drivers/rbug/Makefile.am b/src/gallium/drivers/rbug/Makefile.am +index 655bfe1..3c1a8b5 100644 +--- a/src/gallium/drivers/rbug/Makefile.am ++++ b/src/gallium/drivers/rbug/Makefile.am +@@ -30,6 +30,7 @@ noinst_LTLIBRARIES = librbug.la + # preprocessor is determined by the ordering of the -I flags. + AM_CFLAGS = \ + $(GALLIUM_CFLAGS) \ ++ $(VISIBILITY_CFLAGS) \ + -I$(top_srcdir)/src/gallium/drivers \ + -I$(top_srcdir)/include + +diff --git a/src/gallium/drivers/svga/Makefile.am b/src/gallium/drivers/svga/Makefile.am +index fdaa3c8..7eacd90 100644 +--- a/src/gallium/drivers/svga/Makefile.am ++++ b/src/gallium/drivers/svga/Makefile.am +@@ -29,6 +29,8 @@ AM_CPPFLAGS = \ + -I$(top_srcdir)/include \ + $(GALLIUM_CFLAGS) + ++AM_CFLAGS = $(VISIBILITY_CFLAGS) ++ + #On some systems -std= must be added to CFLAGS to be the last -std= + CFLAGS += -std=gnu99 + +diff --git a/src/gallium/drivers/trace/Makefile.am b/src/gallium/drivers/trace/Makefile.am +index a9e1457..984ead4 100644 +--- a/src/gallium/drivers/trace/Makefile.am ++++ b/src/gallium/drivers/trace/Makefile.am +@@ -1,7 +1,8 @@ + include $(top_srcdir)/src/gallium/Automake.inc + + AM_CFLAGS = \ +- $(GALLIUM_CFLAGS) ++ $(GALLIUM_CFLAGS) \ ++ $(VISIBILITY_CFLAGS) + + noinst_LTLIBRARIES = libtrace.la + +diff --git a/src/gallium/include/pipe/p_compiler.h b/src/gallium/include/pipe/p_compiler.h +index 5958333..a131969 100644 +--- a/src/gallium/include/pipe/p_compiler.h ++++ b/src/gallium/include/pipe/p_compiler.h +@@ -29,6 +29,8 @@ + #define P_COMPILER_H + + ++#include "c99_compat.h" /* inline, __func__, etc. */ ++ + #include "p_config.h" + + #include +@@ -90,28 +92,7 @@ typedef unsigned char boolean; + #endif + #endif + +-/* Function inlining */ +-#ifndef inline +-# ifdef __cplusplus +- /* C++ supports inline keyword */ +-# elif defined(__GNUC__) +-# define inline __inline__ +-# elif defined(_MSC_VER) +-# define inline __inline +-# elif defined(__ICL) +-# define inline __inline +-# elif defined(__INTEL_COMPILER) +- /* Intel compiler supports inline keyword */ +-# elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100) +-# define inline __inline +-# elif defined(__SUNPRO_C) && defined(__C99FEATURES__) +- /* C99 supports inline keyword */ +-# elif (__STDC_VERSION__ >= 199901L) +- /* C99 supports inline keyword */ +-# else +-# define inline +-# endif +-#endif ++/* XXX: Use standard `inline` keyword instead */ + #ifndef INLINE + # define INLINE inline + #endif +@@ -127,26 +108,6 @@ typedef unsigned char boolean; + # endif + #endif + +-/* +- * Define the C99 restrict keyword. +- * +- * See also: +- * - http://cellperformance.beyond3d.com/articles/2006/05/demystifying-the-restrict-keyword.html +- */ +-#ifndef restrict +-# if (__STDC_VERSION__ >= 199901L) +- /* C99 */ +-# elif defined(__SUNPRO_C) && defined(__C99FEATURES__) +- /* C99 */ +-# elif defined(__GNUC__) +-# define restrict __restrict__ +-# elif defined(_MSC_VER) +-# define restrict __restrict +-# else +-# define restrict /* */ +-# endif +-#endif +- + + /* Function visibility */ + #ifndef PUBLIC +@@ -160,35 +121,10 @@ typedef unsigned char boolean; + #endif + + +-/* The __FUNCTION__ gcc variable is generally only used for debugging. +- * If we're not using gcc, define __FUNCTION__ as a cpp symbol here. +- */ ++/* XXX: Use standard `__func__` instead */ + #ifndef __FUNCTION__ +-# if !defined(__GNUC__) +-# if (__STDC_VERSION__ >= 199901L) /* C99 */ || \ +- (defined(__SUNPRO_C) && defined(__C99FEATURES__)) +-# define __FUNCTION__ __func__ +-# else +-# define __FUNCTION__ "" +-# endif +-# endif +-# if defined(_MSC_VER) && _MSC_VER < 1300 +-# define __FUNCTION__ "" +-# endif ++# define __FUNCTION__ __func__ + #endif +-#ifndef __func__ +-# if (__STDC_VERSION__ >= 199901L) || \ +- (defined(__SUNPRO_C) && defined(__C99FEATURES__)) +- /* __func__ is part of C99 */ +-# elif defined(_MSC_VER) +-# if _MSC_VER >= 1300 +-# define __func__ __FUNCTION__ +-# else +-# define __func__ "" +-# endif +-# endif +-#endif +- + + + /* This should match linux gcc cdecl semantics everywhere, so that we +diff --git a/src/gallium/state_trackers/egl/Makefile.am b/src/gallium/state_trackers/egl/Makefile.am +index e19e9a3..f78b36e 100644 +--- a/src/gallium/state_trackers/egl/Makefile.am ++++ b/src/gallium/state_trackers/egl/Makefile.am +@@ -27,7 +27,7 @@ include $(top_srcdir)/src/gallium/Automake.inc + AM_CFLAGS = $(GALLIUM_CFLAGS) + AM_CPPFLAGS = \ + -I$(top_srcdir)/src/egl/main \ +- -I$(top_srcdir)/src/egl/wayland/wayland-drm/ \ ++ -I$(top_builddir)/src/egl/wayland/wayland-drm/ \ + -I$(top_srcdir)/include + + noinst_LTLIBRARIES = libegl.la +diff --git a/src/gallium/state_trackers/xa/Makefile.am b/src/gallium/state_trackers/xa/Makefile.am +index 5b53ef9..57d55c4 100644 +--- a/src/gallium/state_trackers/xa/Makefile.am ++++ b/src/gallium/state_trackers/xa/Makefile.am +@@ -24,7 +24,9 @@ include $(top_srcdir)/src/gallium/Automake.inc + + AM_CFLAGS = \ + -Wall -pedantic \ +- $(GALLIUM_CFLAGS) ++ $(GALLIUM_CFLAGS) \ ++ $(VISIBILITY_CFLAGS) ++ + AM_CPPFLAGS = \ + -I$(top_srcdir)/src/gallium/ \ + -I$(top_srcdir)/src/gallium/winsys \ +diff --git a/src/gallium/winsys/svga/drm/Makefile.am b/src/gallium/winsys/svga/drm/Makefile.am +index 53bbcc2..d7ada3c 100644 +--- a/src/gallium/winsys/svga/drm/Makefile.am ++++ b/src/gallium/winsys/svga/drm/Makefile.am +@@ -31,6 +31,8 @@ AM_CPPFLAGS = \ + $(GALLIUM_CFLAGS) \ + $(LIBDRM_CFLAGS) + ++AM_CFLAGS = $(VISIBILITY_CFLAGS) ++ + #On some systems -std= must be added to CFLAGS to be the last -std= + CFLAGS += -std=gnu99 -D_FILE_OFFSET_BITS=64 + +diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp +index 02d85b8..dee9709 100644 +--- a/src/glsl/glsl_types.cpp ++++ b/src/glsl/glsl_types.cpp +@@ -446,6 +446,8 @@ const glsl_type *glsl_type::get_scalar_type() const + return int_type; + case GLSL_TYPE_FLOAT: + return float_type; ++ case GLSL_TYPE_BOOL: ++ return bool_type; + default: + /* Handle everything else */ + return type; +diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp +index d8cafd5..78ce13e 100644 +--- a/src/glsl/ir_validate.cpp ++++ b/src/glsl/ir_validate.cpp +@@ -695,6 +695,11 @@ check_node_type(ir_instruction *ir, void *data) + void + validate_ir_tree(exec_list *instructions) + { ++ /* We shouldn't have any reason to validate IR in a release build, ++ * and it's half composed of assert()s anyway which wouldn't do ++ * anything. ++ */ ++#ifdef DEBUG + ir_validate v; + + v.run(instructions); +@@ -704,4 +709,5 @@ validate_ir_tree(exec_list *instructions) + + visit_tree(ir, check_node_type, NULL); + } ++#endif + } +diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp +index 57e7a9a..cf0420c 100644 +--- a/src/glsl/linker.cpp ++++ b/src/glsl/linker.cpp +@@ -1067,13 +1067,11 @@ link_intrastage_shaders(void *mem_ctx, + + free(linking_shaders); + +-#ifdef DEBUG + /* At this point linked should contain all of the linked IR, so + * validate it to make sure nothing went wrong. + */ + if (linked) + validate_ir_tree(linked->ir); +-#endif + + /* Make a pass over all variable declarations to ensure that arrays with + * unspecified sizes have a size specified. The size is inferred from the +diff --git a/src/glx/Makefile.am b/src/glx/Makefile.am +index 4aa900a..f01709b 100644 +--- a/src/glx/Makefile.am ++++ b/src/glx/Makefile.am +@@ -39,6 +39,7 @@ AM_CFLAGS = \ + -I$(top_srcdir)/src/mapi/glapi \ + -I$(top_builddir)/src/mapi \ + -I$(top_builddir)/src/mapi/glapi \ ++ $(VISIBILITY_CFLAGS) \ + $(SHARED_GLAPI_CFLAGS) \ + $(EXTRA_DEFINES_XF86VIDMODE) \ + -D_REENTRANT \ +diff --git a/src/mapi/glapi/gen/gl_x86-64_asm.py b/src/mapi/glapi/gen/gl_x86-64_asm.py +index a3548c2..19e0e15 100644 +--- a/src/mapi/glapi/gen/gl_x86-64_asm.py ++++ b/src/mapi/glapi/gen/gl_x86-64_asm.py +@@ -181,19 +181,6 @@ class PrintGenericStubs(gl_XML.gl_print_base): + + def printRealFooter(self): + print '' +- print '#if defined(GLX_USE_TLS) && defined(__linux__)' +- print ' .section ".note.ABI-tag", "a"' +- print ' .p2align 2' +- print ' .long 1f - 0f /* name length */' +- print ' .long 3f - 2f /* data length */' +- print ' .long 1 /* note length */' +- print '0: .asciz "GNU" /* vendor name */' +- print '1: .p2align 2' +- print '2: .long 0 /* note data: the ABI tag */' +- print ' .long 2,4,20 /* Minimum kernel version w/TLS */' +- print '3: .p2align 2 /* pad out section */' +- print '#endif /* GLX_USE_TLS */' +- print '' + print '#if defined (__ELF__) && defined (__linux__)' + print ' .section .note.GNU-stack,"",%progbits' + print '#endif' +diff --git a/src/mapi/glapi/gen/gl_x86_asm.py b/src/mapi/glapi/gen/gl_x86_asm.py +index 8b0f6ee..919bbc0 100644 +--- a/src/mapi/glapi/gen/gl_x86_asm.py ++++ b/src/mapi/glapi/gen/gl_x86_asm.py +@@ -189,19 +189,6 @@ class PrintGenericStubs(gl_XML.gl_print_base): + print '\t\tALIGNTEXT16' + print 'GLNAME(gl_dispatch_functions_end):' + print '' +- print '#if defined(GLX_USE_TLS) && defined(__linux__)' +- print ' .section ".note.ABI-tag", "a"' +- print ' .p2align 2' +- print ' .long 1f - 0f /* name length */' +- print ' .long 3f - 2f /* data length */' +- print ' .long 1 /* note length */' +- print '0: .asciz "GNU" /* vendor name */' +- print '1: .p2align 2' +- print '2: .long 0 /* note data: the ABI tag */' +- print ' .long 2,4,20 /* Minimum kernel version w/TLS */' +- print '3: .p2align 2 /* pad out section */' +- print '#endif /* GLX_USE_TLS */' +- print '' + print '#if defined (__ELF__) && defined (__linux__)' + print ' .section .note.GNU-stack,"",%progbits' + print '#endif' +diff --git a/src/mapi/mapi/entry_x86-64_tls.h b/src/mapi/mapi/entry_x86-64_tls.h +index 72d4125..36cad00 100644 +--- a/src/mapi/mapi/entry_x86-64_tls.h ++++ b/src/mapi/mapi/entry_x86-64_tls.h +@@ -28,19 +28,6 @@ + + #include "u_macros.h" + +-#ifdef __linux__ +-__asm__(".section .note.ABI-tag, \"a\"\n\t" +- ".p2align 2\n\t" +- ".long 1f - 0f\n\t" /* name length */ +- ".long 3f - 2f\n\t" /* data length */ +- ".long 1\n\t" /* note length */ +- "0: .asciz \"GNU\"\n\t" /* vendor name */ +- "1: .p2align 2\n\t" +- "2: .long 0\n\t" /* note data: the ABI tag */ +- ".long 2,4,20\n\t" /* Minimum kernel version w/TLS */ +- "3: .p2align 2\n\t"); /* pad out section */ +-#endif /* __linux__ */ +- + __asm__(".text\n" + ".balign 32\n" + "x86_64_entry_start:"); +diff --git a/src/mapi/mapi/entry_x86_tls.h b/src/mapi/mapi/entry_x86_tls.h +index de91812..58d09ca 100644 +--- a/src/mapi/mapi/entry_x86_tls.h ++++ b/src/mapi/mapi/entry_x86_tls.h +@@ -29,19 +29,6 @@ + #include + #include "u_macros.h" + +-#ifdef __linux__ +-__asm__(".section .note.ABI-tag, \"a\"\n\t" +- ".p2align 2\n\t" +- ".long 1f - 0f\n\t" /* name length */ +- ".long 3f - 2f\n\t" /* data length */ +- ".long 1\n\t" /* note length */ +- "0: .asciz \"GNU\"\n\t" /* vendor name */ +- "1: .p2align 2\n\t" +- "2: .long 0\n\t" /* note data: the ABI tag */ +- ".long 2,4,20\n\t" /* Minimum kernel version w/TLS */ +- "3: .p2align 2\n\t"); /* pad out section */ +-#endif /* __linux__ */ +- + __asm__(".text"); + + __asm__("x86_current_tls:\n\t" +diff --git a/src/mapi/mapi/u_compiler.h b/src/mapi/mapi/u_compiler.h +index 2b019ed..f376e97 100644 +--- a/src/mapi/mapi/u_compiler.h ++++ b/src/mapi/mapi/u_compiler.h +@@ -1,28 +1,10 @@ + #ifndef _U_COMPILER_H_ + #define _U_COMPILER_H_ + +-/* Function inlining */ +-#ifndef inline +-# ifdef __cplusplus +- /* C++ supports inline keyword */ +-# elif defined(__GNUC__) +-# define inline __inline__ +-# elif defined(_MSC_VER) +-# define inline __inline +-# elif defined(__ICL) +-# define inline __inline +-# elif defined(__INTEL_COMPILER) +- /* Intel compiler supports inline keyword */ +-# elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100) +-# define inline __inline +-# elif defined(__SUNPRO_C) && defined(__C99FEATURES__) +- /* C99 supports inline keyword */ +-# elif (__STDC_VERSION__ >= 199901L) +- /* C99 supports inline keyword */ +-# else +-# define inline +-# endif +-#endif ++#include "c99_compat.h" /* inline, __func__, etc. */ ++ ++ ++/* XXX: Use standard `inline` keyword instead */ + #ifndef INLINE + # define INLINE inline + #endif +diff --git a/src/mesa/drivers/dri/i965/brw_clear.c b/src/mesa/drivers/dri/i965/brw_clear.c +index 53d8e54..cde1a06 100644 +--- a/src/mesa/drivers/dri/i965/brw_clear.c ++++ b/src/mesa/drivers/dri/i965/brw_clear.c +@@ -40,6 +40,8 @@ + #include "intel_mipmap_tree.h" + #include "intel_regions.h" + ++#include "brw_context.h" ++ + #define FILE_DEBUG_FLAG DEBUG_BLIT + + static const char *buffer_names[] = { +@@ -219,7 +221,8 @@ brw_fast_clear_depth(struct gl_context *ctx) + static void + brw_clear(struct gl_context *ctx, GLbitfield mask) + { +- struct intel_context *intel = intel_context(ctx); ++ struct brw_context *brw = brw_context(ctx); ++ struct intel_context *intel = &brw->intel; + + if (!_mesa_check_conditional_render(ctx)) + return; +@@ -229,6 +232,7 @@ brw_clear(struct gl_context *ctx, GLbitfield mask) + } + + intel_prepare_render(intel); ++ brw_workaround_depthstencil_alignment(brw); + + if (mask & BUFFER_BIT_DEPTH) { + if (brw_fast_clear_depth(ctx)) { +diff --git a/src/mesa/drivers/dri/i965/brw_defines.h b/src/mesa/drivers/dri/i965/brw_defines.h +index 79cc12f..4bcfb95 100644 +--- a/src/mesa/drivers/dri/i965/brw_defines.h ++++ b/src/mesa/drivers/dri/i965/brw_defines.h +@@ -437,6 +437,7 @@ + #define BRW_SURFACEFORMAT_B10G10R10A2_SSCALED 0x1B9 + #define BRW_SURFACEFORMAT_B10G10R10A2_UINT 0x1BA + #define BRW_SURFACEFORMAT_B10G10R10A2_SINT 0x1BB ++#define BRW_SURFACEFORMAT_RAW 0x1FF + #define BRW_SURFACE_FORMAT_SHIFT 18 + #define BRW_SURFACE_FORMAT_MASK INTEL_MASK(26, 18) + +@@ -857,6 +858,7 @@ enum brw_message_target { + GEN6_SFID_DATAPORT_CONSTANT_CACHE = 9, + + GEN7_SFID_DATAPORT_DATA_CACHE = 10, ++ HSW_SFID_DATAPORT_DATA_CACHE_1 = 12, + }; + + #define GEN7_MESSAGE_TARGET_DP_DATA_CACHE 10 +@@ -965,7 +967,44 @@ enum brw_message_target { + + /* GEN7 */ + #define GEN7_DATAPORT_WRITE_MESSAGE_OWORD_DUAL_BLOCK_WRITE 10 ++#define GEN7_DATAPORT_DC_OWORD_BLOCK_READ 0 ++#define GEN7_DATAPORT_DC_UNALIGNED_OWORD_BLOCK_READ 1 ++#define GEN7_DATAPORT_DC_OWORD_DUAL_BLOCK_READ 2 + #define GEN7_DATAPORT_DC_DWORD_SCATTERED_READ 3 ++#define GEN7_DATAPORT_DC_BYTE_SCATTERED_READ 4 ++#define GEN7_DATAPORT_DC_UNTYPED_SURFACE_READ 5 ++#define GEN7_DATAPORT_DC_UNTYPED_ATOMIC_OP 6 ++#define GEN7_DATAPORT_DC_MEMORY_FENCE 7 ++#define GEN7_DATAPORT_DC_OWORD_BLOCK_WRITE 8 ++#define GEN7_DATAPORT_DC_OWORD_DUAL_BLOCK_WRITE 10 ++#define GEN7_DATAPORT_DC_DWORD_SCATTERED_WRITE 11 ++#define GEN7_DATAPORT_DC_BYTE_SCATTERED_WRITE 12 ++#define GEN7_DATAPORT_DC_UNTYPED_SURFACE_WRITE 13 ++ ++/* HSW */ ++#define HSW_DATAPORT_DC_PORT0_OWORD_BLOCK_READ 0 ++#define HSW_DATAPORT_DC_PORT0_UNALIGNED_OWORD_BLOCK_READ 1 ++#define HSW_DATAPORT_DC_PORT0_OWORD_DUAL_BLOCK_READ 2 ++#define HSW_DATAPORT_DC_PORT0_DWORD_SCATTERED_READ 3 ++#define HSW_DATAPORT_DC_PORT0_BYTE_SCATTERED_READ 4 ++#define HSW_DATAPORT_DC_PORT0_MEMORY_FENCE 7 ++#define HSW_DATAPORT_DC_PORT0_OWORD_BLOCK_WRITE 8 ++#define HSW_DATAPORT_DC_PORT0_OWORD_DUAL_BLOCK_WRITE 10 ++#define HSW_DATAPORT_DC_PORT0_DWORD_SCATTERED_WRITE 11 ++#define HSW_DATAPORT_DC_PORT0_BYTE_SCATTERED_WRITE 12 ++ ++#define HSW_DATAPORT_DC_PORT1_UNTYPED_SURFACE_READ 1 ++#define HSW_DATAPORT_DC_PORT1_UNTYPED_ATOMIC_OP 2 ++#define HSW_DATAPORT_DC_PORT1_UNTYPED_ATOMIC_OP_SIMD4X2 3 ++#define HSW_DATAPORT_DC_PORT1_MEDIA_BLOCK_READ 4 ++#define HSW_DATAPORT_DC_PORT1_TYPED_SURFACE_READ 5 ++#define HSW_DATAPORT_DC_PORT1_TYPED_ATOMIC_OP 6 ++#define HSW_DATAPORT_DC_PORT1_TYPED_ATOMIC_OP_SIMD4X2 7 ++#define HSW_DATAPORT_DC_PORT1_UNTYPED_SURFACE_WRITE 9 ++#define HSW_DATAPORT_DC_PORT1_MEDIA_BLOCK_WRITE 10 ++#define HSW_DATAPORT_DC_PORT1_ATOMIC_COUNTER_OP 11 ++#define HSW_DATAPORT_DC_PORT1_ATOMIC_COUNTER_OP_SIMD4X2 12 ++#define HSW_DATAPORT_DC_PORT1_TYPED_SURFACE_WRITE 13 + + /* dataport atomic operations. */ + #define BRW_AOP_AND 1 +diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c b/src/mesa/drivers/dri/i965/brw_eu_emit.c +index b34754a..40cae37 100644 +--- a/src/mesa/drivers/dri/i965/brw_eu_emit.c ++++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c +@@ -2539,15 +2539,22 @@ void brw_shader_time_add(struct brw_compile *p, + brw_set_src0(p, send, brw_vec1_reg(BRW_MESSAGE_REGISTER_FILE, + base_mrf, 0)); + ++ uint32_t sfid, msg_type; ++ if (intel->is_haswell) { ++ sfid = HSW_SFID_DATAPORT_DATA_CACHE_1; ++ msg_type = HSW_DATAPORT_DC_PORT1_UNTYPED_ATOMIC_OP; ++ } else { ++ sfid = GEN7_SFID_DATAPORT_DATA_CACHE; ++ msg_type = GEN7_DATAPORT_DC_UNTYPED_ATOMIC_OP; ++ } ++ + bool header_present = false; + bool eot = false; + uint32_t mlen = 2; /* offset, value */ + uint32_t rlen = 0; +- brw_set_message_descriptor(p, send, +- GEN7_SFID_DATAPORT_DATA_CACHE, +- mlen, rlen, header_present, eot); ++ brw_set_message_descriptor(p, send, sfid, mlen, rlen, header_present, eot); + +- send->bits3.ud |= 6 << 14; /* untyped atomic op */ ++ send->bits3.ud |= msg_type << 14; + send->bits3.ud |= 0 << 13; /* no return data */ + send->bits3.ud |= 1 << 12; /* SIMD8 mode */ + send->bits3.ud |= BRW_AOP_ADD << 8; +diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp +index f80219e..4924441 100644 +--- a/src/mesa/drivers/dri/i965/brw_fs.cpp ++++ b/src/mesa/drivers/dri/i965/brw_fs.cpp +@@ -2295,7 +2295,8 @@ clear_deps_for_inst_src(fs_inst *inst, int dispatch_width, bool *deps, + void + fs_visitor::insert_gen4_pre_send_dependency_workarounds(fs_inst *inst) + { +- int write_len = inst->regs_written() * dispatch_width / 8; ++ int reg_size = dispatch_width / 8; ++ int write_len = inst->regs_written() * reg_size; + int first_write_grf = inst->dst.reg; + bool needs_dep[BRW_MAX_MRF]; + assert(write_len < (int)sizeof(needs_dep) - 1); +@@ -2334,14 +2335,19 @@ fs_visitor::insert_gen4_pre_send_dependency_workarounds(fs_inst *inst) + * instruction but a MOV that might have left us an outstanding + * dependency has more latency than a MOV. + */ +- if (scan_inst->dst.file == GRF && +- scan_inst->dst.reg >= first_write_grf && +- scan_inst->dst.reg < first_write_grf + write_len && +- needs_dep[scan_inst->dst.reg - first_write_grf]) { +- inst->insert_before(DEP_RESOLVE_MOV(scan_inst->dst.reg)); +- needs_dep[scan_inst->dst.reg - first_write_grf] = false; +- if (scan_inst_16wide) +- needs_dep[scan_inst->dst.reg - first_write_grf + 1] = false; ++ if (scan_inst->dst.file == GRF) { ++ for (int i = 0; i < scan_inst->regs_written(); i++) { ++ int reg = scan_inst->dst.reg + i * reg_size; ++ ++ if (reg >= first_write_grf && ++ reg < first_write_grf + write_len && ++ needs_dep[reg - first_write_grf]) { ++ inst->insert_before(DEP_RESOLVE_MOV(reg)); ++ needs_dep[reg - first_write_grf] = false; ++ if (scan_inst_16wide) ++ needs_dep[reg - first_write_grf + 1] = false; ++ } ++ } + } + + /* Clear the flag for registers that actually got read (as expected). */ +@@ -2494,6 +2500,8 @@ fs_visitor::lower_uniform_pull_constant_loads() + inst->insert_before(setup2); + inst->opcode = FS_OPCODE_UNIFORM_PULL_CONSTANT_LOAD_GEN7; + inst->src[1] = payload; ++ ++ this->live_intervals_valid = false; + } else { + /* Before register allocation, we didn't tell the scheduler about the + * MRF we use. We know it's safe to use this MRF because nothing +diff --git a/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp b/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp +index db8f397..4c7991d 100644 +--- a/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp ++++ b/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp +@@ -190,6 +190,37 @@ fs_visitor::calculate_live_intervals() + int reg = inst->src[i].reg; + + use[reg] = ip; ++ ++ /* In most cases, a register can be written over safely by the ++ * same instruction that is its last use. For a single ++ * instruction, the sources are dereferenced before writing of the ++ * destination starts (naturally). This gets more complicated for ++ * simd16, because the instruction: ++ * ++ * mov(16) g4<1>F g4<8,8,1>F g6<8,8,1>F ++ * ++ * is actually decoded in hardware as: ++ * ++ * mov(8) g4<1>F g4<8,8,1>F g6<8,8,1>F ++ * mov(8) g5<1>F g5<8,8,1>F g7<8,8,1>F ++ * ++ * Which is safe. However, if we have uniform accesses ++ * happening, we get into trouble: ++ * ++ * mov(8) g4<1>F g4<0,1,0>F g6<8,8,1>F ++ * mov(8) g5<1>F g4<0,1,0>F g7<8,8,1>F ++ * ++ * Now our destination for the first instruction overwrote the ++ * second instruction's src0, and we get garbage for those 8 ++ * pixels. There's a similar issue for the pre-gen6 ++ * pixel_x/pixel_y, which are registers of 16-bit values and thus ++ * would get stomped by the first decode as well. ++ */ ++ if (dispatch_width == 16 && (inst->src[i].smear || ++ (this->pixel_x.reg == reg || ++ this->pixel_y.reg == reg))) { ++ use[reg]++; ++ } + } + } + +@@ -264,28 +295,5 @@ fs_visitor::virtual_grf_interferes(int a, int b) + int start = MAX2(a_def, b_def); + int end = MIN2(a_use, b_use); + +- /* If the register is used to store 16 values of less than float +- * size (only the case for pixel_[xy]), then we can't allocate +- * another dword-sized thing to that register that would be used in +- * the same instruction. This is because when the GPU decodes (for +- * example): +- * +- * (declare (in ) vec4 gl_FragCoord@0x97766a0) +- * add(16) g6<1>F g6<8,8,1>UW 0.5F { align1 compr }; +- * +- * it's actually processed as: +- * add(8) g6<1>F g6<8,8,1>UW 0.5F { align1 }; +- * add(8) g7<1>F g6.8<8,8,1>UW 0.5F { align1 sechalf }; +- * +- * so our second half values in g6 got overwritten in the first +- * half. +- */ +- if (dispatch_width == 16 && (this->pixel_x.reg == a || +- this->pixel_x.reg == b || +- this->pixel_y.reg == a || +- this->pixel_y.reg == b)) { +- return start <= end; +- } +- + return start < end; + } +diff --git a/src/mesa/drivers/dri/i965/brw_state.h b/src/mesa/drivers/dri/i965/brw_state.h +index ecc61c4..02ce57b 100644 +--- a/src/mesa/drivers/dri/i965/brw_state.h ++++ b/src/mesa/drivers/dri/i965/brw_state.h +@@ -216,6 +216,8 @@ void gen7_set_surface_mcs_info(struct brw_context *brw, + bool is_render_target); + void gen7_check_surface_setup(uint32_t *surf, bool is_render_target); + void gen7_init_vtable_surface_functions(struct brw_context *brw); ++void gen7_create_shader_time_surface(struct brw_context *brw, ++ uint32_t *out_offset); + + /* brw_wm_sampler_state.c */ + uint32_t translate_wrap_mode(GLenum wrap, bool using_nearest); +diff --git a/src/mesa/drivers/dri/i965/brw_vs_surface_state.c b/src/mesa/drivers/dri/i965/brw_vs_surface_state.c +index 4da7eaa..2aefc0c 100644 +--- a/src/mesa/drivers/dri/i965/brw_vs_surface_state.c ++++ b/src/mesa/drivers/dri/i965/brw_vs_surface_state.c +@@ -137,14 +137,11 @@ const struct brw_tracked_state brw_vs_ubo_surfaces = { + static void + brw_vs_upload_binding_table(struct brw_context *brw) + { +- struct intel_context *intel = &brw->intel; + uint32_t *bind; + int i; + + if (INTEL_DEBUG & DEBUG_SHADER_TIME) { +- intel->vtbl.create_constant_surface(brw, brw->shader_time.bo, 0, +- brw->shader_time.bo->size, +- &brw->vs.surf_offset[SURF_INDEX_VS_SHADER_TIME]); ++ gen7_create_shader_time_surface(brw, &brw->vs.surf_offset[SURF_INDEX_VS_SHADER_TIME]); + + assert(brw->vs.prog_data->num_surfaces <= SURF_INDEX_VS_SHADER_TIME); + brw->vs.prog_data->num_surfaces = SURF_INDEX_VS_SHADER_TIME; +diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c +index 6ec7d71..657a56f 100644 +--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c ++++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c +@@ -770,7 +770,8 @@ brw_get_texture_swizzle(const struct gl_context *ctx, + case GL_RED: + case GL_RG: + case GL_RGB: +- swizzles[3] = SWIZZLE_ONE; ++ if (_mesa_get_format_bits(img->TexFormat, GL_ALPHA_BITS) > 0) ++ swizzles[3] = SWIZZLE_ONE; + break; + } + +@@ -1468,14 +1469,11 @@ const struct brw_tracked_state brw_wm_ubo_surfaces = { + static void + brw_upload_wm_binding_table(struct brw_context *brw) + { +- struct intel_context *intel = &brw->intel; + uint32_t *bind; + int i; + + if (INTEL_DEBUG & DEBUG_SHADER_TIME) { +- intel->vtbl.create_constant_surface(brw, brw->shader_time.bo, 0, +- brw->shader_time.bo->size, +- &brw->wm.surf_offset[SURF_INDEX_WM_SHADER_TIME]); ++ gen7_create_shader_time_surface(brw, &brw->wm.surf_offset[SURF_INDEX_WM_SHADER_TIME]); + } + + /* Might want to calculate nr_surfaces first, to avoid taking up so much +diff --git a/src/mesa/drivers/dri/i965/gen6_cc.c b/src/mesa/drivers/dri/i965/gen6_cc.c +index d32f636..7ac5d5f 100644 +--- a/src/mesa/drivers/dri/i965/gen6_cc.c ++++ b/src/mesa/drivers/dri/i965/gen6_cc.c +@@ -126,7 +126,7 @@ gen6_upload_blend_state(struct brw_context *brw) + * not read the alpha channel, but will instead use the correct + * implicit value for alpha. + */ +- if (!_mesa_base_format_has_channel(rb->_BaseFormat, GL_TEXTURE_ALPHA_TYPE)) ++ if (rb && !_mesa_base_format_has_channel(rb->_BaseFormat, GL_TEXTURE_ALPHA_TYPE)) + { + srcRGB = brw_fix_xRGB_alpha(srcRGB); + srcA = brw_fix_xRGB_alpha(srcA); +diff --git a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c +index 24f1b9c..2913fc6 100644 +--- a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c ++++ b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c +@@ -413,6 +413,46 @@ gen7_create_constant_surface(struct brw_context *brw, + gen7_check_surface_setup(surf, false /* is_render_target */); + } + ++/** ++ * Create a surface for shader time. ++ */ ++void ++gen7_create_shader_time_surface(struct brw_context *brw, uint32_t *out_offset) ++{ ++ struct intel_context *intel = &brw->intel; ++ const int w = brw->shader_time.bo->size - 1; ++ ++ uint32_t *surf = brw_state_batch(brw, AUB_TRACE_SURFACE_STATE, ++ 8 * 4, 32, out_offset); ++ memset(surf, 0, 8 * 4); ++ ++ surf[0] = BRW_SURFACE_BUFFER << BRW_SURFACE_TYPE_SHIFT | ++ BRW_SURFACEFORMAT_RAW << BRW_SURFACE_FORMAT_SHIFT | ++ BRW_SURFACE_RC_READ_WRITE; ++ ++ surf[1] = brw->shader_time.bo->offset; /* reloc */ ++ ++ surf[2] = SET_FIELD(w & 0x7f, GEN7_SURFACE_WIDTH) | ++ SET_FIELD((w >> 7) & 0x1fff, GEN7_SURFACE_HEIGHT); ++ surf[3] = SET_FIELD((w >> 20) & 0x7f, BRW_SURFACE_DEPTH); ++ ++ /* Unlike texture or renderbuffer surfaces, we only do untyped operations ++ * on the shader_time surface, so there's no need to set HSW channel ++ * overrides. ++ */ ++ ++ /* Emit relocation to surface contents. Section 5.1.1 of the gen4 ++ * bspec ("Data Cache") says that the data cache does not exist as ++ * a separate cache and is just the sampler cache. ++ */ ++ drm_intel_bo_emit_reloc(intel->batch.bo, ++ *out_offset + 4, ++ brw->shader_time.bo, 0, ++ I915_GEM_DOMAIN_SAMPLER, 0); ++ ++ gen7_check_surface_setup(surf, false /* is_render_target */); ++} ++ + static void + gen7_update_null_renderbuffer_surface(struct brw_context *brw, unsigned unit) + { +diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c +index 5ec93f1..4173c0f 100644 +--- a/src/mesa/drivers/dri/intel/intel_screen.c ++++ b/src/mesa/drivers/dri/intel/intel_screen.c +@@ -312,7 +312,7 @@ intel_create_image_from_name(__DRIscreen *screen, + cpp = _mesa_get_format_bytes(image->format); + image->region = intel_region_alloc_for_handle(intelScreen, + cpp, width, height, +- pitch, name, "image"); ++ pitch * cpp, name, "image"); + if (image->region == NULL) { + free(image); + return NULL; +diff --git a/src/mesa/drivers/dri/nouveau/nouveau_driver.c b/src/mesa/drivers/dri/nouveau/nouveau_driver.c +index f56b3b2..6c119d5 100644 +--- a/src/mesa/drivers/dri/nouveau/nouveau_driver.c ++++ b/src/mesa/drivers/dri/nouveau/nouveau_driver.c +@@ -69,7 +69,8 @@ nouveau_flush(struct gl_context *ctx) + __DRIdri2LoaderExtension *dri2 = screen->dri2.loader; + __DRIdrawable *drawable = nctx->dri_context->driDrawablePriv; + +- dri2->flushFrontBuffer(drawable, drawable->loaderPrivate); ++ if (drawable && drawable->loaderPrivate) ++ dri2->flushFrontBuffer(drawable, drawable->loaderPrivate); + } + } + +diff --git a/src/mesa/drivers/dri/nouveau/nv10_context.c b/src/mesa/drivers/dri/nouveau/nv10_context.c +index 7eda4e0..4ffc4ef 100644 +--- a/src/mesa/drivers/dri/nouveau/nv10_context.c ++++ b/src/mesa/drivers/dri/nouveau/nv10_context.c +@@ -469,7 +469,7 @@ nv10_context_create(struct nouveau_screen *screen, const struct gl_config *visua + goto fail; + + /* 3D engine. */ +- if (context_chipset(ctx) >= 0x17) ++ if (context_chipset(ctx) >= 0x17 && context_chipset(ctx) != 0x1a) + celsius_class = NV17_3D_CLASS; + else if (context_chipset(ctx) >= 0x11) + celsius_class = NV15_3D_CLASS; +diff --git a/src/mesa/drivers/osmesa/Makefile.am b/src/mesa/drivers/osmesa/Makefile.am +index c4b178b..2503401 100644 +--- a/src/mesa/drivers/osmesa/Makefile.am ++++ b/src/mesa/drivers/osmesa/Makefile.am +@@ -24,6 +24,7 @@ + AM_CPPFLAGS = \ + -I$(top_srcdir)/include \ + -I$(top_srcdir)/src/mapi \ ++ -I$(top_builddir)/src/mapi \ + -I$(top_srcdir)/src/mesa/ \ + $(DEFINES) \ + $(API_DEFINES) +diff --git a/src/mesa/main/compiler.h b/src/mesa/main/compiler.h +index b22b994..8b23665 100644 +--- a/src/mesa/main/compiler.h ++++ b/src/mesa/main/compiler.h +@@ -48,6 +48,8 @@ + #include + #include + ++#include "c99_compat.h" /* inline, __func__, etc. */ ++ + + #ifdef __cplusplus + extern "C" { +@@ -111,30 +113,7 @@ extern "C" { + + + +-/** +- * Function inlining +- */ +-#ifndef inline +-# ifdef __cplusplus +- /* C++ supports inline keyword */ +-# elif defined(__GNUC__) +-# define inline __inline__ +-# elif defined(_MSC_VER) +-# define inline __inline +-# elif defined(__ICL) +-# define inline __inline +-# elif defined(__INTEL_COMPILER) +- /* Intel compiler supports inline keyword */ +-# elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100) +-# define inline __inline +-# elif defined(__SUNPRO_C) && defined(__C99FEATURES__) +- /* C99 supports inline keyword */ +-# elif (__STDC_VERSION__ >= 199901L) +- /* C99 supports inline keyword */ +-# else +-# define inline +-# endif +-#endif ++/* XXX: Use standard `inline` keyword instead */ + #ifndef INLINE + # define INLINE inline + #endif +@@ -177,35 +156,10 @@ extern "C" { + # endif + #endif + +-/** +- * The __FUNCTION__ gcc variable is generally only used for debugging. +- * If we're not using gcc, define __FUNCTION__ as a cpp symbol here. +- * Don't define it if using a newer Windows compiler. +- */ ++/* XXX: Use standard `__func__` instead */ + #ifndef __FUNCTION__ +-# if !defined(__GNUC__) && !defined(__xlC__) && \ +- (!defined(_MSC_VER) || _MSC_VER < 1300) +-# if (__STDC_VERSION__ >= 199901L) /* C99 */ || \ +- (defined(__SUNPRO_C) && defined(__C99FEATURES__)) +-# define __FUNCTION__ __func__ +-# else +-# define __FUNCTION__ "" +-# endif +-# endif ++# define __FUNCTION__ __func__ + #endif +-#ifndef __func__ +-# if (__STDC_VERSION__ >= 199901L) || \ +- (defined(__SUNPRO_C) && defined(__C99FEATURES__)) +- /* __func__ is part of C99 */ +-# elif defined(_MSC_VER) +-# if _MSC_VER >= 1300 +-# define __func__ __FUNCTION__ +-# else +-# define __func__ "" +-# endif +-# endif +-#endif +- + + /** + * Either define MESA_BIG_ENDIAN or MESA_LITTLE_ENDIAN, and CPU_TO_LE32. +@@ -353,8 +307,9 @@ static INLINE GLuint CPU_TO_LE32(GLuint x) + * USE_IEEE: Determine if we're using IEEE floating point + */ + #if defined(__i386__) || defined(__386__) || defined(__sparc__) || \ +- defined(__s390x__) || defined(__powerpc__) || \ ++ defined(__s390__) || defined(__s390x__) || defined(__powerpc__) || \ + defined(__x86_64__) || \ ++ defined(__m68k__) || \ + defined(ia64) || defined(__ia64__) || \ + defined(__hppa__) || defined(hpux) || \ + defined(__mips) || defined(_MIPS_ARCH) || \ +diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c +index 257f839..61c1151 100644 +--- a/src/mesa/main/fbobject.c ++++ b/src/mesa/main/fbobject.c +@@ -3160,7 +3160,9 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, + } + } + +- if (!mask) { ++ if (!mask || ++ (srcX1 - srcX0) == 0 || (srcY1 - srcY0) == 0 || ++ (dstX1 - dstX0) == 0 || (dstY1 - dstY0) == 0) { + return; + } + +diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c +index 5f4e2fa..6fb2f5d 100644 +--- a/src/mesa/main/get.c ++++ b/src/mesa/main/get.c +@@ -34,6 +34,7 @@ + #include "state.h" + #include "texcompress.h" + #include "framebuffer.h" ++#include "samplerobj.h" + + /* This is a table driven implemetation of the glGet*v() functions. + * The basic idea is that most getters just look up an int somewhere +@@ -823,7 +824,16 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu + { + struct gl_sampler_object *samp = + ctx->Texture.Unit[ctx->Texture.CurrentUnit].Sampler; +- v->value_int = samp ? samp->Name : 0; ++ ++ /* ++ * The sampler object may have been deleted on another context, ++ * so we try to lookup the sampler object before returning its Name. ++ */ ++ if (samp && _mesa_lookup_samplerobj(ctx, samp->Name)) { ++ v->value_int = samp->Name; ++ } else { ++ v->value_int = 0; ++ } + } + break; + /* GL_ARB_uniform_buffer_object */ +diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py +index 9aab889..15c1c4d 100644 +--- a/src/mesa/main/get_hash_params.py ++++ b/src/mesa/main/get_hash_params.py +@@ -412,7 +412,7 @@ descriptor=[ + [ "DEPTH_SCALE", "CONTEXT_FLOAT(Pixel.DepthScale), NO_EXTRA" ], + [ "DOUBLEBUFFER", "BUFFER_INT(Visual.doubleBufferMode), NO_EXTRA" ], + [ "DRAW_BUFFER", "BUFFER_ENUM(ColorDrawBuffer[0]), NO_EXTRA" ], +- [ "EDGE_FLAG", "LOC_CUSTOM, TYPE_BOOLEAN, 0, NO_EXTRA" ], ++ [ "EDGE_FLAG", "LOC_CUSTOM, TYPE_BOOLEAN, 0, extra_flush_current" ], + [ "FEEDBACK_BUFFER_SIZE", "CONTEXT_INT(Feedback.BufferSize), NO_EXTRA" ], + [ "FEEDBACK_BUFFER_TYPE", "CONTEXT_ENUM(Feedback.Type), NO_EXTRA" ], + [ "FOG_INDEX", "CONTEXT_FLOAT(Fog.Index), NO_EXTRA" ], +diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h +index 3369623..8f906ae 100644 +--- a/src/mesa/main/mtypes.h ++++ b/src/mesa/main/mtypes.h +@@ -1274,6 +1274,7 @@ struct gl_texture_object + GLfloat Priority; /**< in [0,1] */ + GLint BaseLevel; /**< min mipmap level, OpenGL 1.2 */ + GLint MaxLevel; /**< max mipmap level, OpenGL 1.2 */ ++ GLint ImmutableLevels; /**< ES 3.0 / ARB_texture_view */ + GLint _MaxLevel; /**< actual max mipmap level (q in the spec) */ + GLfloat _MaxLambda; /**< = _MaxLevel - BaseLevel (q - b in spec) */ + GLint CropRect[4]; /**< GL_OES_draw_texture */ +diff --git a/src/mesa/main/samplerobj.c b/src/mesa/main/samplerobj.c +index 319a444..5cff329 100644 +--- a/src/mesa/main/samplerobj.c ++++ b/src/mesa/main/samplerobj.c +@@ -40,7 +40,7 @@ + #include "main/samplerobj.h" + + +-static struct gl_sampler_object * ++struct gl_sampler_object * + _mesa_lookup_samplerobj(struct gl_context *ctx, GLuint name) + { + if (name == 0) +@@ -206,9 +206,19 @@ _mesa_DeleteSamplers(GLsizei count, const GLuint *samplers) + + for (i = 0; i < count; i++) { + if (samplers[i]) { ++ GLuint j; + struct gl_sampler_object *sampObj = + _mesa_lookup_samplerobj(ctx, samplers[i]); ++ + if (sampObj) { ++ /* If the sampler is currently bound, unbind it. */ ++ for (j = 0; j < ctx->Const.MaxCombinedTextureImageUnits; j++) { ++ if (ctx->Texture.Unit[j].Sampler == sampObj) { ++ FLUSH_VERTICES(ctx, _NEW_TEXTURE); ++ _mesa_reference_sampler_object(ctx, &ctx->Texture.Unit[j].Sampler, NULL); ++ } ++ } ++ + /* The ID is immediately freed for re-use */ + _mesa_HashRemove(ctx->Shared->SamplerObjects, samplers[i]); + /* But the object exists until its reference count goes to zero */ +diff --git a/src/mesa/main/samplerobj.h b/src/mesa/main/samplerobj.h +index 3114257..69e3899 100644 +--- a/src/mesa/main/samplerobj.h ++++ b/src/mesa/main/samplerobj.h +@@ -62,6 +62,8 @@ _mesa_reference_sampler_object(struct gl_context *ctx, + _mesa_reference_sampler_object_(ctx, ptr, samp); + } + ++extern struct gl_sampler_object * ++_mesa_lookup_samplerobj(struct gl_context *ctx, GLuint name); + + extern struct gl_sampler_object * + _mesa_new_sampler_object(struct gl_context *ctx, GLuint name); +diff --git a/src/mesa/main/tests/hash_table/Makefile.am b/src/mesa/main/tests/hash_table/Makefile.am +index 272c63a..f63841d 100644 +--- a/src/mesa/main/tests/hash_table/Makefile.am ++++ b/src/mesa/main/tests/hash_table/Makefile.am +@@ -19,6 +19,7 @@ + # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + AM_CPPFLAGS = \ ++ -I$(top_srcdir)/include \ + -I$(top_srcdir)/src/mesa/main \ + $(API_DEFINES) $(DEFINES) $(INCLUDE_DIRS) + +diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c +index 7299a4b..74b09ef 100644 +--- a/src/mesa/main/texgetimage.c ++++ b/src/mesa/main/texgetimage.c +@@ -518,6 +518,7 @@ get_tex_rgba(struct gl_context *ctx, GLuint dimensions, + if (type_needs_clamping(type)) { + /* the returned image type can't have negative values */ + if (dataType == GL_FLOAT || ++ dataType == GL_HALF_FLOAT || + dataType == GL_SIGNED_NORMALIZED || + format == GL_LUMINANCE || + format == GL_LUMINANCE_ALPHA) { +diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c +index 1b9525b..1b91b89 100644 +--- a/src/mesa/main/teximage.c ++++ b/src/mesa/main/teximage.c +@@ -1362,6 +1362,7 @@ _mesa_legal_texture_dimensions(struct gl_context *ctx, GLenum target, + return GL_FALSE; + return GL_TRUE; + ++ case GL_TEXTURE_CUBE_MAP: + case GL_TEXTURE_CUBE_MAP_POSITIVE_X: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: +@@ -3438,19 +3439,21 @@ copyteximage(struct gl_context *ctx, GLuint dims, + _mesa_init_teximage_fields(ctx, texImage, width, height, 1, + border, internalFormat, texFormat); + +- /* Allocate texture memory (no pixel data yet) */ +- ctx->Driver.AllocTextureImageBuffer(ctx, texImage); ++ if (width && height) { ++ /* Allocate texture memory (no pixel data yet) */ ++ ctx->Driver.AllocTextureImageBuffer(ctx, texImage); + +- if (_mesa_clip_copytexsubimage(ctx, &dstX, &dstY, &srcX, &srcY, +- &width, &height)) { +- struct gl_renderbuffer *srcRb = +- get_copy_tex_image_source(ctx, texImage->TexFormat); ++ if (_mesa_clip_copytexsubimage(ctx, &dstX, &dstY, &srcX, &srcY, ++ &width, &height)) { ++ struct gl_renderbuffer *srcRb = ++ get_copy_tex_image_source(ctx, texImage->TexFormat); + +- ctx->Driver.CopyTexSubImage(ctx, dims, texImage, dstX, dstY, dstZ, +- srcRb, srcX, srcY, width, height); +- } ++ ctx->Driver.CopyTexSubImage(ctx, dims, texImage, dstX, dstY, dstZ, ++ srcRb, srcX, srcY, width, height); ++ } + +- check_gen_mipmap(ctx, target, texObj, level); ++ check_gen_mipmap(ctx, target, texObj, level); ++ } + + _mesa_update_fbo_texture(ctx, texObj, face, level); + +diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c +index 6f18ec6..dd67baa 100644 +--- a/src/mesa/main/texparam.c ++++ b/src/mesa/main/texparam.c +@@ -1432,6 +1432,12 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params ) + *params = (GLfloat) obj->Immutable; + break; + ++ case GL_TEXTURE_IMMUTABLE_LEVELS: ++ if (!_mesa_is_gles3(ctx)) ++ goto invalid_pname; ++ *params = (GLfloat) obj->ImmutableLevels; ++ break; ++ + case GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES: + if (!_mesa_is_gles(ctx) || !ctx->Extensions.OES_EGL_image_external) + goto invalid_pname; +@@ -1609,6 +1615,12 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params ) + *params = (GLint) obj->Immutable; + break; + ++ case GL_TEXTURE_IMMUTABLE_LEVELS: ++ if (!_mesa_is_gles3(ctx)) ++ goto invalid_pname; ++ *params = obj->ImmutableLevels; ++ break; ++ + case GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES: + if (!_mesa_is_gles(ctx) || !ctx->Extensions.OES_EGL_image_external) + goto invalid_pname; +diff --git a/src/mesa/main/texstorage.c b/src/mesa/main/texstorage.c +index 00f19ba..675fd74 100644 +--- a/src/mesa/main/texstorage.c ++++ b/src/mesa/main/texstorage.c +@@ -397,6 +397,7 @@ texstorage(GLuint dims, GLenum target, GLsizei levels, GLenum internalformat, + } + + texObj->Immutable = GL_TRUE; ++ texObj->ImmutableLevels = levels; + } + } + +diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c +index efb386e..f5b5c41 100644 +--- a/src/mesa/vbo/vbo_save_draw.c ++++ b/src/mesa/vbo/vbo_save_draw.c +@@ -253,7 +253,7 @@ vbo_save_playback_vertex_list(struct gl_context *ctx, void *data) + struct vbo_save_context *save = &vbo_context(ctx)->save; + GLboolean remap_vertex_store = GL_FALSE; + +- if (save->vertex_store->buffer) { ++ if (save->vertex_store && save->vertex_store->buffer) { + /* The vertex store is currently mapped but we're about to replay + * a display list. This can happen when a nested display list is + * being build with GL_COMPILE_AND_EXECUTE. diff --git a/mesa.spec b/mesa.spec index cdf5126..7d9f01b 100644 --- a/mesa.spec +++ b/mesa.spec @@ -47,8 +47,8 @@ Summary: Mesa graphics libraries Name: mesa -Version: 9.1 -Release: 6%{?dist} +Version: 9.1.1 +Release: 1%{?dist} License: MIT Group: System Environment/Libraries URL: http://www.mesa3d.org @@ -64,7 +64,7 @@ Source3: make-git-snapshot.sh Source4: Mesa-MLAA-License-Clarification-Email.txt # git diff-tree -p mesa-9.1..origin/9.1 > `git describe origin/9.1`.patch -Patch0: mesa-9.1-53-gd0ccb5b.patch +Patch0: mesa-9.1.1-53-g3cff41c.patch Patch1: nv50-fix-build.patch Patch2: intel-revert-gl3.patch @@ -592,6 +592,9 @@ rm -rf $RPM_BUILD_ROOT %endif %changelog +* Sat Apr 27 2013 Dave Airlie 9.1.1-1 +- rebase to Mesa 9.1.1 + fixes from git + * Thu Apr 11 2013 Dave Airlie 9.1-6 - enable glx tls for glamor to work properly diff --git a/sources b/sources index 9dba37c..7ecd241 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -d3891e02215422e120271d976ff1947e MesaLib-9.1.tar.bz2 +6ea2bdc3b7ecfb4257b39814b4182580 MesaLib-9.1.1.tar.bz2