Mesa (master): st/egl: add NATIVE_PARAM_PREMULTIPLIED_ALPHA

2011-09-08 Thread Chia-I Wu
Module: Mesa
Branch: master
Commit: f4c37d6ab256f860a755fe69dfea5fb8df217a2f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f4c37d6ab256f860a755fe69dfea5fb8df217a2f

Author: Chia-I Wu o...@lunarg.com
Date:   Thu Sep  8 01:39:27 2011 +0800

st/egl: add NATIVE_PARAM_PREMULTIPLIED_ALPHA

Return TRUE if the display supports premultiplied alpha.

---

 src/gallium/state_trackers/egl/common/native.h |   11 ++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/src/gallium/state_trackers/egl/common/native.h 
b/src/gallium/state_trackers/egl/common/native.h
index 0c86b75..c85aedf 100644
--- a/src/gallium/state_trackers/egl/common/native.h
+++ b/src/gallium/state_trackers/egl/common/native.h
@@ -70,7 +70,13 @@ enum native_param_type {
/**
 * Return the maximum supported swap interval.
 */
-   NATIVE_PARAM_MAX_SWAP_INTERVAL
+   NATIVE_PARAM_MAX_SWAP_INTERVAL,
+
+   /**
+* Return TRUE if the display supports premultiplied alpha, regardless of
+* the surface color format.
+*/
+   NATIVE_PARAM_PREMULTIPLIED_ALPHA
 };
 
 /**
@@ -85,6 +91,9 @@ struct native_present_control {
 
/** wait until the given vsyncs has passed since the last presentation */
uint swap_interval;
+
+   /** pixels use premultiplied alpha */
+   boolean premultiplied_alpha;
 };
 
 struct native_surface {

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


Mesa (master): st/egl: add native_present_control

2011-09-08 Thread Chia-I Wu
Module: Mesa
Branch: master
Commit: 08e1076fd2d3f6fb879dd2529e7d035d6a399da2
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=08e1076fd2d3f6fb879dd2529e7d035d6a399da2

Author: Chia-I Wu o...@lunarg.com
Date:   Fri Sep  2 21:26:24 2011 +0800

st/egl: add native_present_control

Replace the parameters of native_surface::present by a struct,
native_present_control.  Using a struct allows us to add more control
options without having to update each backend every time.

---

 .../state_trackers/egl/android/native_android.cpp  |   10 --
 .../state_trackers/egl/common/egl_g3d_api.c|   11 +++
 src/gallium/state_trackers/egl/common/egl_g3d_st.c |7 +--
 src/gallium/state_trackers/egl/common/native.h |   18 +++---
 .../state_trackers/egl/common/native_helper.c  |6 +-
 src/gallium/state_trackers/egl/drm/modeset.c   |   10 --
 .../state_trackers/egl/fbdev/native_fbdev.c|   12 +---
 src/gallium/state_trackers/egl/gdi/native_gdi.c|8 +++-
 .../state_trackers/egl/wayland/native_wayland.c|8 +++-
 src/gallium/state_trackers/egl/x11/native_dri2.c   |8 +++-
 src/gallium/state_trackers/egl/x11/native_ximage.c |8 +++-
 11 files changed, 57 insertions(+), 49 deletions(-)

diff --git a/src/gallium/state_trackers/egl/android/native_android.cpp 
b/src/gallium/state_trackers/egl/android/native_android.cpp
index 338427d..5f4638a 100644
--- a/src/gallium/state_trackers/egl/android/native_android.cpp
+++ b/src/gallium/state_trackers/egl/android/native_android.cpp
@@ -386,24 +386,22 @@ copy_resources(struct native_display *ndpy,
 
 static boolean
 android_surface_present(struct native_surface *nsurf,
-enum native_attachment natt,
-boolean preserve,
-uint swap_interval)
+const native_present_control *ctrl)
 {
struct android_surface *asurf = android_surface(nsurf);
struct android_display *adpy = asurf-adpy;
boolean ret;
 
-   if (swap_interval || natt != NATIVE_ATTACHMENT_BACK_LEFT)
+   if (ctrl-swap_interval || ctrl-natt != NATIVE_ATTACHMENT_BACK_LEFT)
   return FALSE;
 
/* we always render to color_res first when it exists */
if (asurf-color_res) {
   copy_resources(adpy-base, asurf-color_res, asurf-buf_res);
-  if (!preserve)
+  if (!ctrl-preserve)
  pipe_resource_reference(asurf-color_res, NULL);
}
-   else if (preserve) {
+   else if (ctrl-preserve) {
   struct pipe_resource templ;
 
   memset(templ, 0, sizeof(templ));
diff --git a/src/gallium/state_trackers/egl/common/egl_g3d_api.c 
b/src/gallium/state_trackers/egl/common/egl_g3d_api.c
index f897054..27bc8be 100644
--- a/src/gallium/state_trackers/egl/common/egl_g3d_api.c
+++ b/src/gallium/state_trackers/egl/common/egl_g3d_api.c
@@ -551,6 +551,7 @@ egl_g3d_swap_buffers(_EGLDriver *drv, _EGLDisplay *dpy, 
_EGLSurface *surf)
struct egl_g3d_surface *gsurf = egl_g3d_surface(surf);
_EGLContext *ctx = _eglGetCurrentContext();
struct egl_g3d_context *gctx = NULL;
+   struct native_present_control ctrl;
 
/* no-op for pixmap or pbuffer surface */
if (gsurf-base.Type == EGL_PIXMAP_BIT ||
@@ -569,10 +570,12 @@ egl_g3d_swap_buffers(_EGLDriver *drv, _EGLDisplay *dpy, 
_EGLSurface *surf)
   gctx-stctxi-flush(gctx-stctxi, ST_FLUSH_FRONT, NULL);
}
 
-   return gsurf-native-present(gsurf-native,
- NATIVE_ATTACHMENT_BACK_LEFT,
- gsurf-base.SwapBehavior == EGL_BUFFER_PRESERVED,
- gsurf-base.SwapInterval);
+   memset(ctrl, 0, sizeof(ctrl));
+   ctrl.natt = NATIVE_ATTACHMENT_BACK_LEFT;
+   ctrl.preserve = (gsurf-base.SwapBehavior == EGL_BUFFER_PRESERVED);
+   ctrl.swap_interval = gsurf-base.SwapInterval;
+
+   return gsurf-native-present(gsurf-native, ctrl);
 }
 
 static EGLBoolean
diff --git a/src/gallium/state_trackers/egl/common/egl_g3d_st.c 
b/src/gallium/state_trackers/egl/common/egl_g3d_st.c
index b839f84..50ed669 100644
--- a/src/gallium/state_trackers/egl/common/egl_g3d_st.c
+++ b/src/gallium/state_trackers/egl/common/egl_g3d_st.c
@@ -192,9 +192,12 @@ egl_g3d_st_framebuffer_flush_front(struct 
st_framebuffer_iface *stfbi,
 {
_EGLSurface *surf = (_EGLSurface *) stfbi-st_manager_private;
struct egl_g3d_surface *gsurf = egl_g3d_surface(surf);
+   struct native_present_control ctrl;
 
-   return gsurf-native-present(gsurf-native,
- NATIVE_ATTACHMENT_FRONT_LEFT, FALSE, 0);
+   memset(ctrl, 0, sizeof(ctrl));
+   ctrl.natt = NATIVE_ATTACHMENT_FRONT_LEFT;
+
+   return gsurf-native-present(gsurf-native, ctrl);
 }
 
 static boolean 
diff --git a/src/gallium/state_trackers/egl/common/native.h 
b/src/gallium/state_trackers/egl/common/native.h
index 58593a4..0c86b75 100644
--- a/src/gallium/state_trackers/egl/common/native.h
+++ b/src/gallium/state_trackers/egl/common/native.h
@@ -73,6 +73,20 @@ enum native_param_type {
NATIVE_PARAM_MAX_SWAP_INTERVAL
 

Mesa (master): st/egl: correctly return configs under wayland

2011-09-08 Thread Chia-I Wu
Module: Mesa
Branch: master
Commit: 95b445699d7f049116ee0927387a958a9933766b
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=95b445699d7f049116ee0927387a958a9933766b

Author: Chia-I Wu o...@lunarg.com
Date:   Thu Sep  8 02:29:55 2011 +0800

st/egl: correctly return configs under wayland

When wl_drm is avaiable and enabled, handle format events and return
configs for the supported formats.  Otherwise, assume all formats of
wl_shm are supported.

---

 .../state_trackers/egl/wayland/native_drm.c|   70 +++-
 .../state_trackers/egl/wayland/native_shm.c|   41 +++-
 .../state_trackers/egl/wayland/native_wayland.c|   28 +---
 .../state_trackers/egl/wayland/native_wayland.h|4 +-
 4 files changed, 113 insertions(+), 30 deletions(-)

diff --git a/src/gallium/state_trackers/egl/wayland/native_drm.c 
b/src/gallium/state_trackers/egl/wayland/native_drm.c
index 05c32f4..facab32 100644
--- a/src/gallium/state_trackers/egl/wayland/native_drm.c
+++ b/src/gallium/state_trackers/egl/wayland/native_drm.c
@@ -58,6 +58,11 @@ struct wayland_drm_display {
int fd;
char *device_name;
boolean authenticated;
+
+   /* supported formats */
+   boolean argb32;
+   boolean argb32_pre;
+   boolean xrgb32;
 };
 
 static INLINE struct wayland_drm_display *
@@ -77,8 +82,8 @@ wayland_drm_display_destroy(struct native_display *ndpy)
   wl_drm_destroy(drmdpy-wl_drm);
if (drmdpy-device_name)
   FREE(drmdpy-device_name);
-   if (drmdpy-base.config)
-  FREE(drmdpy-base.config);
+   if (drmdpy-base.configs)
+  FREE(drmdpy-base.configs);
if (drmdpy-base.own_dpy)
   wl_display_destroy(drmdpy-base.dpy);
 
@@ -124,6 +129,50 @@ wayland_create_drm_buffer(struct wayland_display *display,
width, height, wsh.stride, format);
 }
 
+static boolean
+wayland_drm_display_add_configs(struct wayland_drm_display *drmdpy)
+{
+   struct wayland_config *configs;
+   enum pipe_format formats[2];
+   int i, num_formats = 0;
+
+   /*
+* Only argb32 counts here.  If we make (!argbb32  argb32_pre) count, we
+* will not be able to support the case where
+* native_present_control::premultiplied_alpha is FALSE.
+*/
+   if (drmdpy-argb32)
+  formats[num_formats++] = PIPE_FORMAT_B8G8R8A8_UNORM;
+
+   if (drmdpy-xrgb32)
+  formats[num_formats++] = PIPE_FORMAT_B8G8R8X8_UNORM;
+
+   if (!num_formats)
+  return FALSE;
+
+   configs = CALLOC(num_formats, sizeof(*configs));
+   if (!configs)
+  return FALSE;
+
+   for (i = 0; i  num_formats; i++) {
+  struct native_config *nconf = configs[i].base;
+
+  nconf-buffer_mask =
+ (1  NATIVE_ATTACHMENT_FRONT_LEFT) |
+ (1  NATIVE_ATTACHMENT_BACK_LEFT);
+
+  nconf-color_format = formats[i];
+
+  nconf-window_bit = TRUE;
+  nconf-pixmap_bit = TRUE;
+   }
+
+   drmdpy-base.configs = configs;
+   drmdpy-base.num_configs = num_formats;
+
+   return TRUE;
+}
+
 static void
 drm_handle_device(void *data, struct wl_drm *drm, const char *device)
 {
@@ -148,7 +197,19 @@ drm_handle_device(void *data, struct wl_drm *drm, const 
char *device)
 static void
 drm_handle_format(void *data, struct wl_drm *drm, uint32_t format)
 {
-   /* TODO */
+   struct wayland_drm_display *drmdpy = data;
+
+   switch (format) {
+   case WL_DRM_FORMAT_ARGB32:
+  drmdpy-argb32 = TRUE;
+  break;
+   case WL_DRM_FORMAT_PREMULTIPLIED_ARGB32:
+  drmdpy-argb32_pre = TRUE;
+  break;
+   case WL_DRM_FORMAT_XRGB32:
+  drmdpy-xrgb32 = TRUE;
+  break;
+   }
 }
 
 static void
@@ -191,6 +252,9 @@ wayland_drm_display_init_screen(struct native_display *ndpy)
if (!drmdpy-authenticated)
   return FALSE;
 
+   if (!wayland_drm_display_add_configs(drmdpy))
+  return FALSE;
+
drmdpy-base.base.screen =
   drmdpy-event_handler-new_drm_screen(drmdpy-base.base,
 NULL, drmdpy-fd);
diff --git a/src/gallium/state_trackers/egl/wayland/native_shm.c 
b/src/gallium/state_trackers/egl/wayland/native_shm.c
index 598df9f..5882e74 100644
--- a/src/gallium/state_trackers/egl/wayland/native_shm.c
+++ b/src/gallium/state_trackers/egl/wayland/native_shm.c
@@ -63,8 +63,8 @@ wayland_shm_display_destroy(struct native_display *ndpy)
 {
struct wayland_shm_display *shmdpy = wayland_shm_display(ndpy);
 
-   if (shmdpy-base.config)
-  FREE(shmdpy-base.config);
+   if (shmdpy-base.configs)
+  FREE(shmdpy-base.configs);
if (shmdpy-base.own_dpy)
   wl_display_destroy(shmdpy-base.dpy);
 
@@ -111,6 +111,40 @@ wayland_create_shm_buffer(struct wayland_display *display,
 }
 
 static boolean
+wayland_shm_display_add_configs(struct wayland_shm_display *shmdpy)
+{
+   struct wayland_config *configs;
+   enum pipe_format formats[2];
+   int i, num_formats = 0;
+
+   /* assume all formats are supported */
+   formats[num_formats++] = PIPE_FORMAT_B8G8R8A8_UNORM;
+   formats[num_formats++] = PIPE_FORMAT_B8G8R8X8_UNORM;
+
+   

Mesa (master): st/egl: add premultiplied alpha support to wayland

2011-09-08 Thread Chia-I Wu
Module: Mesa
Branch: master
Commit: 23aa978a9d76a48f4b93e9a8911ec50c0e5d94ab
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=23aa978a9d76a48f4b93e9a8911ec50c0e5d94ab

Author: Chia-I Wu o...@lunarg.com
Date:   Thu Sep  8 03:00:31 2011 +0800

st/egl: add premultiplied alpha support to wayland

Return true for NATIVE_PARAM_PREMULTIPLIED_ALPHA when all formats with
alpha support premultiplied alpha.  Currently, it means when argb32 and
argb32_pre are both supported.

---

 .../state_trackers/egl/wayland/native_drm.c|8 ++--
 .../state_trackers/egl/wayland/native_shm.c|6 +-
 .../state_trackers/egl/wayland/native_wayland.c|   18 ++
 .../state_trackers/egl/wayland/native_wayland.h|3 +++
 4 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/src/gallium/state_trackers/egl/wayland/native_drm.c 
b/src/gallium/state_trackers/egl/wayland/native_drm.c
index facab32..e177e7c 100644
--- a/src/gallium/state_trackers/egl/wayland/native_drm.c
+++ b/src/gallium/state_trackers/egl/wayland/native_drm.c
@@ -114,8 +114,8 @@ wayland_create_drm_buffer(struct wayland_display *display,
 
switch (surface-color_format) {
case PIPE_FORMAT_B8G8R8A8_UNORM:
-  /* assume premultiplied */
-  format = WL_DRM_FORMAT_PREMULTIPLIED_ARGB32;
+  format = (surface-premultiplied_alpha) ?
+ WL_DRM_FORMAT_PREMULTIPLIED_ARGB32 : WL_DRM_FORMAT_ARGB32;
   break;
case PIPE_FORMAT_B8G8R8X8_UNORM:
   format = WL_DRM_FORMAT_XRGB32;
@@ -255,6 +255,10 @@ wayland_drm_display_init_screen(struct native_display 
*ndpy)
if (!wayland_drm_display_add_configs(drmdpy))
   return FALSE;
 
+   /* check that premultiplied alpha is supported for all formats with alpha */
+   if (!drmdpy-argb32 || drmdpy-argb32_pre)
+  drmdpy-base.param_premultiplied_alpha = TRUE;
+
drmdpy-base.base.screen =
   drmdpy-event_handler-new_drm_screen(drmdpy-base.base,
 NULL, drmdpy-fd);
diff --git a/src/gallium/state_trackers/egl/wayland/native_shm.c 
b/src/gallium/state_trackers/egl/wayland/native_shm.c
index 5882e74..e2d2437 100644
--- a/src/gallium/state_trackers/egl/wayland/native_shm.c
+++ b/src/gallium/state_trackers/egl/wayland/native_shm.c
@@ -95,7 +95,8 @@ wayland_create_shm_buffer(struct wayland_display *display,
 
switch (surface-color_format) {
case PIPE_FORMAT_B8G8R8A8_UNORM:
-  format = WL_SHM_FORMAT_PREMULTIPLIED_ARGB32;
+  format = (surface-premultiplied_alpha) ?
+ WL_SHM_FORMAT_PREMULTIPLIED_ARGB32 : WL_SHM_FORMAT_ARGB32;
   break;
case PIPE_FORMAT_B8G8R8X8_UNORM:
   format = WL_SHM_FORMAT_XRGB32;
@@ -165,6 +166,9 @@ wayland_shm_display_init_screen(struct native_display *ndpy)
if (!wayland_shm_display_add_configs(shmdpy))
   return FALSE;
 
+   /* assume all formats are supported */
+   shmdpy-base.param_premultiplied_alpha = TRUE;
+
winsys = wayland_create_sw_winsys(shmdpy-base.dpy);
if (!winsys)
   return FALSE;
diff --git a/src/gallium/state_trackers/egl/wayland/native_wayland.c 
b/src/gallium/state_trackers/egl/wayland/native_wayland.c
index 14cc908..b2dab8f 100644
--- a/src/gallium/state_trackers/egl/wayland/native_wayland.c
+++ b/src/gallium/state_trackers/egl/wayland/native_wayland.c
@@ -60,9 +60,13 @@ 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) {
+   case NATIVE_PARAM_PREMULTIPLIED_ALPHA:
+  val = display-param_premultiplied_alpha;
+  break;
case NATIVE_PARAM_USE_NATIVE_BUFFER:
case NATIVE_PARAM_PRESERVE_BUFFER:
case NATIVE_PARAM_MAX_SWAP_INTERVAL:
@@ -283,6 +287,20 @@ wayland_surface_present(struct native_surface *nsurf,
if (ctrl-preserve || ctrl-swap_interval)
   return FALSE;
 
+   /* force buffers to be re-created if they will be presented differently */
+   if (surface-premultiplied_alpha != ctrl-premultiplied_alpha) {
+  enum wayland_buffer_type buffer;
+
+  for (buffer = 0; buffer  WL_BUFFER_COUNT; ++buffer) {
+ if (surface-buffer[buffer]) {
+wl_buffer_destroy(surface-buffer[buffer]);
+surface-buffer[buffer] = NULL;
+ }
+  }
+
+  surface-premultiplied_alpha = ctrl-premultiplied_alpha;
+   }
+
switch (ctrl-natt) {
case NATIVE_ATTACHMENT_FRONT_LEFT:
   ret = TRUE;
diff --git a/src/gallium/state_trackers/egl/wayland/native_wayland.h 
b/src/gallium/state_trackers/egl/wayland/native_wayland.h
index 93e670b..6cf98a8 100644
--- a/src/gallium/state_trackers/egl/wayland/native_wayland.h
+++ b/src/gallium/state_trackers/egl/wayland/native_wayland.h
@@ -44,6 +44,8 @@ struct wayland_display {
 
struct wayland_config *configs;
int num_configs;
+   /* true if all formats with alpha support premultiplied alpha */
+   boolean param_premultiplied_alpha;
 
struct 

Mesa (master): Revert st/egl: add premultiplied alpha support to wayland

2011-09-08 Thread Chia-I Wu
Module: Mesa
Branch: master
Commit: 93a96abe16068fa3ca8a1eb8d1c34195bffdc470
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=93a96abe16068fa3ca8a1eb8d1c34195bffdc470

Author: Chia-I Wu o...@lunarg.com
Date:   Thu Sep  8 16:05:22 2011 +0800

Revert st/egl: add premultiplied alpha support to wayland

This reverts commit 23aa978a9d76a48f4b93e9a8911ec50c0e5d94ab.

---

 .../state_trackers/egl/wayland/native_drm.c|8 ++--
 .../state_trackers/egl/wayland/native_shm.c|6 +-
 .../state_trackers/egl/wayland/native_wayland.c|   18 --
 .../state_trackers/egl/wayland/native_wayland.h|3 ---
 4 files changed, 3 insertions(+), 32 deletions(-)

diff --git a/src/gallium/state_trackers/egl/wayland/native_drm.c 
b/src/gallium/state_trackers/egl/wayland/native_drm.c
index e177e7c..facab32 100644
--- a/src/gallium/state_trackers/egl/wayland/native_drm.c
+++ b/src/gallium/state_trackers/egl/wayland/native_drm.c
@@ -114,8 +114,8 @@ wayland_create_drm_buffer(struct wayland_display *display,
 
switch (surface-color_format) {
case PIPE_FORMAT_B8G8R8A8_UNORM:
-  format = (surface-premultiplied_alpha) ?
- WL_DRM_FORMAT_PREMULTIPLIED_ARGB32 : WL_DRM_FORMAT_ARGB32;
+  /* assume premultiplied */
+  format = WL_DRM_FORMAT_PREMULTIPLIED_ARGB32;
   break;
case PIPE_FORMAT_B8G8R8X8_UNORM:
   format = WL_DRM_FORMAT_XRGB32;
@@ -255,10 +255,6 @@ wayland_drm_display_init_screen(struct native_display 
*ndpy)
if (!wayland_drm_display_add_configs(drmdpy))
   return FALSE;
 
-   /* check that premultiplied alpha is supported for all formats with alpha */
-   if (!drmdpy-argb32 || drmdpy-argb32_pre)
-  drmdpy-base.param_premultiplied_alpha = TRUE;
-
drmdpy-base.base.screen =
   drmdpy-event_handler-new_drm_screen(drmdpy-base.base,
 NULL, drmdpy-fd);
diff --git a/src/gallium/state_trackers/egl/wayland/native_shm.c 
b/src/gallium/state_trackers/egl/wayland/native_shm.c
index e2d2437..5882e74 100644
--- a/src/gallium/state_trackers/egl/wayland/native_shm.c
+++ b/src/gallium/state_trackers/egl/wayland/native_shm.c
@@ -95,8 +95,7 @@ wayland_create_shm_buffer(struct wayland_display *display,
 
switch (surface-color_format) {
case PIPE_FORMAT_B8G8R8A8_UNORM:
-  format = (surface-premultiplied_alpha) ?
- WL_SHM_FORMAT_PREMULTIPLIED_ARGB32 : WL_SHM_FORMAT_ARGB32;
+  format = WL_SHM_FORMAT_PREMULTIPLIED_ARGB32;
   break;
case PIPE_FORMAT_B8G8R8X8_UNORM:
   format = WL_SHM_FORMAT_XRGB32;
@@ -166,9 +165,6 @@ wayland_shm_display_init_screen(struct native_display *ndpy)
if (!wayland_shm_display_add_configs(shmdpy))
   return FALSE;
 
-   /* assume all formats are supported */
-   shmdpy-base.param_premultiplied_alpha = TRUE;
-
winsys = wayland_create_sw_winsys(shmdpy-base.dpy);
if (!winsys)
   return FALSE;
diff --git a/src/gallium/state_trackers/egl/wayland/native_wayland.c 
b/src/gallium/state_trackers/egl/wayland/native_wayland.c
index b2dab8f..14cc908 100644
--- a/src/gallium/state_trackers/egl/wayland/native_wayland.c
+++ b/src/gallium/state_trackers/egl/wayland/native_wayland.c
@@ -60,13 +60,9 @@ 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) {
-   case NATIVE_PARAM_PREMULTIPLIED_ALPHA:
-  val = display-param_premultiplied_alpha;
-  break;
case NATIVE_PARAM_USE_NATIVE_BUFFER:
case NATIVE_PARAM_PRESERVE_BUFFER:
case NATIVE_PARAM_MAX_SWAP_INTERVAL:
@@ -287,20 +283,6 @@ wayland_surface_present(struct native_surface *nsurf,
if (ctrl-preserve || ctrl-swap_interval)
   return FALSE;
 
-   /* force buffers to be re-created if they will be presented differently */
-   if (surface-premultiplied_alpha != ctrl-premultiplied_alpha) {
-  enum wayland_buffer_type buffer;
-
-  for (buffer = 0; buffer  WL_BUFFER_COUNT; ++buffer) {
- if (surface-buffer[buffer]) {
-wl_buffer_destroy(surface-buffer[buffer]);
-surface-buffer[buffer] = NULL;
- }
-  }
-
-  surface-premultiplied_alpha = ctrl-premultiplied_alpha;
-   }
-
switch (ctrl-natt) {
case NATIVE_ATTACHMENT_FRONT_LEFT:
   ret = TRUE;
diff --git a/src/gallium/state_trackers/egl/wayland/native_wayland.h 
b/src/gallium/state_trackers/egl/wayland/native_wayland.h
index 6cf98a8..93e670b 100644
--- a/src/gallium/state_trackers/egl/wayland/native_wayland.h
+++ b/src/gallium/state_trackers/egl/wayland/native_wayland.h
@@ -44,8 +44,6 @@ struct wayland_display {
 
struct wayland_config *configs;
int num_configs;
-   /* true if all formats with alpha support premultiplied alpha */
-   boolean param_premultiplied_alpha;
 
struct wl_buffer *(*create_buffer)(struct wayland_display *display,
   struct 

Mesa (master): Revert st/egl: correctly return configs under wayland

2011-09-08 Thread Chia-I Wu
Module: Mesa
Branch: master
Commit: ee0e6ae2bb25bfa02547ef9986bdff8afc792d49
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ee0e6ae2bb25bfa02547ef9986bdff8afc792d49

Author: Chia-I Wu o...@lunarg.com
Date:   Thu Sep  8 16:05:32 2011 +0800

Revert st/egl: correctly return configs under wayland

This reverts commit 95b445699d7f049116ee0927387a958a9933766b.

---

 .../state_trackers/egl/wayland/native_drm.c|   70 +---
 .../state_trackers/egl/wayland/native_shm.c|   41 +---
 .../state_trackers/egl/wayland/native_wayland.c|   28 +++-
 .../state_trackers/egl/wayland/native_wayland.h|4 +-
 4 files changed, 30 insertions(+), 113 deletions(-)

diff --git a/src/gallium/state_trackers/egl/wayland/native_drm.c 
b/src/gallium/state_trackers/egl/wayland/native_drm.c
index facab32..05c32f4 100644
--- a/src/gallium/state_trackers/egl/wayland/native_drm.c
+++ b/src/gallium/state_trackers/egl/wayland/native_drm.c
@@ -58,11 +58,6 @@ struct wayland_drm_display {
int fd;
char *device_name;
boolean authenticated;
-
-   /* supported formats */
-   boolean argb32;
-   boolean argb32_pre;
-   boolean xrgb32;
 };
 
 static INLINE struct wayland_drm_display *
@@ -82,8 +77,8 @@ wayland_drm_display_destroy(struct native_display *ndpy)
   wl_drm_destroy(drmdpy-wl_drm);
if (drmdpy-device_name)
   FREE(drmdpy-device_name);
-   if (drmdpy-base.configs)
-  FREE(drmdpy-base.configs);
+   if (drmdpy-base.config)
+  FREE(drmdpy-base.config);
if (drmdpy-base.own_dpy)
   wl_display_destroy(drmdpy-base.dpy);
 
@@ -129,50 +124,6 @@ wayland_create_drm_buffer(struct wayland_display *display,
width, height, wsh.stride, format);
 }
 
-static boolean
-wayland_drm_display_add_configs(struct wayland_drm_display *drmdpy)
-{
-   struct wayland_config *configs;
-   enum pipe_format formats[2];
-   int i, num_formats = 0;
-
-   /*
-* Only argb32 counts here.  If we make (!argbb32  argb32_pre) count, we
-* will not be able to support the case where
-* native_present_control::premultiplied_alpha is FALSE.
-*/
-   if (drmdpy-argb32)
-  formats[num_formats++] = PIPE_FORMAT_B8G8R8A8_UNORM;
-
-   if (drmdpy-xrgb32)
-  formats[num_formats++] = PIPE_FORMAT_B8G8R8X8_UNORM;
-
-   if (!num_formats)
-  return FALSE;
-
-   configs = CALLOC(num_formats, sizeof(*configs));
-   if (!configs)
-  return FALSE;
-
-   for (i = 0; i  num_formats; i++) {
-  struct native_config *nconf = configs[i].base;
-
-  nconf-buffer_mask =
- (1  NATIVE_ATTACHMENT_FRONT_LEFT) |
- (1  NATIVE_ATTACHMENT_BACK_LEFT);
-
-  nconf-color_format = formats[i];
-
-  nconf-window_bit = TRUE;
-  nconf-pixmap_bit = TRUE;
-   }
-
-   drmdpy-base.configs = configs;
-   drmdpy-base.num_configs = num_formats;
-
-   return TRUE;
-}
-
 static void
 drm_handle_device(void *data, struct wl_drm *drm, const char *device)
 {
@@ -197,19 +148,7 @@ drm_handle_device(void *data, struct wl_drm *drm, const 
char *device)
 static void
 drm_handle_format(void *data, struct wl_drm *drm, uint32_t format)
 {
-   struct wayland_drm_display *drmdpy = data;
-
-   switch (format) {
-   case WL_DRM_FORMAT_ARGB32:
-  drmdpy-argb32 = TRUE;
-  break;
-   case WL_DRM_FORMAT_PREMULTIPLIED_ARGB32:
-  drmdpy-argb32_pre = TRUE;
-  break;
-   case WL_DRM_FORMAT_XRGB32:
-  drmdpy-xrgb32 = TRUE;
-  break;
-   }
+   /* TODO */
 }
 
 static void
@@ -252,9 +191,6 @@ wayland_drm_display_init_screen(struct native_display *ndpy)
if (!drmdpy-authenticated)
   return FALSE;
 
-   if (!wayland_drm_display_add_configs(drmdpy))
-  return FALSE;
-
drmdpy-base.base.screen =
   drmdpy-event_handler-new_drm_screen(drmdpy-base.base,
 NULL, drmdpy-fd);
diff --git a/src/gallium/state_trackers/egl/wayland/native_shm.c 
b/src/gallium/state_trackers/egl/wayland/native_shm.c
index 5882e74..598df9f 100644
--- a/src/gallium/state_trackers/egl/wayland/native_shm.c
+++ b/src/gallium/state_trackers/egl/wayland/native_shm.c
@@ -63,8 +63,8 @@ wayland_shm_display_destroy(struct native_display *ndpy)
 {
struct wayland_shm_display *shmdpy = wayland_shm_display(ndpy);
 
-   if (shmdpy-base.configs)
-  FREE(shmdpy-base.configs);
+   if (shmdpy-base.config)
+  FREE(shmdpy-base.config);
if (shmdpy-base.own_dpy)
   wl_display_destroy(shmdpy-base.dpy);
 
@@ -111,40 +111,6 @@ wayland_create_shm_buffer(struct wayland_display *display,
 }
 
 static boolean
-wayland_shm_display_add_configs(struct wayland_shm_display *shmdpy)
-{
-   struct wayland_config *configs;
-   enum pipe_format formats[2];
-   int i, num_formats = 0;
-
-   /* assume all formats are supported */
-   formats[num_formats++] = PIPE_FORMAT_B8G8R8A8_UNORM;
-   formats[num_formats++] = PIPE_FORMAT_B8G8R8X8_UNORM;
-
-   configs = CALLOC(num_formats, sizeof(*configs));
-   if (!configs)
-  return FALSE;
-

Mesa (master): st/egl: correctly return configs under wayland

2011-09-08 Thread Chia-I Wu
Module: Mesa
Branch: master
Commit: 1191d203632e2954ce59163f87c9896b1c6ed40a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=1191d203632e2954ce59163f87c9896b1c6ed40a

Author: Benjamin Franzke benjaminfran...@googlemail.com
Date:   Thu Sep  8 08:03:34 2011 +0200

st/egl: correctly return configs under wayland

Handle format events and return configs for the supported formats.

(Based on Chia-I Wu's patch)

[olv: update and explain why PIPE_FORMAT_B8G8R8A8_UNORM should not be
  enabled without HAS_ARGB32]

---

 .../state_trackers/egl/wayland/native_drm.c|   25 +--
 .../state_trackers/egl/wayland/native_shm.c|   37 ++--
 .../state_trackers/egl/wayland/native_wayland.c|   47 ++--
 .../state_trackers/egl/wayland/native_wayland.h|   12 +-
 4 files changed, 98 insertions(+), 23 deletions(-)

diff --git a/src/gallium/state_trackers/egl/wayland/native_drm.c 
b/src/gallium/state_trackers/egl/wayland/native_drm.c
index 05c32f4..9f6757b 100644
--- a/src/gallium/state_trackers/egl/wayland/native_drm.c
+++ b/src/gallium/state_trackers/egl/wayland/native_drm.c
@@ -77,8 +77,8 @@ wayland_drm_display_destroy(struct native_display *ndpy)
   wl_drm_destroy(drmdpy-wl_drm);
if (drmdpy-device_name)
   FREE(drmdpy-device_name);
-   if (drmdpy-base.config)
-  FREE(drmdpy-base.config);
+   if (drmdpy-base.configs)
+  FREE(drmdpy-base.configs);
if (drmdpy-base.own_dpy)
   wl_display_destroy(drmdpy-base.dpy);
 
@@ -97,7 +97,7 @@ wayland_create_drm_buffer(struct wayland_display *display,
struct pipe_resource *resource;
struct winsys_handle wsh;
uint width, height;
-   uint32_t format;
+   enum wl_drm_format format;
 
resource = resource_surface_get_single_resource(surface-rsurf, attachment);
resource_surface_get_size(surface-rsurf, width, height);
@@ -148,7 +148,19 @@ drm_handle_device(void *data, struct wl_drm *drm, const 
char *device)
 static void
 drm_handle_format(void *data, struct wl_drm *drm, uint32_t format)
 {
-   /* TODO */
+   struct wayland_drm_display *drmdpy = data;
+
+   switch (format) {
+   case WL_DRM_FORMAT_ARGB32:
+  drmdpy-base.formats |= HAS_ARGB32;
+  break;
+   case WL_DRM_FORMAT_PREMULTIPLIED_ARGB32:
+  drmdpy-base.formats |= HAS_PREMUL_ARGB32;
+  break;
+   case WL_DRM_FORMAT_XRGB32:
+  drmdpy-base.formats |= HAS_XRGB32;
+  break;
+   }
 }
 
 static void
@@ -191,6 +203,11 @@ wayland_drm_display_init_screen(struct native_display 
*ndpy)
if (!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 =
   drmdpy-event_handler-new_drm_screen(drmdpy-base.base,
 NULL, drmdpy-fd);
diff --git a/src/gallium/state_trackers/egl/wayland/native_shm.c 
b/src/gallium/state_trackers/egl/wayland/native_shm.c
index 598df9f..8a50915 100644
--- a/src/gallium/state_trackers/egl/wayland/native_shm.c
+++ b/src/gallium/state_trackers/egl/wayland/native_shm.c
@@ -63,8 +63,8 @@ wayland_shm_display_destroy(struct native_display *ndpy)
 {
struct wayland_shm_display *shmdpy = wayland_shm_display(ndpy);
 
-   if (shmdpy-base.config)
-  FREE(shmdpy-base.config);
+   if (shmdpy-base.configs)
+  FREE(shmdpy-base.configs);
if (shmdpy-base.own_dpy)
   wl_display_destroy(shmdpy-base.dpy);
 
@@ -73,7 +73,6 @@ wayland_shm_display_destroy(struct native_display *ndpy)
FREE(shmdpy);
 }
 
-
 static struct wl_buffer *
 wayland_create_shm_buffer(struct wayland_display *display,
   struct wayland_surface *surface,
@@ -84,7 +83,7 @@ wayland_create_shm_buffer(struct wayland_display *display,
struct pipe_resource *resource;
struct winsys_handle wsh;
uint width, height;
-   uint32_t format;
+   enum wl_shm_format format;
 
resource = resource_surface_get_single_resource(surface-rsurf, attachment);
resource_surface_get_size(surface-rsurf, width, height);
@@ -95,6 +94,7 @@ wayland_create_shm_buffer(struct wayland_display *display,
 
switch (surface-color_format) {
case PIPE_FORMAT_B8G8R8A8_UNORM:
+  /* assume premultiplied */
   format = WL_SHM_FORMAT_PREMULTIPLIED_ARGB32;
   break;
case PIPE_FORMAT_B8G8R8X8_UNORM:
@@ -110,6 +110,28 @@ wayland_create_shm_buffer(struct wayland_display *display,
wsh.stride, format);
 }
 
+static void
+shm_handle_format(void *data, struct wl_shm *shm, uint32_t format)
+{
+   struct wayland_shm_display *shmdpy = data;
+
+   switch (format) {
+   case WL_SHM_FORMAT_ARGB32:
+  shmdpy-base.formats |= HAS_ARGB32;
+  break;
+   case WL_SHM_FORMAT_PREMULTIPLIED_ARGB32:
+  shmdpy-base.formats |= HAS_PREMUL_ARGB32;
+  break;
+   case WL_SHM_FORMAT_XRGB32:
+  shmdpy-base.formats |= HAS_XRGB32;
+  break;
+   }
+}
+
+static const struct 

Mesa (master): st/egl: add premultiplied alpha support to wayland

2011-09-08 Thread Chia-I Wu
Module: Mesa
Branch: master
Commit: 7645c49e07b638de94f03d5f71fde397066a46ee
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7645c49e07b638de94f03d5f71fde397066a46ee

Author: Benjamin Franzke benjaminfran...@googlemail.com
Date:   Thu Sep  8 08:01:46 2011 +0200

st/egl: add premultiplied alpha support to wayland

Return true for NATIVE_PARAM_PREMULTIPLIED_ALPHA when all formats with
alpha support premultiplied alpha.

(Based on Chia-I Wu's patch)

[olv: remove the use of param_premultiplied_alpha from the original
  patch]

---

 .../state_trackers/egl/wayland/native_drm.c|4 ++--
 .../state_trackers/egl/wayland/native_shm.c|4 ++--
 .../state_trackers/egl/wayland/native_wayland.c|   19 +++
 .../state_trackers/egl/wayland/native_wayland.h|1 +
 4 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/src/gallium/state_trackers/egl/wayland/native_drm.c 
b/src/gallium/state_trackers/egl/wayland/native_drm.c
index 9f6757b..5618f3e 100644
--- a/src/gallium/state_trackers/egl/wayland/native_drm.c
+++ b/src/gallium/state_trackers/egl/wayland/native_drm.c
@@ -109,8 +109,8 @@ wayland_create_drm_buffer(struct wayland_display *display,
 
switch (surface-color_format) {
case PIPE_FORMAT_B8G8R8A8_UNORM:
-  /* assume premultiplied */
-  format = WL_DRM_FORMAT_PREMULTIPLIED_ARGB32;
+  format = (surface-premultiplied_alpha) ?
+ WL_DRM_FORMAT_PREMULTIPLIED_ARGB32 : WL_DRM_FORMAT_ARGB32;
   break;
case PIPE_FORMAT_B8G8R8X8_UNORM:
   format = WL_DRM_FORMAT_XRGB32;
diff --git a/src/gallium/state_trackers/egl/wayland/native_shm.c 
b/src/gallium/state_trackers/egl/wayland/native_shm.c
index 8a50915..f9a7d81 100644
--- a/src/gallium/state_trackers/egl/wayland/native_shm.c
+++ b/src/gallium/state_trackers/egl/wayland/native_shm.c
@@ -94,8 +94,8 @@ wayland_create_shm_buffer(struct wayland_display *display,
 
switch (surface-color_format) {
case PIPE_FORMAT_B8G8R8A8_UNORM:
-  /* assume premultiplied */
-  format = WL_SHM_FORMAT_PREMULTIPLIED_ARGB32;
+  format = (surface-premultiplied_alpha) ?
+ WL_SHM_FORMAT_PREMULTIPLIED_ARGB32 : WL_SHM_FORMAT_ARGB32;
   break;
case PIPE_FORMAT_B8G8R8X8_UNORM:
   format = WL_SHM_FORMAT_XRGB32;
diff --git a/src/gallium/state_trackers/egl/wayland/native_wayland.c 
b/src/gallium/state_trackers/egl/wayland/native_wayland.c
index 7273d0e..c694293 100644
--- a/src/gallium/state_trackers/egl/wayland/native_wayland.c
+++ b/src/gallium/state_trackers/egl/wayland/native_wayland.c
@@ -99,9 +99,14 @@ 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) {
+   case NATIVE_PARAM_PREMULTIPLIED_ALPHA:
+  val = ((display-formats  HAS_ARGB32) 
+ (display-formats  HAS_PREMUL_ARGB32));
+  break;
case NATIVE_PARAM_USE_NATIVE_BUFFER:
case NATIVE_PARAM_PRESERVE_BUFFER:
case NATIVE_PARAM_MAX_SWAP_INTERVAL:
@@ -322,6 +327,20 @@ wayland_surface_present(struct native_surface *nsurf,
if (ctrl-preserve || ctrl-swap_interval)
   return FALSE;
 
+   /* force buffers to be re-created if they will be presented differently */
+   if (surface-premultiplied_alpha != ctrl-premultiplied_alpha) {
+  enum wayland_buffer_type buffer;
+
+  for (buffer = 0; buffer  WL_BUFFER_COUNT; ++buffer) {
+ if (surface-buffer[buffer]) {
+wl_buffer_destroy(surface-buffer[buffer]);
+surface-buffer[buffer] = NULL;
+ }
+  }
+
+  surface-premultiplied_alpha = ctrl-premultiplied_alpha;
+   }
+
switch (ctrl-natt) {
case NATIVE_ATTACHMENT_FRONT_LEFT:
   ret = TRUE;
diff --git a/src/gallium/state_trackers/egl/wayland/native_wayland.h 
b/src/gallium/state_trackers/egl/wayland/native_wayland.h
index 0350a95..143428c 100644
--- a/src/gallium/state_trackers/egl/wayland/native_wayland.h
+++ b/src/gallium/state_trackers/egl/wayland/native_wayland.h
@@ -87,6 +87,7 @@ struct wayland_surface {
unsigned int attachment_mask;
 
boolean block_swap_buffers;
+   boolean premultiplied_alpha;
 };
 
 struct wayland_config {

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


Mesa (master): Define INLINE macro in terms of inline.

2011-09-08 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 1cf808c86e7e88b173a5ca0ec6fef562ecae16b3
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=1cf808c86e7e88b173a5ca0ec6fef562ecae16b3

Author: José Fonseca jfons...@vmware.com
Date:   Wed Sep  7 18:42:07 2011 +0100

Define INLINE macro in terms of inline.

---

 src/egl/main/eglcompiler.h|   41 +---
 src/gallium/include/pipe/p_compiler.h |   25 +++-
 src/mapi/mapi/u_compiler.h|   25 +++-
 src/mesa/main/compiler.h  |   31 +
 4 files changed, 66 insertions(+), 56 deletions(-)

diff --git a/src/egl/main/eglcompiler.h b/src/egl/main/eglcompiler.h
index 1bc8cc8..d63bd90 100644
--- a/src/egl/main/eglcompiler.h
+++ b/src/egl/main/eglcompiler.h
@@ -65,26 +65,29 @@
 /**
  * Function inlining
  */
-#if defined(__GNUC__)
-#  define INLINE __inline__
-#elif defined(__MSC__)
-#  define INLINE __inline
-#elif defined(_MSC_VER)
-#  define INLINE __inline
-#elif defined(__ICL)
-#  define INLINE __inline
-#elif defined(__INTEL_COMPILER)
-#  define INLINE inline
-#elif defined(__WATCOMC__)  (__WATCOMC__ = 1100)
-#  define INLINE __inline
-#elif defined(__SUNPRO_C)  defined(__C99FEATURES__)
-#  define INLINE inline
-#  define __inline inline
-#  define __inline__ inline
-#elif (__STDC_VERSION__ = 199901L) /* C99 */
+#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
+#ifndef INLINE
 #  define INLINE inline
-#else
-#  define INLINE
 #endif
 
 
diff --git a/src/gallium/include/pipe/p_compiler.h 
b/src/gallium/include/pipe/p_compiler.h
index 05de9ff..6ac3644 100644
--- a/src/gallium/include/pipe/p_compiler.h
+++ b/src/gallium/include/pipe/p_compiler.h
@@ -91,27 +91,30 @@ typedef unsigned char boolean;
 #endif
 
 /* Function inlining */
-#ifndef INLINE
+#ifndef inline
 #  ifdef __cplusplus
-#define INLINE inline
+ /* C++ supports inline keyword */
 #  elif defined(__GNUC__)
-#define INLINE __inline__
+#define inline __inline__
 #  elif defined(_MSC_VER)
-#define INLINE __inline
+#define inline __inline
 #  elif defined(__ICL)
-#define INLINE __inline
+#define inline __inline
 #  elif defined(__INTEL_COMPILER)
-#define INLINE inline
+ /* Intel compiler supports inline keyword */
 #  elif defined(__WATCOMC__)  (__WATCOMC__ = 1100)
-#define INLINE __inline
+#define inline __inline
 #  elif defined(__SUNPRO_C)  defined(__C99FEATURES__)
-#define INLINE inline
-#  elif (__STDC_VERSION__ = 199901L) /* C99 */
-#define INLINE inline
+ /* C99 supports inline keyword */
+#  elif (__STDC_VERSION__ = 199901L)
+ /* C99 supports inline keyword */
 #  else
-#define INLINE
+#define inline
 #  endif
 #endif
+#ifndef INLINE
+#  define INLINE inline
+#endif
 
 /* Forced function inlining */
 #ifndef ALWAYS_INLINE
diff --git a/src/mapi/mapi/u_compiler.h b/src/mapi/mapi/u_compiler.h
index f1752d1..2b019ed 100644
--- a/src/mapi/mapi/u_compiler.h
+++ b/src/mapi/mapi/u_compiler.h
@@ -2,27 +2,30 @@
 #define _U_COMPILER_H_
 
 /* Function inlining */
-#ifndef INLINE
+#ifndef inline
 #  ifdef __cplusplus
-#define INLINE inline
+ /* C++ supports inline keyword */
 #  elif defined(__GNUC__)
-#define INLINE __inline__
+#define inline __inline__
 #  elif defined(_MSC_VER)
-#define INLINE __inline
+#define inline __inline
 #  elif defined(__ICL)
-#define INLINE __inline
+#define inline __inline
 #  elif defined(__INTEL_COMPILER)
-#define INLINE inline
+ /* Intel compiler supports inline keyword */
 #  elif defined(__WATCOMC__)  (__WATCOMC__ = 1100)
-#define INLINE __inline
+#define inline __inline
 #  elif defined(__SUNPRO_C)  defined(__C99FEATURES__)
-#define INLINE inline
-#  elif (__STDC_VERSION__ = 199901L) /* C99 */
-#define INLINE inline
+ /* C99 supports inline keyword */
+#  elif (__STDC_VERSION__ = 199901L)
+ /* C99 supports inline keyword */
 #  else
-#define INLINE
+#define inline
 #  endif
 #endif
+#ifndef INLINE
+#  define INLINE inline
+#endif
 
 /* Function visibility */
 #ifndef PUBLIC
diff --git a/src/mesa/main/compiler.h b/src/mesa/main/compiler.h
index 8ed1c6f..89d6cda 100644
--- a/src/mesa/main/compiler.h
+++ b/src/mesa/main/compiler.h
@@ -114,29 +114,30 @@ extern C {
 /**
  * Function inlining
  */
-#ifndef INLINE
-#  if defined(__GNUC__)
-#define INLINE __inline__
-# 

Mesa (master): st/egl: Fix GDI build.

2011-09-08 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 221a04fa8e264fc3aaba17e11f1f97c166416da2
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=221a04fa8e264fc3aaba17e11f1f97c166416da2

Author: José Fonseca jfons...@vmware.com
Date:   Thu Sep  8 09:32:10 2011 +0100

st/egl: Fix GDI build.

---

 src/gallium/state_trackers/egl/gdi/native_gdi.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/gallium/state_trackers/egl/gdi/native_gdi.c 
b/src/gallium/state_trackers/egl/gdi/native_gdi.c
index d3fec71..78dbe7c 100644
--- a/src/gallium/state_trackers/egl/gdi/native_gdi.c
+++ b/src/gallium/state_trackers/egl/gdi/native_gdi.c
@@ -161,7 +161,7 @@ gdi_surface_swap_buffers(struct native_surface *nsurf)
 
 static boolean
 gdi_surface_present(struct native_surface *nsurf,
-const native_present_control *ctrl)
+const struct native_present_control *ctrl)
 {
boolean ret;
 

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


Mesa (master): scons: Use -g instead of -g3.

2011-09-08 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 2864f723d111810532fab7697ad7badf161f45ab
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=2864f723d111810532fab7697ad7badf161f45ab

Author: José Fonseca jfons...@vmware.com
Date:   Thu Sep  8 09:59:01 2011 +0100

scons: Use -g instead of -g3.

-g3 causes binaries to be 3x - 10x bigger, not only on MinGW w/ dwarf
debugging info, but linux as well.

Stick with -g, (which defaults to -g2), like autoconf does.

---

 scons/gallium.py |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/scons/gallium.py b/scons/gallium.py
index dc77904..1c9c0ea 100755
--- a/scons/gallium.py
+++ b/scons/gallium.py
@@ -363,7 +363,7 @@ def generate(env):
 ccflags += ['-O3']
 # Work around aliasing bugs - developers should comment this out
 ccflags += ['-fno-strict-aliasing']
-ccflags += ['-g3']
+ccflags += ['-g']
 if env['build'] in ('checked', 'profile'):
 # See 
http://code.google.com/p/jrfonseca/wiki/Gprof2Dot#Which_options_should_I_pass_to_gcc_when_compiling_for_profiling?
 ccflags += [

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


Mesa (master): glsl: Make gl_ClipDistance[] implicitly sized.

2011-09-08 Thread Paul Berry
Module: Mesa
Branch: master
Commit: af243b55ac346f39acda1ad20d90e7c8cc1a33c7
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=af243b55ac346f39acda1ad20d90e7c8cc1a33c7

Author: Paul Berry stereotype...@gmail.com
Date:   Thu Aug 11 15:03:19 2011 -0700

glsl: Make gl_ClipDistance[] implicitly sized.

From the GLSL 1.30 spec, section 7.1 (Vertex Shader Special Variables):

  The gl_ClipDistance array is predeclared as unsized and must be
  sized by the shader either redeclaring it with a size or indexing it
  only with integral constant expressions.

Fixes piglit tests clip-distance-implicit-length.vert,
clip-distance-implicit-nonconst-access.vert, and
{vs,fs}-clip-distance-explicitly-sized.shader_test.

Reviewed-by: Kenneth Graunke kenn...@whitecape.org
Reviewed-by: Ian Romanick ian.d.roman...@intel.com

---

 src/glsl/ir_variable.cpp |   28 
 1 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/src/glsl/ir_variable.cpp b/src/glsl/ir_variable.cpp
index b848769..3809456 100644
--- a/src/glsl/ir_variable.cpp
+++ b/src/glsl/ir_variable.cpp
@@ -595,9 +595,18 @@ generate_130_vs_variables(exec_list *instructions,
builtin_130_vs_variables[i]);
}
 
+   /* From the GLSL 1.30 spec, section 7.1 (Vertex Shader Special
+* Variables):
+*
+*   The gl_ClipDistance array is predeclared as unsized and must
+*   be sized by the shader either redeclaring it with a size or
+*   indexing it only with integral constant expressions.
+*
+* We represent this in Mesa by initially declaring the array as
+* size 0.
+*/
const glsl_type *const clip_distance_array_type =
-  glsl_type::get_array_instance(glsl_type::float_type,
-   state-Const.MaxClipPlanes);
+  glsl_type::get_array_instance(glsl_type::float_type, 0);
 
/* FINISHME: gl_ClipDistance needs a real location assigned. */
add_variable(instructions, state-symbols,
@@ -802,9 +811,20 @@ generate_130_fs_variables(exec_list *instructions,
 {
generate_120_fs_variables(instructions, state);
 
+   /* From the GLSL 1.30 spec, section 7.2 (Fragment Shader Special
+* Variables):
+*
+*   The built-in input variable gl_ClipDistance array contains linearly
+*   interpolated values for the vertex values written by the vertex shader
+*   to the gl_ClipDistance vertex output variable. This array must be
+*   sized in the fragment shader either implicitly or explicitly to be the
+*   same size as it was sized in the vertex shader.
+*
+* In other words, the array must be pre-declared as implicitly sized.  We
+* represent this in Mesa by initially declaring the array as size 0.
+*/
const glsl_type *const clip_distance_array_type =
-  glsl_type::get_array_instance(glsl_type::float_type,
-   state-Const.MaxClipPlanes);
+  glsl_type::get_array_instance(glsl_type::float_type, 0);
 
/* FINISHME: gl_ClipDistance needs a real location assigned. */
add_variable(instructions, state-symbols,

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


Mesa (master): glsl: Add constant gl_MaxClipDistances.

2011-09-08 Thread Paul Berry
Module: Mesa
Branch: master
Commit: 36c4b1a3da44a80624eab9da6543540b4b253f1d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=36c4b1a3da44a80624eab9da6543540b4b253f1d

Author: Paul Berry stereotype...@gmail.com
Date:   Thu Aug 11 17:33:06 2011 -0700

glsl: Add constant gl_MaxClipDistances.

Fixes piglit tests {vs,fs}-clip-distance-sizeable-to-max.shader_test.

Reviewed-by: Kenneth Graunke kenn...@whitecape.org
Reviewed-by: Ian Romanick ian.d.roman...@intel.com

---

 src/glsl/ir_variable.cpp |   15 +++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/src/glsl/ir_variable.cpp b/src/glsl/ir_variable.cpp
index 3809456..e0b6f38 100644
--- a/src/glsl/ir_variable.cpp
+++ b/src/glsl/ir_variable.cpp
@@ -585,6 +585,17 @@ generate_120_vs_variables(exec_list *instructions,
 
 
 static void
+generate_130_uniforms(exec_list *instructions,
+ struct _mesa_glsl_parse_state *state)
+{
+   glsl_symbol_table *const symtab = state-symbols;
+
+   add_builtin_constant(instructions, symtab, gl_MaxClipDistances,
+state-Const.MaxClipPlanes);
+}
+
+
+static void
 generate_130_vs_variables(exec_list *instructions,
  struct _mesa_glsl_parse_state *state)
 {
@@ -595,6 +606,8 @@ generate_130_vs_variables(exec_list *instructions,
builtin_130_vs_variables[i]);
}
 
+   generate_130_uniforms(instructions, state);
+
/* From the GLSL 1.30 spec, section 7.1 (Vertex Shader Special
 * Variables):
 *
@@ -811,6 +824,8 @@ generate_130_fs_variables(exec_list *instructions,
 {
generate_120_fs_variables(instructions, state);
 
+   generate_130_uniforms(instructions, state);
+
/* From the GLSL 1.30 spec, section 7.2 (Fragment Shader Special
 * Variables):
 *

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


Mesa (master): glsl: Rework oversize array check for gl_TexCoord.

2011-09-08 Thread Paul Berry
Module: Mesa
Branch: master
Commit: 93b9758d01e2542ec3c2b8672cca0ae19b257aac
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=93b9758d01e2542ec3c2b8672cca0ae19b257aac

Author: Paul Berry stereotype...@gmail.com
Date:   Tue Sep  6 10:01:51 2011 -0700

glsl: Rework oversize array check for gl_TexCoord.

The check now applies both when explicitly declaring the size of
gl_TexCoord and when implicitly setting the size of gl_TexCoord by
accessing it using integral constant expressions.

This is prep work for adding similar size checks to gl_ClipDistance.

Fixes piglit tests texcoord/implicit-access-max.{frag,vert}.

Reviewed-by: Kenneth Graunke kenn...@whitecape.org
Reviewed-by: Ian Romanick ian.d.roman...@intel.com

---

 src/glsl/ast_to_hir.cpp |   45 +
 1 files changed, 33 insertions(+), 12 deletions(-)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 9e7496b..fbb2c14 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -893,6 +893,29 @@ get_scalar_boolean_operand(exec_list *instructions,
return new(ctx) ir_constant(true);
 }
 
+/**
+ * If name refers to a builtin array whose maximum allowed size is less than
+ * size, report an error and return true.  Otherwise return false.
+ */
+static bool
+check_builtin_array_max_size(const char *name, unsigned size,
+ YYLTYPE loc, struct _mesa_glsl_parse_state *state)
+{
+   if ((strcmp(gl_TexCoord, name) == 0)
+(size  state-Const.MaxTextureCoords)) {
+  /* From page 54 (page 60 of the PDF) of the GLSL 1.20 spec:
+   *
+   * The size [of gl_TexCoord] can be at most
+   * gl_MaxTextureCoords.
+   */
+  _mesa_glsl_error(loc, state, `gl_TexCoord' array size cannot 
+   be larger than gl_MaxTextureCoords (%u)\n,
+   state-Const.MaxTextureCoords);
+  return true;
+   }
+   return false;
+}
+
 ir_rvalue *
 ast_expression::hir(exec_list *instructions,
struct _mesa_glsl_parse_state *state)
@@ -1550,8 +1573,15 @@ ast_expression::hir(exec_list *instructions,
 * FINISHME: array access limits be added to ir_dereference?
 */
ir_variable *const v = array-whole_variable_referenced();
-   if ((v != NULL)  (unsigned(idx)  v-max_array_access))
+   if ((v != NULL)  (unsigned(idx)  v-max_array_access)) {
   v-max_array_access = idx;
+
+   /* Check whether this access will, as a side effect, implicitly
+* cause the size of a built-in array to be too large.
+*/
+   if (check_builtin_array_max_size(v-name, idx+1, loc, state))
+  error_emitted = true;
+}
 }
   } else if (array-type-array_size() == 0) {
 _mesa_glsl_error(loc, state, unsized array index must be constant);
@@ -2121,18 +2151,9 @@ get_variable_being_redeclared(ir_variable *var, 
ast_declaration *decl,
* FINISHME: required or not.
*/
 
-  /* From page 54 (page 60 of the PDF) of the GLSL 1.20 spec:
-   *
-   * The size [of gl_TexCoord] can be at most
-   * gl_MaxTextureCoords.
-   */
   const unsigned size = unsigned(var-type-array_size());
-  if ((strcmp(gl_TexCoord, var-name) == 0)
-  (size  state-Const.MaxTextureCoords)) {
-_mesa_glsl_error( loc, state, `gl_TexCoord' array size cannot 
- be larger than gl_MaxTextureCoords (%u)\n,
- state-Const.MaxTextureCoords);
-  } else if ((size  0)  (size = earlier-max_array_access)) {
+  check_builtin_array_max_size(var-name, size, loc, state);
+  if ((size  0)  (size = earlier-max_array_access)) {
 _mesa_glsl_error( loc, state, array size must be  %u due to 
  previous access,
  earlier-max_array_access);

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


Mesa (master): glsl: Check that gl_ClipDistance[] is not sized too large.

2011-09-08 Thread Paul Berry
Module: Mesa
Branch: master
Commit: 37bb1c4de2eb2fa80d09b6e8dc8f39814d790e09
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=37bb1c4de2eb2fa80d09b6e8dc8f39814d790e09

Author: Paul Berry stereotype...@gmail.com
Date:   Thu Aug 11 15:23:33 2011 -0700

glsl: Check that gl_ClipDistance[] is not sized too large.

Fixes piglit tests
clip-distance-explicit-too-large-with-access.{frag,vert} and
clip-distance-explicit-too-large.{frag,vert}.

Reviewed-by: Kenneth Graunke kenn...@whitecape.org
Reviewed-by: Ian Romanick ian.d.roman...@intel.com

---

 src/glsl/ast_to_hir.cpp |   15 +++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index fbb2c14..a4eaf85 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -912,6 +912,21 @@ check_builtin_array_max_size(const char *name, unsigned 
size,
be larger than gl_MaxTextureCoords (%u)\n,
state-Const.MaxTextureCoords);
   return true;
+   } else if (strcmp(gl_ClipDistance, name) == 0
+   size  state-Const.MaxClipPlanes) {
+  /* From section 7.1 (Vertex Shader Special Variables) of the
+   * GLSL 1.30 spec:
+   *
+   *   The gl_ClipDistance array is predeclared as unsized and
+   *   must be sized by the shader either redeclaring it with a
+   *   size or indexing it only with integral constant
+   *   expressions. ... The size can be at most
+   *   gl_MaxClipDistances.
+   */
+  _mesa_glsl_error(loc, state, `gl_ClipDistance' array size cannot 
+   be larger than gl_MaxClipDistances (%u)\n,
+   state-Const.MaxClipPlanes);
+  return true;
}
return false;
 }

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


Mesa (master): glsl: Make sure gl_ClipDistance and gl_ClipVertex are not both written.

2011-09-08 Thread Paul Berry
Module: Mesa
Branch: master
Commit: b453ba2c9f8ccb1d61a0ef50f0a40592df3366c3
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b453ba2c9f8ccb1d61a0ef50f0a40592df3366c3

Author: Paul Berry stereotype...@gmail.com
Date:   Thu Aug 11 18:10:22 2011 -0700

glsl: Make sure gl_ClipDistance and gl_ClipVertex are not both written.

From section 7.1 (Vertex Shader Special Variables) of the GLSL 1.30
spec:

  It is an error for a shader to statically write both
  gl_ClipVertex and gl_ClipDistance.

Fixes piglit test mixing-clip-distance-and-clip-vertex-disallowed.c.

Reviewed-by: Kenneth Graunke kenn...@whitecape.org
Reviewed-by: Ian Romanick ian.d.roman...@intel.com

---

 src/glsl/linker.cpp |   19 +++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index ba81c59..195f58f 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -262,6 +262,25 @@ validate_vertex_shader_executable(struct gl_shader_program 
*prog,
   return false;
}
 
+   if (prog-Version = 130) {
+  /* From section 7.1 (Vertex Shader Special Variables) of the
+   * GLSL 1.30 spec:
+   *
+   *   It is an error for a shader to statically write both
+   *   gl_ClipVertex and gl_ClipDistance.
+   */
+  find_assignment_visitor clip_vertex(gl_ClipVertex);
+  find_assignment_visitor clip_distance(gl_ClipDistance);
+
+  clip_vertex.run(shader-ir);
+  clip_distance.run(shader-ir);
+  if (clip_vertex.variable_found()  clip_distance.variable_found()) {
+ linker_error(prog, vertex shader writes to both `gl_ClipVertex' 
+  and `gl_ClipDistance'\n);
+ return false;
+  }
+   }
+
return true;
 }
 

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


Mesa (master): gles: Fix glGet(GL_{NUM_, }COMPRESSED_TEXTURE_FORMATS_ARB)

2011-09-08 Thread Adam Jackson
Module: Mesa
Branch: master
Commit: faf5d6584b9d75a10987c4460b376af7d1e4d496
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=faf5d6584b9d75a10987c4460b376af7d1e4d496

Author: Adam Jackson a...@redhat.com
Date:   Thu Sep  8 13:34:53 2011 -0400

gles: Fix glGet(GL_{NUM_,}COMPRESSED_TEXTURE_FORMATS_ARB)

We'd still accept the GL_PALETTE[48]_* formats in glCompressedTexImage2D,
but they wouldn't be listed if you queried whether they were supported.

Signed-off-by: Adam Jackson a...@redhat.com

---

 src/mesa/main/texcompress.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/mesa/main/texcompress.c b/src/mesa/main/texcompress.c
index 42bd1ee..390fc53 100644
--- a/src/mesa/main/texcompress.c
+++ b/src/mesa/main/texcompress.c
@@ -259,7 +259,6 @@ _mesa_get_compressed_formats(struct gl_context *ctx, GLint 
*formats)
  n += 4;
   }
}
-   return n;
 
 #if FEATURE_ES1 || FEATURE_ES2
if (formats) {
@@ -278,6 +277,8 @@ _mesa_get_compressed_formats(struct gl_context *ctx, GLint 
*formats)
   n += 10;
}
 #endif
+
+   return n;
 }
 
 

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


Mesa (master): nv50: fix screen-blitctx memory leak

2011-09-08 Thread Marcin Ślusarz
Module: Mesa
Branch: master
Commit: d8035fe173d87b319d85fcd64192a6d4fbe5
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d8035fe173d87b319d85fcd64192a6d4fbe5

Author: Marcin Slusarz marcin.slus...@gmail.com
Date:   Sun Aug 28 01:05:22 2011 +0200

nv50: fix screen-blitctx memory leak

---

 src/gallium/drivers/nv50/nv50_screen.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/nv50/nv50_screen.c 
b/src/gallium/drivers/nv50/nv50_screen.c
index 235cd82..aa791ae 100644
--- a/src/gallium/drivers/nv50/nv50_screen.c
+++ b/src/gallium/drivers/nv50/nv50_screen.c
@@ -226,6 +226,8 @@ nv50_screen_destroy(struct pipe_screen *pscreen)
   nouveau_fence_ref (NULL, screen-base.fence.current);
}
screen-base.channel-user_private = NULL;
+   if (screen-blitctx)
+  FREE(screen-blitctx);
 
nouveau_bo_ref(NULL, screen-code);
nouveau_bo_ref(NULL, screen-tls_bo);

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


Mesa (master): nouveau: fix nouveau_fence leak

2011-09-08 Thread Marcin Ślusarz
Module: Mesa
Branch: master
Commit: 96054375b1ea98d7827f0d4b567168fa2baeb38e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=96054375b1ea98d7827f0d4b567168fa2baeb38e

Author: Marcin Slusarz marcin.slus...@gmail.com
Date:   Tue Sep  6 16:12:52 2011 +0200

nouveau: fix nouveau_fence leak

Note: This is a candidate for the 7.11 branch.

---

 src/gallium/drivers/nouveau/nouveau_fence.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/nouveau/nouveau_fence.c 
b/src/gallium/drivers/nouveau/nouveau_fence.c
index d8f59dc..ea2038c 100644
--- a/src/gallium/drivers/nouveau/nouveau_fence.c
+++ b/src/gallium/drivers/nouveau/nouveau_fence.c
@@ -219,5 +219,7 @@ nouveau_fence_next(struct nouveau_screen *screen)
if (screen-fence.current-state  NOUVEAU_FENCE_STATE_EMITTED)
   nouveau_fence_emit(screen-fence.current);
 
+   nouveau_fence_ref(NULL, screen-fence.current);
+
nouveau_fence_new(screen, screen-fence.current, FALSE);
 }

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


Mesa (master): meta: move texcoord setup into setup_texture_coords()

2011-09-08 Thread Brian Paul
Module: Mesa
Branch: master
Commit: 8e9485870bfac93d5c26a094390a37aad2e264eb
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8e9485870bfac93d5c26a094390a37aad2e264eb

Author: Brian Paul bri...@vmware.com
Date:   Thu Sep  8 20:16:18 2011 -0600

meta: move texcoord setup into setup_texture_coords()

---

 src/mesa/drivers/common/meta.c |  268 ++--
 1 files changed, 176 insertions(+), 92 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index ad04d36..a0e9316 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -2477,6 +2477,160 @@ _mesa_meta_check_generate_mipmap_fallback(struct 
gl_context *ctx, GLenum target,
 
 
 /**
+ * Compute the texture coordinates for the four vertices of a quad for
+ * drawing a 2D texture image or slice of a cube/3D texture.
+ * \param faceTarget  GL_TEXTURE_1D/2D/3D or cube face name
+ * \param slice  slice of a 1D/2D array texture or 3D texture
+ * \param width  width of the texture image
+ * \param height  height of the texture image
+ * \param coords0/1/2/3  returns the computed texcoords
+ */
+static void
+setup_texture_coords(GLenum faceTarget,
+ GLint slice,
+ GLint width,
+ GLint height,
+ GLfloat coords0[3],
+ GLfloat coords1[3],
+ GLfloat coords2[3],
+ GLfloat coords3[3])
+{
+   static const GLfloat st[4][2] = {
+  {0.0f, 0.0f}, {1.0f, 0.0f}, {1.0f, 1.0f}, {0.0f, 1.0f}
+   };
+   GLuint i;
+   GLfloat r;
+
+   switch (faceTarget) {
+   case GL_TEXTURE_1D:
+   case GL_TEXTURE_2D:
+   case GL_TEXTURE_3D:
+   case GL_TEXTURE_2D_ARRAY:
+  if (faceTarget == GL_TEXTURE_3D)
+ r = 1.0F / slice;
+  else if (faceTarget == GL_TEXTURE_2D_ARRAY)
+ r = slice;
+  else
+ r = 0.0F;
+  coords0[0] = 0.0F; /* s */
+  coords0[1] = 0.0F; /* t */
+  coords0[2] = r; /* r */
+  coords1[0] = 1.0F;
+  coords1[1] = 0.0F;
+  coords1[2] = r;
+  coords2[0] = 1.0F;
+  coords2[1] = 1.0F;
+  coords2[2] = r;
+  coords3[0] = 0.0F;
+  coords3[1] = 1.0F;
+  coords3[2] = r;
+  break;
+   case GL_TEXTURE_RECTANGLE_ARB:
+  coords0[0] = 0.0F; /* s */
+  coords0[1] = 0.0F; /* t */
+  coords0[2] = 0.0F; /* r */
+  coords1[0] = width;
+  coords1[1] = 0.0F;
+  coords1[2] = 0.0F;
+  coords2[0] = width;
+  coords2[1] = height;
+  coords2[2] = 0.0F;
+  coords3[0] = 0.0F;
+  coords3[1] = height;
+  coords3[2] = 0.0F;
+  break;
+   case GL_TEXTURE_1D_ARRAY:
+  coords0[0] = 0.0F; /* s */
+  coords0[1] = slice; /* t */
+  coords0[2] = 0.0F; /* r */
+  coords1[0] = 1.0f;
+  coords1[1] = slice;
+  coords1[2] = 0.0F;
+  coords2[0] = 1.0F;
+  coords2[1] = slice;
+  coords2[2] = 0.0F;
+  coords3[0] = 0.0F;
+  coords3[1] = slice;
+  coords3[2] = 0.0F;
+  break;
+
+   case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
+   case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
+   case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
+   case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
+   case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
+   case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
+  /* loop over quad verts */
+  for (i = 0; i  4; i++) {
+ /* Compute sc = +/-scale and tc = +/-scale.
+  * Not +/-1 to avoid cube face selection ambiguity near the edges,
+  * though that can still sometimes happen with this scale factor...
+  */
+ const GLfloat scale = 0.f;
+ const GLfloat sc = (2.0f * st[i][0] - 1.0f) * scale;
+ const GLfloat tc = (2.0f * st[i][1] - 1.0f) * scale;
+ GLfloat *coord;
+
+ switch (i) {
+ case 0:
+coord = coords0;
+break;
+ case 1:
+coord = coords1;
+break;
+ case 2:
+coord = coords2;
+break;
+ case 3:
+coord = coords3;
+break;
+ default:
+assert(0);
+ }
+
+ switch (faceTarget) {
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
+coord[0] = 1.0f;
+coord[1] = -tc;
+coord[2] = -sc;
+break;
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
+coord[0] = -1.0f;
+coord[1] = -tc;
+coord[2] = sc;
+break;
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
+coord[0] = sc;
+coord[1] = 1.0f;
+coord[2] = tc;
+break;
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
+coord[0] = sc;
+coord[1] = -1.0f;
+coord[2] = -tc;
+break;
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
+coord[0] = sc;
+coord[1] = -tc;
+coord[2] = 1.0f;
+break;
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
+coord[0] = 

Mesa (master): meta: added _mesa_meta_GetTexImage()

2011-09-08 Thread Brian Paul
Module: Mesa
Branch: master
Commit: e3dc78e57a7effbd30dc9539b3ea05ad85ac34e5
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e3dc78e57a7effbd30dc9539b3ea05ad85ac34e5

Author: Brian Paul bri...@vmware.com
Date:   Thu Sep  8 20:16:18 2011 -0600

meta: added _mesa_meta_GetTexImage()

If the texture is compressed, call the meta decompress_texture_image()
function.  Otherwise, call the core _mesa_get_teximage() function.

---

 src/mesa/drivers/common/driverfuncs.c |2 +-
 src/mesa/drivers/common/meta.c|  224 +
 src/mesa/drivers/common/meta.h|7 +
 3 files changed, 232 insertions(+), 1 deletions(-)

diff --git a/src/mesa/drivers/common/driverfuncs.c 
b/src/mesa/drivers/common/driverfuncs.c
index 6484d28..36ed4f8 100644
--- a/src/mesa/drivers/common/driverfuncs.c
+++ b/src/mesa/drivers/common/driverfuncs.c
@@ -94,7 +94,7 @@ _mesa_init_driver_functions(struct dd_function_table *driver)
driver-TexSubImage1D = _mesa_store_texsubimage1d;
driver-TexSubImage2D = _mesa_store_texsubimage2d;
driver-TexSubImage3D = _mesa_store_texsubimage3d;
-   driver-GetTexImage = _mesa_get_teximage;
+   driver-GetTexImage = _mesa_meta_GetTexImage;
driver-CopyTexSubImage1D = _mesa_meta_CopyTexSubImage1D;
driver-CopyTexSubImage2D = _mesa_meta_CopyTexSubImage2D;
driver-CopyTexSubImage3D = _mesa_meta_CopyTexSubImage3D;
diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index a0e9316..2ebcd35 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -59,6 +59,7 @@
 #include main/stencil.h
 #include main/texobj.h
 #include main/texenv.h
+#include main/texgetimage.h
 #include main/teximage.h
 #include main/texparam.h
 #include main/texstate.h
@@ -259,6 +260,18 @@ struct gen_mipmap_state
GLuint FBO;
 };
 
+
+/**
+ * State for texture decompression
+ */
+struct decompress_state
+{
+   GLuint ArrayObj;
+   GLuint VBO, FBO, RBO;
+   GLint Width, Height;
+};
+
+
 #define MAX_META_OPS_DEPTH  2
 /**
  * All per-context meta state.
@@ -278,6 +291,7 @@ struct gl_meta_state
struct drawpix_state DrawPix;  /** For _mesa_meta_DrawPixels() */
struct bitmap_state Bitmap;/** For _mesa_meta_Bitmap() */
struct gen_mipmap_state Mipmap;/** For _mesa_meta_GenerateMipmap() */
+   struct decompress_state Decompress;  /** For texture decompression */
 };
 
 
@@ -3023,3 +3037,213 @@ _mesa_meta_CopyTexSubImage3D(struct gl_context *ctx, 
GLenum target, GLint level,
copy_tex_sub_image(ctx, 3, target, level, xoffset, yoffset, zoffset,
   x, y, width, height);
 }
+
+
+/**
+ * Decompress a texture image by drawing a quad with the compressed
+ * texture and reading the pixels out of the color buffer.
+ * \param slice  which slice of a 3D texture or layer of a 1D/2D texture
+ * \param destFormat  format, ala glReadPixels
+ * \param destType  type, ala glReadPixels
+ * \param dest  destination buffer
+ * \param destRowLength  dest image rowLength (ala GL_PACK_ROW_LENGTH)
+ */
+static void
+decompress_texture_image(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
+ GLuint slice,
+ GLenum destFormat, GLenum destType,
+ GLvoid *dest, GLint destRowLength)
+{
+   struct decompress_state *decompress = ctx-Meta-Decompress;
+   struct gl_texture_object *texObj = texImage-TexObject;
+   const GLint width = texImage-Width;
+   const GLint height = texImage-Height;
+   const GLenum target = texObj-Target;
+   GLenum faceTarget;
+   struct vertex {
+  GLfloat x, y, tex[3];
+   };
+   struct vertex verts[4];
+   GLuint fboDrawSave, fboReadSave;
+
+   if (slice  0) {
+  assert(target == GL_TEXTURE_3D ||
+ target == GL_TEXTURE_2D_ARRAY);
+   }
+
+   if (target == GL_TEXTURE_CUBE_MAP) {
+  faceTarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X + texImage-Face;
+   }
+   else {
+  faceTarget = target;
+   }
+
+   /* save fbo bindings (not saved by _mesa_meta_begin()) */
+   fboDrawSave = ctx-DrawBuffer-Name;
+   fboReadSave = ctx-ReadBuffer-Name;
+
+   _mesa_meta_begin(ctx, MESA_META_ALL);
+
+   /* Create/bind FBO/renderbuffer */
+   if (decompress-FBO == 0) {
+  _mesa_GenFramebuffersEXT(1, decompress-FBO);
+  _mesa_GenRenderbuffersEXT(1, decompress-RBO);
+  _mesa_BindFramebufferEXT(GL_FRAMEBUFFER_EXT, decompress-FBO);
+  _mesa_BindRenderbufferEXT(GL_RENDERBUFFER_EXT, decompress-RBO);
+  _mesa_FramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
+   GL_COLOR_ATTACHMENT0_EXT,
+   GL_RENDERBUFFER_EXT,
+   decompress-RBO);
+   }
+   else {
+  _mesa_BindFramebufferEXT(GL_FRAMEBUFFER_EXT, decompress-FBO);
+   }
+
+   /* alloc dest surface */
+   if (width != decompress-Width || height != decompress-Height) {
+  

Mesa (master): mesa: add new pixel format unpacking code

2011-09-08 Thread Brian Paul
Module: Mesa
Branch: master
Commit: 730952aa12c257af25af0873e0b284f742fb485e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=730952aa12c257af25af0873e0b284f742fb485e

Author: Brian Paul bri...@vmware.com
Date:   Thu Sep  8 20:16:18 2011 -0600

mesa: add new pixel format unpacking code

This will be used instead of the texel fetch code to unpack images
in various formats.

---

 src/mesa/SConscript   |1 +
 src/mesa/main/format_unpack.c | 1494 +
 src/mesa/main/format_unpack.h |   49 ++
 src/mesa/sources.mak  |1 +
 4 files changed, 1545 insertions(+), 0 deletions(-)

diff --git a/src/mesa/SConscript b/src/mesa/SConscript
index 64b7065..dfc8bd4 100644
--- a/src/mesa/SConscript
+++ b/src/mesa/SConscript
@@ -72,6 +72,7 @@ main_sources = [
 'main/ffvertex_prog.c',
 'main/fog.c',
 'main/formats.c',
+'main/format_unpack.c',
 'main/framebuffer.c',
 'main/get.c',
 'main/getstring.c',
diff --git a/src/mesa/main/format_unpack.c b/src/mesa/main/format_unpack.c
new file mode 100644
index 000..c5146f7
--- /dev/null
+++ b/src/mesa/main/format_unpack.c
@@ -0,0 +1,1494 @@
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (c) 2011 VMware, Inc.
+ *
+ * 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, sublicense,
+ * 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 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 NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS 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.
+ */
+
+
+#include colormac.h
+#include format_unpack.h
+#include macros.h
+#include ../../gallium/auxiliary/util/u_format_rgb9e5.h
+#include ../../gallium/auxiliary/util/u_format_r11g11b10f.h
+
+
+/**
+ * Convert an 8-bit sRGB value from non-linear space to a
+ * linear RGB value in [0, 1].
+ * Implemented with a 256-entry lookup table.
+ */
+static INLINE GLfloat
+nonlinear_to_linear(GLubyte cs8)
+{
+   static GLfloat table[256];
+   static GLboolean tableReady = GL_FALSE;
+   if (!tableReady) {
+  /* compute lookup table now */
+  GLuint i;
+  for (i = 0; i  256; i++) {
+ const GLfloat cs = UBYTE_TO_FLOAT(i);
+ if (cs = 0.04045) {
+table[i] = cs / 12.92f;
+ }
+ else {
+table[i] = (GLfloat) pow((cs + 0.055) / 1.055, 2.4);
+ }
+  }
+  tableReady = GL_TRUE;
+   }
+   return table[cs8];
+}
+
+
+typedef void (*unpack_rgba_func)(const void *src, GLfloat dst[4]);
+
+
+static void
+unpack_RGBA(const void *src, GLfloat dst[4])
+{
+   const GLuint s = *((const GLuint *) src);
+   dst[RCOMP] = UBYTE_TO_FLOAT( (s  24));
+   dst[GCOMP] = UBYTE_TO_FLOAT( (s  16)  0xff );
+   dst[BCOMP] = UBYTE_TO_FLOAT( (s   8)  0xff );
+   dst[ACOMP] = UBYTE_TO_FLOAT( (s  )  0xff );
+}
+
+static void
+unpack_RGBA_REV(const void *src, GLfloat dst[4])
+{
+   const GLuint s = *((const GLuint *) src);
+   dst[RCOMP] = UBYTE_TO_FLOAT( (s  )  0xff );
+   dst[GCOMP] = UBYTE_TO_FLOAT( (s   8)  0xff );
+   dst[BCOMP] = UBYTE_TO_FLOAT( (s  16)  0xff );
+   dst[ACOMP] = UBYTE_TO_FLOAT( (s  24));
+}
+
+static void
+unpack_ARGB(const void *src, GLfloat dst[4])
+{
+   const GLuint s = *((const GLuint *) src);
+   dst[RCOMP] = UBYTE_TO_FLOAT( (s  16)  0xff );
+   dst[GCOMP] = UBYTE_TO_FLOAT( (s   8)  0xff );
+   dst[BCOMP] = UBYTE_TO_FLOAT( (s  )  0xff );
+   dst[ACOMP] = UBYTE_TO_FLOAT( (s  24));
+}
+
+static void
+unpack_ARGB_REV(const void *src, GLfloat dst[4])
+{
+   const GLuint s = *((const GLuint *) src);
+   dst[RCOMP] = UBYTE_TO_FLOAT( (s   8)  0xff );
+   dst[GCOMP] = UBYTE_TO_FLOAT( (s  16)  0xff );
+   dst[BCOMP] = UBYTE_TO_FLOAT( (s  24));
+   dst[ACOMP] = UBYTE_TO_FLOAT( (s  )  0xff );
+}
+
+static void
+unpack_XRGB(const void *src, GLfloat dst[4])
+{
+   const GLuint s = *((const GLuint *) src);
+   dst[RCOMP] = UBYTE_TO_FLOAT( (s  16)  0xff );
+   dst[GCOMP] = UBYTE_TO_FLOAT( (s   8)  0xff );
+   dst[BCOMP] = UBYTE_TO_FLOAT( (s  )  0xff );
+   dst[ACOMP] = 1.0f;
+}
+
+static void
+unpack_XRGB_REV(const void *src, GLfloat dst[4])
+{
+   const GLuint s = *((const GLuint *) src);
+   dst[RCOMP] = 

Mesa (master): mesa: new _mesa_decompress_image() function

2011-09-08 Thread Brian Paul
Module: Mesa
Branch: master
Commit: 3370ba802ff93fde399c9b07303a71ab0827e217
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=3370ba802ff93fde399c9b07303a71ab0827e217

Author: Brian Paul bri...@vmware.com
Date:   Thu Sep  8 20:16:18 2011 -0600

mesa: new _mesa_decompress_image() function

Use the old texture fetch functions to decompress a whole image.
To be used by glGetTexImage().

---

 src/mesa/main/texcompress.c |   86 +++
 src/mesa/main/texcompress.h |5 ++
 2 files changed, 91 insertions(+), 0 deletions(-)

diff --git a/src/mesa/main/texcompress.c b/src/mesa/main/texcompress.c
index 390fc53..4e5c14c 100644
--- a/src/mesa/main/texcompress.c
+++ b/src/mesa/main/texcompress.c
@@ -37,6 +37,9 @@
 #include mfeatures.h
 #include mtypes.h
 #include texcompress.h
+#include texcompress_fxt1.h
+#include texcompress_rgtc.h
+#include texcompress_s3tc.h
 
 
 /**
@@ -438,3 +441,86 @@ _mesa_compressed_image_address(GLint col, GLint row, GLint 
img,
 
return (GLubyte *) image + offset;
 }
+
+
+/**
+ * Decompress a compressed texture image, returning a GL_RGBA/GL_FLOAT image.
+ */
+void
+_mesa_decompress_image(gl_format format, GLuint width, GLuint height,
+   const GLubyte *src, GLint srcRowStride,
+   GLfloat *dest)
+{
+   void (*fetch)(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel);
+   struct gl_texture_image texImage;  /* dummy teximage */
+   GLuint i, j;
+
+   /* setup dummy texture image info */
+   memset(texImage, 0, sizeof(texImage));
+   texImage.Data = (void *) src;
+   texImage.RowStride = srcRowStride;
+
+   switch (format) {
+   /* DXT formats */
+   case MESA_FORMAT_RGB_DXT1:
+  fetch = _mesa_fetch_texel_2d_f_rgb_dxt1;
+  break;
+   case MESA_FORMAT_RGBA_DXT1:
+  fetch = _mesa_fetch_texel_2d_f_rgba_dxt1;
+  break;
+   case MESA_FORMAT_RGBA_DXT3:
+  fetch = _mesa_fetch_texel_2d_f_rgba_dxt3;
+  break;
+   case MESA_FORMAT_RGBA_DXT5:
+  fetch = _mesa_fetch_texel_2d_f_rgba_dxt5;
+  break;
+
+   /* FXT1 formats */
+   case MESA_FORMAT_RGB_FXT1:
+  fetch = _mesa_fetch_texel_2d_f_rgb_fxt1;
+  break;
+   case MESA_FORMAT_RGBA_FXT1:
+  fetch = _mesa_fetch_texel_2d_f_rgba_fxt1;
+  break;
+
+   /* Red/RG formats */
+   case MESA_FORMAT_RED_RGTC1:
+  fetch = _mesa_fetch_texel_2d_f_red_rgtc1;
+  break;
+   case MESA_FORMAT_SIGNED_RED_RGTC1:
+  fetch = _mesa_fetch_texel_2d_f_signed_red_rgtc1;
+  break;
+   case MESA_FORMAT_RG_RGTC2:
+  fetch = _mesa_fetch_texel_2d_f_rg_rgtc2;
+  break;
+   case MESA_FORMAT_SIGNED_RG_RGTC2:
+  fetch = _mesa_fetch_texel_2d_f_signed_rg_rgtc2;
+  break;
+
+   /* L/LA formats */
+   case MESA_FORMAT_L_LATC1:
+  fetch = _mesa_fetch_texel_2d_f_l_latc1;
+  break;
+   case MESA_FORMAT_SIGNED_L_LATC1:
+  fetch = _mesa_fetch_texel_2d_f_signed_l_latc1;
+  break;
+   case MESA_FORMAT_LA_LATC2:
+  fetch = _mesa_fetch_texel_2d_f_la_latc2;
+  break;
+   case MESA_FORMAT_SIGNED_LA_LATC2:
+  fetch = _mesa_fetch_texel_2d_f_signed_la_latc2;
+  break;
+
+   default:
+  _mesa_problem(NULL, Unexpected format in _mesa_decompress_image());
+  return;
+   }
+
+   for (j = 0; j  height; j++) {
+  for (i = 0; i  width; i++) {
+ fetch(texImage, i, j, 0, dest);
+ dest += 4;
+  }
+   }
+}
diff --git a/src/mesa/main/texcompress.h b/src/mesa/main/texcompress.h
index 375cf90..2c35706 100644
--- a/src/mesa/main/texcompress.h
+++ b/src/mesa/main/texcompress.h
@@ -50,6 +50,11 @@ _mesa_compressed_image_address(GLint col, GLint row, GLint 
img,
gl_format mesaFormat,
GLsizei width, const GLubyte *image);
 
+extern void
+_mesa_decompress_image(gl_format format, GLuint width, GLuint height,
+   const GLubyte *src, GLint srcRowStride,
+   GLfloat *dest);
+
 #else /* _HAVE_FULL_GL */
 
 /* no-op macros */

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


Mesa (master): mesa: handle compressed images in get_tex_rgba()

2011-09-08 Thread Brian Paul
Module: Mesa
Branch: master
Commit: c1b3faefc06ef6dfc9b0eb226f0a0af4dd6c6c9d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=c1b3faefc06ef6dfc9b0eb226f0a0af4dd6c6c9d

Author: Brian Paul bri...@vmware.com
Date:   Thu Sep  8 20:16:18 2011 -0600

mesa: handle compressed images in get_tex_rgba()

Uses the new _mesa_decompress_image() function.  Unlike the meta path
that uses textured quad rendering to do decompression, this works with
signed formats as well.

---

 src/mesa/main/texgetimage.c |  164 ---
 1 files changed, 106 insertions(+), 58 deletions(-)

diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c
index 99ace91..a39ac59 100644
--- a/src/mesa/main/texgetimage.c
+++ b/src/mesa/main/texgetimage.c
@@ -34,11 +34,13 @@
 #include enums.h
 #include context.h
 #include formats.h
+#include format_unpack.h
 #include image.h
 #include mfeatures.h
 #include mtypes.h
 #include pack.h
 #include pbo.h
+#include texcompress.h
 #include texgetimage.h
 #include texfetch.h
 #include teximage.h
@@ -173,95 +175,141 @@ get_tex_ycbcr(struct gl_context *ctx, GLuint dimensions,
 
 
 /**
- * glGetTexImage for (s)RGBA, Luminance, etc. pixels.
- * This is the slow way since we use texture sampling.
+ * glGetTexImage for color formats (RGBA, RGB, alpha, LA, etc).
+ * Compressed textures are handled here as well.
  */
 static void
 get_tex_rgba(struct gl_context *ctx, GLuint dimensions,
  GLenum format, GLenum type, GLvoid *pixels,
  struct gl_texture_image *texImage)
 {
-   const GLint width = texImage-Width;
-   const GLint height = texImage-Height;
-   const GLint depth = texImage-Depth;
-   const GLenum dataType = _mesa_get_format_datatype(texImage-TexFormat);
+   /* don't want to apply sRGB - RGB conversion here so override the format */
+   const gl_format texFormat = 
_mesa_get_srgb_format_linear(texImage-TexFormat);
+   const GLuint width = texImage-Width;
+   const GLuint height = texImage-Height;
+   const GLuint depth = texImage-Depth;
+   const GLenum dataType = _mesa_get_format_datatype(texFormat);
+   const GLenum baseFormat = _mesa_get_format_base_format(texFormat);
/* Normally, no pixel transfer ops are performed during glGetTexImage.
 * The only possible exception is component clamping to [0,1].
 */
GLbitfield transferOps = 0x0;
-   GLint img, row;
-   GLfloat (*rgba)[4] = (GLfloat (*)[4]) malloc(4 * width * sizeof(GLfloat));
-   const GLboolean is_sampler_srgb_decode =
-   _mesa_get_format_color_encoding(texImage-TexFormat) == GL_SRGB 
-   texImage-TexObject-Sampler.sRGBDecode == GL_DECODE_EXT;
 
-   if (!rgba) {
-  _mesa_error(ctx, GL_OUT_OF_MEMORY, glGetTexImage);
-  return;
-   }
-
-   /* Clamping does not apply to GetTexImage (final conversion)?
-* Looks like we need clamp though when going from format
-* containing negative values to unsigned format.
+   /* In general, clamping does not apply to glGetTexImage, except when
+* the returned type of the image can't hold negative values.
 */
-   if (format == GL_LUMINANCE || format == GL_LUMINANCE_ALPHA) {
-  transferOps |= IMAGE_CLAMP_BIT;
-   }
-   else if (!type_with_negative_values(type) 
-(dataType == GL_FLOAT ||
- dataType == GL_SIGNED_NORMALIZED)) {
-  transferOps |= IMAGE_CLAMP_BIT;
+   if (!type_with_negative_values(type)) {
+  /* the returned image type can't have negative values */
+  if (dataType == GL_FLOAT ||
+  dataType == GL_SIGNED_NORMALIZED ||
+  format == GL_LUMINANCE ||
+  format == GL_LUMINANCE_ALPHA) {
+ transferOps |= IMAGE_CLAMP_BIT;
+  }
}
 
-   /* glGetTexImage always returns sRGB data for sRGB textures. Make sure the
-* fetch functions return sRGB data without linearizing it.
-*/
-   if (is_sampler_srgb_decode) {
-  texImage-TexObject-Sampler.sRGBDecode = GL_SKIP_DECODE_EXT;
-  _mesa_set_fetch_functions(texImage, dimensions);
-   }
+   if (_mesa_is_format_compressed(texFormat)) {
+  /* Decompress into temp buffer, then pack into user buffer */
+  GLfloat *tempImage, *srcRow;
+  GLuint row;
 
-   for (img = 0; img  depth; img++) {
+  tempImage = (GLfloat *) malloc(texImage-Width * texImage-Height *
+ texImage-Depth * 4 * sizeof(GLfloat));
+  if (!tempImage) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, glGetTexImage());
+ return;
+  }
+
+  _mesa_decompress_image(texFormat, texImage-Width, texImage-Height,
+ texImage-Data, texImage-RowStride, tempImage);
+
+  if (baseFormat == GL_LUMINANCE ||
+  baseFormat == GL_LUMINANCE_ALPHA) {
+ /* Set green and blue to zero since the pack function here will
+  * compute L=R+G+B.
+  */
+ GLuint i;
+ for (i = 0; i  width * height; i++) {
+tempImage[i * 4 + GCOMP] = tempImage[i * 4 + BCOMP] = 0.0f;
+ 

Mesa (master): mesa: use _mesa_unpack_float_z_row in get_tex_depth()

2011-09-08 Thread Brian Paul
Module: Mesa
Branch: master
Commit: c6ca3ca5520289572859a4a874f69366f76ad421
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=c6ca3ca5520289572859a4a874f69366f76ad421

Author: Brian Paul bri...@vmware.com
Date:   Thu Sep  8 20:16:18 2011 -0600

mesa: use _mesa_unpack_float_z_row in get_tex_depth()

Removes another use of the gl_texture_image::FetchTexelf() function.

---

 src/mesa/main/texgetimage.c |   12 +++-
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c
index a39ac59..4ab39a4 100644
--- a/src/mesa/main/texgetimage.c
+++ b/src/mesa/main/texgetimage.c
@@ -77,8 +77,9 @@ get_tex_depth(struct gl_context *ctx, GLuint dimensions,
const GLint width = texImage-Width;
const GLint height = texImage-Height;
const GLint depth = texImage-Depth;
-   GLint img, row, col;
+   GLint img, row;
GLfloat *depthRow = (GLfloat *) malloc(width * sizeof(GLfloat));
+   const GLint texelSize = _mesa_get_format_bytes(texImage-TexFormat);
 
if (!depthRow) {
   _mesa_error(ctx, GL_OUT_OF_MEMORY, glGetTexImage);
@@ -90,11 +91,12 @@ get_tex_depth(struct gl_context *ctx, GLuint dimensions,
  void *dest = _mesa_image_address(dimensions, ctx-Pack, pixels,
   width, height, format, type,
   img, row, 0);
- assert(dest);
+ const GLubyte *src = (GLubyte *) texImage-Data +
+(texImage-ImageOffsets[img] +
+ texImage-RowStride * row) * texelSize;
+
+ _mesa_unpack_float_z_row(texImage-TexFormat, width, src, depthRow);
 
- for (col = 0; col  width; col++) {
-texImage-FetchTexelf(texImage, col, row, img, depthRow + col);
- }
  _mesa_pack_depth_span(ctx, width, dest, type, depthRow, ctx-Pack);
   }
}

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


Mesa (master): mesa: remove unneeded #include of texfetch.h

2011-09-08 Thread Brian Paul
Module: Mesa
Branch: master
Commit: ce64b6d612dc167c4b8c00594d87517d6ed0e5fa
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ce64b6d612dc167c4b8c00594d87517d6ed0e5fa

Author: Brian Paul bri...@vmware.com
Date:   Thu Sep  8 20:54:37 2011 -0600

mesa: remove unneeded #include of texfetch.h

---

 src/mesa/main/texgetimage.c |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c
index 4ab39a4..2830dda 100644
--- a/src/mesa/main/texgetimage.c
+++ b/src/mesa/main/texgetimage.c
@@ -42,7 +42,6 @@
 #include pbo.h
 #include texcompress.h
 #include texgetimage.h
-#include texfetch.h
 #include teximage.h
 
 

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


Mesa (master): glsl: Fix setting of OutputsWritten for whole array dereference.

2011-09-08 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: d00deae3ef3a7828de1e566ad95b3a5b1ab7034d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d00deae3ef3a7828de1e566ad95b3a5b1ab7034d

Author: Eric Anholt e...@anholt.net
Date:   Wed Sep  7 11:00:03 2011 -0700

glsl: Fix setting of OutputsWritten for whole array dereference.

We just want to mark the whole thing used, not mark from each element
the whole size in use.  Fixes undefined URB entry writes on i965,
which blew up with debugging enabled.

Reviewed-by: Ian Romanick ian.d.roman...@intel.com

---

 src/glsl/ir_set_program_inouts.cpp |6 ++
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/glsl/ir_set_program_inouts.cpp 
b/src/glsl/ir_set_program_inouts.cpp
index 0854565..3b10b90 100644
--- a/src/glsl/ir_set_program_inouts.cpp
+++ b/src/glsl/ir_set_program_inouts.cpp
@@ -94,10 +94,8 @@ ir_set_program_inouts_visitor::visit(ir_dereference_variable 
*ir)
   return visit_continue;
 
if (ir-type-is_array()) {
-  for (unsigned int i = 0; i  ir-type-length; i++) {
-mark(this-prog, ir-var, i,
- ir-type-length * ir-type-fields.array-matrix_columns);
-  }
+  mark(this-prog, ir-var, 0,
+  ir-type-length * ir-type-fields.array-matrix_columns);
} else {
   mark(this-prog, ir-var, 0, ir-type-matrix_columns);
}

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


Mesa (master): glsl: When assiging from a whole array, mark it as used.

2011-09-08 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: 407a1001aefcb15e8d066031417d91ea22f1daf1
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=407a1001aefcb15e8d066031417d91ea22f1daf1

Author: Eric Anholt e...@anholt.net
Date:   Wed Sep  7 11:53:20 2011 -0700

glsl: When assiging from a whole array, mark it as used.

Fixes piglit link-uniform-array-size.

Reviewed-by: Ian Romanick ian.d.roman...@intel.com

---

 src/glsl/ast_to_hir.cpp |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index a4eaf85..e70e0b3 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -723,6 +723,7 @@ do_assignment(exec_list *instructions, struct 
_mesa_glsl_parse_state *state,
   rhs-type-array_size());
 d-type = var-type;
   }
+  mark_whole_array_access(rhs);
   mark_whole_array_access(lhs);
}
 

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


Mesa (master): glsl: Clarify error message about whole-array assignment in GLSL 1.10.

2011-09-08 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: 525cec98a5c65c27c62fed0cff706bca50bf8c6e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=525cec98a5c65c27c62fed0cff706bca50bf8c6e

Author: Eric Anholt e...@anholt.net
Date:   Wed Sep  7 12:03:36 2011 -0700

glsl: Clarify error message about whole-array assignment in GLSL 1.10.

Previously, it would produce:

Failed to compile FS: 0:6(7): error: non-lvalue in assignment

and now it produces:

Failed to compile FS: 0:5(7): error: whole array assignment is not
allowed in GLSL 1.10 or GLSL ES 1.00.

Also, add spec quotation to the two places we have code for array
lvalues in GLSL 1.10.

Reviewed-by: Kenneth Graunke kenn...@whitecape.org
Reviewed-by: Ian Romanick ian.d.roman...@intel.com

---

 src/glsl/ast_to_hir.cpp |   31 +--
 1 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index e70e0b3..777f190 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -679,16 +679,20 @@ do_assignment(exec_list *instructions, struct 
_mesa_glsl_parse_state *state,
   lhs-variable_referenced()-name);
  error_emitted = true;
 
+  } else if (state-language_version = 110  lhs-type-is_array()) {
+/* From page 32 (page 38 of the PDF) of the GLSL 1.10 spec:
+ *
+ *Other binary or unary expressions, non-dereferenced
+ * arrays, function names, swizzles with repeated fields,
+ * and constants cannot be l-values.
+ */
+_mesa_glsl_error(lhs_loc, state, whole array assignment is not 
+ allowed in GLSL 1.10 or GLSL ES 1.00.);
+error_emitted = true;
   } else if (!lhs-is_lvalue()) {
 _mesa_glsl_error( lhs_loc, state, non-lvalue in assignment);
 error_emitted = true;
   }
-
-  if (state-es_shader  lhs-type-is_array()) {
-_mesa_glsl_error(lhs_loc, state, whole array assignment is not 
- allowed in GLSL ES 1.00.);
-error_emitted = true;
-  }
}
 
ir_rvalue *new_rhs =
@@ -2117,6 +2121,21 @@ apply_type_qualifier_to_variable(const struct 
ast_type_qualifier *qual,
else
var-depth_layout = ir_depth_layout_none;
 
+   /* From page 46 (page 52 of the PDF) of the GLSL ES specification:
+*
+*Array variables are l-values and may be passed to parameters
+* declared as out or inout. However, they may not be used as
+* the target of an assignment.
+*
+* From page 32 (page 38 of the PDF) of the GLSL 1.10 spec:
+*
+*Other binary or unary expressions, non-dereferenced arrays,
+* function names, swizzles with repeated fields, and constants
+* cannot be l-values.
+*
+* So we only mark 1.10 as non-lvalues, and check for array
+* assignment in 100 specifically in do_assignment.
+*/
if (var-type-is_array()  state-language_version != 110) {
   var-array_lvalue = true;
}

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


Mesa (master): glsl: Don't do structure splitting until link time.

2011-09-08 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: 60df737ad57c20701b66d7cd3f63d1dc75745986
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=60df737ad57c20701b66d7cd3f63d1dc75745986

Author: Eric Anholt e...@anholt.net
Date:   Wed Sep  7 12:04:57 2011 -0700

glsl: Don't do structure splitting until link time.

We were splitting on each side of an unlinked program, and the two
sides lost track of which variables they referenced, resulting in
assertion failure during validation.  Fixes piglit
link-struct-uniform-usage.

Reviewed-by: Ian Romanick ian.d.roman...@intel.com

---

 src/glsl/glsl_parser_extras.cpp |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index 8f740e6..8faddc5 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -891,8 +891,8 @@ do_common_optimization(exec_list *ir, bool linked, unsigned 
max_unroll_iteration
if (linked) {
   progress = do_function_inlining(ir) || progress;
   progress = do_dead_functions(ir) || progress;
+  progress = do_structure_splitting(ir) || progress;
}
-   progress = do_structure_splitting(ir) || progress;
progress = do_if_simplification(ir) || progress;
progress = do_discard_simplification(ir) || progress;
progress = do_copy_propagation(ir) || progress;

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


Mesa (master): dri2: add __DRI_IMAGE_FORMAT_ABGR8888 to __DRI_IMAGE

2011-09-08 Thread Chia-I Wu
Module: Mesa
Branch: master
Commit: e3cf7b69f24c186310eb3be4c462cccea028e6f2
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e3cf7b69f24c186310eb3be4c462cccea028e6f2

Author: Chia-I Wu o...@lunarg.com
Date:   Sun Aug 21 21:22:41 2011 +0800

dri2: add __DRI_IMAGE_FORMAT_ABGR to __DRI_IMAGE

Add a new format token, __DRI_IMAGE_FORMAT_ABGR, to __DRI_IMAGE.  It
maps to MESA_FORMAT_RGBA_REV in core mesa or
PIPE_FORMAT_R8G8B8A8_UNORM in gallium.  The format is used by
translucent surfaces on Android.

---

 include/GL/internal/dri_interface.h |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/include/GL/internal/dri_interface.h 
b/include/GL/internal/dri_interface.h
index eed159e..8a9ca19 100644
--- a/include/GL/internal/dri_interface.h
+++ b/include/GL/internal/dri_interface.h
@@ -817,6 +817,7 @@ struct __DRIdri2ExtensionRec {
 #define __DRI_IMAGE_FORMAT_RGB565   0x1001
 #define __DRI_IMAGE_FORMAT_XRGB 0x1002
 #define __DRI_IMAGE_FORMAT_ARGB 0x1003
+#define __DRI_IMAGE_FORMAT_ABGR 0x1004
 
 #define __DRI_IMAGE_USE_SHARE  0x0001
 #define __DRI_IMAGE_USE_SCANOUT0x0002

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


Mesa (master): st/dri: add support for __DRI_IMAGE_FORMAT_ABGR8888

2011-09-08 Thread Chia-I Wu
Module: Mesa
Branch: master
Commit: 4f341ee65a7f9017481108861adaf1ed2ca227c5
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4f341ee65a7f9017481108861adaf1ed2ca227c5

Author: Chia-I Wu o...@lunarg.com
Date:   Sun Aug 21 21:39:34 2011 +0800

st/dri: add support for __DRI_IMAGE_FORMAT_ABGR

It maps to PIPE_FORMAT_R8G8B8A8_UNORM.

---

 src/gallium/state_trackers/dri/drm/dri2.c |6 ++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/src/gallium/state_trackers/dri/drm/dri2.c 
b/src/gallium/state_trackers/dri/drm/dri2.c
index 6cf2375..2b6919d 100644
--- a/src/gallium/state_trackers/dri/drm/dri2.c
+++ b/src/gallium/state_trackers/dri/drm/dri2.c
@@ -419,6 +419,9 @@ dri2_create_image_from_name(__DRIscreen *_screen,
case __DRI_IMAGE_FORMAT_ARGB:
   pf = PIPE_FORMAT_B8G8R8A8_UNORM;
   break;
+   case __DRI_IMAGE_FORMAT_ABGR:
+  pf = PIPE_FORMAT_R8G8B8A8_UNORM;
+  break;
default:
   pf = PIPE_FORMAT_NONE;
   break;
@@ -503,6 +506,9 @@ dri2_create_image(__DRIscreen *_screen,
case __DRI_IMAGE_FORMAT_ARGB:
   pf = PIPE_FORMAT_B8G8R8A8_UNORM;
   break;
+   case __DRI_IMAGE_FORMAT_ABGR:
+  pf = PIPE_FORMAT_R8G8B8A8_UNORM;
+  break;
default:
   pf = PIPE_FORMAT_NONE;
   break;

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


Mesa (master): intel: add support for __DRI_IMAGE_FORMAT_ABGR8888

2011-09-08 Thread Chia-I Wu
Module: Mesa
Branch: master
Commit: 9fe197c62611815ebe74248033271ad9fd07ae06
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9fe197c62611815ebe74248033271ad9fd07ae06

Author: Chia-I Wu o...@lunarg.com
Date:   Sun Aug 21 21:36:40 2011 +0800

intel: add support for __DRI_IMAGE_FORMAT_ABGR

It maps to MESA_FORMAT_RGBA_REV.  Surfaces of the format can only be
sampled from but not render to.

Only i915 is tested.

Reviewed-by: Eric Anholt e...@anholt.net

[olv: add a check in intel_image_target_renderbuffer_storage]

---

 src/mesa/drivers/dri/i915/i915_texstate.c|2 ++
 src/mesa/drivers/dri/i965/brw_wm_surface_state.c |4 
 src/mesa/drivers/dri/intel/intel_fbo.c   |   11 +++
 src/mesa/drivers/dri/intel/intel_screen.c|   10 ++
 4 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/src/mesa/drivers/dri/i915/i915_texstate.c 
b/src/mesa/drivers/dri/i915/i915_texstate.c
index 7cd6820..5e789c4 100644
--- a/src/mesa/drivers/dri/i915/i915_texstate.c
+++ b/src/mesa/drivers/dri/i915/i915_texstate.c
@@ -60,6 +60,8 @@ translate_texture_format(gl_format mesa_format, GLenum 
DepthMode)
   return MAPSURF_32BIT | MT_32BIT_ARGB;
case MESA_FORMAT_XRGB:
   return MAPSURF_32BIT | MT_32BIT_XRGB;
+   case MESA_FORMAT_RGBA_REV:
+  return MAPSURF_32BIT | MT_32BIT_ABGR;
case MESA_FORMAT_YCBCR_REV:
   return (MAPSURF_422 | MT_422_YCRCB_NORMAL);
case MESA_FORMAT_YCBCR:
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 ad90978..7528952 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -190,6 +190,10 @@ translate_tex_format(gl_format mesa_format,
   else if (srgb_decode == GL_SKIP_DECODE_EXT)
 return 
brw_format_for_mesa_format(_mesa_get_srgb_format_linear(mesa_format));
 
+   case MESA_FORMAT_RGBA_REV:
+  /* This format is not renderable? */
+  return BRW_SURFACEFORMAT_R8G8B8A8_UNORM;
+
case MESA_FORMAT_RGBA_FLOAT32:
   /* The value of this BRW_SURFACEFORMAT is 0, which tricks the
* assertion below.
diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c 
b/src/mesa/drivers/dri/intel/intel_fbo.c
index 754f9f2..22c5ac2 100644
--- a/src/mesa/drivers/dri/intel/intel_fbo.c
+++ b/src/mesa/drivers/dri/intel/intel_fbo.c
@@ -269,6 +269,17 @@ intel_image_target_renderbuffer_storage(struct gl_context 
*ctx,
if (image == NULL)
   return;
 
+   /* __DRIimage is opaque to the core so it has to be checked here */
+   switch (image-format) {
+   case MESA_FORMAT_RGBA_REV:
+  _mesa_error(intel-ctx, GL_INVALID_OPERATION,
+glEGLImageTargetRenderbufferStorage(unsupported image format);
+  return;
+  break;
+   default:
+  break;
+   }
+
irb = intel_renderbuffer(rb);
intel_region_reference(irb-region, image-region);
 
diff --git a/src/mesa/drivers/dri/intel/intel_screen.c 
b/src/mesa/drivers/dri/intel/intel_screen.c
index bd8d574..2909486 100644
--- a/src/mesa/drivers/dri/intel/intel_screen.c
+++ b/src/mesa/drivers/dri/intel/intel_screen.c
@@ -152,6 +152,11 @@ intel_create_image_from_name(__DRIscreen *screen,
image-internal_format = GL_RGBA;
image-data_type = GL_UNSIGNED_BYTE;
break;
+case __DRI_IMAGE_FORMAT_ABGR:
+   image-format = MESA_FORMAT_RGBA_REV;
+   image-internal_format = GL_RGBA;
+   image-data_type = GL_UNSIGNED_BYTE;
+   break;
 default:
free(image);
return NULL;
@@ -246,6 +251,11 @@ intel_create_image(__DRIscreen *screen,
   image-internal_format = GL_RGBA;
   image-data_type = GL_UNSIGNED_BYTE;
   break;
+case __DRI_IMAGE_FORMAT_ABGR:
+   image-format = MESA_FORMAT_RGBA_REV;
+   image-internal_format = GL_RGBA;
+   image-data_type = GL_UNSIGNED_BYTE;
+   break;
default:
   free(image);
   return NULL;

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


Mesa (master): egl_dri2: add support for RGBA_8888 android native buffer

2011-09-08 Thread Chia-I Wu
Module: Mesa
Branch: master
Commit: 48eb1fe6f9bca74364cf43c36e48ff3fd7cd53f5
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=48eb1fe6f9bca74364cf43c36e48ff3fd7cd53f5

Author: Chia-I Wu o...@lunarg.com
Date:   Sun Aug 21 21:34:10 2011 +0800

egl_dri2: add support for RGBA_ android native buffer

HAL_PIXEL_FORMAT_RGBA_ maps to __DRI_IMAGE_FORMAT_ABGR.

---

 src/egl/drivers/dri2/platform_android.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/src/egl/drivers/dri2/platform_android.c 
b/src/egl/drivers/dri2/platform_android.c
index a0e4c65..3abd536 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -308,6 +308,8 @@ dri2_create_image_android_native_buffer(_EGLDisplay *disp,
   format = __DRI_IMAGE_FORMAT_RGB565;
   break;
case HAL_PIXEL_FORMAT_RGBA_:
+  format = __DRI_IMAGE_FORMAT_ABGR;
+  break;
case HAL_PIXEL_FORMAT_RGBX_:
case HAL_PIXEL_FORMAT_RGB_888:
case HAL_PIXEL_FORMAT_RGBA_5551:

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


Mesa (master): i965/vs: Add annotation to more of the URB write.

2011-09-08 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: 6af968b6736c87c05ea579df50e23b6f23b900d4
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6af968b6736c87c05ea579df50e23b6f23b900d4

Author: Eric Anholt e...@anholt.net
Date:   Tue Sep  6 13:29:21 2011 -0700

i965/vs: Add annotation to more of the URB write.

While we had nice debug output for most of the instruction stream, it
was terminated by a series of anonymous MOVs and a send.

Reviewed-by: Ian Romanick ian.d.roman...@intel.com
Reviewed-by: Kenneth Graunke kenn...@whitecape.org

---

 src/mesa/drivers/dri/i965/brw_vec4.h   |1 +
 src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp |5 -
 2 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h 
b/src/mesa/drivers/dri/i965/brw_vec4.h
index 67b509a..0bfd88b 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h
@@ -361,6 +361,7 @@ public:
 * for the ir-location's used.
 */
dst_reg output_reg[BRW_VERT_RESULT_MAX];
+   const char *output_reg_annotation[BRW_VERT_RESULT_MAX];
int uniform_size[MAX_UNIFORMS];
int uniform_vector_size[MAX_UNIFORMS];
int uniforms;
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
index dac8cf9..afbd8d9 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
@@ -800,6 +800,7 @@ vec4_visitor::visit(ir_variable *ir)
 output_reg[ir-location + i] = *reg;
 output_reg[ir-location + i].reg_offset = i;
 output_reg[ir-location + i].type = BRW_REGISTER_TYPE_F;
+output_reg_annotation[ir-location + i] = ir-name;
   }
   break;
 
@@ -1856,7 +1857,7 @@ vec4_visitor::emit_urb_slot(int mrf, int vert_result)
   break;
default: {
   assert (vert_result  VERT_RESULT_MAX);
-  current_annotation = NULL;
+  current_annotation = output_reg_annotation[vert_result];
   /* Copy the register, saturating if necessary */
   vec4_instruction *inst = emit(MOV(reg,
 src_reg(output_reg[vert_result])));
@@ -1947,6 +1948,7 @@ vec4_visitor::emit_urb_writes()
   }
}
 
+   current_annotation = URB write;
vec4_instruction *inst = emit(VS_OPCODE_URB_WRITE);
inst-base_mrf = base_mrf;
inst-mlen = align_interleaved_urb_mlen(brw, mrf - base_mrf);
@@ -1962,6 +1964,7 @@ vec4_visitor::emit_urb_writes()
  emit_urb_slot(mrf++, c-vue_map.slot_to_vert_result[slot]);
   }
 
+  current_annotation = URB write;
   inst = emit(VS_OPCODE_URB_WRITE);
   inst-base_mrf = base_mrf;
   inst-mlen = align_interleaved_urb_mlen(brw, mrf - base_mrf);

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


Mesa (master): i965/vs: Fix variable indexed array access with more than one array.

2011-09-08 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: 27c03cb86aa9149d001eefb3cf1e67a97f5bc886
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=27c03cb86aa9149d001eefb3cf1e67a97f5bc886

Author: Eric Anholt e...@anholt.net
Date:   Tue Sep  6 17:46:25 2011 -0700

i965/vs: Fix variable indexed array access with more than one array.

The offset to the arrays after the first was mis-scaled, so we'd go
access off the end of the surface and read 0s.  Fixes
glsl-vs-uniform-array-3.

Reviewed-by: Ian Romanick ian.d.roman...@intel.com
Acked-by: Kenneth Graunke kenn...@whitecape.org

---

 src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
index afbd8d9..c50a722 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
@@ -2211,7 +2211,7 @@ 
vec4_visitor::move_uniform_array_access_to_pull_constants()
 if (pull_constant_loc[uniform] == -1) {
const float **values = prog_data-param[uniform * 4];
 
-   pull_constant_loc[uniform] = prog_data-nr_pull_params;
+   pull_constant_loc[uniform] = prog_data-nr_pull_params / 4;
 
for (int j = 0; j  uniform_size[uniform] * 4; j++) {
   prog_data-pull_param[prog_data-nr_pull_params++] = values[j];

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


Mesa (master): i965/vs: When failing due to lack of spilling, don' t continue on.

2011-09-08 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: 14081695137c095f0a8430779ecb09165bec6455
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=14081695137c095f0a8430779ecb09165bec6455

Author: Eric Anholt e...@anholt.net
Date:   Wed Sep  7 10:32:20 2011 -0700

i965/vs: When failing due to lack of spilling, don't continue on.

Fixes assertion failure from double-free in oglc
glsl-arrayobject constructor.declaration.structure

Reviewed-by: Ian Romanick ian.d.roman...@intel.com
Reviewed-by: Kenneth Graunke kenn...@whitecape.org

---

 .../drivers/dri/i965/brw_vec4_reg_allocate.cpp |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_vec4_reg_allocate.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4_reg_allocate.cpp
index 9fd4922..1ace91f 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_reg_allocate.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_reg_allocate.cpp
@@ -205,6 +205,7 @@ vec4_visitor::reg_allocate()
if (!ra_allocate_no_spills(g)) {
   ralloc_free(g);
   fail(No register spilling support yet\n);
+  return;
}
 
/* Get the chosen virtual registers for each node, and map virtual

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


Mesa (master): i965/vs: Pack uniform registers before optimization

2011-09-08 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: f3ed973f53d2a621d915de2cdc8e09c0755db016
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f3ed973f53d2a621d915de2cdc8e09c0755db016

Author: Eric Anholt e...@anholt.net
Date:   Tue Sep  6 22:13:20 2011 -0700

i965/vs: Pack uniform registers before optimization

We don't expect uniform accesses to generally go away from being dead
code at this point, and we will want to have uniforms packed before
spilling them out to pull constants when we are forced to do that.

Reviewed-by: Ian Romanick ian.d.roman...@intel.com
Acked-by: Kenneth Graunke kenn...@whitecape.org

---

 src/mesa/drivers/dri/i965/brw_vec4_emit.cpp |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp
index 30bb0f6..3567949 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp
@@ -607,6 +607,7 @@ vec4_visitor::run()
 */
move_grf_array_access_to_scratch();
move_uniform_array_access_to_pull_constants();
+   pack_uniform_registers();
 
bool progress;
do {
@@ -614,7 +615,6 @@ vec4_visitor::run()
   progress = dead_code_eliminate() || progress;
} while (progress);
 
-   pack_uniform_registers();
 
if (failed)
   return false;

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


Mesa (master): i965/vs: Switch to the new VS backend by default.

2011-09-08 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: d7c6c8428c9908047c88f2672cd1edf6ba60f785
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d7c6c8428c9908047c88f2672cd1edf6ba60f785

Author: Eric Anholt e...@anholt.net
Date:   Tue Sep  6 18:03:43 2011 -0700

i965/vs: Switch to the new VS backend by default.

Now instead of env INTEL_NEW_VS=1 to get it, you need INTEL_OLD_VS=1
to not get it.  While it's not quite to the same codegen efficiency as
the old backend, it is not regressing piglit on G965 and G45, and
actually fixing bugs on gen6, and the remaining codegen quality
regressions all appear tractable.

Reviewed-by: Ian Romanick ian.d.roman...@intel.com
Reviewed-by: Kenneth Graunke kenn...@whitecape.org

---

 src/mesa/drivers/dri/i965/brw_context.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.c 
b/src/mesa/drivers/dri/i965/brw_context.c
index 5ea7385..cb37319 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -248,7 +248,7 @@ GLboolean brwCreateContext( int api,
 
brw_draw_init( brw );
 
-   brw-new_vs_backend = (getenv(INTEL_NEW_VS) != NULL);
+   brw-new_vs_backend = (getenv(INTEL_OLD_VS) == NULL);
 
/* If we're using the new shader backend, we require integer uniforms
 * stored as actual integers.

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


Mesa (master): i965/vs: Keep track of indices into a per-register array for virtual GRFs.

2011-09-08 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: 87b51fc4a807616eaab0c4b38e41c328c08875e3
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=87b51fc4a807616eaab0c4b38e41c328c08875e3

Author: Eric Anholt e...@anholt.net
Date:   Thu Sep  1 08:34:18 2011 -0700

i965/vs: Keep track of indices into a per-register array for virtual GRFs.

Tracking virtual GRFs has tension between using a packed array per
virtual GRF (which is good for register allocation), and sparse arrays
where there's an element per actual register (so the first and second
column of a mat2 can be distinguished inside of an optimization pass).

The FS mostly avoided the need for this second sparse array by doing
virtual GRF splitting, but that meant that instances where virtual GRF
splitting didn't work, instructions using those registers got much
less optimized.

---

 src/mesa/drivers/dri/i965/brw_vec4.h   |9 +
 src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp |6 ++
 2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h 
b/src/mesa/drivers/dri/i965/brw_vec4.h
index 1597f98..f148ca6 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h
@@ -320,6 +320,15 @@ public:
int first_non_payload_grf;
int *virtual_grf_def;
int *virtual_grf_use;
+
+   /**
+* This is the size to be used for an array with an element per
+* reg_offset
+*/
+   int virtual_grf_reg_count;
+   /** Per-virtual-grf indices into an array of size virtual_grf_reg_count */
+   int *virtual_grf_reg_map;
+
bool live_intervals_valid;
 
dst_reg *variable_storage(ir_variable *var);
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
index c50a722..83f543f 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
@@ -432,7 +432,11 @@ vec4_visitor::virtual_grf_alloc(int size)
 virtual_grf_array_size *= 2;
   virtual_grf_sizes = reralloc(mem_ctx, virtual_grf_sizes, int,
   virtual_grf_array_size);
+  virtual_grf_reg_map = reralloc(mem_ctx, virtual_grf_reg_map, int,
+virtual_grf_array_size);
}
+   virtual_grf_reg_map[virtual_grf_count] = virtual_grf_reg_count;
+   virtual_grf_reg_count += size;
virtual_grf_sizes[virtual_grf_count] = size;
return virtual_grf_count++;
 }
@@ -2272,6 +2276,8 @@ vec4_visitor::vec4_visitor(struct brw_vs_compile *c,
this-virtual_grf_use = NULL;
this-virtual_grf_sizes = NULL;
this-virtual_grf_count = 0;
+   this-virtual_grf_reg_map = NULL;
+   this-virtual_grf_reg_count = 0;
this-virtual_grf_array_size = 0;
this-live_intervals_valid = false;
 

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


Mesa (master): i965/vs: Add constant propagation to a few opcodes.

2011-09-08 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: 42ce13195b94d0d51ca8e7fa5eed07fde8f37988
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=42ce13195b94d0d51ca8e7fa5eed07fde8f37988

Author: Eric Anholt e...@anholt.net
Date:   Tue Aug 30 13:25:15 2011 -0700

i965/vs: Add constant propagation to a few opcodes.

This differs from the FS in that we track constants in each
destination channel, and we we have to look at all the swizzled source
channels.  Also, the instruction stream walk is done in an O(n) manner
instead of O(n^2).

Across shader-db, this reduces 8.0% of the instructions from 60.0% of
the vertex shaders, leaving us now behind the old backend by 11.1%
overall.

---

 src/mesa/drivers/dri/i965/Makefile.sources |1 +
 src/mesa/drivers/dri/i965/brw_vec4.cpp |   16 ++
 src/mesa/drivers/dri/i965/brw_vec4.h   |3 +
 .../drivers/dri/i965/brw_vec4_copy_propagation.cpp |  260 
 src/mesa/drivers/dri/i965/brw_vec4_emit.cpp|1 +
 5 files changed, 281 insertions(+), 0 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/Makefile.sources 
b/src/mesa/drivers/dri/i965/Makefile.sources
index 6917286..da7a952 100644
--- a/src/mesa/drivers/dri/i965/Makefile.sources
+++ b/src/mesa/drivers/dri/i965/Makefile.sources
@@ -119,6 +119,7 @@ i965_CXX_SOURCES := \
brw_shader.cpp \
brw_vec4.cpp \
brw_vec4_emit.cpp \
+   brw_vec4_copy_propagation.cpp \
brw_vec4_reg_allocate.cpp \
brw_vec4_visitor.cpp
 
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4.cpp
index e3562d2..656589d 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp
@@ -31,6 +31,22 @@ extern C {
 
 namespace brw {
 
+bool
+src_reg::equals(src_reg *r)
+{
+   return (file == r-file 
+  reg == r-reg 
+  reg_offset == r-reg_offset 
+  type == r-type 
+  negate == r-negate 
+  abs == r-abs 
+  swizzle == r-swizzle 
+  !reladdr  !r-reladdr 
+  memcmp(fixed_hw_reg, r-fixed_hw_reg,
+ sizeof(fixed_hw_reg)) == 0 
+  imm.u == r-imm.u);
+}
+
 void
 vec4_visitor::calculate_live_intervals()
 {
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h 
b/src/mesa/drivers/dri/i965/brw_vec4.h
index f148ca6..545e8f1 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h
@@ -162,6 +162,8 @@ public:
   this-imm.i = i;
}
 
+   bool equals(src_reg *r);
+
src_reg(class vec4_visitor *v, const struct glsl_type *type);
 
explicit src_reg(dst_reg reg);
@@ -396,6 +398,7 @@ public:
void calculate_live_intervals();
bool dead_code_eliminate();
bool virtual_grf_interferes(int a, int b);
+   bool opt_copy_propagation();
 
vec4_instruction *emit(vec4_instruction *inst);
 
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp
new file mode 100644
index 000..1e24e2e
--- /dev/null
+++ b/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp
@@ -0,0 +1,260 @@
+/*
+ * Copyright © 2011 Intel Corporation
+ *
+ * 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, sublicense,
+ * 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 NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS 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 brw_vec4_copy_propagation.cpp
+ *
+ * Implements tracking of values copied between registers, and
+ * optimizations based on that: copy propagation and constant
+ * propagation.
+ */
+
+#include brw_vec4.h
+extern C {
+#include main/macros.h
+}
+
+namespace brw {
+
+static bool
+is_direct_copy(vec4_instruction *inst)
+{
+   return (inst-opcode == BRW_OPCODE_MOV 
+  !inst-predicate 
+  inst-dst.file == GRF 
+  !inst-saturate 
+  !inst-dst.reladdr 
+  !inst-src[0].reladdr 
+  inst-dst.type == inst-src[0].type);
+}
+
+static bool
+is_dominated_by_previous_instruction(vec4_instruction *inst)
+{
+   return (inst-opcode != 

Mesa (master): i965/vs: Add support for copy propagation of the UNIFORM and ATTR files.

2011-09-08 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: cc9eb936c220267b6130b705fc696d05906a31df
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=cc9eb936c220267b6130b705fc696d05906a31df

Author: Eric Anholt e...@anholt.net
Date:   Thu Sep  1 16:21:14 2011 -0700

i965/vs: Add support for copy propagation of the UNIFORM and ATTR files.

Removes 2.0% of the instructions from 35.7% of vertex shaders in shader-db.

---

 src/mesa/drivers/dri/i965/brw_vec4.cpp |   13 +
 src/mesa/drivers/dri/i965/brw_vec4.h   |2 +
 .../drivers/dri/i965/brw_vec4_copy_propagation.cpp |   58 +++-
 3 files changed, 72 insertions(+), 1 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4.cpp
index 656589d..436de2f 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp
@@ -32,6 +32,19 @@ extern C {
 namespace brw {
 
 bool
+vec4_instruction::is_math()
+{
+   return (opcode == SHADER_OPCODE_RCP ||
+  opcode == SHADER_OPCODE_RSQ ||
+  opcode == SHADER_OPCODE_SQRT ||
+  opcode == SHADER_OPCODE_EXP2 ||
+  opcode == SHADER_OPCODE_LOG2 ||
+  opcode == SHADER_OPCODE_SIN ||
+  opcode == SHADER_OPCODE_COS ||
+  opcode == SHADER_OPCODE_POW);
+}
+
+bool
 src_reg::equals(src_reg *r)
 {
return (file == r-file 
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h 
b/src/mesa/drivers/dri/i965/brw_vec4.h
index 545e8f1..7739a15 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h
@@ -275,6 +275,8 @@ public:
 */
ir_instruction *ir;
const char *annotation;
+
+   bool is_math();
 };
 
 class vec4_visitor : public ir_visitor
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp
index 1e24e2e..4b33df1 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp
@@ -153,6 +153,61 @@ try_constant_propagation(vec4_instruction *inst, int arg, 
src_reg *values[4])
return false;
 }
 
+static bool
+try_copy_propagation(struct intel_context *intel,
+vec4_instruction *inst, int arg, src_reg *values[4])
+{
+   /* For constant propagation, we only handle the same constant
+* across all 4 channels.  Some day, we should handle the 8-bit
+* float vector format, which would let us constant propagate
+* vectors better.
+*/
+   src_reg value = *values[0];
+   for (int i = 1; i  4; i++) {
+  /* This is equals() except we don't care about the swizzle. */
+  if (value.file != values[i]-file ||
+ value.reg != values[i]-reg ||
+ value.reg_offset != values[i]-reg_offset ||
+ value.type != values[i]-type ||
+ value.negate != values[i]-negate ||
+ value.abs != values[i]-abs) {
+return false;
+  }
+   }
+
+   /* Compute the swizzle of the original register by swizzling the
+* component loaded from each value according to the swizzle of
+* operand we're going to change.
+*/
+   int s[4];
+   for (int i = 0; i  4; i++) {
+  s[i] = BRW_GET_SWZ(values[i]-swizzle,
+BRW_GET_SWZ(inst-src[arg].swizzle, i));
+   }
+   value.swizzle = BRW_SWIZZLE4(s[0], s[1], s[2], s[3]);
+
+   if (value.file != UNIFORM 
+   value.file != ATTR)
+  return false;
+
+   if (inst-src[arg].abs) {
+  value.negate = false;
+  value.abs = true;
+   }
+   if (inst-src[arg].negate)
+  value.negate = true;
+
+   /* FINISHME: We can't copy-propagate things that aren't normal
+* vec8s into gen6 math instructions, because of the weird src
+* handling for those instructions.  Just ignore them for now.
+*/
+   if (intel-gen = 6  inst-is_math())
+  return false;
+
+   inst-src[arg] = value;
+   return true;
+}
+
 bool
 vec4_visitor::opt_copy_propagation()
 {
@@ -216,7 +271,8 @@ vec4_visitor::opt_copy_propagation()
 if (c != 4)
continue;
 
-if (try_constant_propagation(inst, i, values))
+if (try_constant_propagation(inst, i, values) ||
+try_copy_propagation(intel, inst, i, values))
progress = true;
   }
 

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


Mesa (master): i965/vs: Clear tracked copy propagation values whose source gets overwritten.

2011-09-08 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: 6d0c018776977219e355c534eaafec53a30d993b
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6d0c018776977219e355c534eaafec53a30d993b

Author: Eric Anholt e...@anholt.net
Date:   Thu Sep  1 16:40:07 2011 -0700

i965/vs: Clear tracked copy propagation values whose source gets overwritten.

This only occurs for GRFs, and hasn't mattered until now because we
only copy propagated non-GRFs.

---

 .../drivers/dri/i965/brw_vec4_copy_propagation.cpp |   15 ---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp
index 4b33df1..7862d78 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp
@@ -289,9 +289,6 @@ vec4_visitor::opt_copy_propagation()
 
   /* For any updated channels, clear tracking of them as a source
* or destination.
-   *
-   * FINISHME: Sources aren't handled, which will need to be done
-   * for copy propagation.
*/
   if (inst-dst.file == GRF) {
 if (inst-dst.reladdr)
@@ -303,6 +300,18 @@ vec4_visitor::opt_copy_propagation()
   if (inst-dst.writemask  (1  i))
  cur_value[reg][i] = NULL;
}
+
+   for (int i = 0; i  virtual_grf_reg_count; i++) {
+  for (int j = 0; j  4; j++) {
+ if (inst-dst.writemask  (1  i) 
+ cur_value[i][j] 
+ cur_value[i][j]-file == GRF 
+ cur_value[i][j]-reg == inst-dst.reg 
+ cur_value[i][j]-reg == inst-dst.reg) {
+cur_value[i][j] = NULL;
+ }
+  }
+   }
 }
   }
}

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


Mesa (master): i965/vs: Allow copy propagation on GRFs.

2011-09-08 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: 29361e14df8e5e92df747d52303da2c454e2cacc
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=29361e14df8e5e92df747d52303da2c454e2cacc

Author: Eric Anholt e...@anholt.net
Date:   Thu Sep  1 16:43:38 2011 -0700

i965/vs: Allow copy propagation on GRFs.

Further reduces instruction count by 4.0% in 40.7% of the vertex
shaders.

---

 .../drivers/dri/i965/brw_vec4_copy_propagation.cpp |7 ++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp
index 7862d78..c46735a 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp
@@ -187,6 +187,7 @@ try_copy_propagation(struct intel_context *intel,
value.swizzle = BRW_SWIZZLE4(s[0], s[1], s[2], s[3]);
 
if (value.file != UNIFORM 
+   value.file != GRF 
value.file != ATTR)
   return false;
 
@@ -204,6 +205,10 @@ try_copy_propagation(struct intel_context *intel,
if (intel-gen = 6  inst-is_math())
   return false;
 
+   /* Don't report progress if this is a noop. */
+   if (value.equals(inst-src[arg]))
+  return false;
+
inst-src[arg] = value;
return true;
 }
@@ -307,7 +312,7 @@ vec4_visitor::opt_copy_propagation()
  cur_value[i][j] 
  cur_value[i][j]-file == GRF 
  cur_value[i][j]-reg == inst-dst.reg 
- cur_value[i][j]-reg == inst-dst.reg) {
+ cur_value[i][j]-reg_offset == inst-dst.reg_offset) {
 cur_value[i][j] = NULL;
  }
   }

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