[Mesa-dev] [PATCH 00/11] Add YUYV format support of dri image

2012-07-09 Thread Zhao Halley
Intel SNB/IVB platform supports rendering YUYV buffer to overlay plane, however 
YUYV is missing support from mesa/dri-image yet.
so I go ahead to add it; basing on it, libva can send YUYV buffer directly to 
wayland/weston, then weston output it to overlay plane.

v2 update:
- set internal_format to GL_YCBCR_MESA
- improve gbm/intel-driver to support YUYV bo generation, 
  add handle2 (intel buffer name) in gbm
  buffer data update (intel_image_write with tiling support)
- update test case to depend on gbm instead of intel driver directly

v3 update:
- move wayland-drm-test to $mesa/src/egl/wayland/wayland-drm/drm-test-client
- add YUYV support to eglCreateDRMImageMesa/eglExportDRMImageMesa 
  and eglCreateImageKHR
- add egl-create-drm-image test to piglit

v4 update:
- gbm: change gbm_bo_get_handle2() to gbm_bo_get_shared_handle(), 
- gbm: allocate region name only when it is asked
- drm-test-client update according to above change: gbm_bo_get_shared_handle

v5 update:
- rebase to latest git tree for check in, 0002/0003 patches are updated.


Zhao Halley (10):
  GL: add YUYV to dri image format
  intel: add YUYV format for dri images
  egl wayland: add YUYV support
  gallium egl wayland: add YUYV support
  gbm dri backend: add YUYV support
  wayland-drm: add YUYV support
  gbm: add shared_handle(drm buffer region name)
  intel driver: dri image write update
  test: test case drm-test-client in src/egl/wayland/wayland-drm
  EGL: add YUYV support to eglCreateImageKHR and eglCreateDRMImageMESA

 include/EGL/eglmesaext.h   |3 +
 include/GL/internal/dri_interface.h|1 +
 src/egl/drivers/dri2/egl_dri2.c|9 +-
 src/egl/drivers/dri2/platform_wayland.c|7 +-
 src/egl/wayland/wayland-drm/Makefile.am|   15 +-
 src/egl/wayland/wayland-drm/drm-test-client.c  |  456 
 src/egl/wayland/wayland-drm/wayland-drm.c  |3 +
 .../state_trackers/egl/wayland/native_drm.c|3 +
 .../state_trackers/egl/wayland/native_wayland.h|3 +-
 src/gbm/backends/dri/gbm_dri.c |   22 +
 src/gbm/main/gbm.c |   18 +
 src/gbm/main/gbm.h |8 +-
 src/gbm/main/gbmint.h  |2 +
 src/mesa/drivers/dri/intel/intel_screen.c  |   20 +-
 src/mesa/drivers/dri/intel/intel_tex_image.c   |6 +
 15 files changed, 569 insertions(+), 7 deletions(-)
 mode change 100644 = 100755 include/EGL/eglext.h
 mode change 100644 = 100755 include/EGL/eglmesaext.h
 mode change 100644 = 100755 include/GL/internal/dri_interface.h
 mode change 100644 = 100755 src/egl/drivers/dri2/platform_wayland.c
 create mode 100755 src/egl/wayland/wayland-drm/drm-test-client.c
 mode change 100644 = 100755 src/egl/wayland/wayland-drm/wayland-drm.c
 mode change 100644 = 100755 
src/gallium/state_trackers/egl/wayland/native_drm.c
 mode change 100644 = 100755 
src/gallium/state_trackers/egl/wayland/native_wayland.h
 mode change 100644 = 100755 src/gbm/backends/dri/gbm_dri.c
 mode change 100644 = 100755 src/gbm/main/gbm.c
 mode change 100644 = 100755 src/gbm/main/gbm.h
 mode change 100644 = 100755 src/gbm/main/gbmint.h
 mode change 100644 = 100755 src/mesa/drivers/dri/intel/intel_screen.c
 mode change 100644 = 100755 src/mesa/drivers/dri/intel/intel_tex_image.c

-- 
1.7.4.1

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


[Mesa-dev] [PATCH 01/11 v5] GL: add YUYV to dri image format

2012-07-09 Thread Zhao Halley
---
 include/GL/internal/dri_interface.h |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
 mode change 100644 = 100755 include/GL/internal/dri_interface.h

diff --git a/include/GL/internal/dri_interface.h 
b/include/GL/internal/dri_interface.h
old mode 100644
new mode 100755
index e37917e..5e325cf
--- a/include/GL/internal/dri_interface.h
+++ b/include/GL/internal/dri_interface.h
@@ -907,6 +907,7 @@ struct __DRIdri2ExtensionRec {
 #define __DRI_IMAGE_FORMAT_ARGB 0x1003
 #define __DRI_IMAGE_FORMAT_ABGR 0x1004
 #define __DRI_IMAGE_FORMAT_XBGR 0x1005
+#define __DRI_IMAGE_FORMAT_YUYV 0x1006
 
 #define __DRI_IMAGE_USE_SHARE  0x0001
 #define __DRI_IMAGE_USE_SCANOUT0x0002
-- 
1.7.4.1

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


[Mesa-dev] [PATCH 04/11 v5] gallium egl wayland: add YUYV support

2012-07-09 Thread Zhao Halley
---
 .../state_trackers/egl/wayland/native_drm.c|3 +++
 .../state_trackers/egl/wayland/native_wayland.h|3 ++-
 2 files changed, 5 insertions(+), 1 deletions(-)
 mode change 100644 = 100755 
src/gallium/state_trackers/egl/wayland/native_drm.c
 mode change 100644 = 100755 
src/gallium/state_trackers/egl/wayland/native_wayland.h

diff --git a/src/gallium/state_trackers/egl/wayland/native_drm.c 
b/src/gallium/state_trackers/egl/wayland/native_drm.c
old mode 100644
new mode 100755
index e3bd628..f2d2e74
--- a/src/gallium/state_trackers/egl/wayland/native_drm.c
+++ b/src/gallium/state_trackers/egl/wayland/native_drm.c
@@ -164,6 +164,9 @@ drm_handle_format(void *data, struct wl_drm *drm, uint32_t 
format)
case WL_DRM_FORMAT_XRGB:
   drmdpy-base.formats |= HAS_XRGB;
   break;
+  case WL_DRM_FORMAT_YUYV:
+ drmdpy-base.formats |= HAS_YUYV;
+ break;
}
 }
 
diff --git a/src/gallium/state_trackers/egl/wayland/native_wayland.h 
b/src/gallium/state_trackers/egl/wayland/native_wayland.h
old mode 100644
new mode 100755
index e6a914f..bd26bf0
--- a/src/gallium/state_trackers/egl/wayland/native_wayland.h
+++ b/src/gallium/state_trackers/egl/wayland/native_wayland.h
@@ -38,7 +38,8 @@ struct wayland_surface;
 
 enum wayland_format_flag {
HAS_ARGB= (1  0),
-   HAS_XRGB= (1  1)
+   HAS_XRGB= (1  1),
+   HAS_YUYV= (1  2)
 };
 
 struct wayland_display {
-- 
1.7.4.1

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


[Mesa-dev] [PATCH 02/11 v5] intel: add YUYV format for dri images

2012-07-09 Thread Zhao Halley
YUYV image works for overlay now
YUYV image works for texture will come soon
---
 src/mesa/drivers/dri/intel/intel_screen.c|3 +++
 src/mesa/drivers/dri/intel/intel_tex_image.c |6 ++
 2 files changed, 9 insertions(+), 0 deletions(-)
 mode change 100644 = 100755 src/mesa/drivers/dri/intel/intel_screen.c
 mode change 100644 = 100755 src/mesa/drivers/dri/intel/intel_tex_image.c

diff --git a/src/mesa/drivers/dri/intel/intel_screen.c 
b/src/mesa/drivers/dri/intel/intel_screen.c
old mode 100644
new mode 100755
index 2b70aa4..644ec5b
--- a/src/mesa/drivers/dri/intel/intel_screen.c
+++ b/src/mesa/drivers/dri/intel/intel_screen.c
@@ -202,6 +202,9 @@ intel_allocate_image(int dri_format, void *loaderPrivate)
 case __DRI_IMAGE_FORMAT_XBGR:
image-format = MESA_FORMAT_RGBX_REV;
break;
+case __DRI_IMAGE_FORMAT_YUYV:
+   image-format = MESA_FORMAT_YCBCR;
+   break;
 default:
free(image);
return NULL;
diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c 
b/src/mesa/drivers/dri/intel/intel_tex_image.c
old mode 100644
new mode 100755
index 6e7e7018..ee9b857
--- a/src/mesa/drivers/dri/intel/intel_tex_image.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_image.c
@@ -346,6 +346,12 @@ intel_image_target_texture_2d(struct gl_context *ctx, 
GLenum target,
if (image == NULL)
   return;
 
+   if (image-format == MESA_FORMAT_YCBCR) {
+  _mesa_error(intel-ctx, GL_INVALID_OPERATION, 
+glEGLImageTargetTexture2DOES, YUYV format isn't supported yet);
+  return;
+}
+
intel_set_texture_image_region(ctx, texImage, image-region,
  target, image-internal_format, 
image-format);
 }
-- 
1.7.4.1

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


[Mesa-dev] [PATCH 05/11 v5] gbm dri backend: add YUYV support

2012-07-09 Thread Zhao Halley
---
 src/gbm/backends/dri/gbm_dri.c |9 +
 src/gbm/main/gbm.h |5 -
 2 files changed, 13 insertions(+), 1 deletions(-)
 mode change 100644 = 100755 src/gbm/backends/dri/gbm_dri.c
 mode change 100644 = 100755 src/gbm/main/gbm.h

diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
old mode 100644
new mode 100755
index e5ddfb6..9e2bd83
--- a/src/gbm/backends/dri/gbm_dri.c
+++ b/src/gbm/backends/dri/gbm_dri.c
@@ -280,6 +280,9 @@ gbm_dri_is_format_supported(struct gbm_device *gbm,
   if (usage  GBM_BO_USE_SCANOUT)
  return 0;
   break;
+  case GBM_BO_FORMAT_YUYV:
+  case GBM_FORMAT_YUYV:
+ break;
default:
   return 0;
}
@@ -331,6 +334,9 @@ gbm_dri_to_gbm_format(uint32_t dri_format)
case __DRI_IMAGE_FORMAT_ABGR:
   ret = GBM_FORMAT_ABGR;
   break;
+  case __DRI_IMAGE_FORMAT_YUYV:
+ ret = GBM_FORMAT_YUYV;
+ break;
default:
   ret = 0;
   break;
@@ -428,6 +434,9 @@ gbm_dri_bo_create(struct gbm_device *gbm,
case GBM_FORMAT_ABGR:
   dri_format = __DRI_IMAGE_FORMAT_ABGR;
   break;
+  case GBM_FORMAT_YUYV:
+ dri_format = __DRI_IMAGE_FORMAT_YUYV;
+ break;
default:
   return NULL;
}
diff --git a/src/gbm/main/gbm.h b/src/gbm/main/gbm.h
old mode 100644
new mode 100755
index af5dc5a..b2a0aa3
--- a/src/gbm/main/gbm.h
+++ b/src/gbm/main/gbm.h
@@ -73,7 +73,10 @@ enum gbm_bo_format {
/** RGB with 8 bits per channel in a 32 bit value */
GBM_BO_FORMAT_XRGB, 
/** ARGB with 8 bits per channel in a 32 bit value */
-   GBM_BO_FORMAT_ARGB
+   GBM_BO_FORMAT_ARGB, 
+   /** YUYV: packed YUV format with 422 subsampling*/
+   GBM_BO_FORMAT_YUYV,
+   
 };
 
 #define __gbm_fourcc_code(a,b,c,d) ((uint32_t)(a) | ((uint32_t)(b)  8) | \
-- 
1.7.4.1

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


[Mesa-dev] [PATCH 03/11 v5] egl wayland: add YUYV support

2012-07-09 Thread Zhao Halley
---
 src/egl/drivers/dri2/platform_wayland.c |7 ++-
 1 files changed, 6 insertions(+), 1 deletions(-)
 mode change 100644 = 100755 src/egl/drivers/dri2/platform_wayland.c

diff --git a/src/egl/drivers/dri2/platform_wayland.c 
b/src/egl/drivers/dri2/platform_wayland.c
old mode 100644
new mode 100755
index d291f0f..962ee7f
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -42,7 +42,9 @@
 
 enum wl_drm_format_flags {
HAS_ARGB = 1,
-   HAS_XRGB = 2
+   HAS_XRGB = (1  1),
+   HAS_YUYV = (1  2)
+   
 };
 
 static void
@@ -778,6 +780,9 @@ drm_handle_format(void *data, struct wl_drm *drm, uint32_t 
format)
case WL_DRM_FORMAT_XRGB:
   dri2_dpy-formats |= HAS_XRGB;
   break;
+   case WL_DRM_FORMAT_YUYV:
+  dri2_dpy-formats |= HAS_YUYV;
+  break;
}
 }
 
-- 
1.7.4.1

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


[Mesa-dev] [PATCH 07/11 v5] gbm: add shared_handle(drm buffer region name)

2012-07-09 Thread Zhao Halley
  it can be shared among processed
---
 src/gbm/backends/dri/gbm_dri.c |   13 +
 src/gbm/main/gbm.c |   18 ++
 src/gbm/main/gbm.h |3 +++
 src/gbm/main/gbmint.h  |2 ++
 4 files changed, 36 insertions(+), 0 deletions(-)
 mode change 100644 = 100755 src/gbm/main/gbm.c
 mode change 100644 = 100755 src/gbm/main/gbmint.h

diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
index 9e2bd83..0646b47 100755
--- a/src/gbm/backends/dri/gbm_dri.c
+++ b/src/gbm/backends/dri/gbm_dri.c
@@ -345,6 +345,18 @@ gbm_dri_to_gbm_format(uint32_t dri_format)
return ret;
 }
 
+static union gbm_bo_handle
+gbm_dri_bo_get_shared_handle(struct gbm_bo *_bo)
+{
+   struct gbm_dri_device *dri = gbm_dri_device(_bo-gbm);
+   struct gbm_dri_bo *bo = gbm_dri_bo(_bo);
+
+   dri-image-queryImage(bo-image, __DRI_IMAGE_ATTRIB_NAME,
+  (uint32_t *) bo-base.base.shared_handle.u32);
+
+   return bo-base.base.shared_handle;
+}
+
 static struct gbm_bo *
 gbm_dri_bo_create_from_egl_image(struct gbm_device *gbm,
  void *egl_dpy, void *egl_img,
@@ -522,6 +534,7 @@ dri_device_create(int fd)
dri-base.base.destroy = dri_destroy;
dri-base.base.surface_create = gbm_dri_surface_create;
dri-base.base.surface_destroy = gbm_dri_surface_destroy;
+   dri-base.base.bo_get_shared_handle = gbm_dri_bo_get_shared_handle;
 
dri-base.type = GBM_DRM_DRIVER_TYPE_DRI;
dri-base.base.name = drm;
diff --git a/src/gbm/main/gbm.c b/src/gbm/main/gbm.c
old mode 100644
new mode 100755
index 3994f86..017cb2d
--- a/src/gbm/main/gbm.c
+++ b/src/gbm/main/gbm.c
@@ -231,6 +231,24 @@ gbm_bo_get_handle(struct gbm_bo *bo)
return bo-handle;
 }
 
+/** Get shared handle(global buffer region name) of the buffer object, 
+ * this handle can be shared among processes
+ *
+ * This is stored in the platform generic union gbm_bo_handle type. However
+ * the format of this handle is platform specific.
+ *
+ * \param bo The buffer object
+ * \return Returns the handle of the allocated buffer object
+ */
+GBM_EXPORT union gbm_bo_handle
+gbm_bo_get_shared_handle(struct gbm_bo *bo)
+{
+   if (bo-shared_handle.u32) return bo-shared_handle;
+   
+   return bo-gbm-bo_get_shared_handle(bo);
+   
+}
+
 /** Write data into the buffer object
  *
  * If the buffer object was created with the GBM_BO_USE_WRITE flag,
diff --git a/src/gbm/main/gbm.h b/src/gbm/main/gbm.h
index b2a0aa3..68309fb 100755
--- a/src/gbm/main/gbm.h
+++ b/src/gbm/main/gbm.h
@@ -257,6 +257,9 @@ gbm_bo_get_device(struct gbm_bo *bo);
 union gbm_bo_handle
 gbm_bo_get_handle(struct gbm_bo *bo);
 
+union gbm_bo_handle
+gbm_bo_get_shared_handle(struct gbm_bo *bo);
+
 int
 gbm_bo_write(struct gbm_bo *bo, const void *buf, size_t count);
 
diff --git a/src/gbm/main/gbmint.h b/src/gbm/main/gbmint.h
old mode 100644
new mode 100755
index 8eb8671..6327f94
--- a/src/gbm/main/gbmint.h
+++ b/src/gbm/main/gbmint.h
@@ -70,6 +70,7 @@ struct gbm_device {
   void *egl_dpy, void *egl_img,
   uint32_t width, uint32_t height,
   uint32_t usage);
+   union gbm_bo_handle (*bo_get_shared_handle)(struct gbm_bo *bo);
int (*bo_write)(struct gbm_bo *bo, const void *buf, size_t data);
void (*bo_destroy)(struct gbm_bo *bo);
 
@@ -95,6 +96,7 @@ struct gbm_bo {
uint32_t pitch;
uint32_t format;
union gbm_bo_handle  handle;
+   union gbm_bo_handle  shared_handle; // global handle can be shared among 
processes
void *user_data;
void (*destroy_user_data)(struct gbm_bo *, void *);
 };
-- 
1.7.4.1

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


[Mesa-dev] [PATCH 06/11 v5] wayland-drm: add YUYV support

2012-07-09 Thread Zhao Halley
---
 src/egl/wayland/wayland-drm/wayland-drm.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
 mode change 100644 = 100755 src/egl/wayland/wayland-drm/wayland-drm.c

diff --git a/src/egl/wayland/wayland-drm/wayland-drm.c 
b/src/egl/wayland/wayland-drm/wayland-drm.c
old mode 100644
new mode 100755
index 5f831b3..d9cfe09
--- a/src/egl/wayland/wayland-drm/wayland-drm.c
+++ b/src/egl/wayland/wayland-drm/wayland-drm.c
@@ -111,6 +111,7 @@ drm_create_buffer(struct wl_client *client, struct 
wl_resource *resource,
switch (format) {
case WL_DRM_FORMAT_ARGB:
case WL_DRM_FORMAT_XRGB:
+case WL_DRM_FORMAT_YUYV:
break;
default:
wl_resource_post_error(resource,
@@ -186,6 +187,8 @@ bind_drm(struct wl_client *client, void *data, uint32_t 
version, uint32_t id)
   WL_DRM_FORMAT_ARGB);
wl_resource_post_event(resource, WL_DRM_FORMAT,
   WL_DRM_FORMAT_XRGB);
+   wl_resource_post_event(resource, WL_DRM_FORMAT,
+  WL_DRM_FORMAT_YUYV);
 }
 
 struct wl_drm *
-- 
1.7.4.1

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


[Mesa-dev] [PATCH 08/11 v5] intel driver: dri image write update

2012-07-09 Thread Zhao Halley
add tiling support for intel_image_write()
all drm image can be written from app
---
 src/mesa/drivers/dri/intel/intel_screen.c |   17 +++--
 1 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_screen.c 
b/src/mesa/drivers/dri/intel/intel_screen.c
index 644ec5b..fa36a3f 100755
--- a/src/mesa/drivers/dri/intel/intel_screen.c
+++ b/src/mesa/drivers/dri/intel/intel_screen.c
@@ -307,10 +307,13 @@ intel_create_image(__DRIscreen *screen,
   tiling = I915_TILING_NONE;
}
 
+#if 0
+   // add tiling support in intel_image_write(), so all drm images are ok 
for write
/* We only support write for cursor drm images */
if ((use  __DRI_IMAGE_USE_WRITE) 
use != (__DRI_IMAGE_USE_WRITE | __DRI_IMAGE_USE_CURSOR))
   return NULL;
+#endif
 
image = intel_allocate_image(format, loaderPrivate);
image-usage = use;
@@ -393,9 +396,19 @@ intel_image_write(__DRIimage *image, const void *buf, 
size_t count)
if (!(image-usage  __DRI_IMAGE_USE_WRITE))
   return -1;
 
-   drm_intel_bo_map(image-region-bo, true);
+   int tiling, swizzle;
+   dri_bo_get_tiling(image-region-bo, tiling, swizzle);
+   if (tiling != I915_TILING_NONE)
+   drm_intel_gem_bo_map_gtt(image-region-bo);
+   else
+   drm_intel_bo_map(image-region-bo, true);
+   
memcpy(image-region-bo-virtual, buf, count);
-   drm_intel_bo_unmap(image-region-bo);
+
+   if (tiling != I915_TILING_NONE)
+   drm_intel_gem_bo_unmap_gtt(image-region-bo);
+   else
+   drm_intel_bo_unmap(image-region-bo);
 
return 0;
 }
-- 
1.7.4.1

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


[Mesa-dev] [PATCH 10/11 v5] EGL: add YUYV support to eglCreateImageKHR and eglCreateDRMImageMESA

2012-07-09 Thread Zhao Halley
---
 include/EGL/eglmesaext.h|3 +++
 src/egl/drivers/dri2/egl_dri2.c |9 -
 2 files changed, 11 insertions(+), 1 deletions(-)
 mode change 100644 = 100755 include/EGL/eglext.h
 mode change 100644 = 100755 include/EGL/eglmesaext.h

diff --git a/include/EGL/eglext.h b/include/EGL/eglext.h
old mode 100644
new mode 100755
diff --git a/include/EGL/eglmesaext.h b/include/EGL/eglmesaext.h
old mode 100644
new mode 100755
index 52dd5b1..cb251fd
--- a/include/EGL/eglmesaext.h
+++ b/include/EGL/eglmesaext.h
@@ -107,6 +107,9 @@ typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETDRMDISPLAYMESA) 
(int fd);
 #ifndef EGL_DRM_BUFFER_USE_CURSOR_MESA
 #define EGL_DRM_BUFFER_USE_CURSOR_MESA 0x0004
 #endif
+#ifndef EGL_DRM_BUFFER_FORMAT_YUYV_MESA
+#define EGL_DRM_BUFFER_FORMAT_YUYV_MESA0x31D6  /* 
EGL_DRM_BUFFER_FORMAT_MESA attribute value */
+#endif
 #endif
 
 #ifndef EGL_WL_bind_wayland_display
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index e2dee79..3638fec 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1031,8 +1031,12 @@ dri2_create_image_mesa_drm_buffer(_EGLDisplay *disp, 
_EGLContext *ctx,
switch (attrs.DRMBufferFormatMESA) {
case EGL_DRM_BUFFER_FORMAT_ARGB32_MESA:
   format = __DRI_IMAGE_FORMAT_ARGB;
-  pitch = attrs.DRMBufferStrideMESA;
+  pitch = attrs.DRMBufferStrideMESA/4;
   break;
+   case EGL_DRM_BUFFER_FORMAT_YUYV_MESA:
+  format = __DRI_IMAGE_FORMAT_YUYV;
+  pitch = attrs.DRMBufferStrideMESA/2;
+ break;
default:
   _eglError(EGL_BAD_PARAMETER,
dri2_create_image_khr: unsupported pixmap depth);
@@ -1150,6 +1154,9 @@ dri2_create_drm_image_mesa(_EGLDriver *drv, _EGLDisplay 
*disp,
case EGL_DRM_BUFFER_FORMAT_ARGB32_MESA:
   format = __DRI_IMAGE_FORMAT_ARGB;
   break;
+   case EGL_DRM_BUFFER_FORMAT_YUYV_MESA:
+  format = __DRI_IMAGE_FORMAT_YUYV;
+  break;
default:
   _eglLog(_EGL_WARNING, bad image format value 0x%04x,
 attrs.DRMBufferFormatMESA);
-- 
1.7.4.1

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


[Mesa-dev] [PATCH 11/11 v5] [piglit] add egl-create-drm-image test

2012-07-09 Thread Zhao Halley
---
 tests/egl/CMakeLists.gl.txt  |2 +
 tests/egl/egl-create-drm-image.c |  145 ++
 2 files changed, 147 insertions(+), 0 deletions(-)
 create mode 100755 tests/egl/egl-create-drm-image.c

diff --git a/tests/egl/CMakeLists.gl.txt b/tests/egl/CMakeLists.gl.txt
index ddfbbef..1e8865c 100644
--- a/tests/egl/CMakeLists.gl.txt
+++ b/tests/egl/CMakeLists.gl.txt
@@ -20,6 +20,8 @@ IF(${CMAKE_SYSTEM_NAME} MATCHES Linux)
target_link_libraries(egl-create-surface pthread ${X11_X11_LIB})
piglit_add_executable (egl-query-surface egl-util.c egl-query-surface.c)
target_link_libraries(egl-query-surface pthread ${X11_X11_LIB})
+   piglit_add_executable (egl-create-drm-image egl-util.c 
egl-create-drm-image.c)
+   target_link_libraries(egl-create-drm-image pthread ${X11_X11_LIB})
 ENDIF(${CMAKE_SYSTEM_NAME} MATCHES Linux)
 
 # vim: ft=cmake:
diff --git a/tests/egl/egl-create-drm-image.c b/tests/egl/egl-create-drm-image.c
new file mode 100755
index 000..d20d27e
--- /dev/null
+++ b/tests/egl/egl-create-drm-image.c
@@ -0,0 +1,145 @@
+/*
+ * Copyright © 2012 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.
+ *
+ * Author: Halley Zhao halley.z...@intel.com
+ */
+
+/** @file egl-create-drm-image.c
+ *
+ * Test EGL_MESA_drm_image.
+ */
+
+#include piglit-util.h
+#include egl-util.h
+
+#ifdef EGL_MESA_drm_image
+
+const char *extensions[] = { EGL_MESA_drm_image, NULL }; 
+
+static enum piglit_result
+draw(struct egl_state *state)
+{
+PFNEGLCREATEDRMIMAGEMESAPROC create_drm_image;
+PFNEGLEXPORTDRMIMAGEMESAPROC export_drm_image;
+PFNEGLCREATEIMAGEKHRPROCcreate_image;
+PFNEGLDESTROYIMAGEKHRPROC   destroy_image;
+
+EGLImageKHR image1 = EGL_NO_IMAGE_KHR;
+EGLImageKHR image2 = EGL_NO_IMAGE_KHR;
+
+EGLint attr_list1[] = {
+EGL_WIDTH, 256, EGL_HEIGHT, 256, 
+EGL_DRM_BUFFER_FORMAT_MESA, EGL_DRM_BUFFER_FORMAT_YUYV_MESA, 
+// EGL_DRM_BUFFER_FORMAT_MESA, EGL_DRM_BUFFER_FORMAT_ARGB32_MESA,
+EGL_NONE
+};
+
+EGLint name, handle, stride;
+EGLint attr_list2[] = {
+EGL_DRM_BUFFER_STRIDE_MESA, 0, 
+EGL_WIDTH, 256, EGL_HEIGHT, 256, 
+EGL_DRM_BUFFER_FORMAT_MESA, EGL_DRM_BUFFER_FORMAT_YUYV_MESA, 
+// EGL_DRM_BUFFER_FORMAT_MESA, EGL_DRM_BUFFER_FORMAT_ARGB32_MESA,
+EGL_NONE
+};
+#define STRIDE_INDEX1
+
+   create_drm_image = 
(PFNEGLCREATEDRMIMAGEMESAPROC)eglGetProcAddress(eglCreateDRMImageMESA);
+   if (create_drm_image == NULL ) {
+   fprintf(stderr, could not getproc eglCreateDRMImageMESA);
+   piglit_report_result(PIGLIT_PASS);
+   }
+
+   export_drm_image = 
(PFNEGLEXPORTDRMIMAGEMESAPROC)eglGetProcAddress(eglExportDRMImageMESA);
+   if (export_drm_image == NULL ) {
+   fprintf(stderr, could not getproc eglExportDRMImageMESA);
+   piglit_report_result(PIGLIT_PASS);
+   }
+
+   create_image = 
(PFNEGLCREATEIMAGEKHRPROC)eglGetProcAddress(eglCreateImageKHR);
+   if (create_image == NULL ) {
+   fprintf(stderr, could not getproc eglCreateImageKHR);
+   piglit_report_result(PIGLIT_PASS);
+   }
+
+   destroy_image = 
(PFNEGLDESTROYIMAGEKHRPROC)eglGetProcAddress(eglDestroyImageKHR);
+   if (destroy_image == NULL ) {
+   fprintf(stderr, could not getproc eglDestroyImageKHR);
+   piglit_report_result(PIGLIT_PASS);
+   }
+
+image1 = create_drm_image(state-egl_dpy, attr_list1);
+if(image1 == EGL_NO_IMAGE_KHR) {
+   fprintf(stderr, fail to create YUYV EGLImageKHR from 
eglCreateDRMImageMESA);
+   piglit_report_result(PIGLIT_FAIL);
+}
+
+if (export_drm_image(state-egl_dpy, image1, name, handle, stride) == 
EGL_FALSE) {
+   fprintf(stderr, fail to create export YUYV EGLImageKHR 

[Mesa-dev] [PATCH] es2tri: Define precision in fragment shader

2012-07-09 Thread Shuang He
According to GLSL ES spec, section 4.5.2:
If the precision cannot be determined by this method e.g. if an entire 
expression is composed only of
operands with no precision qualifier, and the result is not assigned or passed 
as an argument, then it
 is evaluated at the default precision of the type or greater. When this occurs 
in the fragment shader,
the default precision must be defined.
---
 src/egl/opengles2/es2tri.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/egl/opengles2/es2tri.c b/src/egl/opengles2/es2tri.c
index 6dcc1b8..349a576 100644
--- a/src/egl/opengles2/es2tri.c
+++ b/src/egl/opengles2/es2tri.c
@@ -139,6 +139,7 @@ static void
 create_shaders(void)
 {
static const char *fragShaderText =
+  precision mediump float;\n
   varying vec4 v_color;\n
   void main() {\n
  gl_FragColor = v_color;\n
-- 
1.7.7

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


[Mesa-dev] [PATCH 0/9] Automake continued

2012-07-09 Thread Jon TURNEY
On 13/06/2012 18:30, Eric Anholt wrote:
 Here's a bunch more automake.  We're at the point that an enterprising
 person could potentially convert libmesa.a if they figure out how to
 work that into the gallium build.  I also haven't converted osmesa,
 because I didn't think I knew of any tests for it (but wait, there's
 mesa-demos).

I am not that person, and I'm not sure what the issue with the gallium
build is you refer to, but since linking libtool and non-libtool archives
isn't portable to my platform of interest, I can't built git master mesa
at the moment, so here is a bunch more automaking.  This converts libglsl,
libglapi and libmesa, and includes Laurent Carlier's patch to convert libOsmesa.

Jon TURNEY (8):
  automake: convert libglsl building
  Rename sparc/clip.S - sparc/sparc_clip.S
  automake: convert libmesa and libmesagallium
  Remove unused MESA_MODULES autoconf variable
  Link dri drivers with mesa or dricore libtool library
  Rename X86-64_API - X86_64_API
  automake: convert libglapi
  Don't explicitly link libOsmesa with libmesa's dependency libglapi

Laurent Carlier (1):
  automake: convert libOSmesa building

 configs/current.in  |3 +-
 configure.ac|   27 +++--
 src/egl/main/Makefile.am|2 +-
 src/gallium/targets/Makefile.dri|4 +-
 src/glsl/.gitignore |1 +
 src/glsl/Makefile   |  144 -
 src/glsl/Makefile.am|  111 +
 src/glsl/glcpp/.gitignore   |1 +
 src/glsl/glcpp/Makefile.am  |   32 +
 src/glsl/tests/Makefile.am  |4 +-
 src/glx/Makefile.am |2 +-
 src/mapi/glapi/.gitignore   |1 +
 src/mapi/glapi/Makefile |   77 
 src/mapi/glapi/Makefile.am  |   68 ++
 src/mapi/glapi/sources.mak  |2 +-
 src/mapi/glapi/tests/Makefile.am|2 +-
 src/mesa/Makefile.am|   45 ++-
 src/mesa/Makefile.old   |   57 +-
 src/mesa/SConscript |2 +-
 src/mesa/drivers/osmesa/.gitignore  |1 +
 src/mesa/drivers/osmesa/Makefile|   51 
 src/mesa/drivers/osmesa/Makefile.am |   49 
 src/mesa/drivers/x11/Makefile.am|4 +-
 src/mesa/main/tests/Makefile.am |2 +-
 src/mesa/sources.mak|2 +-
 src/mesa/sparc/clip.S   |  233 ---
 src/mesa/sparc/sparc_clip.S |  233 +++
 27 files changed, 569 insertions(+), 591 deletions(-)
 delete mode 100644 src/glsl/Makefile
 create mode 100644 src/glsl/Makefile.am
 create mode 100644 src/glsl/glcpp/Makefile.am
 delete mode 100644 src/mapi/glapi/Makefile
 create mode 100644 src/mapi/glapi/Makefile.am
 create mode 100644 src/mesa/drivers/osmesa/.gitignore
 delete mode 100644 src/mesa/drivers/osmesa/Makefile
 create mode 100644 src/mesa/drivers/osmesa/Makefile.am
 delete mode 100644 src/mesa/sparc/clip.S
 create mode 100644 src/mesa/sparc/sparc_clip.S

-- 
1.7.9

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


[Mesa-dev] [PATCH 1/9] automake: convert libOSmesa building

2012-07-09 Thread Jon TURNEY
From: Laurent Carlier lordhea...@gmail.com

This also currently fix the installation of libOSmesa.

v2: Remove old Makefile, libOSmesa is now versioned, fix typos
v3: Keep config substitution alphabetized
v4: Update .gitignore

Reviewed-by: Jon TURNEY jon.tur...@dronecode.org.uk
---
 configure.ac|5 +++
 src/mesa/drivers/osmesa/.gitignore  |1 +
 src/mesa/drivers/osmesa/Makefile|   51 ---
 src/mesa/drivers/osmesa/Makefile.am |   50 ++
 4 files changed, 56 insertions(+), 51 deletions(-)
 create mode 100644 src/mesa/drivers/osmesa/.gitignore
 delete mode 100644 src/mesa/drivers/osmesa/Makefile
 create mode 100644 src/mesa/drivers/osmesa/Makefile.am

diff --git a/configure.ac b/configure.ac
index 46265a2..e5ac791 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1370,10 +1370,14 @@ if test x$enable_osmesa = xyes; then
 OSMESA_MESA_DEPS=
 OSMESA_PC_LIB_PRIV=-lm -lpthread $SELINUX_LIBS $DLOPEN_LIBS
 fi
+
+OSMESA_VERSION=`echo $VERSION | $SED 's/\./:/g'`
+
 AC_SUBST([OSMESA_LIB_DEPS])
 AC_SUBST([OSMESA_MESA_DEPS])
 AC_SUBST([OSMESA_PC_REQ])
 AC_SUBST([OSMESA_PC_LIB_PRIV])
+AC_SUBST([OSMESA_VERSION])
 
 dnl
 dnl gbm configuration
@@ -2188,6 +2192,7 @@ AC_CONFIG_FILES([configs/current
src/mesa/drivers/dri/r200/Makefile
src/mesa/drivers/dri/radeon/Makefile
src/mesa/drivers/dri/swrast/Makefile
+   src/mesa/drivers/osmesa/Makefile
src/mesa/drivers/x11/Makefile
src/mesa/gl.pc
src/mesa/osmesa.pc])
diff --git a/src/mesa/drivers/osmesa/.gitignore 
b/src/mesa/drivers/osmesa/.gitignore
new file mode 100644
index 000..5fc607b
--- /dev/null
+++ b/src/mesa/drivers/osmesa/.gitignore
@@ -0,0 +1 @@
+/Makefile
diff --git a/src/mesa/drivers/osmesa/Makefile b/src/mesa/drivers/osmesa/Makefile
deleted file mode 100644
index 39ab09a..000
--- a/src/mesa/drivers/osmesa/Makefile
+++ /dev/null
@@ -1,51 +0,0 @@
-# src/mesa/drivers/osmesa/Makefile for libOSMesa.so
-
-# Note that we may generate libOSMesa.so or libOSMesa16.so or libOSMesa32.so
-# with this Makefile
-
-
-TOP = ../../../..
-
-include $(TOP)/configs/current
-
-
-
-SOURCES = osmesa.c
-
-OBJECTS = $(SOURCES:.c=.o)
-
-INCLUDE_DIRS = \
-   -I$(TOP)/include \
-   -I$(TOP)/src/mapi \
-   -I$(TOP)/src/mesa \
-   -I$(TOP)/src/mesa/main
-
-CORE_MESA = \
-   $(TOP)/src/mesa/libmesa.a \
-   $(TOP)/src/mapi/glapi/libglapi.a \
-   $(TOP)/src/glsl/libglsl.a
-
-.c.o:
-   $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $ -o $@
-
-
-default: $(TOP)/$(LIB_DIR)/$(OSMESA_LIB_NAME)
-
-
-# libOSMesa can be used in conjuction with libGL or with all other Mesa
-# sources. We can also build libOSMesa16/libOSMesa32 by setting
-# -DCHAN_BITS=16/32.
-$(TOP)/$(LIB_DIR)/$(OSMESA_LIB_NAME): $(OBJECTS) $(CORE_MESA)
-   $(MKLIB) -o $(OSMESA_LIB) -linker '$(CXX)' -ldflags '$(LDFLAGS)' \
-   -major $(MESA_MAJOR) -minor $(MESA_MINOR) -patch $(MESA_TINY) \
-   -install $(TOP)/$(LIB_DIR) -cplusplus $(MKLIB_OPTIONS) \
-   -id $(INSTALL_LIB_DIR)/lib$(OSMESA_LIB).$(MESA_MAJOR).dylib \
-   $(OSMESA_LIB_DEPS) $(OBJECTS) $(CORE_MESA)
-
-
-
-clean:
-   -rm -f *.o *~
-
-
-# XXX todo install rule?
diff --git a/src/mesa/drivers/osmesa/Makefile.am 
b/src/mesa/drivers/osmesa/Makefile.am
new file mode 100644
index 000..863c8f7
--- /dev/null
+++ b/src/mesa/drivers/osmesa/Makefile.am
@@ -0,0 +1,50 @@
+
+
+# Copyright © 2012 Laurent Carlier lordhea...@gmail.com
+#
+# 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.
+
+# Hack to make some of the non-automake variables work.
+TOP=$(top_builddir)
+
+AM_CFLAGS = \
+   -I$(top_srcdir)/include \
+   -I$(top_srcdir)/src/mapi \
+   -I$(top_srcdir)/src/mesa/ \
+   $(DEFINES) \
+   $(API_DEFINES)
+
+if HAVE_OSMESA_DRIVER
+lib_LTLIBRARIES = 

[Mesa-dev] [PATCH 2/9] automake: convert libglsl building

2012-07-09 Thread Jon TURNEY
Signed-off-by: Jon TURNEY jon.tur...@dronecode.org.uk
---
 configure.ac|2 +
 src/glsl/.gitignore |1 +
 src/glsl/Makefile   |  144 ---
 src/glsl/Makefile.am|  111 +++
 src/glsl/glcpp/.gitignore   |1 +
 src/glsl/glcpp/Makefile.am  |   32 
 src/glsl/tests/Makefile.am  |2 +-
 src/mesa/drivers/osmesa/Makefile.am |2 +-
 8 files changed, 149 insertions(+), 146 deletions(-)
 delete mode 100644 src/glsl/Makefile
 create mode 100644 src/glsl/Makefile.am
 create mode 100644 src/glsl/glcpp/Makefile.am

diff --git a/configure.ac b/configure.ac
index e5ac791..93a8493 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2170,6 +2170,8 @@ AC_CONFIG_FILES([configs/current
src/egl/wayland/wayland-egl/Makefile
src/egl/wayland/wayland-egl/wayland-egl.pc
src/egl/wayland/wayland-drm/Makefile
+   src/glsl/Makefile
+   src/glsl/glcpp/Makefile
src/glsl/tests/Makefile
src/glx/Makefile
src/glx/tests/Makefile
diff --git a/src/glsl/.gitignore b/src/glsl/.gitignore
index d26839a..e3531cd 100644
--- a/src/glsl/.gitignore
+++ b/src/glsl/.gitignore
@@ -6,3 +6,4 @@ glsl_parser.output
 builtin_function.cpp
 builtin_compiler
 glsl_test
+/Makefile
diff --git a/src/glsl/Makefile b/src/glsl/Makefile
deleted file mode 100644
index 3cf9fc9..000
--- a/src/glsl/Makefile
+++ /dev/null
@@ -1,144 +0,0 @@
-
-#src/glsl/pp/Makefile
-
-TOP = ../..
-
-include $(TOP)/configs/current
-
-LIBNAME = glsl
-
-GLSL_SRCDIR=.
-include Makefile.sources
-
-GLCPP_SOURCES = \
-   $(LIBGLCPP_GENERATED_FILES) \
-   $(LIBGLCPP_FILES) \
-   ralloc.c \
-   glcpp/glcpp.c
-
-C_SOURCES = \
-   $(LIBGLCPP_GENERATED_FILES) \
-   $(LIBGLCPP_FILES) \
-   $(LIBGLSL_FILES)
-
-# common sources for builtin_compiler and libglsl
-CXX_SOURCES = \
-   $(BUILTIN_COMPILER_GENERATED_CXX_FILES) \
-   $(LIBGLSL_CXX_FILES)
-
-LIBS = \
-   $(TOP)/src/glsl/libglsl.a
-
-APPS = glsl_compiler glsl_test glcpp/glcpp
-
-GLSL2_C_SOURCES = \
-   ../mesa/program/hash_table.c \
-   ../mesa/program/symbol_table.c
-GLSL2_CXX_SOURCES = \
-   $(GLSL_COMPILER_CXX_FILES)
-
-GLSL2_OBJECTS = \
-   $(GLSL2_C_SOURCES:.c=.o) \
-   $(GLSL2_CXX_SOURCES:.cpp=.o)
-
-TEST_C_SOURCES = \
-   ../mesa/program/hash_table.c \
-   ../mesa/program/symbol_table.c
-
-TEST_CXX_SOURCES = \
-   standalone_scaffolding.cpp \
-   test.cpp \
-   test_optpass.cpp
-
-TEST_OBJECTS = \
-   $(TEST_C_SOURCES:.c=.o) \
-   $(TEST_CXX_SOURCES:.cpp=.o)
-
-### Basic defines ###
-
-DEFINES += \
-   $(LIBRARY_DEFINES) \
-   $(API_DEFINES)
-
-GLCPP_OBJECTS = \
-   $(GLCPP_SOURCES:.c=.o) \
-   ../mesa/program/hash_table.o
-
-OBJECTS = \
-   $(C_SOURCES:.c=.o) \
-   $(CXX_SOURCES:.cpp=.o)
-
-INCLUDES = \
-   -I. \
-   -I../mesa \
-   -I../mapi \
-   -I../../include \
-   $(LIBRARY_INCLUDES)
-
-ALL_SOURCES = \
-   $(C_SOURCES) \
-   $(CXX_SOURCES) \
-   $(GLSL2_CXX_SOURCES) \
-   $(GLSL2_C_SOURCES) \
-   $(TEST_CXX_SOURCES) \
-   $(TEST_C_SOURCES)
-
-# TARGETS #
-
-default: depend lib$(LIBNAME).a $(APPS)
-
-lib$(LIBNAME).a: $(OBJECTS) builtin_function.o Makefile 
$(TOP)/src/glsl/Makefile.template
-   $(MKLIB) -cplusplus -o $(LIBNAME) -static $(OBJECTS) builtin_function.o
-
-depend: $(ALL_SOURCES) Makefile
-   rm -f depend
-   touch depend
-   $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(ALL_SOURCES) 2 /dev/null
-
-# Remove .o and backup files
-clean:
-   rm -f $(GLCPP_OBJECTS) $(GLSL2_OBJECTS) $(TEST_OBJECTS) $(OBJECTS) 
lib$(LIBNAME).a depend depend.bak builtin_function.cpp builtin_function.o 
builtin_stubs.o builtin_compiler
-   -rm -f $(APPS)
-
-# Dummy target
-install:
-   @echo -n 
-
-# RULES #
-
-glsl_compiler: $(GLSL2_OBJECTS) libglsl.a
-   $(APP_CXX) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(GLSL2_OBJECTS) $(LIBS) -o 
$@
-
-glsl_test: $(TEST_OBJECTS) libglsl.a
-   $(APP_CXX) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(TEST_OBJECTS) $(LIBS) -o 
$@
-
-glcpp: glcpp/glcpp
-glcpp/glcpp: $(GLCPP_OBJECTS)
-   $(APP_CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(GLCPP_OBJECTS) -o $@
-
-.cpp.o:
-   $(CXX) -c $(INCLUDES) $(CXXFLAGS) $(DEFINES) $ -o $@
-
-.c.o:
-   $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $ -o $@
-
-glsl_lexer.cpp: glsl_lexer.ll
-   $(FLEX) --nounistd -o$@  $
-
-glsl_parser.cpp: glsl_parser.yy
-   $(BISON) -v -o $@ -p _mesa_glsl_ --defines=glsl_parser.h $
-
-glcpp/glcpp-lex.c: glcpp/glcpp-lex.l
-   $(FLEX) --nounistd -o$@  $
-
-glcpp/glcpp-parse.c: glcpp/glcpp-parse.y
-   $(BISON) -v -o $@ --defines=glcpp/glcpp-parse.h $
-
-builtin_compiler: $(GLSL2_OBJECTS) $(OBJECTS) builtin_stubs.o
-   $(APP_CXX) $(INCLUDES) $(CXXFLAGS) $(LDFLAGS) 

[Mesa-dev] [PATCH 4/9] automake: convert libmesa and libmesagallium

2012-07-09 Thread Jon TURNEY
Signed-off-by: Jon TURNEY jon.tur...@dronecode.org.uk
---
 src/glsl/tests/Makefile.am  |2 +-
 src/mesa/Makefile.am|   45 +--
 src/mesa/Makefile.old   |   57 +--
 src/mesa/drivers/osmesa/Makefile.am |2 +-
 src/mesa/drivers/x11/Makefile.am|2 +-
 src/mesa/main/tests/Makefile.am |2 +-
 6 files changed, 46 insertions(+), 64 deletions(-)

diff --git a/src/glsl/tests/Makefile.am b/src/glsl/tests/Makefile.am
index 4829fb2..33e634d 100644
--- a/src/glsl/tests/Makefile.am
+++ b/src/glsl/tests/Makefile.am
@@ -28,7 +28,7 @@ uniform_initializer_test_SOURCES =\
 uniform_initializer_test_LDADD =   \
$(top_builddir)/src/gtest/libgtest.la   \
$(top_builddir)/src/glsl/libglsl.la \
-   $(top_builddir)/src/mesa/libmesa.a  \
+   $(top_builddir)/src/mesa/libmesa.la \
-lpthread
 
 ralloc_test_SOURCES = ralloc_test.cpp $(top_builddir)/src/glsl/ralloc.c
diff --git a/src/mesa/Makefile.am b/src/mesa/Makefile.am
index bada760..08beaa6 100644
--- a/src/mesa/Makefile.am
+++ b/src/mesa/Makefile.am
@@ -93,14 +93,51 @@ program/lex.yy.c: program/program_lexer.l
mkdir -p program
$(LEX) --never-interactive --outfile=$@ $
 
-all-local:
-   $(MAKE) -f $(srcdir)/Makefile.old
+noinst_LTLIBRARIES = libmesa.la libmesagallium.la
+
+SRCDIR = $(top_srcdir)/src/mesa
+include sources.mak
+
+AM_CFLAGS = $(API_DEFINES) $(DEFINES) $(INCLUDE_DIRS) $(LLVM_CFLAGS) $(CFLAGS)
+AM_CXXFLAGS = $(API_DEFINES) $(DEFINES) $(INCLUDE_DIRS) $(LLVM_CFLAGS) 
$(CXXFLAGS)
+
+# cannot just add $(MESA_ASM_FILES) to libmesa_la_SOURCES as it contains a 
configure substitution
+MESA_ASM_FILES_FOR_ARCH =
+
+if HAVE_X86_ASM
+MESA_ASM_FILES_FOR_ARCH += $(X86_FILES)
+endif
+if HAVE_X86_64_ASM
+MESA_ASM_FILES_FOR_ARCH += $(X86_64_FILES)
+endif
+if HAVE_SPARC_ASM
+MESA_ASM_FILES_FOR_ARCH += $(SPARC_FILES)
+endif
+
+libmesa_la_SOURCES = \
+   $(MESA_FILES) \
+   $(MESA_CXX_FILES) \
+$(MESA_ASM_FILES_FOR_ARCH)
+
+libmesa_la_LIBADD = $(top_builddir)/src/glsl/libglsl.la
+libmesa_la_LDFLAGS = -static
+
+libmesagallium_la_SOURCES = \
+   $(MESA_GALLIUM_FILES) \
+   $(MESA_GALLIUM_CXX_FILES) \
+$(MESA_ASM_FILES_FOR_ARCH)
+
+libmesagallium_la_LIBADD = $(top_builddir)/src/glsl/libglsl.la
+libmesagallium_la_LDFLAGS = -static
 
 install-exec-local:
$(MAKE) -f $(srcdir)/Makefile.old install
 
-clean-local:
-   $(MAKE) -f $(srcdir)/Makefile.old clean
+# Provide compatibility with scripts for the old Mesa build system for
+# a while by putting a link to the library in the current directory.
+all-local: libmesa.la libmesagallium.la
+   ln -f .libs/libmesa.a .
+   ln -f .libs/libmesagallium.a .
 
 pkgconfigdir = $(libdir)/pkgconfig
 
diff --git a/src/mesa/Makefile.old b/src/mesa/Makefile.old
index 4ea70d4..3266a5d 100644
--- a/src/mesa/Makefile.old
+++ b/src/mesa/Makefile.old
@@ -3,58 +3,10 @@
 TOP = ../..
 include $(TOP)/configs/current
 
-MESA_LIBS := libmesa.a libmesagallium.a
-DEPENDS := depend
-
 SRCDIR = .
 include sources.mak
 
-# define preprocessor flags
-MESA_CPPFLAGS := $(API_DEFINES) $(DEFINES)
-
-# append include dirs
-MESA_CPPFLAGS += $(INCLUDE_DIRS)
-
-# tidy compiler flags
-CFLAGS := $(filter-out $(DEFINES), $(CFLAGS))
-CXXFLAGS := $(filter-out $(DEFINES), $(CXXFLAGS))
-
-# LLVM is needed for the state tracker
-MESA_CFLAGS := $(LLVM_CFLAGS) $(CFLAGS)
-MESA_CXXFLAGS := $(LLVM_CFLAGS) $(CXXFLAGS)
-
-%.o: %.c
-   $(CC) -c -o $@ $ $(MESA_CPPFLAGS) $(MESA_CFLAGS)
-
-%.o: %.cpp
-   $(CXX) -c -o $@ $ $(MESA_CPPFLAGS) $(MESA_CXXFLAGS)
-
-%.o: %.S
-   $(CC) -c -o $@ $ $(MESA_CPPFLAGS) $(MESA_CFLAGS)
-
-# Default: build dependencies, then asm_subdirs, GLSL built-in lib,
-# then convenience libs (.a) and finally the device drivers:
-default: $(DEPENDS) $(MESA_LIBS)
-
-##
-# Helper libraries used by many drivers:
-
-# Make archive of core mesa object files
-libmesa.a: $(MESA_OBJECTS) $(GLSL_LIBS)
-   @ $(MKLIB) -o mesa -static $(MESA_OBJECTS) $(GLSL_LIBS)
-
-# Make archive of subset of core mesa object files for gallium
-libmesagallium.a: $(MESA_GALLIUM_OBJECTS) $(GLSL_LIBS)
-   @ $(MKLIB) -o mesagallium -static $(MESA_GALLIUM_OBJECTS) $(GLSL_LIBS)
-
-##
-# Dependency generation
-
-depend: $(ALL_FILES) main/git_sha1.h
-   @ echo running $(MKDEP)
-   @ touch depend
-   @$(MKDEP) $(MKDEP_OPTIONS) $(MESA_CPPFLAGS) \
-   $(ALL_FILES)  /dev/null 2/dev/null
+default:
 
 ##
 # Installation rules
@@ -73,10 +25,3 @@ install-osmesa: default
 # Emacs tags
 tags:
etags `find . -name \*.[ch]` $(TOP)/include/GL/*.h
-
-clean:
-   -rm -f */*.o
-   -rm -f */*/*.o
-   -rm -f depend depend.bak 

[Mesa-dev] [PATCH 5/9] Remove unused MESA_MODULES autoconf variable

2012-07-09 Thread Jon TURNEY
---
 configs/current.in |1 -
 configure.ac   |3 ---
 2 files changed, 0 insertions(+), 4 deletions(-)

diff --git a/configs/current.in b/configs/current.in
index f4858bd..ca817c4 100644
--- a/configs/current.in
+++ b/configs/current.in
@@ -147,7 +147,6 @@ VG_LIB_DEPS = $(EXTRA_LIB_PATH) @VG_LIB_DEPS@
 GLAPI_LIB_DEPS = $(EXTRA_LIB_PATH) @GLAPI_LIB_DEPS@
 
 # DRI dependencies
-MESA_MODULES = @MESA_MODULES@
 DRI_LIB_DEPS = $(EXTRA_LIB_PATH) @DRI_LIB_DEPS@
 LIBDRM_CFLAGS = @LIBDRM_CFLAGS@
 LIBDRM_LIB = @LIBDRM_LIBS@
diff --git a/configure.ac b/configure.ac
index 93a8493..ae28007 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1086,15 +1086,12 @@ AC_SUBST([GLAPI_LIB_DEPS])
 
 dnl Setup default DRI CFLAGS
 DRI_LIB_DEPS='$(TOP)/src/mesa/libmesa.a'
-MESA_MODULES='$(TOP)/src/mesa/libmesa.a'
 
 if test x$enable_dri = xyes  test x$driglx_direct = xyes ; then
 DRI_LIB_DEPS=-L\$(TOP)/\$(LIB_DIR) -ldricore$VERSION
-MESA_MODULES=\$(TOP)/\$(LIB_DIR)/libdricore$VERSION.so
 HAVE_DRICORE=yes
 fi
 AM_CONDITIONAL(HAVE_DRICORE, test x$HAVE_DRICORE = xyes)
-AC_SUBST([MESA_MODULES])
 
 AC_SUBST([HAVE_XF86VIDMODE])
 
-- 
1.7.9

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


[Mesa-dev] [PATCH 6/9] Link dri drivers with mesa or dricore libtool library

2012-07-09 Thread Jon TURNEY
Now mesa/drivers/dri is converted to automake, we want to update DRI_LIB_DEPS
so that we link with the libmesa or libdricore libtool library, as appropriate.

However, this is complicated by the fact that gallium/targets is not (yet)
converted, so we can't share the DRI_LIB_DEPS autoconf variable with that 
anymore.

Add an additional autoconf variable GALLIUM_DRI_LIB_DEPS, whic is now used in
gallium/targets/Makefile.dri, to link with the libdircore or libmesa native 
library.
(we also need to link with the dependencies, which libtool follows for us when 
we link with the .la)

Signed-off-by: Jon TURNEY jon.tur...@dronecode.org.uk
---
 configs/current.in   |1 +
 configure.ac |   11 ---
 src/gallium/targets/Makefile.dri |4 ++--
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/configs/current.in b/configs/current.in
index ca817c4..e0c0130 100644
--- a/configs/current.in
+++ b/configs/current.in
@@ -148,6 +148,7 @@ GLAPI_LIB_DEPS = $(EXTRA_LIB_PATH) @GLAPI_LIB_DEPS@
 
 # DRI dependencies
 DRI_LIB_DEPS = $(EXTRA_LIB_PATH) @DRI_LIB_DEPS@
+GALLIUM_DRI_LIB_DEPS = $(EXTRA_LIB_PATH) @GALLIUM_DRI_LIB_DEPS@
 LIBDRM_CFLAGS = @LIBDRM_CFLAGS@
 LIBDRM_LIB = @LIBDRM_LIBS@
 DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@
diff --git a/configure.ac b/configure.ac
index ae28007..216ec3b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1084,11 +1084,14 @@ GLAPI_LIB_DEPS=-lpthread $SELINUX_LIBS
 AC_SUBST([GLAPI_LIB_DEPS])
 
 
-dnl Setup default DRI CFLAGS
-DRI_LIB_DEPS='$(TOP)/src/mesa/libmesa.a'
+dnl dri libraries are linking with mesa
+DRI_LIB_DEPS='$(TOP)/src/mesa/libmesa.la'
+GALLIUM_DRI_LIB_DEPS='$(TOP)/src/mesa/libmesa.a $(TOP)/src/glsl/libglsl.a'
 
+dnl ... or dricore?
 if test x$enable_dri = xyes  test x$driglx_direct = xyes ; then
-DRI_LIB_DEPS=-L\$(TOP)/\$(LIB_DIR) -ldricore$VERSION
+DRI_LIB_DEPS='$(TOP)/src/mesa/libdricore/libdricore$VERSION.la'
+GALLIUM_DRI_LIB_DEPS='$(TOP)/src/mesa/libdricore/libdricore$VERSION.a'
 HAVE_DRICORE=yes
 fi
 AM_CONDITIONAL(HAVE_DRICORE, test x$HAVE_DRICORE = xyes)
@@ -1266,10 +1269,12 @@ if test x$enable_dri = xyes; then
 
 # put all the necessary libs together
 DRI_LIB_DEPS=$DRI_LIB_DEPS $SELINUX_LIBS $LIBDRM_LIBS $EXPAT_LIB -lm 
-lpthread $DLOPEN_LIBS
+GALLIUM_DRI_LIB_DEPS=$GALLIUM_DRI_LIB_DEPS $SELINUX_LIBS $LIBDRM_LIBS 
$EXPAT_LIB -lm -lpthread $DLOPEN_LIBS
 fi
 AC_SUBST([DRI_DIRS])
 AC_SUBST([EXPAT_INCLUDES])
 AC_SUBST([DRI_LIB_DEPS])
+AC_SUBST([GALLIUM_DRI_LIB_DEPS])
 
 case $DRI_DIRS in
 *i915*|*i965*)
diff --git a/src/gallium/targets/Makefile.dri b/src/gallium/targets/Makefile.dri
index 3abed82..5b6676d 100644
--- a/src/gallium/targets/Makefile.dri
+++ b/src/gallium/targets/Makefile.dri
@@ -73,8 +73,8 @@ $(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(PIPE_DRIVERS) 
Makefile \
$(MKLIB) -o $@.tmp -noprefix -linker '$(CXX)' -ldflags '$(LDFLAGS)' \
$(OBJECTS) $(PIPE_DRIVERS) \
 -Wl,--start-group $(MESA_MODULES) -Wl,--end-group \
- $(DRI_LIB_DEPS) $(DRIVER_EXTRAS)
-   $(CXX) $(CFLAGS) -o $@.test 
$(TOP)/src/mesa/drivers/dri/common/dri_test.o $@.tmp $(DRI_LIB_DEPS) $(LDFLAGS);
+ $(GALLIUM_DRI_LIB_DEPS) $(DRIVER_EXTRAS)
+   $(CXX) $(CFLAGS) -o $@.test 
$(TOP)/src/mesa/drivers/dri/common/dri_test.o $@.tmp $(GALLIUM_DRI_LIB_DEPS) 
$(LDFLAGS);
@rm -f $@.test
mv -f $@.tmp $@
 
-- 
1.7.9

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


[Mesa-dev] [PATCH 3/9] Rename sparc/clip.S - sparc/sparc_clip.S

2012-07-09 Thread Jon TURNEY
Automake can't handle having both clip.S and clip.c, even though they have 
different paths

src/mesa/Makefile.am: object `clip.lo' created by `$(SRCDIR)/sparc/clip.S' and 
`$(SRCDIR)/main/clip.c'

Signed-off-by: Jon TURNEY jon.tur...@dronecode.org.uk
---
 src/mesa/SConscript |2 +-
 src/mesa/sources.mak|2 +-
 src/mesa/sparc/clip.S   |  233 ---
 src/mesa/sparc/sparc_clip.S |  233 +++
 4 files changed, 235 insertions(+), 235 deletions(-)
 delete mode 100644 src/mesa/sparc/clip.S
 create mode 100644 src/mesa/sparc/sparc_clip.S

diff --git a/src/mesa/SConscript b/src/mesa/SConscript
index 819a0fd..906c579 100644
--- a/src/mesa/SConscript
+++ b/src/mesa/SConscript
@@ -430,7 +430,7 @@ if env['gcc'] and env['platform'] not in ('darwin', 
'windows'):
 elif env['machine'] == 'sparc':
 mesa_sources += [
 'sparc/sparc.c',
-'sparc/clip.S',
+'sparc/sparc_clip.S',
 'sparc/norm.S',
 'sparc/xform.S',
 ]
diff --git a/src/mesa/sources.mak b/src/mesa/sources.mak
index 16b1c39..d22f059 100644
--- a/src/mesa/sources.mak
+++ b/src/mesa/sources.mak
@@ -307,7 +307,7 @@ X86_64_FILES =  \
$(SRCDIR)/x86-64/xform4.S
 
 SPARC_FILES =  \
-   $(SRCDIR)/sparc/clip.S  \
+   $(SRCDIR)/sparc/sparc_clip.S\
$(SRCDIR)/sparc/norm.S  \
$(SRCDIR)/sparc/xform.S
 
diff --git a/src/mesa/sparc/clip.S b/src/mesa/sparc/clip.S
deleted file mode 100644
index dc23917..000
--- a/src/mesa/sparc/clip.S
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * Clip testing in SPARC assembly
- */
-
-#if __arch64__
-#define LDPTR  ldx
-#define V4F_DATA   0x00
-#define V4F_START  0x08
-#define V4F_COUNT  0x10
-#define V4F_STRIDE 0x14
-#define V4F_SIZE   0x18
-#define V4F_FLAGS  0x1c
-#else
-#define LDPTR  ld
-#define V4F_DATA   0x00
-#define V4F_START  0x04
-#define V4F_COUNT  0x08
-#define V4F_STRIDE 0x0c
-#define V4F_SIZE   0x10
-#define V4F_FLAGS  0x14
-#endif
-
-#define VEC_SIZE_1 1
-#define VEC_SIZE_2 3
-#define VEC_SIZE_3 7
-#define VEC_SIZE_4 15
-
-.register %g2, #scratch
-.register %g3, #scratch
-
-   .text
-   .align  64
-
-one_dot_zero:
-   .word   0x3f80  /* 1.0f */
-
-   /* This trick is shamelessly stolen from the x86
-* Mesa asm.  Very clever, and we can do it too
-* since we have the necessary add with carry
-* instructions on Sparc.
-*/
-clip_table:
-   .byte0,  1,  0,  2,  4,  5,  4,  6
-   .byte0,  1,  0,  2,  8,  9,  8, 10
-   .byte   32, 33, 32, 34, 36, 37, 36, 38
-   .byte   32, 33, 32, 34, 40, 41, 40, 42
-   .byte0,  1,  0,  2,  4,  5,  4,  6
-   .byte0,  1,  0,  2,  8,  9,  8, 10
-   .byte   16, 17, 16, 18, 20, 21, 20, 22
-   .byte   16, 17, 16, 18, 24, 25, 24, 26
-   .byte   63, 61, 63, 62, 55, 53, 55, 54
-   .byte   63, 61, 63, 62, 59, 57, 59, 58
-   .byte   47, 45, 47, 46, 39, 37, 39, 38
-   .byte   47, 45, 47, 46, 43, 41, 43, 42
-   .byte   63, 61, 63, 62, 55, 53, 55, 54
-   .byte   63, 61, 63, 62, 59, 57, 59, 58
-   .byte   31, 29, 31, 30, 23, 21, 23, 22
-   .byte   31, 29, 31, 30, 27, 25, 27, 26
-
-/* GLvector4f *clip_vec, GLvector4f *proj_vec, 
-   GLubyte clipMask[], GLubyte *orMask, GLubyte *andMask,
-   GLboolean viewport_z_enable */
-
-   .align  64
-__pc_tramp:
-   retl
-nop
-
-   .globl  _mesa_sparc_cliptest_points4
-_mesa_sparc_cliptest_points4:
-   save%sp, -64, %sp
-   call__pc_tramp
-sub%o7, (. - one_dot_zero - 4), %g1
-   ld  [%g1 + 0x0], %f4
-   add %g1, 0x4, %g1
-
-   ld  [%i0 + V4F_STRIDE], %l1
-   ld  [%i0 + V4F_COUNT], %l3
-   LDPTR   [%i0 + V4F_START], %i0
-   LDPTR   [%i1 + V4F_START], %i5
-   ldub[%i3], %g2
-   ldub[%i4], %g3
-   sll %g3, 8, %g3
-   or  %g2, %g3, %g2
-
-   ld  [%i1 + V4F_FLAGS], %g3
-   or  %g3, VEC_SIZE_4, %g3
-   st  %g3, [%i1 + V4F_FLAGS]
-   mov 3, %g3
-   st  %g3, [%i1 + V4F_SIZE]
-   st  %l3, [%i1 + V4F_COUNT]
-   clr %l2
-   clr %l0
-
-   /* l0:  i
-* l3:  count
-* l1:  stride
-* l2:  c
-* g2:  (tmpAndMask  8) | tmpOrMask
-* g1:  clip_table
-* i0:  from[stride][i]
-* i2:  clipMask
-* i5:  vProj[4][i]
-*/
-
-1: ld  [%i0 + 0x0c], %f3   ! LSU   Group
-   ld  [%i0 + 0x0c], %g5   ! LSU   Group
-   ld  [%i0 + 

[Mesa-dev] [PATCH 8/9] automake: convert libglapi

2012-07-09 Thread Jon TURNEY
* configure substitutions are not allowed in _SOURCES variables in automake,
so remove the AC_SUBST'ed GLAPI_ASM_SOURCES and instead use some AM_CONDITIONALS
to choose which asm sources are used

* Change GLAPI_LIB to point to the .la file in other Makefile.am files, and 
make a link
to the .a file for the convenience of other Makefiles which have not yet been 
converted
to automake

Signed-off-by: Jon TURNEY jon.tur...@dronecode.org.uk
---
 configs/current.in  |1 -
 configure.ac|6 +--
 src/egl/main/Makefile.am|2 +-
 src/glx/Makefile.am |2 +-
 src/mapi/glapi/.gitignore   |1 +
 src/mapi/glapi/Makefile |   77 ---
 src/mapi/glapi/Makefile.am  |   68 ++
 src/mapi/glapi/tests/Makefile.am|2 +-
 src/mesa/drivers/osmesa/Makefile.am |2 +-
 src/mesa/drivers/x11/Makefile.am|2 +-
 10 files changed, 75 insertions(+), 88 deletions(-)
 delete mode 100644 src/mapi/glapi/Makefile
 create mode 100644 src/mapi/glapi/Makefile.am

diff --git a/configs/current.in b/configs/current.in
index e0c0130..dc0dea8 100644
--- a/configs/current.in
+++ b/configs/current.in
@@ -47,7 +47,6 @@ DLOPEN_LIBS = @DLOPEN_LIBS@
 
 # Source selection
 MESA_ASM_FILES = @MESA_ASM_FILES@
-GLAPI_ASM_SOURCES = @GLAPI_ASM_SOURCES@
 
 # Misc tools and flags
 MAKE = @MAKE@
diff --git a/configure.ac b/configure.ac
index c7a42cb..c4e4852 100644
--- a/configure.ac
+++ b/configure.ac
@@ -454,7 +454,6 @@ AC_ARG_ENABLE([asm],
 )
 asm_arch=
 MESA_ASM_FILES=
-GLAPI_ASM_SOURCES=
 AC_MSG_CHECKING([whether to enable assembly])
 test x$enable_asm = xno  AC_MSG_RESULT([no])
 # disable if cross compiling on x86/x86_64 since we must run gen_matypes
@@ -503,19 +502,16 @@ if test x$enable_asm = xyes; then
 x86)
 DEFINES=$DEFINES -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM 
-DUSE_SSE_ASM
 MESA_ASM_FILES='$(X86_FILES)'
-GLAPI_ASM_SOURCES='$(X86_API)'
 AC_MSG_RESULT([yes, x86])
 ;;
 x86_64)
 DEFINES=$DEFINES -DUSE_X86_64_ASM
 MESA_ASM_FILES='$(X86_64_FILES)'
-GLAPI_ASM_SOURCES='$(X86_64_API)'
 AC_MSG_RESULT([yes, x86_64])
 ;;
 sparc)
 DEFINES=$DEFINES -DUSE_SPARC_ASM
 MESA_ASM_FILES='$(SPARC_FILES)'
-GLAPI_ASM_SOURCES='$(SPARC_API)'
 AC_MSG_RESULT([yes, sparc])
 ;;
 *)
@@ -524,7 +520,6 @@ if test x$enable_asm = xyes; then
 esac
 fi
 AC_SUBST([MESA_ASM_FILES])
-AC_SUBST([GLAPI_ASM_SOURCES])
 
 dnl PIC code macro
 MESA_PIC_FLAGS
@@ -2177,6 +2172,7 @@ AC_CONFIG_FILES([configs/current
src/glsl/tests/Makefile
src/glx/Makefile
src/glx/tests/Makefile
+   src/mapi/glapi/Makefile
src/mapi/glapi/gen/Makefile
src/mapi/shared-glapi/Makefile
src/mapi/glapi/tests/Makefile
diff --git a/src/egl/main/Makefile.am b/src/egl/main/Makefile.am
index 9c3935b..ca5257a 100644
--- a/src/egl/main/Makefile.am
+++ b/src/egl/main/Makefile.am
@@ -19,7 +19,7 @@
 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 # IN THE SOFTWARE.
 
-GLAPI_LIB = ../mapi/glapi/libglapi.a
+GLAPI_LIB = ../mapi/glapi/libglapi.la
 
 if HAVE_XF86VIDMODE
 EXTRA_DEFINES_XF86VIDMODE = -DXF86VIDMODE
diff --git a/src/glx/Makefile.am b/src/glx/Makefile.am
index 37a938d..6ca85cd 100644
--- a/src/glx/Makefile.am
+++ b/src/glx/Makefile.am
@@ -26,7 +26,7 @@ endif
 
 SUBDIRS=tests
 
-GLAPI_LIB = ../mapi/glapi/libglapi.a
+GLAPI_LIB = ../mapi/glapi/libglapi.la
 
 if HAVE_XF86VIDMODE
 EXTRA_DEFINES_XF86VIDMODE = -DXF86VIDMODE
diff --git a/src/mapi/glapi/.gitignore b/src/mapi/glapi/.gitignore
index ecae56a..25d3dfd 100644
--- a/src/mapi/glapi/.gitignore
+++ b/src/mapi/glapi/.gitignore
@@ -7,3 +7,4 @@ glapi_x86.S
 glapitable.h
 glapitemp.h
 glprocs.h
+\Makefile
diff --git a/src/mapi/glapi/Makefile b/src/mapi/glapi/Makefile
deleted file mode 100644
index 211f384..000
--- a/src/mapi/glapi/Makefile
+++ /dev/null
@@ -1,77 +0,0 @@
-# src/mapi/glapi/Makefile
-
-TOP = ../../..
-include $(TOP)/configs/current
-
-TARGET = glapi
-
-MAPI = $(TOP)/src/mapi/mapi
-
-include sources.mak
-include $(MAPI)/sources.mak
-
-glapi_CPPFLAGS := \
-   -I$(TOP)/include \
-   -I$(TOP)/src/mapi \
-   -I$(TOP)/src/mesa
-
-ifeq ($(SHARED_GLAPI),1)
-glapi_CPPFLAGS += \
-   -DMAPI_MODE_BRIDGE \
-   -DMAPI_ABI_HEADER=\glapi/glapi_mapi_tmp.h\
-glapi_SOURCES := $(MAPI_BRIDGE_FILES)
-
-glapi_GLAPI_OBJECTS :=
-glapi_ASM_OBJECTS :=
-glapi_MAPI_OBJECTS := $(notdir $(MAPI_BRIDGE_FILES:.c=.o))
-else
-glapi_CPPFLAGS += -DMAPI_MODE_UTIL
-glapi_SOURCES := $(GLAPI_SOURCES) $(MAPI_UTIL_FILES)
-
-glapi_GLAPI_OBJECTS := $(GLAPI_SOURCES:.c=.o)
-glapi_ASM_OBJECTS := $(GLAPI_ASM_SOURCES:.S=.o)
-glapi_MAPI_OBJECTS := $(notdir $(MAPI_UTIL_FILES:.c=.o))
-endif # SHARED_GLAPI
-
-glapi_OBJECTS := \
-   

[Mesa-dev] [PATCH 9/9] Don't explicitly link libOsmesa with libmesa's dependency libglapi

2012-07-09 Thread Jon TURNEY
We must either:
(i) Not link libmesa with libglapi, and link anything that uses libmesa with
libglapi as well, or
(ii) Link libmesa with libglapi, and not link anything that uses libmesa with
libglapi

I choose (ii) just because it's least change, but I'm not sure it's right.

Note that drivers/X11 makes libGL by linking with libmesa, but not libglapi,
so it's a bit unclear to me how this was working correctly before in both cases
(It might be some sort of accidental side-effect of what mklib's 
expand_archives()
function does that this ever worked before?)
---
 src/mesa/drivers/osmesa/Makefile.am |3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/osmesa/Makefile.am 
b/src/mesa/drivers/osmesa/Makefile.am
index a91d9e2..cfba658 100644
--- a/src/mesa/drivers/osmesa/Makefile.am
+++ b/src/mesa/drivers/osmesa/Makefile.am
@@ -40,8 +40,7 @@ lib@OSMESA_LIB@_la_SOURCES = osmesa.c
 lib@OSMESA_LIB@_la_LDFLAGS = -module -version-number @OSMESA_VERSION@ -shared
 lib@OSMESA_LIB@_la_LIBADD = \
$(top_srcdir)/src/mesa/libmesa.la \
-   $(top_srcdir)/src/mapi/glapi/libglapi.la \
-   $(top_srcdir)/src/glsl/libglsl.la
+   $(top_srcdir)/src/mapi/glapi/libglapi.la
 
 # Provide compatibility with scripts for the old Mesa build system for
 # a while by putting a link to the driver into /lib of the build tree.
-- 
1.7.9

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


[Mesa-dev] [PATCH 7/9] Rename X86-64_API - X86_64_API

2012-07-09 Thread Jon TURNEY
automake doesn't allow hyphens in variable names

Signed-off-by: Jon TURNEY jon.tur...@dronecode.org.uk
---
 configure.ac   |2 +-
 src/mapi/glapi/sources.mak |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 216ec3b..c7a42cb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -509,7 +509,7 @@ if test x$enable_asm = xyes; then
 x86_64)
 DEFINES=$DEFINES -DUSE_X86_64_ASM
 MESA_ASM_FILES='$(X86_64_FILES)'
-GLAPI_ASM_SOURCES='$(X86-64_API)'
+GLAPI_ASM_SOURCES='$(X86_64_API)'
 AC_MSG_RESULT([yes, x86_64])
 ;;
 sparc)
diff --git a/src/mapi/glapi/sources.mak b/src/mapi/glapi/sources.mak
index dfc6cc6..aa8a4d4 100644
--- a/src/mapi/glapi/sources.mak
+++ b/src/mapi/glapi/sources.mak
@@ -12,7 +12,7 @@ GLAPI_SOURCES = \
 X86_API =  \
glapi_x86.S
 
-X86-64_API =   \
+X86_64_API =   \
glapi_x86-64.S
 
 SPARC_API =\
-- 
1.7.9

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


Re: [Mesa-dev] [PATCH] Make it possible to install gl.pc and osmesa.pc together.

2012-07-09 Thread Johannes Obermayr
Am Sonntag, 8. Juli 2012, 19:41:33 schrieb Kenneth Graunke:
 On 07/08/2012 03:12 PM, Johannes Obermayr wrote:
  ---
   configure.ac |1 +
   src/mesa/Makefile.am |9 ++---
   2 files changed, 7 insertions(+), 3 deletions(-)
 
 It's never been clear to me whether one can build OSMesa and non-OSMesa
 at the same time.  If you can, then of course this makes sense.

http://cgit.freedesktop.org/mesa/mesa/commit/?id=9e7a4147c730adda047aae66c17f07d9de5b4a28

 
 Reviewed-by: Kenneth Graunke kenn...@whitecape.org
 
 

Is anybody willing to push it or should I request an account after 11 (12) 
commits pushed to mesa and a few pushed to other repositories on fdo?
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 9/9] Don't explicitly link libOsmesa with libmesa's dependency libglapi

2012-07-09 Thread Eric Anholt
Jon TURNEY jon.tur...@dronecode.org.uk writes:

 We must either:
 (i) Not link libmesa with libglapi, and link anything that uses libmesa with
 libglapi as well, or
 (ii) Link libmesa with libglapi, and not link anything that uses libmesa with
 libglapi

 I choose (ii) just because it's least change, but I'm not sure it's right.

 Note that drivers/X11 makes libGL by linking with libmesa, but not libglapi,
 so it's a bit unclear to me how this was working correctly before in both 
 cases
 (It might be some sort of accidental side-effect of what mklib's 
 expand_archives()
 function does that this ever worked before?)
 ---
  src/mesa/drivers/osmesa/Makefile.am |3 +--
  1 files changed, 1 insertions(+), 2 deletions(-)

 diff --git a/src/mesa/drivers/osmesa/Makefile.am 
 b/src/mesa/drivers/osmesa/Makefile.am
 index a91d9e2..cfba658 100644
 --- a/src/mesa/drivers/osmesa/Makefile.am
 +++ b/src/mesa/drivers/osmesa/Makefile.am
 @@ -40,8 +40,7 @@ lib@OSMESA_LIB@_la_SOURCES = osmesa.c
  lib@OSMESA_LIB@_la_LDFLAGS = -module -version-number @OSMESA_VERSION@ -shared
  lib@OSMESA_LIB@_la_LIBADD = \
   $(top_srcdir)/src/mesa/libmesa.la \
 - $(top_srcdir)/src/mapi/glapi/libglapi.la \
 - $(top_srcdir)/src/glsl/libglsl.la
 + $(top_srcdir)/src/mapi/glapi/libglapi.la

This commit actually looks like it drops linking with libglsl.  What's
up?


pgpGu9y1VO1uV.pgp
Description: PGP signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 0/9] Automake continued

2012-07-09 Thread Eric Anholt
Jon TURNEY jon.tur...@dronecode.org.uk writes:

 On 13/06/2012 18:30, Eric Anholt wrote:
 Here's a bunch more automake.  We're at the point that an enterprising
 person could potentially convert libmesa.a if they figure out how to
 work that into the gallium build.  I also haven't converted osmesa,
 because I didn't think I knew of any tests for it (but wait, there's
 mesa-demos).

 I am not that person, and I'm not sure what the issue with the gallium
 build is you refer to, but since linking libtool and non-libtool archives
 isn't portable to my platform of interest, I can't built git master mesa
 at the moment, so here is a bunch more automaking.  This converts libglsl,
 libglapi and libmesa, and includes Laurent Carlier's patch to convert 
 libOsmesa.

I haven't done a careful review of all the patches, since converting
Makefiles is a ton of text to visually diff as a reviewer.  But patches
without comments are at least:

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


pgpwbHOqQzu87.pgp
Description: PGP signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/4] mesa: implement glGet(GL_TIMESTAMP) v2

2012-07-09 Thread Eric Anholt
Marek Olšák mar...@gmail.com writes:

 This is adds a new driver function to retrieve the timestamp.


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


pgpiAIdFyMQAr.pgp
Description: PGP signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] Make it possible to install gl.pc and osmesa.pc together.

2012-07-09 Thread Eric Anholt
osmesa didn't install gl.pc in the past as far as I can see, and I don't
think it should -- it's not a normal GL implementation, so you want to
be specifically looking for osmesa in your pkgconfig checks.


pgp9AaCd4EExB.pgp
Description: PGP signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 4/9] automake: convert libmesa and libmesagallium

2012-07-09 Thread Eric Anholt
Jon TURNEY jon.tur...@dronecode.org.uk writes:
 diff --git a/src/mesa/Makefile.am b/src/mesa/Makefile.am
 index bada760..08beaa6 100644
 --- a/src/mesa/Makefile.am
 +++ b/src/mesa/Makefile.am

 +libmesa_la_SOURCES = \
 + $(MESA_FILES) \
 + $(MESA_CXX_FILES) \
 +$(MESA_ASM_FILES_FOR_ARCH)
 +
 +libmesa_la_LIBADD = $(top_builddir)/src/glsl/libglsl.la
 +libmesa_la_LDFLAGS = -static

Doesn't this -static result in relocations for static libs getting
built, which would then be a problem for the linking into shared
libraries later?  I don't really know this stuff well, but a -static in
the middle of a shared lib build seems strange.

The helper lib for the asm code in libdricore built a .a file without
-static being specified.

Also, with this commit, did you test that git_sha1 depencies were
working correctly and commit --amending would produce a new sha1 in your
drivers?


pgpIbpdE2iqQt.pgp
Description: PGP signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 3/9] Rename sparc/clip.S - sparc/sparc_clip.S

2012-07-09 Thread Eric Anholt
Jan Engelhardt jeng...@inai.de writes:

 On Monday 2012-07-09 13:41, Jon TURNEY wrote:

Automake can't handle having both clip.S and clip.c, even though they 
have different paths
src/mesa/Makefile.am: object `clip.lo' created by `$(SRCDIR)/sparc/clip.S' 
and `$(SRCDIR)/main/clip.c'

 It should - have you tried AM_INIT_AUTOMAKE([subdir-objects]) ?

My experiments with that option showed it to be ridiculously broken.

The approach I took in libdricore for the same problem was to build a
libtool lib for the asm, then link that in to libmesa.  It's really sad
how lame automake is in dealing with this (It's detected the problem!
Just build into a different .o file instead of punishing the user!)

I'm not opposed to just moving the file, though.


pgp1ELvSGPaF3.pgp
Description: PGP signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 0/5] intel: Enable GL_OES_compressed_ETC1_RGB8_texture

2012-07-09 Thread Chad Versace
This series enables it for all hardware. The implementation simply
decodes the ETC1 data into RGB at time of glTexImage, so no hardware support
is needed. This series lives on my etc1-v8 branch.

Tested against pending Piglit test OES_compressed_ETC1_RGB8_texture/miptree,
which lives on my Piglit etc1-v8 branch.

Chad Versace (5):
  mesa: Fold texcompress_etc1_tmp.h into texcompress_etc.c
  mesa: Remove unneeded extern qualifiers
  mesa: Document some etc1 functions
  mesa: Add function for decoding ETC1 textures
  intel: Enable GL_OES_compressed_ETC1_RGB8_texture

 src/mesa/drivers/dri/i965/brw_wm_surface_state.c |   5 +
 src/mesa/drivers/dri/intel/intel_extensions.c|   1 +
 src/mesa/drivers/dri/intel/intel_mipmap_tree.c   |  71 +++-
 src/mesa/drivers/dri/intel/intel_mipmap_tree.h   |  15 ++
 src/mesa/main/texcompress_etc.c  | 215 +--
 src/mesa/main/texcompress_etc.h  |  10 +-
 src/mesa/main/texcompress_etc_tmp.h  | 136 --
 7 files changed, 302 insertions(+), 151 deletions(-)
 delete mode 100644 src/mesa/main/texcompress_etc_tmp.h

-- 
1.7.11.1

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


[Mesa-dev] [PATCH 2/5] mesa: Remove unneeded extern qualifiers

2012-07-09 Thread Chad Versace
Remove 'extern' from the functions declared in texcompress_etc.h.

Signed-off-by: Chad Versace chad.vers...@linux.intel.com
---
 src/mesa/main/texcompress_etc.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mesa/main/texcompress_etc.h b/src/mesa/main/texcompress_etc.h
index 4e166b2..8e8427f 100644
--- a/src/mesa/main/texcompress_etc.h
+++ b/src/mesa/main/texcompress_etc.h
@@ -30,10 +30,10 @@
 
 struct swrast_texture_image;
 
-extern GLboolean
+GLboolean
 _mesa_texstore_etc1_rgb8(TEXSTORE_PARAMS);
 
-extern void
+void
 _mesa_fetch_texel_2d_f_etc1_rgb8(const struct swrast_texture_image *texImage,
  GLint i, GLint j, GLint k, GLfloat *texel);
 
-- 
1.7.11.1

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


[Mesa-dev] [PATCH 3/5] mesa: Document some etc1 functions

2012-07-09 Thread Chad Versace
- Add doxygen to etc1_texel_fetch().
- Rename ambiguously named `dst` variables to `bgr888` in order to be
  better self-documenting.

Signed-off-by: Chad Versace chad.vers...@linux.intel.com
---
 src/mesa/main/texcompress_etc.c | 22 +-
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/src/mesa/main/texcompress_etc.c b/src/mesa/main/texcompress_etc.c
index a5482f4..e3b2e83 100644
--- a/src/mesa/main/texcompress_etc.c
+++ b/src/mesa/main/texcompress_etc.c
@@ -122,10 +122,14 @@ etc1_parse_block(struct etc1_block *block, const uint8_t 
*src)
   (src[4]  24) | (src[5]  16) | (src[6]  8) | src[7];
 }
 
+/**
+ * Fetch the texel located at (x, y) within @a block and return it
+ * in @a bgr888.
+ */
 static void
 etc1_fetch_texel(const struct etc1_block *block,
  int x, int y,
- uint8_t *dst)
+ uint8_t *bgr888)
 {
const uint8_t *base_color;
int modifier, bit, idx, blk;
@@ -141,9 +145,9 @@ etc1_fetch_texel(const struct etc1_block *block,
base_color = block-base_colors[blk];
modifier = block-modifier_tables[blk][idx];
 
-   dst[0] = etc1_clamp(base_color[0], modifier);
-   dst[1] = etc1_clamp(base_color[1], modifier);
-   dst[2] = etc1_clamp(base_color[2], modifier);
+   bgr888[0] = etc1_clamp(base_color[0], modifier);
+   bgr888[1] = etc1_clamp(base_color[1], modifier);
+   bgr888[2] = etc1_clamp(base_color[2], modifier);
 }
 
 GLboolean
@@ -160,17 +164,17 @@ _mesa_fetch_texel_2d_f_etc1_rgb8(const struct 
swrast_texture_image *texImage,
  GLint i, GLint j, GLint k, GLfloat *texel)
 {
struct etc1_block block;
-   GLubyte dst[3];
+   uint8_t bgr888[3];
const GLubyte *src;
 
src = (const GLubyte *) texImage-Map +
   (((texImage-RowStride + 3) / 4) * (j / 4) + (i / 4)) * 8;
 
etc1_parse_block(block, src);
-   etc1_fetch_texel(block, i % 4, j % 4, dst);
+   etc1_fetch_texel(block, i % 4, j % 4, bgr888);
 
-   texel[RCOMP] = UBYTE_TO_FLOAT(dst[0]);
-   texel[GCOMP] = UBYTE_TO_FLOAT(dst[1]);
-   texel[BCOMP] = UBYTE_TO_FLOAT(dst[2]);
+   texel[RCOMP] = UBYTE_TO_FLOAT(bgr888[0]);
+   texel[GCOMP] = UBYTE_TO_FLOAT(bgr888[1]);
+   texel[BCOMP] = UBYTE_TO_FLOAT(bgr888[2]);
texel[ACOMP] = 1.0f;
 }
-- 
1.7.11.1

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


[Mesa-dev] [PATCH 4/5] mesa: Add function for decoding ETC1 textures

2012-07-09 Thread Chad Versace
Add function _mesa_etc1_image_decode_to_abgr(). It is intended to be
used by glCompressedTexSubImage2D to translate ETC1 textures into ABGR.

Signed-off-by: Chad Versace chad.vers...@linux.intel.com
---
 src/mesa/main/texcompress_etc.c | 82 +
 src/mesa/main/texcompress_etc.h |  6 +++
 2 files changed, 88 insertions(+)

diff --git a/src/mesa/main/texcompress_etc.c b/src/mesa/main/texcompress_etc.c
index e3b2e83..d84ee0e 100644
--- a/src/mesa/main/texcompress_etc.c
+++ b/src/mesa/main/texcompress_etc.c
@@ -178,3 +178,85 @@ _mesa_fetch_texel_2d_f_etc1_rgb8(const struct 
swrast_texture_image *texImage,
texel[BCOMP] = UBYTE_TO_FLOAT(bgr888[2]);
texel[ACOMP] = 1.0f;
 }
+
+static int
+align(int x, int m)
+{
+   return (m * x + m - 1) / m;
+}
+
+/**
+ * Decode texture data in format `MESA_FORMAT_ETC1_RGB8` to
+ * `MESA_FORMAT_ABGR`.
+ *
+ * The size of the source data must be a multiple of the ETC1 block size,
+ * which is 8, even if the texture image's dimensions are not aligned to 4.
+ * From the GL_OES_compressed_ETC1_RGB8_texture spec:
+ *   The texture is described as a number of 4x4 pixel blocks. If the
+ *   texture (or a particular mip-level) is smaller than 4 pixels in
+ *   any dimension (such as a 2x2 or a 8x1 texture), the texture is
+ *   found in the upper left part of the block(s), and the rest of the
+ *   pixels are not used. For instance, a texture of size 4x2 will be
+ *   placed in the upper half of a 4x4 block, and the lower half of the
+ *   pixels in the block will not be accessed.
+ *
+ * \param src_width in pixels
+ * \param src_height in pixels
+ * \param dst_rowstride in bytes
+ */
+void
+_mesa_etc1_image_decode_to_abgr(const uint8_t *src,
+int src_width,
+int src_height,
+uint8_t *dst,
+int dst_rowstride)
+{
+   /* An XRGB pixel is 4 bytes. */
+   const int pixel_bytes = 4;
+
+   /* A block contains 4x4 pixels. */
+   const int block_width = 4;
+   const int block_height = 4;
+
+   /* A block contains 8 bytes. */
+   const int block_bytes = 8;
+
+   /* The stride in units of blocks. */
+   const int block_stride = align(src_width, block_width) / block_width;
+
+   /* The block being decoded. */
+   int block_x;
+   int block_y;
+
+   /* Iterate over each block. */
+   for (block_y = 0; block_y * block_height  src_height; ++block_y) {
+  for (block_x = 0; block_x * block_width  src_width; ++block_x) {
+ struct etc1_block block;
+
+ /* The pixel's position relative to the block's base. */
+ int pixel_x;
+ int pixel_y;
+
+ const uint8_t *src_block_base =
+   src + block_bytes * (block_y * block_stride + block_x);
+
+ uint8_t *dst_block_base = dst
+ + block_y * block_height * dst_rowstride
+ + block_x * block_width * pixel_bytes;
+
+ etc1_parse_block(block, src_block_base);
+
+ /* Iterate over each pixel in block. */
+ for (pixel_y = 0; pixel_y  block_height; ++pixel_y) {
+for (pixel_x = 0; pixel_x  block_width; ++pixel_x) {
+   uint8_t *dst_texel = dst_block_base
+  + pixel_y * dst_rowstride
+  + pixel_x * pixel_bytes;
+
+   etc1_fetch_texel(block, pixel_x, pixel_y, dst_texel);
+   dst_texel[3] = 0xff;
+}
+ }
+  }
+   }
+}
diff --git a/src/mesa/main/texcompress_etc.h b/src/mesa/main/texcompress_etc.h
index 8e8427f..552a7bd 100644
--- a/src/mesa/main/texcompress_etc.h
+++ b/src/mesa/main/texcompress_etc.h
@@ -36,5 +36,11 @@ _mesa_texstore_etc1_rgb8(TEXSTORE_PARAMS);
 void
 _mesa_fetch_texel_2d_f_etc1_rgb8(const struct swrast_texture_image *texImage,
  GLint i, GLint j, GLint k, GLfloat *texel);
+void
+_mesa_etc1_image_decode_to_abgr(const uint8_t *src,
+int src_width,
+int src_height,
+uint8_t *dst,
+int dst_rowstride);
 
 #endif
-- 
1.7.11.1

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


[Mesa-dev] [PATCH 5/5] intel: Enable GL_OES_compressed_ETC1_RGB8_texture

2012-07-09 Thread Chad Versace
Enable it for all hardware.

No current hardware supports ETC1, so this patch implements it by
translating the ETC1 data to RGBX data during the call to
glCompressedTexImage2D(). For details, see the doxygen for
intel_mipmap_tree::wraps_etc1.

Tested on Sandybridge with Piglit test
OES_compressed_ETC1_RGB8_texture/miptree (test is pending review).

Signed-off-by: Chad Versace chad.vers...@linux.intel.com
---
 src/mesa/drivers/dri/i965/brw_wm_surface_state.c |  5 ++
 src/mesa/drivers/dri/intel/intel_extensions.c|  1 +
 src/mesa/drivers/dri/intel/intel_mipmap_tree.c   | 71 +++-
 src/mesa/drivers/dri/intel/intel_mipmap_tree.h   | 15 +
 4 files changed, 91 insertions(+), 1 deletion(-)

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 26e65af..794aadb 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -551,6 +551,11 @@ brw_init_surface_formats(struct brw_context *brw)
ctx-TextureFormatSupported[MESA_FORMAT_Z32_FLOAT] = true;
ctx-TextureFormatSupported[MESA_FORMAT_Z32_FLOAT_X24S8] = true;
ctx-TextureFormatSupported[MESA_FORMAT_Z16] = true;
+
+   /* On hardware that lacks support for ETC1, we map ETC1 to RGBX
+* during glCompressedTexImage2D(). See intel_mipmap_tree::wraps_etc1.
+*/
+   ctx-TextureFormatSupported[MESA_FORMAT_ETC1_RGB8] = true;
 }
 
 bool
diff --git a/src/mesa/drivers/dri/intel/intel_extensions.c 
b/src/mesa/drivers/dri/intel/intel_extensions.c
index 953b983..844125d 100755
--- a/src/mesa/drivers/dri/intel/intel_extensions.c
+++ b/src/mesa/drivers/dri/intel/intel_extensions.c
@@ -91,6 +91,7 @@ intelInitExtensions(struct gl_context *ctx)
ctx-Extensions.OES_EGL_image = true;
 #endif
ctx-Extensions.OES_draw_texture = true;
+   ctx-Extensions.OES_compressed_ETC1_RGB8_texture = true;
 
if (intel-gen = 6)
   ctx-Const.GLSLVersion = 130;
diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c 
b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
index 7018c37..9220cc1 100644
--- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
@@ -38,6 +38,7 @@
 #include main/enums.h
 #include main/formats.h
 #include main/image.h
+#include main/texcompress_etc.h
 #include main/teximage.h
 
 #define FILE_DEBUG_FLAG DEBUG_MIPTREE
@@ -180,7 +181,15 @@ intel_miptree_create(struct intel_context *intel,
 {
struct intel_mipmap_tree *mt;
uint32_t tiling = I915_TILING_NONE;
-   GLenum base_format = _mesa_get_format_base_format(format);
+   GLenum base_format;
+   bool wraps_etc1 = false;
+
+   if (format == MESA_FORMAT_ETC1_RGB8) {
+  format = MESA_FORMAT_RGBX_REV;
+  wraps_etc1 = true;
+   }
+
+   base_format = _mesa_get_format_base_format(format);
 
if (intel-use_texture_tiling  !_mesa_is_format_compressed(format)) {
   if (intel-gen = 4 
@@ -227,6 +236,7 @@ intel_miptree_create(struct intel_context *intel,
   return NULL;
}
 
+   mt-wraps_etc1 = wraps_etc1;
mt-region = intel_region_alloc(intel-intelScreen,
   tiling,
   mt-cpp,
@@ -978,6 +988,61 @@ intel_miptree_unmap_s8(struct intel_context *intel,
free(map-buffer);
 }
 
+static void
+intel_miptree_map_etc1(struct intel_context *intel,
+   struct intel_mipmap_tree *mt,
+   struct intel_miptree_map *map,
+   unsigned int level,
+   unsigned int slice)
+{
+   /* For justification of these invariants,
+* see intel_mipmap_tree:wraps_etc1.
+*/
+   assert(mt-wraps_etc1);
+   assert(mt-format == MESA_FORMAT_RGBX_REV);
+
+   /* From the GL_OES_compressed_ETC1_RGB8_texture spec:
+*   INVALID_OPERATION is generated by CompressedTexSubImage2D,
+*   TexSubImage2D, or CopyTexSubImage2D if the texture image level
+*   bound to target has internal format ETC1_RGB8_OES.
+*
+* This implies that intel_miptree_map_etc1() can only be called from
+* glCompressedTexImage2D, and hence the assertions below hold.
+*/
+   assert(map-mode  GL_MAP_WRITE_BIT);
+   assert(map-mode  GL_MAP_INVALIDATE_RANGE_BIT);
+   assert(map-x == 0);
+   assert(map-y == 0);
+
+   /* Each ETC1 block contains 4x4 pixels in 8 bytes. */
+   map-stride = 2 * map-w;
+   map-buffer = map-ptr = malloc(map-stride * map-h);
+}
+
+static void
+intel_miptree_unmap_etc1(struct intel_context *intel,
+ struct intel_mipmap_tree *mt,
+ struct intel_miptree_map *map,
+ unsigned int level,
+ unsigned int slice)
+{
+   uint32_t image_x;
+   uint32_t image_y;
+   intel_miptree_get_image_offset(mt, level, 0, slice, image_x, image_y);
+
+   uint8_t *xbgr = intel_region_map(intel, mt-region, map-mode)
+ + image_y * mt-region-pitch * mt-region-cpp
+  

Re: [Mesa-dev] [PATCH] Make it possible to install gl.pc and osmesa.pc together.

2012-07-09 Thread Johannes Obermayr
Am Montag, 9. Juli 2012, 09:45:56 schrieb Eric Anholt:
 osmesa didn't install gl.pc in the past as far as I can see, and I don't
 think it should -- it's not a normal GL implementation, so you want to
 be specifically looking for osmesa in your pkgconfig checks.

Mesa-demos require gl.pc (line 28) and osmesa.pc (line 36):
https://build.opensuse.org/package/view_file?file=Mesa-demos.specpackage=Mesa-demosproject=home:jobermayr

Building Mesa with

./autogen.sh --host=i586-suse-linux-gnu --build=i586-suse-linux-gnu 
--program-prefix= --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin 
--sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share 
--includedir=/usr/include --libdir=/usr/lib --libexecdir=/usr/lib 
--localstatedir=/var --sharedstatedir=/usr/com --mandir=/usr/share/man 
--infodir=/usr/share/info --enable-xvmc --enable-vdpau --enable-texture-float 
--enable-debug --enable-dri --enable-glx --enable-osmesa 
--with-dri-drivers=i915,i965,nouveau,r200,radeon,swrast --enable-gles1 
--enable-gles2 --enable-openvg --enable-shared-glapi 
--with-gallium-drivers=i915,nouveau,r300,r600,svga,swrast --enable-gbm 
--enable-xorg --enable-xa --enable-gallium-egl --with-x --enable-gallium-llvm 
--enable-gallium-gbm --enable-gallium-g3dvl

worked for almost a year until

http://cgit.freedesktop.org/mesa/mesa/commit/?id=39785488e6a3f6beeb58372b88d49274a76d02f4

because both pc files were installed ...

After that commit OBS bitched a missing gl.pc until I applied the patch.___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] i965: Revert the VBOs-in-system-memory hack by Chris.

2012-07-09 Thread Eric Anholt
It didn't change performance on Lightsmark or Nexuiz, which both used
DYNAMIC_DRAW buffers, but it was killing performance (40% CPU wasted pwriting
buffers) on a closed-source app we're looking at.
---
 src/mesa/drivers/dri/intel/intel_buffer_objects.c |   13 +
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_buffer_objects.c 
b/src/mesa/drivers/dri/intel/intel_buffer_objects.c
index d2a0709..ef511e6 100644
--- a/src/mesa/drivers/dri/intel/intel_buffer_objects.c
+++ b/src/mesa/drivers/dri/intel/intel_buffer_objects.c
@@ -140,15 +140,11 @@ intel_bufferobj_data(struct gl_context * ctx,
intel_obj-sys_buffer = NULL;
 
if (size != 0) {
-  if (usage == GL_DYNAMIC_DRAW
 #ifdef I915
- /* On pre-965, stick VBOs in system memory, as we're always doing
-  * swtnl with their contents anyway.
-  */
- || target == GL_ARRAY_BUFFER || target == GL_ELEMENT_ARRAY_BUFFER
-#endif
-)
-  {
+  /* On pre-965, stick VBOs in system memory, as we're always doing
+   * swtnl with their contents anyway.
+   */
+  if (target == GL_ARRAY_BUFFER || target == GL_ELEMENT_ARRAY_BUFFER) {
 intel_obj-sys_buffer = malloc(size);
 if (intel_obj-sys_buffer != NULL) {
if (data != NULL)
@@ -156,6 +152,7 @@ intel_bufferobj_data(struct gl_context * ctx,
return true;
 }
   }
+#endif
   intel_bufferobj_alloc_buffer(intel, intel_obj);
   if (!intel_obj-buffer)
  return false;
-- 
1.7.10

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


[Mesa-dev] [PATCH 1/2] i965: Rip out system memory backing for buffer objects; just use BOs.

2012-07-09 Thread Kenneth Graunke
In one workload, 45% of CPU time was spent in pwrite(), primarily
uploading large amounts of VBO data.  This was in fact the hottest path
in the application, according to sysprof.  Removing the system memory
buffer and just storing VBOs in actual BOs cut the application's CPU
usage by about half, and moved pwrite down to about 2.5% of CPU time.

Signed-off-by: Kenneth Graunke kenn...@whitecape.org
---
 src/mesa/drivers/dri/intel/intel_buffer_objects.c |  117 +
 src/mesa/drivers/dri/intel/intel_buffer_objects.h |3 -
 2 files changed, 4 insertions(+), 116 deletions(-)

Here's my version of the same patch.  It's quite a bit more invasive,
but it deletes all the code made dead by the change in Eric's patch.

diff --git a/src/mesa/drivers/dri/intel/intel_buffer_objects.c 
b/src/mesa/drivers/dri/intel/intel_buffer_objects.c
index d2a0709..200fce3 100644
--- a/src/mesa/drivers/dri/intel/intel_buffer_objects.c
+++ b/src/mesa/drivers/dri/intel/intel_buffer_objects.c
@@ -97,8 +97,6 @@ intel_bufferobj_free(struct gl_context * ctx, struct 
gl_buffer_object *obj)
if (obj-Pointer)
   intel_bufferobj_unmap(ctx, obj);
 
-   free(intel_obj-sys_buffer);
-
drm_intel_bo_unreference(intel_obj-buffer);
free(intel_obj);
 }
@@ -136,26 +134,7 @@ intel_bufferobj_data(struct gl_context * ctx,
if (intel_obj-buffer != NULL)
   release_buffer(intel_obj);
 
-   free(intel_obj-sys_buffer);
-   intel_obj-sys_buffer = NULL;
-
if (size != 0) {
-  if (usage == GL_DYNAMIC_DRAW
-#ifdef I915
- /* On pre-965, stick VBOs in system memory, as we're always doing
-  * swtnl with their contents anyway.
-  */
- || target == GL_ARRAY_BUFFER || target == GL_ELEMENT_ARRAY_BUFFER
-#endif
-)
-  {
-intel_obj-sys_buffer = malloc(size);
-if (intel_obj-sys_buffer != NULL) {
-   if (data != NULL)
-  memcpy(intel_obj-sys_buffer, data, size);
-   return true;
-}
-  }
   intel_bufferobj_alloc_buffer(intel, intel_obj);
   if (!intel_obj-buffer)
  return false;
@@ -189,20 +168,6 @@ intel_bufferobj_subdata(struct gl_context * ctx,
 
assert(intel_obj);
 
-   /* If we have a single copy in system memory, update that */
-   if (intel_obj-sys_buffer) {
-  if (intel_obj-source)
-release_buffer(intel_obj);
-
-  if (intel_obj-buffer == NULL) {
-memcpy((char *)intel_obj-sys_buffer + offset, data, size);
-return;
-  }
-
-  free(intel_obj-sys_buffer);
-  intel_obj-sys_buffer = NULL;
-   }
-
/* Otherwise we need to update the copy in video memory. */
busy =
   drm_intel_bo_busy(intel_obj-buffer) ||
@@ -253,14 +218,10 @@ intel_bufferobj_get_subdata(struct gl_context * ctx,
struct intel_context *intel = intel_context(ctx);
 
assert(intel_obj);
-   if (intel_obj-sys_buffer)
-  memcpy(data, (char *)intel_obj-sys_buffer + offset, size);
-   else {
-  if (drm_intel_bo_references(intel-batch.bo, intel_obj-buffer)) {
-intel_batchbuffer_flush(intel);
-  }
-  drm_intel_bo_get_subdata(intel_obj-buffer, offset, size, data);
+   if (drm_intel_bo_references(intel-batch.bo, intel_obj-buffer)) {
+  intel_batchbuffer_flush(intel);
}
+   drm_intel_bo_get_subdata(intel_obj-buffer, offset, size, data);
 }
 
 
@@ -298,22 +259,6 @@ intel_bufferobj_map_range(struct gl_context * ctx,
obj-Length = length;
obj-AccessFlags = access;
 
-   if (intel_obj-sys_buffer) {
-  const bool read_only =
-(access  (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)) == GL_MAP_READ_BIT;
-
-  if (!read_only  intel_obj-source)
-release_buffer(intel_obj);
-
-  if (!intel_obj-buffer || intel_obj-source) {
-obj-Pointer = intel_obj-sys_buffer + offset;
-return obj-Pointer;
-  }
-
-  free(intel_obj-sys_buffer);
-  intel_obj-sys_buffer = NULL;
-   }
-
if (intel_obj-buffer == NULL) {
   obj-Pointer = NULL;
   return NULL;
@@ -426,9 +371,7 @@ intel_bufferobj_unmap(struct gl_context * ctx, struct 
gl_buffer_object *obj)
 
assert(intel_obj);
assert(obj-Pointer);
-   if (intel_obj-sys_buffer != NULL) {
-  /* always keep the mapping around. */
-   } else if (intel_obj-range_map_buffer != NULL) {
+   if (intel_obj-range_map_buffer != NULL) {
   /* Since we've emitted some blits to buffers that will (likely) be used
* in rendering operations in other cache domains in this batch, emit a
* flush.  Once again, we wish for a domain tracker in libdrm to cover
@@ -472,17 +415,6 @@ intel_bufferobj_buffer(struct intel_context *intel,
if (intel_obj-source)
   release_buffer(intel_obj);
 
-   if (intel_obj-buffer == NULL) {
-  intel_bufferobj_alloc_buffer(intel, intel_obj);
-  drm_intel_bo_subdata(intel_obj-buffer,
-  0, intel_obj-Base.Size,
-  intel_obj-sys_buffer);
-
-  free(intel_obj-sys_buffer);
-  

[Mesa-dev] [PATCH 2/2] i965: Use the blitter in intel_bufferobj_subdata for busy BOs on Gen6+.

2012-07-09 Thread Kenneth Graunke
Previously we only did this pre-Gen6, and used pwrite on Gen6+.
In one workload, this cuts significant amount of overhead.

Signed-off-by: Kenneth Graunke kenn...@whitecape.org
---
 src/mesa/drivers/dri/intel/intel_buffer_objects.c |   26 +
 1 file changed, 11 insertions(+), 15 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_buffer_objects.c 
b/src/mesa/drivers/dri/intel/intel_buffer_objects.c
index 200fce3..169d777 100644
--- a/src/mesa/drivers/dri/intel/intel_buffer_objects.c
+++ b/src/mesa/drivers/dri/intel/intel_buffer_objects.c
@@ -178,26 +178,22 @@ intel_bufferobj_subdata(struct gl_context * ctx,
   drm_intel_bo_unreference(intel_obj-buffer);
   intel_bufferobj_alloc_buffer(intel, intel_obj);
   drm_intel_bo_subdata(intel_obj-buffer, 0, size, data);
-   } else if (intel-gen  6) {
-  if (busy) {
-drm_intel_bo *temp_bo;
+   } else if (busy) {
+  drm_intel_bo *temp_bo;
 
-temp_bo = drm_intel_bo_alloc(intel-bufmgr, subdata temp, size, 64);
+  temp_bo = drm_intel_bo_alloc(intel-bufmgr, subdata temp, size, 64);
 
-drm_intel_bo_subdata(temp_bo, 0, size, data);
+  drm_intel_bo_subdata(temp_bo, 0, size, data);
 
-intel_emit_linear_blit(intel,
-   intel_obj-buffer, offset,
-   temp_bo, 0,
-   size);
+  intel_emit_linear_blit(intel,
+intel_obj-buffer, offset,
+temp_bo, 0,
+size);
 
-drm_intel_bo_unreference(temp_bo);
-  } else {
-drm_intel_bo_subdata(intel_obj-buffer, offset, size, data);
-  }
+  drm_intel_bo_unreference(temp_bo);
} else {
-  /* Can't use the blit to modify the buffer in the middle of batch. */
-  if (drm_intel_bo_references(intel-batch.bo, intel_obj-buffer)) {
+  if (intel-gen = 6 
+  drm_intel_bo_references(intel-batch.bo, intel_obj-buffer)) {
 intel_batchbuffer_flush(intel);
   }
   drm_intel_bo_subdata(intel_obj-buffer, offset, size, data);
-- 
1.7.10.4

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


Re: [Mesa-dev] [PATCH 1/2] i965: Rip out system memory backing for buffer objects; just use BOs.

2012-07-09 Thread Kenneth Graunke
On 07/09/2012 11:18 AM, Kenneth Graunke wrote:
 In one workload, 45% of CPU time was spent in pwrite(), primarily
 uploading large amounts of VBO data.  This was in fact the hottest path
 in the application, according to sysprof.  Removing the system memory
 buffer and just storing VBOs in actual BOs cut the application's CPU
 usage by about half, and moved pwrite down to about 2.5% of CPU time.
 
 Signed-off-by: Kenneth Graunke kenn...@whitecape.org
 ---
  src/mesa/drivers/dri/intel/intel_buffer_objects.c |  117 
 +
  src/mesa/drivers/dri/intel/intel_buffer_objects.h |3 -
  2 files changed, 4 insertions(+), 116 deletions(-)
 
 Here's my version of the same patch.  It's quite a bit more invasive,
 but it deletes all the code made dead by the change in Eric's patch.

Eric rightly pointed out that this code is still needed by i915.  So,
NAK on my patch 1/2, and

Reviewed-by: Kenneth Graunke kenn...@whitecape.org

on Eric's patch.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] Private window system depth/stencil buffers

2012-07-09 Thread Chad Versace
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 07/04/2012 10:52 AM, Eric Anholt wrote:
 We've been talking about doing this for a long time -- ignore the piece of
 the GLX spec about clients sharing auxiliary buffers across address spaces,
 and just allocate our own buffers.  Ever since HiZ we think it's probably
 been broken, and it was probably just going to get worse with window system
 MSAA buffers without reams of code for communicating the state between
 processes.
 
 This doesn't convert back buffers (we would need a swapbuffers and 
 copyregion interface that took a BO instead of an attachment point) or the
 fake front buffer (I'd really like to bring that into the client, but that
 requires new interfaces between the loader and driver so the driver can
 implement glXWaitGL/X).
 
 Passed piglit, and I resized a glxgears a bunch, but we know we're weak on
 glx testing in piglit.

I've wanted to do this for a long time, but never had the guts to do it :)

All but patch 2 have my review. I think that patch actually needs to kill more
code. And I think it breaks things on pre-gen6. See my reply there.

- 
Chad Versace
chad.vers...@linux.intel.com


-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.19 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJP+ySfAAoJEAIvNt057x8i0fsP/001nqv25ShaO4aMt9CQOf/H
iVYttC3ujHC78ityRmohQaYvuBI57hmAuLbUW6U0Rs/jg/ywb2QyfVA49+aCn84o
/ML2q6MsQBdySBe5LX2pyjO7OiUp1TcLgGIq7RL3U3f+kEgz+ZftOHccLnoRdFg/
Ly0qBqNWn1QZn9lc24UcRlASQuJCyXFLGx+A+WdjSZQUFsa65umEJ7xLZkG3lse3
HGRYMNG6ccPPZ+rLs6gO8UjZhoIUOsV/sMQpkBecl3Ik2wa+cr9P7/jrCj6mJcNZ
RcNyMygn5iWstb4+MuP6PE15Ds0A1KTbwAQpUL62yfow1ltgXlIrVZIqOa87ZFzY
lKBrv2S1R+LNZLgCW09UupV61kDOj8xEeRAA3heoVC/pQ01kcx+r2gvF7oy91iln
w4z3zzyWdA2NsB6Ewj5wvrFkl3FLYOo/5atMsmsSGzu/qSbOWgynd0OBWIfLW7Hs
Sxfyqx0HhDs4JxbdkFyY9bs8sPQAu7CCdX7gZgDBITfzuD6a9MK3+5+KdLGIKy7V
GgecL9h4oaRPi/ihiY/F/sjMCjMF6fyPDUads0WTUfoKKb6Gf+xJ8IdEsUEpIHtx
47sYL70VEhRE4bEXoFWfaxb1jj5lInljf5PsRRh1bnUx7XqNJCq5WTnGUsdr6v7O
NCn/M3I0xpB75bCaPvkC
=6CaC
-END PGP SIGNATURE-
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/6] intel: Convert to using private depth/stencil buffers.

2012-07-09 Thread Chad Versace
On 07/04/2012 10:52 AM, Eric Anholt wrote:
 This means that GLX buffer sharing of these no longer works.  On the
 other hand, just *look* at this code reduction.

I enjoy seeing all this code die ;) I wish we had decided earlier to break GLX
sharing before the ugly handshake code was written.



 @@ -994,8 +902,7 @@ intel_query_dri2_buffers_no_separate_stencil(struct 
 intel_context *intel,
  /**
   * \brief Assign a DRI buffer's DRM region to a renderbuffer.
   *
 - * This is called from intel_update_renderbuffers().  It is used only if
 - * either the hardware or the X driver lacks separate stencil support.
 + * This is called from intel_update_renderbuffers().
   *
   * \par Note:
   *DRI buffers whose attachment point is DRI2BufferStencil or

The \par Note above needs to be updated too.


 @@ -1008,14 +915,12 @@ intel_query_dri2_buffers_no_separate_stencil(struct 
 intel_context *intel,
   * \see intel_region_alloc_for_handle()
   */
  static void
 -intel_process_dri2_buffer_no_separate_stencil(struct intel_context *intel,
 -   __DRIdrawable *drawable,
 -   __DRIbuffer *buffer,
 -   struct intel_renderbuffer *rb,
 -   const char *buffer_name)
 +intel_process_dri2_buffer(struct intel_context *intel,
 +   __DRIdrawable *drawable,
 +   __DRIbuffer *buffer,
 +   struct intel_renderbuffer *rb,
 +   const char *buffer_name)
  {
 -   assert(!intel-must_use_separate_stencil);
 -
 struct gl_framebuffer *fb = drawable-driverPrivate;
 struct intel_renderbuffer *depth_rb = NULL;

Even after this patch, intel_process_dri2_buffer() contains a lot of
depth/stencil code. It looks dead to me and I think it should all be removed.



 @@ -557,16 +558,10 @@ intelCreateBuffer(__DRIscreen * driScrnPriv,
if (mesaVis-depthBits == 24) {
assert(mesaVis-stencilBits == 8);
  
 -  if (screen-hw_has_separate_stencil
 -   screen-dri2_has_hiz != INTEL_DRI2_HAS_HIZ_FALSE) {
 - /*
 -  * Request a separate stencil buffer even if we do not yet know if
 -  * the screen supports it. (See comments for
 -  * enum intel_dri2_has_hiz).
 -  */
 - rb = intel_create_renderbuffer(MESA_FORMAT_X8_Z24);
 +  if (screen-hw_has_separate_stencil) {
 + rb = intel_create_private_renderbuffer(MESA_FORMAT_X8_Z24);
   _mesa_add_renderbuffer(fb, BUFFER_DEPTH, rb-Base.Base);
 - rb = intel_create_renderbuffer(MESA_FORMAT_S8);
 + rb = intel_create_private_renderbuffer(MESA_FORMAT_S8);
   _mesa_add_renderbuffer(fb, BUFFER_STENCIL, rb-Base.Base);
} else {
   /*

Have you tested this on pre-gen6? I expect the else branch to be broken there,
because it's not converted to use intel_create_private_renderbuffer().
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] i965: Rip out system memory backing for buffer objects; just use BOs.

2012-07-09 Thread Chad Versace
 Eric rightly pointed out that this code is still needed by i915.  So,
 NAK on my patch 1/2, and
 
 Reviewed-by: Kenneth Graunke kenn...@whitecape.org
 
 on Eric's patch.

Is it possible to salvage patch 1/2 so that it only applies to post-i915?


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


Re: [Mesa-dev] [PATCH v2] android: fix the build

2012-07-09 Thread Chad Versace
Tapani,

Is this patch still applicable? It seems that the autoconf work has calmed down,
and now is a good time to fix the Android build.

-Chad

On 06/07/2012 04:11 AM, Tapani Pälli wrote:
 Some more of the files are now autogenerated, this caused build breakage,
 patch adds generation of these missing files. Patch also changes existing
 make so that the files are created to be part of the local source
 (not intermediate directory, this causes several problems).
 
 Signed-off-by: Tapani Pälli tapani.pa...@intel.com
 ---
  src/mesa/Android.gen.mk |   45 -
  1 file changed, 16 insertions(+), 29 deletions(-)
 
 diff --git a/src/mesa/Android.gen.mk b/src/mesa/Android.gen.mk
 index 2a08184..2ea8cc4 100644
 --- a/src/mesa/Android.gen.mk
 +++ b/src/mesa/Android.gen.mk
 @@ -28,16 +28,13 @@ LOCAL_MODULE_CLASS := STATIC_LIBRARIES
  endif
  
  intermediates := $(call local-intermediates-dir)
 +mydir := $(call my-dir)
  
  sources := \
 - main/api_exec_es1.c \
   main/api_exec_es1_dispatch.h \
   main/api_exec_es1_remap_helper.h \
 - main/api_exec_es2.c \
   main/api_exec_es2_dispatch.h \
 - main/api_exec_es2_remap_helper.h \
 - program/lex.yy.c \
 - program/program_parse.tab.c
 + main/api_exec_es2_remap_helper.h
  
  LOCAL_SRC_FILES := $(filter-out $(sources), $(LOCAL_SRC_FILES))
  
 @@ -53,6 +50,7 @@ endif
  sources += main/git_sha1.h
  
  sources := $(addprefix $(intermediates)/, $(sources))
 +
  LOCAL_GENERATED_SOURCES += $(sources)
  
  glapi := $(MESA_TOP)/src/mapi/glapi/gen
 @@ -73,43 +71,31 @@ define es-gen
   $(hide) $(PRIVATE_SCRIPT) $(1) $(PRIVATE_XML)  $@
  endef
  
 -define local-l-to-c
 - @mkdir -p $(dir $@)
 - @echo Mesa Lex: $(PRIVATE_MODULE) = $
 - $(hide) $(LEX) -o$@ $
 -endef
 -
 -define local-y-to-c-and-h
 - @mkdir -p $(dir $@)
 - @echo Mesa Yacc: $(PRIVATE_MODULE) = $
 - $(hide) $(YACC) -o $@ $
 +define generate-local
 + @echo generate local sources
 + $(hide) $(MESA_PYTHON2) $(glapi)/gl_enums.py -f 
 $(glapi)/gl_and_es_API.xml  $(mydir)/main/enums.c
 + $(hide) $(MESA_PYTHON2) $(glapi)/gl_table.py -m remap_table -f 
 $(glapi)/gl_and_es_API.xml  $(mydir)/main/dispatch.h
 + $(hide) $(MESA_PYTHON2) $(glapi)/remap_helper.py -f $(glapi)/gl_API.xml 
  $(mydir)/main/remap_helper.h
 + $(hide) $(MESA_PYTHON2) $(mydir)/main/es_generator.py -V GLES1.1 -S 
 $(mydir)/main/APIspec.xml  $(mydir)/main/api_exec_es1.c
 + $(hide) $(MESA_PYTHON2) $(mydir)/main/es_generator.py -V GLES2.0 -S 
 $(mydir)/main/APIspec.xml  $(mydir)/main/api_exec_es2.c
 +
 + @echo Mesa Lex : $(PRIVATE_MODULE)
 + $(hide) $(LEX) -o $(mydir)/program/lex.yy.c 
 $(mydir)/program/program_lexer.l
 + @echo Mesa Yacc: $(PRIVATE_MODULE)
 + $(hide) $(YACC) -d -o $(mydir)/program/program_parse.tab.c 
 $(mydir)/program/program_parse.y
  endef
  
 -$(intermediates)/main/api_exec_%.c: PRIVATE_SCRIPT := $(MESA_PYTHON2) 
 $(LOCAL_PATH)/main/es_generator.py
 -$(intermediates)/main/api_exec_%.c: PRIVATE_XML := -S 
 $(LOCAL_PATH)/main/APIspec.xml
  $(intermediates)/main/api_exec_%_dispatch.h: PRIVATE_SCRIPT := 
 $(MESA_PYTHON2) $(glapi)/gl_table.py
  $(intermediates)/main/api_exec_%_dispatch.h: PRIVATE_XML := -f 
 $(glapi)/gl_and_es_API.xml
  $(intermediates)/main/api_exec_%_remap_helper.h: PRIVATE_SCRIPT := 
 $(MESA_PYTHON2) $(glapi)/remap_helper.py
  $(intermediates)/main/api_exec_%_remap_helper.h: PRIVATE_XML := -f 
 $(glapi)/gl_and_es_API.xml
  
 -$(intermediates)/main/api_exec_es1.c: $(es_src_deps)
 - $(call es-gen,-V GLES1.1)
 -
 -$(intermediates)/main/api_exec_es2.c: $(es_src_deps)
 - $(call es-gen,-V GLES2.0)
 -
  $(intermediates)/main/api_exec_%_dispatch.h: $(es_hdr_deps)
   $(call es-gen, -c $* -m remap_table)
  
  $(intermediates)/main/api_exec_%_remap_helper.h: $(es_hdr_deps)
   $(call es-gen, -c $*)
  
 -$(intermediates)/program/program_parse.tab.c: 
 $(LOCAL_PATH)/program/program_parse.y
 - $(local-y-to-c-and-h)
 -
 -$(intermediates)/program/lex.yy.c: $(LOCAL_PATH)/program/program_lexer.l
 - $(local-l-to-c)
 -
  $(intermediates)/main/git_sha1.h:
   @mkdir -p $(dir $@)
   @echo GIT-SHA1: $(PRIVATE_MODULE) = git
 @@ -129,3 +115,4 @@ $(intermediates)/x86/matypes.h: $(matypes_deps)
   @mkdir -p $(dir $@)
   @echo MATYPES: $(PRIVATE_MODULE) = $(notdir $@)
   $(hide) $  $@
 + $(call generate-local)
 

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


[Mesa-dev] [PATCH 00/22] Gallium and R600 improvements

2012-07-09 Thread Marek Olšák
Hi everyone,

this series has two parts.

Patches 1-12 are Mesa/Gallium improvements. Most importantly, this adds 
acceleration of stencil copying (including glBlitFramebuffer) using the shader 
stencil export functionality. I am afraid r600g and radeonsi are the only 
drivers which can make use of it at the moment. There is also acceleration for 
depth texture mipmap generation.

Patches 13-22 are R600 improvements. There is a new derived state for the CB 
registers which kept cumulating in the draw_vbo function, and some improvements 
for depth-stencil flushing and uploading. My changes to the CB_TARGET_MASK 
emission in the compute code (patch #13) might need some review from somebody 
working on compute.

The R600 changes depend on the not-yet-committed patch r600g: improve flushed 
depth texture handling v2 from Vadim Girlin.

The series fixes 23 depth-stencil piglit tests on r600g.

Marek Olšák (22):
  mesa: remove assertions that do not allow compressed 2D_ARRAY textures
  gallium/u_gen_mipmap: accelerate depth texture mipmap generation
  gallium/u_blitter: minify depth0 when initializing last_layer
  gallium: add util_format_stencil helper function
  gallium/u_blitter: accelerate depth-stencil copying using shader stencil 
export
  gallium/u_blitter: accelerate stencil-only copying
  gallium/util: move pipe_tex_to_tgsi_tex helper function into u_inlines
  gallium/u_blit: don't do two copies for non-2D textures
  gallium/u_blit: drop not-very-useful wrapper around 
util_blit_pixels_writemask
  gallium/u_blit: remove useless memset calls
  st/mesa: set colormask to zero when blitting depth
  st/mesa: implement accelerated stencil blitting using shader stencil 
export
  r600g: move CB_TARGET_MASK setup into new cb_misc_state
  r600g: move MULTIWRITE setup into cb_misc_state for r6xx-r7xx
  r600g: move CB_SHADER_MASK setup into cb_misc_state
  r600g: set DISABLE in CB_COLOR_CONTROL if colormask is 0
  r600g: remove is_flush from DSA state
  r600g: do fine-grained depth texture flushing
  r600g: flush depth textures bound to vertex shaders
  r600g: don't set dirty_db_mask for a flushed depth texture
  r600g: don't flush depth textures set as colorbuffers
  r600g: fix uploading non-zero mipmap levels of depth textures

 src/gallium/auxiliary/postprocess/pp_mlaa.c|3 +-
 src/gallium/auxiliary/postprocess/pp_run.c |3 +-
 src/gallium/auxiliary/util/u_blit.c|  337 +---
 src/gallium/auxiliary/util/u_blit.h|   20 +-
 src/gallium/auxiliary/util/u_blitter.c |  153 ++---
 src/gallium/auxiliary/util/u_blitter.h |4 +-
 src/gallium/auxiliary/util/u_format.h  |   29 ++
 src/gallium/auxiliary/util/u_gen_mipmap.c  |   84 +++--
 src/gallium/auxiliary/util/u_inlines.h |   26 ++
 src/gallium/auxiliary/util/u_simple_shaders.c  |  100 ++
 src/gallium/auxiliary/util/u_simple_shaders.h  |   12 +
 src/gallium/drivers/r600/evergreen_compute.c   |3 +-
 .../drivers/r600/evergreen_compute_internal.c  |2 +-
 src/gallium/drivers/r600/evergreen_hw_context.c|4 -
 src/gallium/drivers/r600/evergreen_state.c |   36 ++-
 src/gallium/drivers/r600/evergreend.h  |2 +
 src/gallium/drivers/r600/r600_blit.c   |   99 +++---
 src/gallium/drivers/r600/r600_hw_context.c |4 +-
 src/gallium/drivers/r600/r600_pipe.h   |   27 +-
 src/gallium/drivers/r600/r600_resource.h   |6 +-
 src/gallium/drivers/r600/r600_state.c  |   42 ++-
 src/gallium/drivers/r600/r600_state_common.c   |   88 ++---
 src/gallium/drivers/r600/r600_texture.c|   23 +-
 src/gallium/drivers/r600/r600d.h   |2 +
 src/mesa/main/formats.c|6 +-
 src/mesa/state_tracker/st_cb_blit.c|   37 ++-
 src/mesa/state_tracker/st_cb_drawpixels.c  |   23 +-
 src/mesa/state_tracker/st_cb_texture.c |   32 +-
 src/mesa/state_tracker/st_context.c|2 +
 src/mesa/state_tracker/st_context.h|2 +-
 30 files changed, 838 insertions(+), 373 deletions(-)

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


[Mesa-dev] [PATCH 01/22] mesa: remove assertions that do not allow compressed 2D_ARRAY textures

2012-07-09 Thread Marek Olšák
NOTE: This is a candidate for the 8.0 branch.
---
 src/mesa/main/formats.c |6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c
index ccc0b17..c65c9c2 100644
--- a/src/mesa/main/formats.c
+++ b/src/mesa/main/formats.c
@@ -1860,8 +1860,7 @@ _mesa_format_image_size(gl_format format, GLsizei width,
   const GLuint wblocks = (width + bw - 1) / bw;
   const GLuint hblocks = (height + bh - 1) / bh;
   const GLuint sz = wblocks * hblocks * info-BytesPerBlock;
-  assert(depth == 1);
-  return sz;
+  return sz * depth;
}
else {
   /* non-compressed */
@@ -1887,8 +1886,7 @@ _mesa_format_image_size64(gl_format format, GLsizei width,
   const uint64_t wblocks = (width + bw - 1) / bw;
   const uint64_t hblocks = (height + bh - 1) / bh;
   const uint64_t sz = wblocks * hblocks * info-BytesPerBlock;
-  assert(depth == 1);
-  return sz;
+  return sz * depth;
}
else {
   /* non-compressed */
-- 
1.7.9.5

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


[Mesa-dev] [PATCH 03/22] gallium/u_blitter: minify depth0 when initializing last_layer

2012-07-09 Thread Marek Olšák
---
 src/gallium/auxiliary/util/u_blitter.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/util/u_blitter.c 
b/src/gallium/auxiliary/util/u_blitter.c
index 47d0227..99bde54 100644
--- a/src/gallium/auxiliary/util/u_blitter.c
+++ b/src/gallium/auxiliary/util/u_blitter.c
@@ -892,7 +892,7 @@ void util_blitter_default_src_texture(struct 
pipe_sampler_view *src_templ,
 src_templ-u.tex.last_level = srclevel;
 src_templ-u.tex.first_layer = 0;
 src_templ-u.tex.last_layer =
-src-target == PIPE_TEXTURE_3D ? src-depth0 - 1
+src-target == PIPE_TEXTURE_3D ? u_minify(src-depth0, srclevel) - 1
: src-array_size - 1;
 src_templ-swizzle_r = PIPE_SWIZZLE_RED;
 src_templ-swizzle_g = PIPE_SWIZZLE_GREEN;
-- 
1.7.9.5

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


[Mesa-dev] [PATCH 04/22] gallium: add util_format_stencil helper function

2012-07-09 Thread Marek Olšák
used for stencil sampler views.
---
 src/gallium/auxiliary/util/u_format.h |   29 +
 src/mesa/state_tracker/st_cb_drawpixels.c |   23 ++-
 2 files changed, 31 insertions(+), 21 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_format.h 
b/src/gallium/auxiliary/util/u_format.h
index e35e164..7995b57 100644
--- a/src/gallium/auxiliary/util/u_format.h
+++ b/src/gallium/auxiliary/util/u_format.h
@@ -882,6 +882,35 @@ util_format_linear(enum pipe_format format)
 }
 
 /**
+ * Given a depth-stencil format, return the corresponding stencil-only format.
+ * For stencil-only formats, return the format unchanged.
+ */
+static INLINE enum pipe_format
+util_format_stencil(enum pipe_format format)
+{
+   switch (format) {
+   /* mask out the depth component */
+   case PIPE_FORMAT_Z24_UNORM_S8_UINT:
+  return PIPE_FORMAT_X24S8_UINT;
+   case PIPE_FORMAT_S8_UINT_Z24_UNORM:
+  return PIPE_FORMAT_S8X24_UINT;
+   case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT:
+  return PIPE_FORMAT_X32_S8X24_UINT;
+
+   /* stencil only formats */
+   case PIPE_FORMAT_X24S8_UINT:
+   case PIPE_FORMAT_S8X24_UINT:
+   case PIPE_FORMAT_X32_S8X24_UINT:
+   case PIPE_FORMAT_S8_UINT:
+  return format;
+
+   default:
+  assert(0);
+  return PIPE_FORMAT_NONE;
+   }
+}
+
+/**
  * Return the number of components stored.
  * Formats with block size != 1x1 will always have 1 component (the block).
  */
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c 
b/src/mesa/state_tracker/st_cb_drawpixels.c
index 2bcbada..727273b 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -1165,27 +1165,8 @@ st_DrawPixels(struct gl_context *ctx, GLint x, GLint y,
  * The stencil is written using the shader stencil export
  * functionality. */
 if (write_stencil) {
-   enum pipe_format stencil_format = PIPE_FORMAT_NONE;
-
-   switch (pt-format) {
-   case PIPE_FORMAT_Z24_UNORM_S8_UINT:
-   case PIPE_FORMAT_X24S8_UINT:
-  stencil_format = PIPE_FORMAT_X24S8_UINT;
-  break;
-   case PIPE_FORMAT_S8_UINT_Z24_UNORM:
-   case PIPE_FORMAT_S8X24_UINT:
-  stencil_format = PIPE_FORMAT_S8X24_UINT;
-  break;
-   case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT:
-   case PIPE_FORMAT_X32_S8X24_UINT:
-  stencil_format = PIPE_FORMAT_X32_S8X24_UINT;
-  break;
-   case PIPE_FORMAT_S8_UINT:
-  stencil_format = PIPE_FORMAT_S8_UINT;
-  break;
-   default:
-  assert(0);
-   }
+   enum pipe_format stencil_format =
+ util_format_stencil(pt-format);
 
sv[1] = st_create_texture_sampler_view_format(st-pipe, pt,
  stencil_format);
-- 
1.7.9.5

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


[Mesa-dev] [PATCH 05/22] gallium/u_blitter: accelerate depth-stencil copying using shader stencil export

2012-07-09 Thread Marek Olšák
This fixes stencil buffer write transfers on r600g.
---
 src/gallium/auxiliary/util/u_blitter.c|   95 ++---
 src/gallium/auxiliary/util/u_blitter.h|4 +-
 src/gallium/auxiliary/util/u_simple_shaders.c |   54 ++
 src/gallium/auxiliary/util/u_simple_shaders.h |6 ++
 4 files changed, 147 insertions(+), 12 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_blitter.c 
b/src/gallium/auxiliary/util/u_blitter.c
index 99bde54..31f3139 100644
--- a/src/gallium/auxiliary/util/u_blitter.c
+++ b/src/gallium/auxiliary/util/u_blitter.c
@@ -78,6 +78,7 @@ struct blitter_context_priv
/* FS which outputs a depth from a texture,
   where the index is PIPE_TEXTURE_* to be sampled. */
void *fs_texfetch_depth[PIPE_MAX_TEXTURE_TYPES];
+   void *fs_texfetch_depthstencil[PIPE_MAX_TEXTURE_TYPES];
 
/* Blend state. */
void *blend_write_color;   /** blend state with writemask of RGBA */
@@ -112,6 +113,7 @@ struct blitter_context_priv
boolean has_geometry_shader;
boolean vertex_has_integers;
boolean has_stream_out;
+   boolean has_stencil_export;
 };
 
 static void blitter_draw_rectangle(struct blitter_context *blitter,
@@ -163,6 +165,10 @@ struct blitter_context *util_blitter_create(struct 
pipe_context *pipe)
   pipe-screen-get_param(pipe-screen,
   PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS) != 0;
 
+   ctx-has_stencil_export =
+ pipe-screen-get_param(pipe-screen,
+ PIPE_CAP_SHADER_STENCIL_EXPORT);
+
/* blend state objects */
memset(blend, 0, sizeof(blend));
ctx-blend_keep_color = pipe-create_blend_state(pipe, blend);
@@ -314,6 +320,8 @@ void util_blitter_destroy(struct blitter_context *blitter)
  pipe-delete_fs_state(pipe, ctx-fs_texfetch_col[i]);
   if (ctx-fs_texfetch_depth[i])
  pipe-delete_fs_state(pipe, ctx-fs_texfetch_depth[i]);
+  if (ctx-fs_texfetch_depthstencil[i])
+ pipe-delete_fs_state(pipe, ctx-fs_texfetch_depthstencil[i]);
}
 
for (i = 0; i = PIPE_MAX_COLOR_BUFS; i++) {
@@ -718,6 +726,26 @@ void *blitter_get_fs_texfetch_depth(struct 
blitter_context_priv *ctx,
return ctx-fs_texfetch_depth[tex_target];
 }
 
+static INLINE
+void *blitter_get_fs_texfetch_depthstencil(struct blitter_context_priv *ctx,
+   unsigned tex_target)
+{
+   struct pipe_context *pipe = ctx-base.pipe;
+
+   assert(tex_target  PIPE_MAX_TEXTURE_TYPES);
+
+   /* Create the fragment shader on-demand. */
+   if (!ctx-fs_texfetch_depthstencil[tex_target]) {
+  unsigned tgsi_tex = pipe_tex_to_tgsi_tex(tex_target);
+
+  ctx-fs_texfetch_depthstencil[tex_target] =
+ util_make_fragment_tex_shader_writedepthstencil(pipe, tgsi_tex,
+  TGSI_INTERPOLATE_LINEAR);
+   }
+
+   return ctx-fs_texfetch_depthstencil[tex_target];
+}
+
 static void blitter_set_common_draw_rect_state(struct blitter_context_priv 
*ctx)
 {
struct pipe_context *pipe = ctx-base.pipe;
@@ -916,6 +944,8 @@ void util_blitter_copy_texture(struct blitter_context 
*blitter,
struct pipe_sampler_view src_templ, *src_view;
unsigned bind;
boolean is_stencil, is_depth;
+   const struct util_format_description *src_desc =
+ util_format_description(src-format);
 
/* Give up if textures are not set. */
assert(dst  src);
@@ -925,8 +955,8 @@ void util_blitter_copy_texture(struct blitter_context 
*blitter,
assert(src-target  PIPE_MAX_TEXTURE_TYPES);
 
/* Is this a ZS format? */
-   is_depth = util_format_get_component_bits(src-format, 
UTIL_FORMAT_COLORSPACE_ZS, 0) != 0;
-   is_stencil = util_format_get_component_bits(src-format, 
UTIL_FORMAT_COLORSPACE_ZS, 1) != 0;
+   is_depth = util_format_has_depth(src_desc);
+   is_stencil = util_format_has_stencil(src_desc);
 
if (is_depth || is_stencil)
   bind = PIPE_BIND_DEPTH_STENCIL;
@@ -935,7 +965,7 @@ void util_blitter_copy_texture(struct blitter_context 
*blitter,
 
/* Check if we can sample from and render to the surfaces. */
/* (assuming copying a stencil buffer is not possible) */
-   if ((!ignore_stencil  is_stencil) ||
+   if ((!ignore_stencil  is_stencil  !ctx-has_stencil_export) ||
!screen-is_format_supported(screen, dst-format, dst-target,
 dst-nr_samples, bind) ||
!screen-is_format_supported(screen, src-format, src-target,
@@ -976,6 +1006,21 @@ void util_blitter_copy_texture_view(struct 
blitter_context *blitter,
enum pipe_texture_target src_target = src-texture-target;
unsigned width = srcbox-width;
unsigned height = srcbox-height;
+   boolean is_stencil, is_depth;
+   const struct util_format_description *src_desc =
+ util_format_description(src-format);
+
+   is_depth = util_format_has_depth(src_desc);
+   is_stencil = util_format_has_stencil(src_desc);
+
+   /* If you want a fallback for stencil copies,
+* use 

[Mesa-dev] [PATCH 06/22] gallium/u_blitter: accelerate stencil-only copying

2012-07-09 Thread Marek Olšák
This doesn't seem to be used by anything yet, but better safe than sorry.
---
 src/gallium/auxiliary/util/u_blitter.c|   28 ++-
 src/gallium/auxiliary/util/u_simple_shaders.c |   46 +
 src/gallium/auxiliary/util/u_simple_shaders.h |6 
 3 files changed, 79 insertions(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/util/u_blitter.c 
b/src/gallium/auxiliary/util/u_blitter.c
index 31f3139..b8bf322 100644
--- a/src/gallium/auxiliary/util/u_blitter.c
+++ b/src/gallium/auxiliary/util/u_blitter.c
@@ -79,6 +79,7 @@ struct blitter_context_priv
   where the index is PIPE_TEXTURE_* to be sampled. */
void *fs_texfetch_depth[PIPE_MAX_TEXTURE_TYPES];
void *fs_texfetch_depthstencil[PIPE_MAX_TEXTURE_TYPES];
+   void *fs_texfetch_stencil[PIPE_MAX_TEXTURE_TYPES];
 
/* Blend state. */
void *blend_write_color;   /** blend state with writemask of RGBA */
@@ -322,6 +323,8 @@ void util_blitter_destroy(struct blitter_context *blitter)
  pipe-delete_fs_state(pipe, ctx-fs_texfetch_depth[i]);
   if (ctx-fs_texfetch_depthstencil[i])
  pipe-delete_fs_state(pipe, ctx-fs_texfetch_depthstencil[i]);
+  if (ctx-fs_texfetch_stencil[i])
+ pipe-delete_fs_state(pipe, ctx-fs_texfetch_stencil[i]);
}
 
for (i = 0; i = PIPE_MAX_COLOR_BUFS; i++) {
@@ -746,6 +749,26 @@ void *blitter_get_fs_texfetch_depthstencil(struct 
blitter_context_priv *ctx,
return ctx-fs_texfetch_depthstencil[tex_target];
 }
 
+static INLINE
+void *blitter_get_fs_texfetch_stencil(struct blitter_context_priv *ctx,
+  unsigned tex_target)
+{
+   struct pipe_context *pipe = ctx-base.pipe;
+
+   assert(tex_target  PIPE_MAX_TEXTURE_TYPES);
+
+   /* Create the fragment shader on-demand. */
+   if (!ctx-fs_texfetch_stencil[tex_target]) {
+  unsigned tgsi_tex = pipe_tex_to_tgsi_tex(tex_target);
+
+  ctx-fs_texfetch_stencil[tex_target] =
+ util_make_fragment_tex_shader_writestencil(pipe, tgsi_tex,
+TGSI_INTERPOLATE_LINEAR);
+   }
+
+   return ctx-fs_texfetch_stencil[tex_target];
+}
+
 static void blitter_set_common_draw_rect_state(struct blitter_context_priv 
*ctx)
 {
struct pipe_context *pipe = ctx-base.pipe;
@@ -1056,7 +1079,10 @@ void util_blitter_copy_texture_view(struct 
blitter_context *blitter,
  pipe-bind_fs_state(pipe,
blitter_get_fs_texfetch_depth(ctx, src_target));
   } else { /* is_stencil */
- assert(0);
+ pipe-bind_depth_stencil_alpha_state(pipe,
+  
ctx-dsa_keep_depth_write_stencil);
+ pipe-bind_fs_state(pipe,
+   blitter_get_fs_texfetch_stencil(ctx, src_target));
   }
 
   fb_state.nr_cbufs = 0;
diff --git a/src/gallium/auxiliary/util/u_simple_shaders.c 
b/src/gallium/auxiliary/util/u_simple_shaders.c
index 545b607..3476b6c 100644
--- a/src/gallium/auxiliary/util/u_simple_shaders.c
+++ b/src/gallium/auxiliary/util/u_simple_shaders.c
@@ -265,6 +265,52 @@ util_make_fragment_tex_shader_writedepthstencil(struct 
pipe_context *pipe,
 
 
 /**
+ * Make a simple fragment texture shader which reads a texture and writes it
+ * as stencil.
+ */
+void *
+util_make_fragment_tex_shader_writestencil(struct pipe_context *pipe,
+   unsigned tex_target,
+   unsigned interp_mode)
+{
+   struct ureg_program *ureg;
+   struct ureg_src stencil_sampler;
+   struct ureg_src tex;
+   struct ureg_dst out, stencil;
+   struct ureg_src imm;
+
+   ureg = ureg_create( TGSI_PROCESSOR_FRAGMENT );
+   if (ureg == NULL)
+  return NULL;
+
+   stencil_sampler = ureg_DECL_sampler( ureg, 0 );
+
+   tex = ureg_DECL_fs_input( ureg,
+ TGSI_SEMANTIC_GENERIC, 0,
+ interp_mode );
+
+   out = ureg_DECL_output( ureg,
+   TGSI_SEMANTIC_COLOR,
+   0 );
+
+   stencil = ureg_DECL_output( ureg,
+ TGSI_SEMANTIC_STENCIL,
+ 0 );
+
+   imm = ureg_imm4f( ureg, 0, 0, 0, 1 );
+
+   ureg_MOV( ureg, out, imm );
+
+   ureg_TEX( ureg,
+ ureg_writemask(stencil, TGSI_WRITEMASK_Y),
+ tex_target, tex, stencil_sampler );
+   ureg_END( ureg );
+
+   return ureg_create_shader_and_destroy( ureg, pipe );
+}
+
+
+/**
  * Make simple fragment color pass-through shader.
  */
 void *
diff --git a/src/gallium/auxiliary/util/u_simple_shaders.h 
b/src/gallium/auxiliary/util/u_simple_shaders.h
index 54d0efe..0764998 100644
--- a/src/gallium/auxiliary/util/u_simple_shaders.h
+++ b/src/gallium/auxiliary/util/u_simple_shaders.h
@@ -81,6 +81,12 @@ util_make_fragment_tex_shader_writedepthstencil(struct 
pipe_context *pipe,
 
 
 extern void *
+util_make_fragment_tex_shader_writestencil(struct pipe_context *pipe,
+

[Mesa-dev] [PATCH 07/22] gallium/util: move pipe_tex_to_tgsi_tex helper function into u_inlines

2012-07-09 Thread Marek Olšák
---
 src/gallium/auxiliary/util/u_blitter.c |   34 
 src/gallium/auxiliary/util/u_inlines.h |   26 
 2 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_blitter.c 
b/src/gallium/auxiliary/util/u_blitter.c
index b8bf322..8b726b7 100644
--- a/src/gallium/auxiliary/util/u_blitter.c
+++ b/src/gallium/auxiliary/util/u_blitter.c
@@ -664,32 +664,6 @@ void *blitter_get_fs_col(struct blitter_context_priv *ctx, 
unsigned num_cbufs,
}
 }
 
-/** Convert PIPE_TEXTURE_x to TGSI_TEXTURE_x */
-static unsigned
-pipe_tex_to_tgsi_tex(enum pipe_texture_target pipe_tex_target)
-{
-   switch (pipe_tex_target) {
-   case PIPE_TEXTURE_1D:
-  return TGSI_TEXTURE_1D;
-   case PIPE_TEXTURE_2D:
-  return TGSI_TEXTURE_2D;
-   case PIPE_TEXTURE_RECT:
-  return TGSI_TEXTURE_RECT;
-   case PIPE_TEXTURE_3D:
-  return TGSI_TEXTURE_3D;
-   case PIPE_TEXTURE_CUBE:
-  return TGSI_TEXTURE_CUBE;
-   case PIPE_TEXTURE_1D_ARRAY:
-  return TGSI_TEXTURE_1D_ARRAY;
-   case PIPE_TEXTURE_2D_ARRAY:
-  return TGSI_TEXTURE_2D_ARRAY;
-   default:
-  assert(0  unexpected texture target);
-  return TGSI_TEXTURE_UNKNOWN;
-   }
-}
-
-
 static INLINE
 void *blitter_get_fs_texfetch_col(struct blitter_context_priv *ctx,
   unsigned tex_target)
@@ -700,7 +674,7 @@ void *blitter_get_fs_texfetch_col(struct 
blitter_context_priv *ctx,
 
/* Create the fragment shader on-demand. */
if (!ctx-fs_texfetch_col[tex_target]) {
-  unsigned tgsi_tex = pipe_tex_to_tgsi_tex(tex_target);
+  unsigned tgsi_tex = util_pipe_tex_to_tgsi_tex(tex_target);
 
   ctx-fs_texfetch_col[tex_target] =
 util_make_fragment_tex_shader(pipe, tgsi_tex, TGSI_INTERPOLATE_LINEAR);
@@ -719,7 +693,7 @@ void *blitter_get_fs_texfetch_depth(struct 
blitter_context_priv *ctx,
 
/* Create the fragment shader on-demand. */
if (!ctx-fs_texfetch_depth[tex_target]) {
-  unsigned tgsi_tex = pipe_tex_to_tgsi_tex(tex_target);
+  unsigned tgsi_tex = util_pipe_tex_to_tgsi_tex(tex_target);
 
   ctx-fs_texfetch_depth[tex_target] =
  util_make_fragment_tex_shader_writedepth(pipe, tgsi_tex,
@@ -739,7 +713,7 @@ void *blitter_get_fs_texfetch_depthstencil(struct 
blitter_context_priv *ctx,
 
/* Create the fragment shader on-demand. */
if (!ctx-fs_texfetch_depthstencil[tex_target]) {
-  unsigned tgsi_tex = pipe_tex_to_tgsi_tex(tex_target);
+  unsigned tgsi_tex = util_pipe_tex_to_tgsi_tex(tex_target);
 
   ctx-fs_texfetch_depthstencil[tex_target] =
  util_make_fragment_tex_shader_writedepthstencil(pipe, tgsi_tex,
@@ -759,7 +733,7 @@ void *blitter_get_fs_texfetch_stencil(struct 
blitter_context_priv *ctx,
 
/* Create the fragment shader on-demand. */
if (!ctx-fs_texfetch_stencil[tex_target]) {
-  unsigned tgsi_tex = pipe_tex_to_tgsi_tex(tex_target);
+  unsigned tgsi_tex = util_pipe_tex_to_tgsi_tex(tex_target);
 
   ctx-fs_texfetch_stencil[tex_target] =
  util_make_fragment_tex_shader_writestencil(pipe, tgsi_tex,
diff --git a/src/gallium/auxiliary/util/u_inlines.h 
b/src/gallium/auxiliary/util/u_inlines.h
index 2ec153c..2d603e4 100644
--- a/src/gallium/auxiliary/util/u_inlines.h
+++ b/src/gallium/auxiliary/util/u_inlines.h
@@ -30,6 +30,7 @@
 
 #include pipe/p_context.h
 #include pipe/p_defines.h
+#include pipe/p_shader_tokens.h
 #include pipe/p_state.h
 #include pipe/p_screen.h
 #include util/u_debug.h
@@ -545,6 +546,31 @@ util_query_clear_result(union pipe_query_result *result, 
unsigned type)
}
 }
 
+/** Convert PIPE_TEXTURE_x to TGSI_TEXTURE_x */
+static INLINE unsigned
+util_pipe_tex_to_tgsi_tex(enum pipe_texture_target pipe_tex_target)
+{
+   switch (pipe_tex_target) {
+   case PIPE_TEXTURE_1D:
+  return TGSI_TEXTURE_1D;
+   case PIPE_TEXTURE_2D:
+  return TGSI_TEXTURE_2D;
+   case PIPE_TEXTURE_RECT:
+  return TGSI_TEXTURE_RECT;
+   case PIPE_TEXTURE_3D:
+  return TGSI_TEXTURE_3D;
+   case PIPE_TEXTURE_CUBE:
+  return TGSI_TEXTURE_CUBE;
+   case PIPE_TEXTURE_1D_ARRAY:
+  return TGSI_TEXTURE_1D_ARRAY;
+   case PIPE_TEXTURE_2D_ARRAY:
+  return TGSI_TEXTURE_2D_ARRAY;
+   default:
+  assert(0  unexpected texture target);
+  return TGSI_TEXTURE_UNKNOWN;
+   }
+}
+
 #ifdef __cplusplus
 }
 #endif
-- 
1.7.9.5

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


[Mesa-dev] [PATCH 08/22] gallium/u_blit: don't do two copies for non-2D textures

2012-07-09 Thread Marek Olšák
Because u_blit couldn't sample a 1D, 3D, CUBE and ARRAY texture, we created
a 2D texture holding a copy of one slice of the source texture (even for 1D).

Let's just do it right.
---
 src/gallium/auxiliary/util/u_blit.c |   72 +++
 1 file changed, 39 insertions(+), 33 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_blit.c 
b/src/gallium/auxiliary/util/u_blit.c
index 9bd2ef5..9a3ff7a 100644
--- a/src/gallium/auxiliary/util/u_blit.c
+++ b/src/gallium/auxiliary/util/u_blit.c
@@ -66,8 +66,8 @@ struct blit_state
enum pipe_texture_target internal_target;
 
void *vs;
-   void *fs[TGSI_WRITEMASK_XYZW + 1];
-   void *fs_depth;
+   void *fs[PIPE_MAX_TEXTURE_TYPES][TGSI_WRITEMASK_XYZW + 1];
+   void *fs_depth[PIPE_MAX_TEXTURE_TYPES];
 
struct pipe_resource *vbuf;  /** quad vertices */
unsigned vbuf_slot;
@@ -153,17 +153,23 @@ void
 util_destroy_blit(struct blit_state *ctx)
 {
struct pipe_context *pipe = ctx-pipe;
-   unsigned i;
+   unsigned i, j;
 
if (ctx-vs)
   pipe-delete_vs_state(pipe, ctx-vs);
 
-   for (i = 0; i  Elements(ctx-fs); i++)
-  if (ctx-fs[i])
- pipe-delete_fs_state(pipe, ctx-fs[i]);
+   for (i = 0; i  Elements(ctx-fs); i++) {
+  for (j = 0; j  Elements(ctx-fs[i]); j++) {
+ if (ctx-fs[i][j])
+pipe-delete_fs_state(pipe, ctx-fs[i][j]);
+  }
+   }
 
-   if (ctx-fs_depth)
-  pipe-delete_fs_state(pipe, ctx-fs_depth);
+   for (i = 0; i  Elements(ctx-fs_depth); i++) {
+  if (ctx-fs_depth[i]) {
+ pipe-delete_fs_state(pipe, ctx-fs_depth[i]);
+  }
+   }
 
pipe_resource_reference(ctx-vbuf, NULL);
 
@@ -175,15 +181,19 @@ util_destroy_blit(struct blit_state *ctx)
  * Helper function to set the fragment shaders.
  */
 static INLINE void
-set_fragment_shader(struct blit_state *ctx, uint writemask)
+set_fragment_shader(struct blit_state *ctx, uint writemask,
+enum pipe_texture_target pipe_tex)
 {
-   if (!ctx-fs[writemask])
-  ctx-fs[writemask] =
- util_make_fragment_tex_shader_writemask(ctx-pipe, TGSI_TEXTURE_2D,
+   if (!ctx-fs[pipe_tex][writemask]) {
+  unsigned tgsi_tex = util_pipe_tex_to_tgsi_tex(pipe_tex);
+
+  ctx-fs[pipe_tex][writemask] =
+ util_make_fragment_tex_shader_writemask(ctx-pipe, tgsi_tex,
  TGSI_INTERPOLATE_LINEAR,
  writemask);
+   }
 
-   cso_set_fragment_shader_handle(ctx-cso, ctx-fs[writemask]);
+   cso_set_fragment_shader_handle(ctx-cso, ctx-fs[pipe_tex][writemask]);
 }
 
 
@@ -191,14 +201,18 @@ set_fragment_shader(struct blit_state *ctx, uint 
writemask)
  * Helper function to set the depthwrite shader.
  */
 static INLINE void
-set_depth_fragment_shader(struct blit_state *ctx)
+set_depth_fragment_shader(struct blit_state *ctx,
+  enum pipe_texture_target pipe_tex)
 {
-   if (!ctx-fs_depth)
-  ctx-fs_depth =
- util_make_fragment_tex_shader_writedepth(ctx-pipe, TGSI_TEXTURE_2D,
+   if (!ctx-fs_depth[pipe_tex]) {
+  unsigned tgsi_tex = util_pipe_tex_to_tgsi_tex(pipe_tex);
+
+  ctx-fs_depth[pipe_tex] =
+ util_make_fragment_tex_shader_writedepth(ctx-pipe, tgsi_tex,
   TGSI_INTERPOLATE_LINEAR);
+   }
 
-   cso_set_fragment_shader_handle(ctx-cso, ctx-fs_depth);
+   cso_set_fragment_shader_handle(ctx-cso, ctx-fs_depth[pipe_tex]);
 }
 
 
@@ -430,20 +444,11 @@ util_blit_pixels_writemask(struct blit_state *ctx,
   dst_surface = pipe-create_surface(pipe, dst-texture, templ);
}
 
-   /* Create a temporary texture when src and dest alias or when src
-* is anything other than a 2d texture.
-* XXX should just use appropriate shader to access 1d / 3d slice / cube 
face,
-* much like the u_blitter code does (should be pretty trivial).
-* 
-* This can still be improved upon.
+   /* Create a temporary texture when src and dest alias.
 */
-   if ((src_tex == dst_surface-texture 
+   if (src_tex == dst_surface-texture 
dst_surface-u.tex.level == src_level 
-   dst_surface-u.tex.first_layer == srcZ0) ||
-   (src_tex-target != PIPE_TEXTURE_2D 
-   src_tex-target != PIPE_TEXTURE_2D 
-   src_tex-target != PIPE_TEXTURE_RECT))
-   {
+   dst_surface-u.tex.first_layer == srcZ0) {
   /* Make a temporary texture which contains a copy of the source pixels.
* Then we'll sample from the temporary texture.
*/
@@ -598,9 +603,9 @@ util_blit_pixels_writemask(struct blit_state *ctx,
 
/* shaders */
if (dst_is_depth) {
-  set_depth_fragment_shader(ctx);
+  set_depth_fragment_shader(ctx, sampler_view-texture-target);
} else {
-  set_fragment_shader(ctx, writemask);
+  set_fragment_shader(ctx, writemask, sampler_view-texture-target);
}
set_vertex_shader(ctx);
cso_set_geometry_shader_handle(ctx-cso, NULL);
@@ -775,7 +780,8 @@ 

[Mesa-dev] [PATCH 10/22] gallium/u_blit: remove useless memset calls

2012-07-09 Thread Marek Olšák
the structure is calloc'd.
---
 src/gallium/auxiliary/util/u_blit.c |6 --
 1 file changed, 6 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_blit.c 
b/src/gallium/auxiliary/util/u_blit.c
index 469f249..6cdfbca 100644
--- a/src/gallium/auxiliary/util/u_blit.c
+++ b/src/gallium/auxiliary/util/u_blit.c
@@ -94,24 +94,19 @@ util_create_blit(struct pipe_context *pipe, struct 
cso_context *cso)
ctx-cso = cso;
 
/* disabled blending/masking */
-   memset(ctx-blend, 0, sizeof(ctx-blend));
ctx-blend.rt[0].colormask = PIPE_MASK_RGBA;
 
/* no-op depth/stencil/alpha */
-   memset(ctx-depthstencil_keep, 0, sizeof(ctx-depthstencil_keep));
-   memset(ctx-depthstencil_write, 0, sizeof(ctx-depthstencil_write));
ctx-depthstencil_write.depth.enabled = 1;
ctx-depthstencil_write.depth.writemask = 1;
ctx-depthstencil_write.depth.func = PIPE_FUNC_ALWAYS;
 
/* rasterizer */
-   memset(ctx-rasterizer, 0, sizeof(ctx-rasterizer));
ctx-rasterizer.cull_face = PIPE_FACE_NONE;
ctx-rasterizer.gl_rasterization_rules = 1;
ctx-rasterizer.depth_clip = 1;
 
/* samplers */
-   memset(ctx-sampler, 0, sizeof(ctx-sampler));
ctx-sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
ctx-sampler.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
ctx-sampler.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
@@ -120,7 +115,6 @@ util_create_blit(struct pipe_context *pipe, struct 
cso_context *cso)
ctx-sampler.mag_img_filter = 0; /* set later */
 
/* vertex elements state */
-   memset(ctx-velem[0], 0, sizeof(ctx-velem[0]) * 2);
for (i = 0; i  2; i++) {
   ctx-velem[i].src_offset = i * 4 * sizeof(float);
   ctx-velem[i].instance_divisor = 0;
-- 
1.7.9.5

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


[Mesa-dev] [PATCH 11/22] st/mesa: set colormask to zero when blitting depth

2012-07-09 Thread Marek Olšák
---
 src/gallium/auxiliary/util/u_blit.c |   12 
 src/mesa/state_tracker/st_cb_blit.c |4 ++--
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_blit.c 
b/src/gallium/auxiliary/util/u_blit.c
index 6cdfbca..30f4a93 100644
--- a/src/gallium/auxiliary/util/u_blit.c
+++ b/src/gallium/auxiliary/util/u_blit.c
@@ -56,7 +56,7 @@ struct blit_state
struct pipe_context *pipe;
struct cso_context *cso;
 
-   struct pipe_blend_state blend;
+   struct pipe_blend_state blend_write_color, blend_keep_color;
struct pipe_depth_stencil_alpha_state depthstencil_keep;
struct pipe_depth_stencil_alpha_state depthstencil_write;
struct pipe_rasterizer_state rasterizer;
@@ -94,7 +94,7 @@ util_create_blit(struct pipe_context *pipe, struct 
cso_context *cso)
ctx-cso = cso;
 
/* disabled blending/masking */
-   ctx-blend.rt[0].colormask = PIPE_MASK_RGBA;
+   ctx-blend_write_color.rt[0].colormask = PIPE_MASK_RGBA;
 
/* no-op depth/stencil/alpha */
ctx-depthstencil_write.depth.enabled = 1;
@@ -564,7 +564,11 @@ util_blit_pixels(struct blit_state *ctx,
cso_save_vertex_buffers(ctx-cso);
 
/* set misc state we care about */
-   cso_set_blend(ctx-cso, ctx-blend);
+   if (writemask)
+  cso_set_blend(ctx-cso, ctx-blend_write_color);
+   else
+  cso_set_blend(ctx-cso, ctx-blend_keep_color);
+
cso_set_depth_stencil_alpha(ctx-cso,
dst_is_depth ? ctx-depthstencil_write :
   ctx-depthstencil_keep);
@@ -721,7 +725,7 @@ util_blit_pixels_tex(struct blit_state *ctx,
cso_save_vertex_buffers(ctx-cso);
 
/* set misc state we care about */
-   cso_set_blend(ctx-cso, ctx-blend);
+   cso_set_blend(ctx-cso, ctx-blend_write_color);
cso_set_depth_stencil_alpha(ctx-cso, ctx-depthstencil_keep);
cso_set_rasterizer(ctx-cso, ctx-rasterizer);
cso_set_vertex_elements(ctx-cso, 2, ctx-velem);
diff --git a/src/mesa/state_tracker/st_cb_blit.c 
b/src/mesa/state_tracker/st_cb_blit.c
index 4547ba7..a50b79a 100644
--- a/src/mesa/state_tracker/st_cb_blit.c
+++ b/src/mesa/state_tracker/st_cb_blit.c
@@ -294,7 +294,7 @@ st_BlitFramebuffer(struct gl_context *ctx,
   srcX0, srcY0, srcX1, srcY1,
   srcDepthRb-surface-u.tex.first_layer,
   dstDepthSurf, dstX0, dstY0, dstX1, dstY1,
-  0.0, pFilter, TGSI_WRITEMASK_XYZW);
+  0.0, pFilter, 0);
   }
   else {
  /* blitting depth and stencil separately */
@@ -305,7 +305,7 @@ st_BlitFramebuffer(struct gl_context *ctx,
  srcX0, srcY0, srcX1, srcY1,
  srcDepthRb-surface-u.tex.first_layer,
  dstDepthSurf, dstX0, dstY0, dstX1, dstY1,
- 0.0, pFilter, TGSI_WRITEMASK_XYZW);
+ 0.0, pFilter, 0);
  }
 
  if (mask  GL_STENCIL_BUFFER_BIT) {
-- 
1.7.9.5

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


[Mesa-dev] [PATCH 12/22] st/mesa: implement accelerated stencil blitting using shader stencil export

2012-07-09 Thread Marek Olšák
---
 src/gallium/auxiliary/postprocess/pp_mlaa.c |2 +-
 src/gallium/auxiliary/postprocess/pp_run.c  |2 +-
 src/gallium/auxiliary/util/u_blit.c |  206 ++-
 src/gallium/auxiliary/util/u_blit.h |4 +-
 src/mesa/state_tracker/st_cb_blit.c |   37 -
 src/mesa/state_tracker/st_cb_texture.c  |   12 +-
 src/mesa/state_tracker/st_context.c |2 +
 src/mesa/state_tracker/st_context.h |2 +-
 8 files changed, 217 insertions(+), 50 deletions(-)

diff --git a/src/gallium/auxiliary/postprocess/pp_mlaa.c 
b/src/gallium/auxiliary/postprocess/pp_mlaa.c
index 80db862..951b76f 100644
--- a/src/gallium/auxiliary/postprocess/pp_mlaa.c
+++ b/src/gallium/auxiliary/postprocess/pp_mlaa.c
@@ -179,7 +179,7 @@ pp_jimenezmlaa_run(struct pp_queue_t *ppq, struct 
pipe_resource *in,
util_blit_pixels(p-blitctx, in, 0, 0, 0,
 w, h, 0, p-framebuffer.cbufs[0],
 0, 0, w, h, 0, PIPE_TEX_MIPFILTER_NEAREST,
-TGSI_WRITEMASK_XYZW);
+TGSI_WRITEMASK_XYZW, 0);
 
u_sampler_view_default_template(v_tmp, in, in-format);
arr[0] = p-pipe-create_sampler_view(p-pipe, in, v_tmp);
diff --git a/src/gallium/auxiliary/postprocess/pp_run.c 
b/src/gallium/auxiliary/postprocess/pp_run.c
index 9d0bfdf..d2f7aa6 100644
--- a/src/gallium/auxiliary/postprocess/pp_run.c
+++ b/src/gallium/auxiliary/postprocess/pp_run.c
@@ -60,7 +60,7 @@ pp_run(struct pp_queue_t *ppq, struct pipe_resource *in,
   util_blit_pixels(ppq-p-blitctx, in, 0, 0, 0,
w, h, 0, ppq-tmps[0],
0, 0, w, h, 0, PIPE_TEX_MIPFILTER_NEAREST,
-   TGSI_WRITEMASK_XYZW);
+   TGSI_WRITEMASK_XYZW, 0);
 
   in = ppq-tmp[0];
}
diff --git a/src/gallium/auxiliary/util/u_blit.c 
b/src/gallium/auxiliary/util/u_blit.c
index 30f4a93..f9fe5fb 100644
--- a/src/gallium/auxiliary/util/u_blit.c
+++ b/src/gallium/auxiliary/util/u_blit.c
@@ -57,8 +57,10 @@ struct blit_state
struct cso_context *cso;
 
struct pipe_blend_state blend_write_color, blend_keep_color;
-   struct pipe_depth_stencil_alpha_state depthstencil_keep;
-   struct pipe_depth_stencil_alpha_state depthstencil_write;
+   struct pipe_depth_stencil_alpha_state dsa_keep_depthstencil;
+   struct pipe_depth_stencil_alpha_state dsa_write_depthstencil;
+   struct pipe_depth_stencil_alpha_state dsa_write_depth;
+   struct pipe_depth_stencil_alpha_state dsa_write_stencil;
struct pipe_rasterizer_state rasterizer;
struct pipe_sampler_state sampler;
struct pipe_viewport_state viewport;
@@ -67,12 +69,16 @@ struct blit_state
 
void *vs;
void *fs[PIPE_MAX_TEXTURE_TYPES][TGSI_WRITEMASK_XYZW + 1];
+   void *fs_depthstencil[PIPE_MAX_TEXTURE_TYPES];
void *fs_depth[PIPE_MAX_TEXTURE_TYPES];
+   void *fs_stencil[PIPE_MAX_TEXTURE_TYPES];
 
struct pipe_resource *vbuf;  /** quad vertices */
unsigned vbuf_slot;
 
float vertices[4][2][4];   /** vertex/texcoords for quad */
+
+   boolean has_stencil_export;
 };
 
 
@@ -96,10 +102,19 @@ util_create_blit(struct pipe_context *pipe, struct 
cso_context *cso)
/* disabled blending/masking */
ctx-blend_write_color.rt[0].colormask = PIPE_MASK_RGBA;
 
-   /* no-op depth/stencil/alpha */
-   ctx-depthstencil_write.depth.enabled = 1;
-   ctx-depthstencil_write.depth.writemask = 1;
-   ctx-depthstencil_write.depth.func = PIPE_FUNC_ALWAYS;
+   /* depth stencil states */
+   ctx-dsa_write_depth.depth.enabled = 1;
+   ctx-dsa_write_depth.depth.writemask = 1;
+   ctx-dsa_write_depth.depth.func = PIPE_FUNC_ALWAYS;
+   ctx-dsa_write_stencil.stencil[0].enabled = 1;
+   ctx-dsa_write_stencil.stencil[0].func = PIPE_FUNC_ALWAYS;
+   ctx-dsa_write_stencil.stencil[0].fail_op = PIPE_STENCIL_OP_REPLACE;
+   ctx-dsa_write_stencil.stencil[0].zpass_op = PIPE_STENCIL_OP_REPLACE;
+   ctx-dsa_write_stencil.stencil[0].zfail_op = PIPE_STENCIL_OP_REPLACE;
+   ctx-dsa_write_stencil.stencil[0].valuemask = 0xff;
+   ctx-dsa_write_stencil.stencil[0].writemask = 0xff;
+   ctx-dsa_write_depthstencil.depth = ctx-dsa_write_depth.depth;
+   ctx-dsa_write_depthstencil.stencil[0] = ctx-dsa_write_stencil.stencil[0];
 
/* rasterizer */
ctx-rasterizer.cull_face = PIPE_FACE_NONE;
@@ -136,6 +151,9 @@ util_create_blit(struct pipe_context *pipe, struct 
cso_context *cso)
else
   ctx-internal_target = PIPE_TEXTURE_RECT;
 
+   ctx-has_stencil_export =
+  pipe-screen-get_param(pipe-screen, PIPE_CAP_SHADER_STENCIL_EXPORT);
+
return ctx;
 }
 
@@ -159,10 +177,16 @@ util_destroy_blit(struct blit_state *ctx)
   }
}
 
-   for (i = 0; i  Elements(ctx-fs_depth); i++) {
+   for (i = 0; i  PIPE_MAX_TEXTURE_TYPES; i++) {
+  if (ctx-fs_depthstencil[i]) {
+ pipe-delete_fs_state(pipe, ctx-fs_depthstencil[i]);
+  }
   if (ctx-fs_depth[i]) {
  pipe-delete_fs_state(pipe, ctx-fs_depth[i]);
   }
+  if (ctx-fs_stencil[i]) {
+   

[Mesa-dev] [PATCH 13/22] r600g: move CB_TARGET_MASK setup into new cb_misc_state

2012-07-09 Thread Marek Olšák
to remove some overhead from draw_vbo. This is a derived state.

BTW, I've got no idea how compute interacts with 3D here, but it should
use cb_misc_state, so that 3D and compute don't conflict.
---
 src/gallium/drivers/r600/evergreen_compute.c   |3 +--
 .../drivers/r600/evergreen_compute_internal.c  |2 +-
 src/gallium/drivers/r600/evergreen_hw_context.c|2 --
 src/gallium/drivers/r600/evergreen_state.c |   17 +
 src/gallium/drivers/r600/r600_hw_context.c |2 +-
 src/gallium/drivers/r600/r600_pipe.h   |9 -
 src/gallium/drivers/r600/r600_state.c  |   17 +
 src/gallium/drivers/r600/r600_state_common.c   |   12 ++--
 8 files changed, 51 insertions(+), 13 deletions(-)

diff --git a/src/gallium/drivers/r600/evergreen_compute.c 
b/src/gallium/drivers/r600/evergreen_compute.c
index 40200ae..322994d 100644
--- a/src/gallium/drivers/r600/evergreen_compute.c
+++ b/src/gallium/drivers/r600/evergreen_compute.c
@@ -280,10 +280,9 @@ void evergreen_direct_dispatch(
 
struct evergreen_compute_resource* res = get_empty_res(rctx-cs_shader,
COMPUTE_RESOURCE_DISPATCH, 0);
-struct r600_pipe_state * cb_state = 
rctx-states[R600_PIPE_STATE_FRAMEBUFFER];
 
/* Set CB_TARGET_MASK */
-   r600_pipe_state_add_reg(cb_state, R_028238_CB_TARGET_MASK, 
rctx-cb_target_mask);
+   evergreen_reg_set(res, R_028238_CB_TARGET_MASK, 
rctx-compute_cb_target_mask);
 
evergreen_reg_set(res, R_008958_VGT_PRIMITIVE_TYPE, 
V_008958_DI_PT_POINTLIST);
 
diff --git a/src/gallium/drivers/r600/evergreen_compute_internal.c 
b/src/gallium/drivers/r600/evergreen_compute_internal.c
index eb86a34..c5aad93 100644
--- a/src/gallium/drivers/r600/evergreen_compute_internal.c
+++ b/src/gallium/drivers/r600/evergreen_compute_internal.c
@@ -289,7 +289,7 @@ void evergreen_set_rat(
 * XXX: I think this is a potential spot for bugs once we start doing
 * GL interop.  cb_target_mask may be modified in the 3D sections
 * of this driver. */
-   pipe-ctx-cb_target_mask |= (0xf  (id * 4));
+   pipe-ctx-compute_cb_target_mask |= (0xf  (id * 4));
 
 
/* Get the CB register writes for the RAT */
diff --git a/src/gallium/drivers/r600/evergreen_hw_context.c 
b/src/gallium/drivers/r600/evergreen_hw_context.c
index 2ab29c9..dcbe0a4 100644
--- a/src/gallium/drivers/r600/evergreen_hw_context.c
+++ b/src/gallium/drivers/r600/evergreen_hw_context.c
@@ -66,7 +66,6 @@ static const struct r600_reg evergreen_context_reg_list[] = {
{R_028204_PA_SC_WINDOW_SCISSOR_TL, 0, 0},
{R_028208_PA_SC_WINDOW_SCISSOR_BR, 0, 0},
{R_028234_PA_SU_HARDWARE_SCREEN_OFFSET, 0, 0},
-   {R_028238_CB_TARGET_MASK, 0, 0},
{R_02823C_CB_SHADER_MASK, 0, 0},
{R_028250_PA_SC_VPORT_SCISSOR_0_TL, 0, 0},
{R_028254_PA_SC_VPORT_SCISSOR_0_BR, 0, 0},
@@ -326,7 +325,6 @@ static const struct r600_reg cayman_context_reg_list[] = {
{R_028204_PA_SC_WINDOW_SCISSOR_TL, 0, 0},
{R_028208_PA_SC_WINDOW_SCISSOR_BR, 0, 0},
{R_028234_PA_SU_HARDWARE_SCREEN_OFFSET, 0, 0},
-   {R_028238_CB_TARGET_MASK, 0, 0},
{R_02823C_CB_SHADER_MASK, 0, 0},
{R_028250_PA_SC_VPORT_SCISSOR_0_TL, 0, 0},
{R_028254_PA_SC_VPORT_SCISSOR_0_BR, 0, 0},
diff --git a/src/gallium/drivers/r600/evergreen_state.c 
b/src/gallium/drivers/r600/evergreen_state.c
index 8b5f664..600e81f 100644
--- a/src/gallium/drivers/r600/evergreen_state.c
+++ b/src/gallium/drivers/r600/evergreen_state.c
@@ -1728,6 +1728,21 @@ static void evergreen_set_framebuffer_state(struct 
pipe_context *ctx,
if (state-zsbuf) {
evergreen_polygon_offset_update(rctx);
}
+
+   if (rctx-cb_misc_state.nr_cbufs != state-nr_cbufs) {
+   rctx-cb_misc_state.nr_cbufs = state-nr_cbufs;
+   r600_atom_dirty(rctx, rctx-cb_misc_state.atom);
+   }
+}
+
+static void evergreen_emit_cb_misc_state(struct r600_context *rctx, struct 
r600_atom *atom)
+{
+   struct radeon_winsys_cs *cs = rctx-cs;
+   struct r600_cb_misc_state *a = (struct r600_cb_misc_state*)atom;
+   unsigned fb_colormask = (1ULL  ((unsigned)a-nr_cbufs * 4)) - 1;
+
+   r600_write_context_reg(cs, R_028238_CB_TARGET_MASK,
+  a-blend_colormask  fb_colormask);
 }
 
 static void evergreen_emit_db_misc_state(struct r600_context *rctx, struct 
r600_atom *atom)
@@ -1862,6 +1877,8 @@ static void evergreen_emit_ps_constant_buffer(struct 
r600_context *rctx, struct
 
 void evergreen_init_state_functions(struct r600_context *rctx)
 {
+   r600_init_atom(rctx-cb_misc_state.atom, evergreen_emit_cb_misc_state, 
0, 0);
+   r600_atom_dirty(rctx, rctx-cb_misc_state.atom);
r600_init_atom(rctx-db_misc_state.atom, evergreen_emit_db_misc_state, 
6, 0);
r600_atom_dirty(rctx, rctx-db_misc_state.atom);

[Mesa-dev] [PATCH 14/22] r600g: move MULTIWRITE setup into cb_misc_state for r6xx-r7xx

2012-07-09 Thread Marek Olšák
---
 src/gallium/drivers/r600/r600_hw_context.c   |1 -
 src/gallium/drivers/r600/r600_pipe.h |3 ++-
 src/gallium/drivers/r600/r600_state.c|4 
 src/gallium/drivers/r600/r600_state_common.c |   33 +++---
 4 files changed, 20 insertions(+), 21 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_hw_context.c 
b/src/gallium/drivers/r600/r600_hw_context.c
index d387678..a89019d 100644
--- a/src/gallium/drivers/r600/r600_hw_context.c
+++ b/src/gallium/drivers/r600/r600_hw_context.c
@@ -358,7 +358,6 @@ static const struct r600_reg r600_context_reg_list[] = {
{R_0287A0_CB_SHADER_CONTROL, 0, 0},
{R_028800_DB_DEPTH_CONTROL, 0, 0},
{R_028804_CB_BLEND_CONTROL, 0, 0},
-   {R_028808_CB_COLOR_CONTROL, 0, 0},
{R_02880C_DB_SHADER_CONTROL, 0, 0},
{R_02800C_DB_DEPTH_BASE, REG_FLAG_NEED_BO|REG_FLAG_RV6XX_SBU, 
SURFACE_BASE_UPDATE_DEPTH},
{R_028000_DB_DEPTH_SIZE, 0, 0},
diff --git a/src/gallium/drivers/r600/r600_pipe.h 
b/src/gallium/drivers/r600/r600_pipe.h
index 3d33348..68827ab 100644
--- a/src/gallium/drivers/r600/r600_pipe.h
+++ b/src/gallium/drivers/r600/r600_pipe.h
@@ -84,8 +84,10 @@ struct r600_db_misc_state {
 
 struct r600_cb_misc_state {
struct r600_atom atom;
+   unsigned cb_color_control; /* this comes from blend state */
unsigned blend_colormask; /* 8*4 bits for 8 RGBA colorbuffers */
unsigned nr_cbufs;
+   bool multiwrite;
 };
 
 enum r600_pipe_state_id {
@@ -292,7 +294,6 @@ struct r600_context {
unsignedsx_alpha_test_control;
unsignedcb_shader_mask;
unsigneddb_shader_control;
-   unsignedcb_color_control;
unsignedpa_sc_line_stipple;
unsignedpa_cl_clip_cntl;
/* for saving when using blitter */
diff --git a/src/gallium/drivers/r600/r600_state.c 
b/src/gallium/drivers/r600/r600_state.c
index a7eb7b6..9e8880f 100644
--- a/src/gallium/drivers/r600/r600_state.c
+++ b/src/gallium/drivers/r600/r600_state.c
@@ -1703,9 +1703,13 @@ static void r600_emit_cb_misc_state(struct r600_context 
*rctx, struct r600_atom
struct radeon_winsys_cs *cs = rctx-cs;
struct r600_cb_misc_state *a = (struct r600_cb_misc_state*)atom;
unsigned fb_colormask = (1ULL  ((unsigned)a-nr_cbufs * 4)) - 1;
+   unsigned multiwrite = a-multiwrite  a-nr_cbufs  1;
 
r600_write_context_reg(cs, R_028238_CB_TARGET_MASK,
   a-blend_colormask  fb_colormask);
+   r600_write_context_reg(cs, R_028808_CB_COLOR_CONTROL,
+  a-cb_color_control |
+  S_028808_MULTIWRITE_ENABLE(multiwrite));
 }
 
 static void r600_emit_db_misc_state(struct r600_context *rctx, struct 
r600_atom *atom)
diff --git a/src/gallium/drivers/r600/r600_state_common.c 
b/src/gallium/drivers/r600/r600_state_common.c
index 0e071d0..cbaaa55 100644
--- a/src/gallium/drivers/r600/r600_state_common.c
+++ b/src/gallium/drivers/r600/r600_state_common.c
@@ -157,9 +157,6 @@ void r600_bind_blend_state(struct pipe_context *ctx, void 
*state)
return;
rstate = blend-rstate;
rctx-states[rstate-id] = rstate;
-   /* Replace every bit except MULTIWRITE_ENABLE. */
-   rctx-cb_color_control = ~C_028808_MULTIWRITE_ENABLE;
-   rctx-cb_color_control |= blend-cb_color_control  
C_028808_MULTIWRITE_ENABLE;
rctx-dual_src_blend = blend-dual_src_blend;
r600_context_pipe_state_set(rctx, rstate);
 
@@ -167,6 +164,11 @@ void r600_bind_blend_state(struct pipe_context *ctx, void 
*state)
rctx-cb_misc_state.blend_colormask = blend-cb_target_mask;
r600_atom_dirty(rctx, rctx-cb_misc_state.atom);
}
+   if (rctx-chip_class = R700 
+   rctx-cb_misc_state.cb_color_control != blend-cb_color_control) {
+   rctx-cb_misc_state.cb_color_control = blend-cb_color_control;
+   r600_atom_dirty(rctx, rctx-cb_misc_state.atom);
+   }
 }
 
 void r600_set_blend_color(struct pipe_context *ctx,
@@ -563,9 +565,16 @@ void r600_bind_ps_shader(struct pipe_context *ctx, void 
*state)
rctx-ps_shader = (struct r600_pipe_shader_selector *)state;
r600_context_pipe_state_set(rctx, rctx-ps_shader-current-rstate);
 
+   if (rctx-chip_class = R700) {
+   bool multiwrite = rctx-ps_shader-current-shader.fs_write_all;
 
-   if (rctx-chip_class  EVERGREEN  rctx-vs_shader) {
-   r600_adjust_gprs(rctx);
+   if (rctx-cb_misc_state.multiwrite != multiwrite) {
+   rctx-cb_misc_state.multiwrite = multiwrite;
+   r600_atom_dirty(rctx, rctx-cb_misc_state.atom);
+   }
+
+   if (rctx-vs_shader)
+   r600_adjust_gprs(rctx);
}
 }
 
@@ -906,13 

[Mesa-dev] [PATCH 15/22] r600g: move CB_SHADER_MASK setup into cb_misc_state

2012-07-09 Thread Marek Olšák
---
 src/gallium/drivers/r600/evergreen_hw_context.c |2 --
 src/gallium/drivers/r600/evergreen_state.c  |   13 ---
 src/gallium/drivers/r600/r600_hw_context.c  |1 -
 src/gallium/drivers/r600/r600_pipe.h|6 ++---
 src/gallium/drivers/r600/r600_state.c   |   10 
 src/gallium/drivers/r600/r600_state_common.c|   28 +++
 6 files changed, 32 insertions(+), 28 deletions(-)

diff --git a/src/gallium/drivers/r600/evergreen_hw_context.c 
b/src/gallium/drivers/r600/evergreen_hw_context.c
index dcbe0a4..53d4582 100644
--- a/src/gallium/drivers/r600/evergreen_hw_context.c
+++ b/src/gallium/drivers/r600/evergreen_hw_context.c
@@ -66,7 +66,6 @@ static const struct r600_reg evergreen_context_reg_list[] = {
{R_028204_PA_SC_WINDOW_SCISSOR_TL, 0, 0},
{R_028208_PA_SC_WINDOW_SCISSOR_BR, 0, 0},
{R_028234_PA_SU_HARDWARE_SCREEN_OFFSET, 0, 0},
-   {R_02823C_CB_SHADER_MASK, 0, 0},
{R_028250_PA_SC_VPORT_SCISSOR_0_TL, 0, 0},
{R_028254_PA_SC_VPORT_SCISSOR_0_BR, 0, 0},
{R_028350_SX_MISC, 0, 0},
@@ -325,7 +324,6 @@ static const struct r600_reg cayman_context_reg_list[] = {
{R_028204_PA_SC_WINDOW_SCISSOR_TL, 0, 0},
{R_028208_PA_SC_WINDOW_SCISSOR_BR, 0, 0},
{R_028234_PA_SU_HARDWARE_SCREEN_OFFSET, 0, 0},
-   {R_02823C_CB_SHADER_MASK, 0, 0},
{R_028250_PA_SC_VPORT_SCISSOR_0_TL, 0, 0},
{R_028254_PA_SC_VPORT_SCISSOR_0_BR, 0, 0},
{R_028350_SX_MISC, 0, 0},
diff --git a/src/gallium/drivers/r600/evergreen_state.c 
b/src/gallium/drivers/r600/evergreen_state.c
index 600e81f..2ca6bc7 100644
--- a/src/gallium/drivers/r600/evergreen_state.c
+++ b/src/gallium/drivers/r600/evergreen_state.c
@@ -1709,11 +1709,6 @@ static void evergreen_set_framebuffer_state(struct 
pipe_context *ctx,
evergreen_db(rctx, rstate, state);
}
 
-   rctx-fb_cb_shader_mask = 0;
-   for (int i = 0; i  state-nr_cbufs; i++) {
-   rctx-fb_cb_shader_mask |= 0xf  (i * 4);
-   }
-
evergreen_get_scissor_rect(rctx, 0, 0, state-width, state-height, 
tl, br);
 
r600_pipe_state_add_reg(rstate,
@@ -1740,9 +1735,11 @@ static void evergreen_emit_cb_misc_state(struct 
r600_context *rctx, struct r600_
struct radeon_winsys_cs *cs = rctx-cs;
struct r600_cb_misc_state *a = (struct r600_cb_misc_state*)atom;
unsigned fb_colormask = (1ULL  ((unsigned)a-nr_cbufs * 4)) - 1;
+   unsigned ps_colormask = (1ULL  ((unsigned)a-nr_ps_color_outputs * 
4)) - 1;
 
-   r600_write_context_reg(cs, R_028238_CB_TARGET_MASK,
-  a-blend_colormask  fb_colormask);
+   r600_write_context_reg_seq(cs, R_028238_CB_TARGET_MASK, 2);
+   r600_write_value(cs, a-blend_colormask  fb_colormask); /* 
R_028238_CB_TARGET_MASK */
+   r600_write_value(cs, (a-dual_src_blend ? ps_colormask : 0) | 
fb_colormask); /* R_02823C_CB_SHADER_MASK */
 }
 
 static void evergreen_emit_db_misc_state(struct r600_context *rctx, struct 
r600_atom *atom)
@@ -2702,7 +2699,7 @@ void evergreen_pipe_shader_ps(struct pipe_context *ctx, 
struct r600_pipe_shader
/* always at least export 1 component per pixel */
exports_ps = 2;
}
-   shader-ps_cb_shader_mask = (1ULL  ((unsigned)num_cout * 4)) - 1;
+   shader-nr_ps_color_outputs = num_cout;
if (ninterp == 0) {
ninterp = 1;
have_perspective = TRUE;
diff --git a/src/gallium/drivers/r600/r600_hw_context.c 
b/src/gallium/drivers/r600/r600_hw_context.c
index a89019d..b236069 100644
--- a/src/gallium/drivers/r600/r600_hw_context.c
+++ b/src/gallium/drivers/r600/r600_hw_context.c
@@ -335,7 +335,6 @@ static const struct r600_reg r600_context_reg_list[] = {
{R_028124_CB_CLEAR_GREEN, 0, 0},
{R_028128_CB_CLEAR_BLUE, 0, 0},
{R_02812C_CB_CLEAR_ALPHA, 0, 0},
-   {R_02823C_CB_SHADER_MASK, 0, 0},
{R_028410_SX_ALPHA_TEST_CONTROL, 0, 0},
{R_028414_CB_BLEND_RED, 0, 0},
{R_028418_CB_BLEND_GREEN, 0, 0},
diff --git a/src/gallium/drivers/r600/r600_pipe.h 
b/src/gallium/drivers/r600/r600_pipe.h
index 68827ab..aac2b1f 100644
--- a/src/gallium/drivers/r600/r600_pipe.h
+++ b/src/gallium/drivers/r600/r600_pipe.h
@@ -87,7 +87,9 @@ struct r600_cb_misc_state {
unsigned cb_color_control; /* this comes from blend state */
unsigned blend_colormask; /* 8*4 bits for 8 RGBA colorbuffers */
unsigned nr_cbufs;
+   unsigned nr_ps_color_outputs;
bool multiwrite;
+   bool dual_src_blend;
 };
 
 enum r600_pipe_state_id {
@@ -221,7 +223,7 @@ struct r600_pipe_shader {
unsignedsprite_coord_enable;
unsignedflatshade;
unsignedpa_cl_vs_out_cntl;
-   unsignedps_cb_shader_mask;
+   unsignednr_ps_color_outputs;
unsignedkey;
unsigneddb_shader_control;

[Mesa-dev] [PATCH 16/22] r600g: set DISABLE in CB_COLOR_CONTROL if colormask is 0

2012-07-09 Thread Marek Olšák
this will be useful for in-place DB decompression, otherwise should be harmless
---
 src/gallium/drivers/r600/evergreen_state.c |   10 +++---
 src/gallium/drivers/r600/evergreend.h  |2 ++
 src/gallium/drivers/r600/r600_state.c  |6 ++
 src/gallium/drivers/r600/r600d.h   |2 ++
 4 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/r600/evergreen_state.c 
b/src/gallium/drivers/r600/evergreen_state.c
index 2ca6bc7..58a5052 100644
--- a/src/gallium/drivers/r600/evergreen_state.c
+++ b/src/gallium/drivers/r600/evergreen_state.c
@@ -680,7 +680,7 @@ static void *evergreen_create_blend_state(struct 
pipe_context *ctx,
struct r600_context *rctx = (struct r600_context *)ctx;
struct r600_pipe_blend *blend = CALLOC_STRUCT(r600_pipe_blend);
struct r600_pipe_state *rstate;
-   uint32_t color_control, target_mask;
+   uint32_t color_control = 0, target_mask;
/* XXX there is more then 8 framebuffer */
unsigned blend_cntl[8];
 
@@ -693,7 +693,6 @@ static void *evergreen_create_blend_state(struct 
pipe_context *ctx,
rstate-id = R600_PIPE_STATE_BLEND;
 
target_mask = 0;
-   color_control = S_028808_MODE(1);
if (state-logicop_enable) {
color_control |= (state-logicop_func  16) | 
(state-logicop_func  20);
} else {
@@ -710,7 +709,12 @@ static void *evergreen_create_blend_state(struct 
pipe_context *ctx,
}
}
blend-cb_target_mask = target_mask;
-   
+
+   if (target_mask)
+   color_control |= S_028808_MODE(V_028808_CB_NORMAL);
+   else
+   color_control |= S_028808_MODE(V_028808_CB_DISABLE);
+
r600_pipe_state_add_reg(rstate, R_028808_CB_COLOR_CONTROL,
color_control);
/* only have dual source on MRT0 */
diff --git a/src/gallium/drivers/r600/evergreend.h 
b/src/gallium/drivers/r600/evergreend.h
index a067ad2..6c4873c 100644
--- a/src/gallium/drivers/r600/evergreend.h
+++ b/src/gallium/drivers/r600/evergreend.h
@@ -482,6 +482,8 @@
 #define   S_028808_MODE(x) (((x)  0x7)  4)
 #define   G_028808_MODE(x) (((x)  4)  0x7)
 #define   C_028808_MODE0xFF8F
+#define V_028808_CB_DISABLE0
+#define V_028808_CB_NORMAL 1
 #define   S_028808_ROP3(x) (((x)  0xFF)  16)
 #define   G_028808_ROP3(x) (((x)  16)  0xFF)
 #define   C_028808_ROP30xFF00
diff --git a/src/gallium/drivers/r600/r600_state.c 
b/src/gallium/drivers/r600/r600_state.c
index 9bbb63f..c261797 100644
--- a/src/gallium/drivers/r600/r600_state.c
+++ b/src/gallium/drivers/r600/r600_state.c
@@ -718,6 +718,12 @@ static void *r600_create_blend_state(struct pipe_context 
*ctx,
target_mask |= (state-rt[0].colormask  (4 * i));
}
}
+
+   if (target_mask)
+   color_control |= S_028808_SPECIAL_OP(V_028808_NORMAL);
+   else
+   color_control |= S_028808_SPECIAL_OP(V_028808_DISABLE);
+
blend-cb_target_mask = target_mask;
blend-cb_color_control = color_control;
/* only MRT0 has dual src blend */
diff --git a/src/gallium/drivers/r600/r600d.h b/src/gallium/drivers/r600/r600d.h
index ab36d73..c9f8422 100644
--- a/src/gallium/drivers/r600/r600d.h
+++ b/src/gallium/drivers/r600/r600d.h
@@ -418,6 +418,8 @@
 #define   G_028808_DEGAMMA_ENABLE(x)   (((x)  3)  0x1)
 #define   C_028808_DEGAMMA_ENABLE  0xFFF7
 #define   S_028808_SPECIAL_OP(x)   (((x)  0x7)  4)
+#defineV_028808_NORMAL 0
+#defineV_028808_DISABLE1
 #define   G_028808_SPECIAL_OP(x)   (((x)  4)  0x7)
 #define   C_028808_SPECIAL_OP  0xFF8F
 #define   S_028808_PER_MRT_BLEND(x)(((x)  0x1)  7)
-- 
1.7.9.5

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


[Mesa-dev] [PATCH 17/22] r600g: remove is_flush from DSA state

2012-07-09 Thread Marek Olšák
we can just update the state when decompressing, there's no need to add
additional info into the DSA state
---
 src/gallium/drivers/r600/r600_blit.c |   13 +
 src/gallium/drivers/r600/r600_pipe.h |3 +--
 src/gallium/drivers/r600/r600_state.c|9 ++---
 src/gallium/drivers/r600/r600_state_common.c |5 -
 4 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_blit.c 
b/src/gallium/drivers/r600/r600_blit.c
index d85324b..b6238dc 100644
--- a/src/gallium/drivers/r600/r600_blit.c
+++ b/src/gallium/drivers/r600/r600_blit.c
@@ -131,6 +131,13 @@ void r600_blit_uncompress_depth(struct pipe_context *ctx,
rctx-family == CHIP_RV620 || rctx-family == CHIP_RV635)
depth = 0.0f;
 
+   if (rctx-chip_class = R700 
+   !rctx-db_misc_state.flush_depthstencil_through_cb) {
+   /* Enable decompression in DB_RENDER_CONTROL */
+   rctx-db_misc_state.flush_depthstencil_through_cb = true;
+   r600_atom_dirty(rctx, rctx-db_misc_state.atom);
+   }
+
for (level = 0; level = texture-resource.b.b.last_level; level++) {
unsigned num_layers = u_num_layers(texture-resource.b.b, 
level);
 
@@ -161,6 +168,12 @@ void r600_blit_uncompress_depth(struct pipe_context *ctx,
 
if (!staging)
texture-dirty_db = FALSE;
+
+   if (rctx-chip_class = R700) {
+   /* Disable decompression in DB_RENDER_CONTROL */
+   rctx-db_misc_state.flush_depthstencil_through_cb = false;
+   r600_atom_dirty(rctx, rctx-db_misc_state.atom);
+   }
 }
 
 void r600_flush_depth_textures(struct r600_context *rctx)
diff --git a/src/gallium/drivers/r600/r600_pipe.h 
b/src/gallium/drivers/r600/r600_pipe.h
index aac2b1f..ebc6be4 100644
--- a/src/gallium/drivers/r600/r600_pipe.h
+++ b/src/gallium/drivers/r600/r600_pipe.h
@@ -79,7 +79,7 @@ struct r600_surface_sync_cmd {
 struct r600_db_misc_state {
struct r600_atom atom;
bool occlusion_query_enabled;
-   bool flush_depthstencil_enabled;
+   bool flush_depthstencil_through_cb;
 };
 
 struct r600_cb_misc_state {
@@ -183,7 +183,6 @@ struct r600_pipe_dsa {
unsignedalpha_ref;
ubyte   valuemask[2];
ubyte   writemask[2];
-   boolis_flush;
unsignedsx_alpha_test_control;
 };
 
diff --git a/src/gallium/drivers/r600/r600_state.c 
b/src/gallium/drivers/r600/r600_state.c
index c261797..6c0c0fe 100644
--- a/src/gallium/drivers/r600/r600_state.c
+++ b/src/gallium/drivers/r600/r600_state.c
@@ -1734,7 +1734,7 @@ static void r600_emit_db_misc_state(struct r600_context 
*rctx, struct r600_atom
}
db_render_override |= S_028D10_NOOP_CULL_DISABLE(1);
}
-   if (a-flush_depthstencil_enabled) {
+   if (a-flush_depthstencil_through_cb) {
db_render_control |= S_028D0C_DEPTH_COPY_ENABLE(1) |
 S_028D0C_STENCIL_COPY_ENABLE(1) |
 S_028D0C_COPY_CENTROID(1);
@@ -2457,8 +2457,6 @@ void r600_fetch_shader(struct pipe_context *ctx,
 void *r600_create_db_flush_dsa(struct r600_context *rctx)
 {
struct pipe_depth_stencil_alpha_state dsa;
-   struct r600_pipe_state *rstate;
-   struct r600_pipe_dsa *dsa_state;
boolean quirk = false;
 
if (rctx-family == CHIP_RV610 || rctx-family == CHIP_RV630 ||
@@ -2477,10 +2475,7 @@ void *r600_create_db_flush_dsa(struct r600_context *rctx)
dsa.stencil[0].writemask = 0xff;
}
 
-   rstate = rctx-context.create_depth_stencil_alpha_state(rctx-context, 
dsa);
-   dsa_state = (struct r600_pipe_dsa*)rstate;
-   dsa_state-is_flush = true;
-   return rstate;
+   return rctx-context.create_depth_stencil_alpha_state(rctx-context, 
dsa);
 }
 
 void r600_update_dual_export_state(struct r600_context * rctx)
diff --git a/src/gallium/drivers/r600/r600_state_common.c 
b/src/gallium/drivers/r600/r600_state_common.c
index 178ddcc..f3808e6 100644
--- a/src/gallium/drivers/r600/r600_state_common.c
+++ b/src/gallium/drivers/r600/r600_state_common.c
@@ -272,11 +272,6 @@ void r600_bind_dsa_state(struct pipe_context *ctx, void 
*state)
ref.writemask[1] = dsa-writemask[1];
 
r600_set_stencil_ref(ctx, ref);
-
-   if (rctx-db_misc_state.flush_depthstencil_enabled != dsa-is_flush) {
-   rctx-db_misc_state.flush_depthstencil_enabled = dsa-is_flush;
-   r600_atom_dirty(rctx, rctx-db_misc_state.atom);
-   }
 }
 
 void r600_set_max_scissor(struct r600_context *rctx)
-- 
1.7.9.5

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


[Mesa-dev] [PATCH 18/22] r600g: do fine-grained depth texture flushing

2012-07-09 Thread Marek Olšák
- maintain a mask of which mipmap levels are dirty (instead of one big flag)
- only flush what was requested at a given point and not the whole resource
  (most often only one level and one layer has to be flushed)
---
 src/gallium/drivers/r600/r600_blit.c |   65 +-
 src/gallium/drivers/r600/r600_pipe.h |4 +-
 src/gallium/drivers/r600/r600_resource.h |6 ++-
 src/gallium/drivers/r600/r600_state_common.c |   10 ++--
 src/gallium/drivers/r600/r600_texture.c  |   18 +--
 5 files changed, 69 insertions(+), 34 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_blit.c 
b/src/gallium/drivers/r600/r600_blit.c
index b6238dc..1d838bd 100644
--- a/src/gallium/drivers/r600/r600_blit.c
+++ b/src/gallium/drivers/r600/r600_blit.c
@@ -98,33 +98,34 @@ static void r600_blitter_end(struct pipe_context *ctx)
r600_resume_nontimer_queries(rctx);
 }
 
-static unsigned u_num_layers(struct pipe_resource *r, unsigned level)
+static unsigned u_max_layer(struct pipe_resource *r, unsigned level)
 {
switch (r-target) {
case PIPE_TEXTURE_CUBE:
-   return 6;
+   return 6 - 1;
case PIPE_TEXTURE_3D:
-   return u_minify(r-depth0, level);
+   return u_minify(r-depth0, level) - 1;
case PIPE_TEXTURE_1D_ARRAY:
-   return r-array_size;
case PIPE_TEXTURE_2D_ARRAY:
-   return r-array_size;
+   return r-array_size - 1;
default:
-   return 1;
+   return 0;
}
 }
 
 void r600_blit_uncompress_depth(struct pipe_context *ctx,
struct r600_resource_texture *texture,
-   struct r600_resource_texture *staging)
+   struct r600_resource_texture *staging,
+   unsigned first_level, unsigned last_level,
+   unsigned first_layer, unsigned last_layer)
 {
struct r600_context *rctx = (struct r600_context *)ctx;
-   unsigned layer, level;
+   unsigned layer, level, checked_last_layer, max_layer;
float depth = 1.0f;
struct r600_resource_texture *flushed_depth_texture = staging ?
staging : texture-flushed_depth_texture;
 
-   if (!staging  !texture-dirty_db)
+   if (!staging  !texture-dirty_db_mask)
return;
 
if (rctx-family == CHIP_RV610 || rctx-family == CHIP_RV630 ||
@@ -138,10 +139,16 @@ void r600_blit_uncompress_depth(struct pipe_context *ctx,
r600_atom_dirty(rctx, rctx-db_misc_state.atom);
}
 
-   for (level = 0; level = texture-resource.b.b.last_level; level++) {
-   unsigned num_layers = u_num_layers(texture-resource.b.b, 
level);
+   for (level = first_level; level = last_level; level++) {
+   if (!staging  !(texture-dirty_db_mask  (1  level)))
+   continue;
+
+   /* The smaller the mipmap level, the less layers there are
+* as far as 3D textures are concerned. */
+   max_layer = u_max_layer(texture-resource.b.b, level);
+   checked_last_layer = last_layer  max_layer ? last_layer : 
max_layer;
 
-   for (layer = 0; layer  num_layers; layer++) {
+   for (layer = first_layer; layer = checked_last_layer; layer++) 
{
struct pipe_surface *zsurf, *cbsurf, surf_tmpl;
 
surf_tmpl.format = texture-real_format;
@@ -164,10 +171,13 @@ void r600_blit_uncompress_depth(struct pipe_context *ctx,
pipe_surface_reference(zsurf, NULL);
pipe_surface_reference(cbsurf, NULL);
}
-   }
 
-   if (!staging)
-   texture-dirty_db = FALSE;
+   /* The texture will always be dirty if some layers aren't 
flushed.
+* I don't think this case can occur though. */
+   if (!staging  first_layer == 0  last_layer == max_layer) {
+   texture-dirty_db_mask = ~(1  level);
+   }
+   }
 
if (rctx-chip_class = R700) {
/* Disable decompression in DB_RENDER_CONTROL */
@@ -183,26 +193,31 @@ void r600_flush_depth_textures(struct r600_context *rctx)
/* XXX: This handles fragment shader textures only. */
 
for (i = 0; i  rctx-ps_samplers.n_views; ++i) {
-   struct r600_pipe_sampler_view *view;
+   struct pipe_sampler_view *view;
struct r600_resource_texture *tex;
 
-   view = rctx-ps_samplers.views[i];
+   view = rctx-ps_samplers.views[i]-base;
if (!view) continue;
 
-   tex = (struct r600_resource_texture *)view-base.texture;
+   tex = (struct r600_resource_texture *)view-texture;
if (!tex-is_depth)
continue;
 
if (tex-is_flushing_texture)
continue;
 
-

[Mesa-dev] [PATCH 19/22] r600g: flush depth textures bound to vertex shaders

2012-07-09 Thread Marek Olšák
This was missing/broken. There are also minor code cleanups.
---
 src/gallium/drivers/r600/r600_blit.c |   29 +-
 src/gallium/drivers/r600/r600_pipe.h |2 +-
 src/gallium/drivers/r600/r600_state_common.c |2 +-
 3 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_blit.c 
b/src/gallium/drivers/r600/r600_blit.c
index 1d838bd..23e3190 100644
--- a/src/gallium/drivers/r600/r600_blit.c
+++ b/src/gallium/drivers/r600/r600_blit.c
@@ -186,24 +186,20 @@ void r600_blit_uncompress_depth(struct pipe_context *ctx,
}
 }
 
-void r600_flush_depth_textures(struct r600_context *rctx)
+static void r600_flush_depth_textures(struct r600_context *rctx,
+ struct r600_textures_info *textures)
 {
-   unsigned int i;
+   unsigned i;
 
-   /* XXX: This handles fragment shader textures only. */
-
-   for (i = 0; i  rctx-ps_samplers.n_views; ++i) {
+   for (i = 0; i  textures-n_views; ++i) {
struct pipe_sampler_view *view;
struct r600_resource_texture *tex;
 
-   view = rctx-ps_samplers.views[i]-base;
+   view = textures-views[i]-base;
if (!view) continue;
 
tex = (struct r600_resource_texture *)view-texture;
-   if (!tex-is_depth)
-   continue;
-
-   if (tex-is_flushing_texture)
+   if (!tex-is_depth || tex-is_flushing_texture)
continue;
 
r600_blit_uncompress_depth(rctx-context, tex, NULL,
@@ -212,6 +208,14 @@ void r600_flush_depth_textures(struct r600_context *rctx)
   0,
   u_max_layer(tex-resource.b.b, 
view-u.tex.first_level));
}
+}
+
+void r600_flush_all_depth_textures(struct r600_context *rctx)
+{
+   unsigned i;
+
+   r600_flush_depth_textures(rctx, rctx-ps_samplers);
+   r600_flush_depth_textures(rctx, rctx-vs_samplers);
 
/* also check CB here */
for (i = 0; i  rctx-framebuffer.nr_cbufs; i++) {
@@ -219,10 +223,7 @@ void r600_flush_depth_textures(struct r600_context *rctx)
struct pipe_surface *surf = rctx-framebuffer.cbufs[i];
tex = (struct r600_resource_texture *)surf-texture;
 
-   if (!tex-is_depth)
-   continue;
-
-   if (tex-is_flushing_texture)
+   if (!tex-is_depth || tex-is_flushing_texture)
continue;
 
r600_blit_uncompress_depth(rctx-context, tex, NULL,
diff --git a/src/gallium/drivers/r600/r600_pipe.h 
b/src/gallium/drivers/r600/r600_pipe.h
index d026532..877088b 100644
--- a/src/gallium/drivers/r600/r600_pipe.h
+++ b/src/gallium/drivers/r600/r600_pipe.h
@@ -445,7 +445,7 @@ void r600_blit_uncompress_depth(struct pipe_context *ctx,
struct r600_resource_texture *staging,
unsigned first_level, unsigned last_level,
unsigned first_layer, unsigned last_layer);
-void r600_flush_depth_textures(struct r600_context *rctx);
+void r600_flush_all_depth_textures(struct r600_context *rctx);
 
 /* r600_buffer.c */
 bool r600_init_resource(struct r600_screen *rscreen,
diff --git a/src/gallium/drivers/r600/r600_state_common.c 
b/src/gallium/drivers/r600/r600_state_common.c
index e62cd2e..d952220 100644
--- a/src/gallium/drivers/r600/r600_state_common.c
+++ b/src/gallium/drivers/r600/r600_state_common.c
@@ -805,7 +805,7 @@ static void r600_update_derived_state(struct r600_context 
*rctx)
 
if (!rctx-blitter-running) {
if (rctx-have_depth_fb || rctx-have_depth_texture)
-   r600_flush_depth_textures(rctx);
+   r600_flush_all_depth_textures(rctx);
}
 
if (rctx-chip_class  EVERGREEN) {
-- 
1.7.9.5

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


[Mesa-dev] [PATCH 20/22] r600g: don't set dirty_db_mask for a flushed depth texture

2012-07-09 Thread Marek Olšák
A flush depth texture is never set as a depth buffer and never flushed.
---
 src/gallium/drivers/r600/r600_texture.c |2 --
 1 file changed, 2 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_texture.c 
b/src/gallium/drivers/r600/r600_texture.c
index c34df2d..a6a83ca 100644
--- a/src/gallium/drivers/r600/r600_texture.c
+++ b/src/gallium/drivers/r600/r600_texture.c
@@ -753,8 +753,6 @@ void r600_init_flushed_depth_texture(struct pipe_context 
*ctx,
 
if (staging)
resource.flags |= R600_RESOURCE_FLAG_TRANSFER;
-   else
-   rtex-dirty_db_mask = (1  (resource.last_level+1)) - 1;
 
*flushed_depth_texture = (struct r600_resource_texture 
*)ctx-screen-resource_create(ctx-screen, resource);
if (*flushed_depth_texture == NULL) {
-- 
1.7.9.5

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


[Mesa-dev] [PATCH 22/22] r600g: fix uploading non-zero mipmap levels of depth textures

2012-07-09 Thread Marek Olšák
This fixes piglit/depth-level-clamp.
---
 src/gallium/drivers/r600/r600_texture.c |5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_texture.c 
b/src/gallium/drivers/r600/r600_texture.c
index a6a83ca..d16c252 100644
--- a/src/gallium/drivers/r600/r600_texture.c
+++ b/src/gallium/drivers/r600/r600_texture.c
@@ -926,8 +926,9 @@ void r600_texture_transfer_destroy(struct pipe_context *ctx,
 
u_box_origin_2d(texture-width0, texture-height0, 
sbox);
 
-   ctx-resource_copy_region(ctx, texture, 0, 0, 0, 0,
- rtransfer-staging-b.b, 0,
+   ctx-resource_copy_region(ctx, texture, transfer-level,
+ 0, 0, transfer-box.z,
+ rtransfer-staging-b.b, 
transfer-level,
  sbox);
}
} else if (rtransfer-staging) {
-- 
1.7.9.5

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


[Mesa-dev] [PATCH 21/22] r600g: don't flush depth textures set as colorbuffers

2012-07-09 Thread Marek Olšák
The only case a depth buffer can be set as a color buffer is when flushing.

That wasn't always the case, but now this code isn't required anymore.
---
 src/gallium/drivers/r600/r600_blit.c |   18 --
 1 file changed, 18 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_blit.c 
b/src/gallium/drivers/r600/r600_blit.c
index 23e3190..fff48a4 100644
--- a/src/gallium/drivers/r600/r600_blit.c
+++ b/src/gallium/drivers/r600/r600_blit.c
@@ -212,26 +212,8 @@ static void r600_flush_depth_textures(struct r600_context 
*rctx,
 
 void r600_flush_all_depth_textures(struct r600_context *rctx)
 {
-   unsigned i;
-
r600_flush_depth_textures(rctx, rctx-ps_samplers);
r600_flush_depth_textures(rctx, rctx-vs_samplers);
-
-   /* also check CB here */
-   for (i = 0; i  rctx-framebuffer.nr_cbufs; i++) {
-   struct r600_resource_texture *tex;
-   struct pipe_surface *surf = rctx-framebuffer.cbufs[i];
-   tex = (struct r600_resource_texture *)surf-texture;
-
-   if (!tex-is_depth || tex-is_flushing_texture)
-   continue;
-
-   r600_blit_uncompress_depth(rctx-context, tex, NULL,
-  surf-u.tex.level,
-  surf-u.tex.level,
-  surf-u.tex.first_layer,
-  surf-u.tex.last_layer);
-   }
 }
 
 static void r600_clear(struct pipe_context *ctx, unsigned buffers,
-- 
1.7.9.5

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


Re: [Mesa-dev] [PATCH 1/2] i965: Rip out system memory backing for buffer objects; just use BOs.

2012-07-09 Thread Kenneth Graunke
On 07/09/2012 11:44 AM, Chad Versace wrote:
 Eric rightly pointed out that this code is still needed by i915.  So,
 NAK on my patch 1/2, and

 Reviewed-by: Kenneth Graunke kenn...@whitecape.org

 on Eric's patch.
 
 Is it possible to salvage patch 1/2 so that it only applies to post-i915?

Sure.  But then it becomes Eric's patch.


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


Re: [Mesa-dev] [PATCH] Make it possible to install gl.pc and osmesa.pc together.

2012-07-09 Thread Eric Anholt
Johannes Obermayr johannesoberm...@gmx.de writes:

 Am Montag, 9. Juli 2012, 09:45:56 schrieb Eric Anholt:
 osmesa didn't install gl.pc in the past as far as I can see, and I don't
 think it should -- it's not a normal GL implementation, so you want to
 be specifically looking for osmesa in your pkgconfig checks.

 Mesa-demos require gl.pc (line 28) and osmesa.pc (line 36):
 https://build.opensuse.org/package/view_file?file=Mesa-demos.specpackage=Mesa-demosproject=home:jobermayr

 Building Mesa with

 ./autogen.sh --host=i586-suse-linux-gnu --build=i586-suse-linux-gnu 
 --program-prefix= --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin 
 --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share 
 --includedir=/usr/include --libdir=/usr/lib --libexecdir=/usr/lib 
 --localstatedir=/var --sharedstatedir=/usr/com --mandir=/usr/share/man 
 --infodir=/usr/share/info --enable-xvmc --enable-vdpau --enable-texture-float 
 --enable-debug --enable-dri --enable-glx --enable-osmesa 
 --with-dri-drivers=i915,i965,nouveau,r200,radeon,swrast --enable-gles1 
 --enable-gles2 --enable-openvg --enable-shared-glapi 
 --with-gallium-drivers=i915,nouveau,r300,r600,svga,swrast --enable-gbm 
 --enable-xorg --enable-xa --enable-gallium-egl --with-x --enable-gallium-llvm 
 --enable-gallium-gbm --enable-gallium-g3dvl

 worked for almost a year until

 http://cgit.freedesktop.org/mesa/mesa/commit/?id=39785488e6a3f6beeb58372b88d49274a76d02f4

 because both pc files were installed ...
 After that commit OBS bitched a missing gl.pc until I applied the
 patch.

OK, so your issue is about a Mesa build with osmesa and another GL
implementation, not about an osmesa-only build.  Your patch is fine with
me, then.



pgpERh9vd8Jlt.pgp
Description: PGP signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/2] i965: Use the blitter in intel_bufferobj_subdata for busy BOs on Gen6+.

2012-07-09 Thread Eric Anholt
Kenneth Graunke kenn...@whitecape.org writes:

 Previously we only did this pre-Gen6, and used pwrite on Gen6+.
 In one workload, this cuts significant amount of overhead.

 Signed-off-by: Kenneth Graunke kenn...@whitecape.org
 ---
  src/mesa/drivers/dri/intel/intel_buffer_objects.c |   26 
 +
  1 file changed, 11 insertions(+), 15 deletions(-)

 diff --git a/src/mesa/drivers/dri/intel/intel_buffer_objects.c 
 b/src/mesa/drivers/dri/intel/intel_buffer_objects.c
 index 200fce3..169d777 100644
 --- a/src/mesa/drivers/dri/intel/intel_buffer_objects.c
 +++ b/src/mesa/drivers/dri/intel/intel_buffer_objects.c
 @@ -178,26 +178,22 @@ intel_bufferobj_subdata(struct gl_context * ctx,
drm_intel_bo_unreference(intel_obj-buffer);
intel_bufferobj_alloc_buffer(intel, intel_obj);
drm_intel_bo_subdata(intel_obj-buffer, 0, size, data);
 -   } else if (intel-gen  6) {
 -  if (busy) {
 -  drm_intel_bo *temp_bo;
 +   } else if (busy) {
 +  drm_intel_bo *temp_bo;
  
 -  temp_bo = drm_intel_bo_alloc(intel-bufmgr, subdata temp, size, 64);
 +  temp_bo = drm_intel_bo_alloc(intel-bufmgr, subdata temp, size, 64);
  
 -  drm_intel_bo_subdata(temp_bo, 0, size, data);
 +  drm_intel_bo_subdata(temp_bo, 0, size, data);
  
 -  intel_emit_linear_blit(intel,
 - intel_obj-buffer, offset,
 - temp_bo, 0,
 - size);
 +  intel_emit_linear_blit(intel,
 +  intel_obj-buffer, offset,
 +  temp_bo, 0,
 +  size);
  
 -  drm_intel_bo_unreference(temp_bo);
 -  } else {
 -  drm_intel_bo_subdata(intel_obj-buffer, offset, size, data);
 -  }
 +  drm_intel_bo_unreference(temp_bo);
 } else {
 -  /* Can't use the blit to modify the buffer in the middle of batch. */
 -  if (drm_intel_bo_references(intel-batch.bo, intel_obj-buffer)) {
 +  if (intel-gen = 6 
 +  drm_intel_bo_references(intel-batch.bo, intel_obj-buffer)) {
intel_batchbuffer_flush(intel);
}

I don't think we need any bo_references check for flushing in this path
any more, since bo_references implies the if (busy) path being taken.

The function might be rewritten in fewer lines of change to be:

if (busy) {
   if (size == obj-size) {
  realloc, subdata
   } else {
  blit
   }
} else {
   subdata
}


pgpcA5dxaEF1e.pgp
Description: PGP signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/8] i965/msaa: Move {rt, tex}_interleaved into blorp program key.

2012-07-09 Thread Chad Versace
 @@ -192,6 +192,12 @@ struct brw_blorp_blit_prog_key
  */
 unsigned tex_samples;
  
 +   /* If tex_samples  0, whether or not the GPU pipeline will be configured
 +* to read from it as though it were an interleaved MSAA layout.  False if
 +* tex_samples == 0.
 +*/
 +   bool tex_interleaved;

There's a confusing sentence fragment here.
 +
 /* Actual number of samples per pixel in the source image. */
 unsigned src_samples;
  
 @@ -205,6 +211,12 @@ struct brw_blorp_blit_prog_key
  */
 unsigned rt_samples;
  
 +   /* If rt_samples  0, whether or not the GPU pipeline will be configured
 +* to write to it as though it were an interleaved MSAA layout.  False if
 +* rt_samples == 0.
 +*/
 +   bool rt_interleaved;

Here too.

But you kill these comments in the next patch, so whatever.

Reviewed-by: Chad Versace chad.vers...@linux.intel.com
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 4/8] i965/msaa: Add CMS MSAA settings to brw_structs.h.

2012-07-09 Thread Chad Versace
On 07/06/2012 03:29 PM, Paul Berry wrote:
 Previously the DWORD used to control the CMS MSAA layout was just a
 pad value, because we didn't use it.
 ---
  src/mesa/drivers/dri/i965/brw_structs.h |   22 --
  1 files changed, 20 insertions(+), 2 deletions(-)

The documentation for that state packet is the most confusing I've yet
encountered. The hw doc guys really need to refactor that table.

Reviewed-by: Chad Versace chad.vers...@linux.intel.com

I'll start reviewing the series' second half tomorrow.


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


Re: [Mesa-dev] [PATCH 1/8] i965/msaa: Move {rt, tex}_interleaved into blorp program key.

2012-07-09 Thread Paul Berry
On 9 July 2012 13:35, Chad Versace chad.vers...@linux.intel.com wrote:

  @@ -192,6 +192,12 @@ struct brw_blorp_blit_prog_key
   */
  unsigned tex_samples;
 
  +   /* If tex_samples  0, whether or not the GPU pipeline will be
 configured
  +* to read from it as though it were an interleaved MSAA layout.
  False if
  +* tex_samples == 0.
  +*/
  +   bool tex_interleaved;

 There's a confusing sentence fragment here.


Oh, wow, that's a pretty bad garden path sentence.  I'll fix it to If
tex_samples  0, this boolean indicates whether or not the GPU pipeline
will be configured


  +
  /* Actual number of samples per pixel in the source image. */
  unsigned src_samples;
 
  @@ -205,6 +211,12 @@ struct brw_blorp_blit_prog_key
   */
  unsigned rt_samples;
 
  +   /* If rt_samples  0, whether or not the GPU pipeline will be
 configured
  +* to write to it as though it were an interleaved MSAA layout.
  False if
  +* rt_samples == 0.
  +*/
  +   bool rt_interleaved;

 Here too.

 But you kill these comments in the next patch, so whatever.

 Reviewed-by: Chad Versace chad.vers...@linux.intel.com

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


Re: [Mesa-dev] [PATCH 3/8] i965/msaa: Allocate MCS buffer when CMS MSAA is in use.

2012-07-09 Thread Paul Berry
On 9 July 2012 13:36, Chad Versace chad.vers...@linux.intel.com wrote:

 On 07/06/2012 03:29 PM, Paul Berry wrote:
  To implement Gen7's CMS MSAA layout, we need an extra buffer, the MCS
  (Multisample Control Surface) buffer.  This patch introduces code for
  allocating and deallocating the buffer, and storing a pointer to it in
  the intel_mipmap_tree struct.
 
  No functional change, since the CMS layout is not enabled yet.
  ---
   src/mesa/drivers/dri/intel/intel_fbo.c |9 +
   src/mesa/drivers/dri/intel/intel_mipmap_tree.c |   45
 
   src/mesa/drivers/dri/intel/intel_mipmap_tree.h |   14 +++
   3 files changed, 68 insertions(+), 0 deletions(-)
 
  diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c
 b/src/mesa/drivers/dri/intel/intel_fbo.c
  index a801bb7..6530b99 100644
  --- a/src/mesa/drivers/dri/intel/intel_fbo.c
  +++ b/src/mesa/drivers/dri/intel/intel_fbo.c
  @@ -282,6 +282,15 @@ intel_alloc_renderbuffer_storage(struct gl_context
 * ctx, struct gl_renderbuffer
 }
  }
 
  +   if (irb-mt-msaa_layout == INTEL_MSAA_LAYOUT_CMS) {
  +  bool ok = intel_miptree_alloc_mcs(intel, irb-mt, rb-NumSamples);
  +  if (!ok) {
  + intel_miptree_release(irb-mt-hiz_mt);
  + intel_miptree_release(irb-mt);
  + return false;
  +  }
  +   }
  +
  return true;
   }

 FYI, though it causes no harm, there's no need to release the hiz miptree
 separately from its parent. The miptree's destructor takes care of that.


Good point.  I'll remove it.




  +   /* From the Ivy Bridge PRM, Vol 2 Part 1 p326:
  +*
  +* When MCS buffer is enabled and bound to MSRT, it is required
 that it
  +* is cleared prior to any rendering.
  +*
  +* Since we don't use the MCS buffer for any purpose other than
 rendering,
  +* it makes sense to just clear it immediately upon allocation.
  +*/
  +   void *data = intel_region_map(intel, mt-mcs_mt-region, 0);
  +   memset(data, 0, mt-mcs_mt-region-bo-size);
  +   intel_region_unmap(intel, mt-mcs_mt-region);

 But the clear value for a 4x MCS is 0xff. Am I missing something?


Yes, you're right.  I had a convoluted reason for believing that
initializing to 0 was better, but it's not standing up to scrutiny.  I'll
change it to 0xff.



 -Chad

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


Re: [Mesa-dev] [PATCH] configure.ac: Add --with-(gl|glu|osmesa)-lib-name options

2012-07-09 Thread Brad King
On 06/11/2012 04:37 PM, Kenneth Graunke wrote:
 Oh, sorry!  Lost track of this.  It looks like Eric's pushed it now.

Yes, thanks Eric!

However, since then another commit broke the feature.  The build
always produces GL no matter the --with-gl-lib-name given.
The GLU and OSMesa options still work.

Running git bisect points to commit 2d4b77c7 (automake:
Convert src/mesa/drivers/x11/Makefile, 2012-06-12).  The change
made by the commit does not obviously drop use of GL_LIB.
Any idea?

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


[Mesa-dev] __DRIimage sub-image v2 series

2012-07-09 Thread Kristian Høgsberg
Here's the patch series with Erics suggestion and comments incorporated,
and I've also added support for the packed YUYV format in this version.

The changes since last series boils down to:

 - Use  __DRI_IMAGE_FORMAT_NONE when we create a __DRIimage we don't intend
   to texture from, and don't expose YUV __DRIimage formats.

 - The RG88 format is really GR88, since the __DRIimage formats are native
   endian.

 - Document lifetime rules for sub-images.

 - Document that rendering to overlapping sub-images is undefined
   (for both __DRIimages and for EGLImages created this way using the
   wayland EGL extension).

 - Validate that a sub-image is contained in the buffer object.

 - Remember to set image-screen from parent image screen when creating
   sub-image.

Kristian

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


[Mesa-dev] [PATCH v2 1/8] __DRIimage: version 5, add new formats and createSubImage

2012-07-09 Thread Kristian Høgsberg
The additions in version 5 enables creating EGLImages for different planes
of a YUV buffer.  createImageFromName is still used to create the containing
__DRIimage, and createSubImage can then be used no that __DRIimage to create
__DRIimages that correspond to the y, u, and v planes (__DRI_IMAGE_FORMAT_R8)
or the uv planes (__DRI_IMAGE_FORMAT_RG88) for formats such as NV12 where
the u and v components are interleaved.  Packed formats such as YUYV etc
doesn't require any special treatment, we just sample those as a regular
ARGB texture.

Signed-off-by: Kristian Høgsberg k...@bitplanet.net
---
 include/GL/internal/dri_interface.h |   27 +++
 1 file changed, 27 insertions(+)

diff --git a/include/GL/internal/dri_interface.h 
b/include/GL/internal/dri_interface.h
index e37917e..08c1886 100644
--- a/include/GL/internal/dri_interface.h
+++ b/include/GL/internal/dri_interface.h
@@ -901,12 +901,19 @@ struct __DRIdri2ExtensionRec {
  * tokens, except in the native endian of the CPU.  For example, on
  * little endian __DRI_IMAGE_FORMAT_XRGB corresponds to
  * MESA_FORMAT_XRGB, but MESA_FORMAT_XRGB_REV on big endian.
+ *
+ * __DRI_IMAGE_FORMAT_NONE is for images that aren't directly usable
+ * by the driver (YUV planar formats) but serve as a base image for
+ * creating sub-images for the different planes within the image.
  */
 #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_FORMAT_XBGR 0x1005
+#define __DRI_IMAGE_FORMAT_R8   0x1006 /* Since version 5 */
+#define __DRI_IMAGE_FORMAT_GR88 0x1007
+#define __DRI_IMAGE_FORMAT_NONE 0x1008
 
 #define __DRI_IMAGE_USE_SHARE  0x0001
 #define __DRI_IMAGE_USE_SCANOUT0x0002
@@ -963,6 +970,26 @@ struct __DRIimageExtensionRec {
 * \since 4
 */
int (*write)(__DRIimage *image, const void *buf, size_t count);
+
+   /**
+* Create an image out of a sub-region of a parent image.  This
+* entry point lets us create individual __DRIimages for different
+* planes in a planar buffer (typically yuv), for example.  While a
+* sub-image shares the underlying buffer object with the parent
+* image and other sibling sub-images, the life times of parent and
+* sub-images are not dependent.  Destroying the parent or a
+* sub-image doesn't affect other images.  The underlying buffer
+* object is free when no __DRIimage remains that references it.
+*
+* Sub-images may overlap, but rendering to overlapping sub-images
+* is undefined.
+*
+* \since 5
+*/
+__DRIimage *(*createSubImage)(__DRIimage *image,
+  int width, int height, int format,
+  int offset, int pitch,
+  void *loaderPrivate);
 };
 
 
-- 
1.7.10.2

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


[Mesa-dev] [PATCH v2 3/8] intel: Add offset field to miptree

2012-07-09 Thread Kristian Høgsberg
This lets us specify an offset into the bo where the miptree starts,
which will let us set up a texture for a single plane in a planar buffer.

Signed-off-by: Kristian Høgsberg k...@bitplanet.net
---
 src/mesa/drivers/dri/i915/i915_texstate.c |2 +-
 src/mesa/drivers/dri/i965/brw_wm_surface_state.c  |5 +++--
 src/mesa/drivers/dri/i965/gen7_wm_surface_state.c |5 +++--
 src/mesa/drivers/dri/intel/intel_mipmap_tree.c|1 +
 src/mesa/drivers/dri/intel/intel_mipmap_tree.h|4 
 src/mesa/drivers/dri/intel/intel_tex_image.c  |9 ++---
 6 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/src/mesa/drivers/dri/i915/i915_texstate.c 
b/src/mesa/drivers/dri/i915/i915_texstate.c
index fd63a69..9e6d3b1 100644
--- a/src/mesa/drivers/dri/i915/i915_texstate.c
+++ b/src/mesa/drivers/dri/i915/i915_texstate.c
@@ -165,7 +165,7 @@ i915_update_tex_unit(struct intel_context *intel, GLuint 
unit, GLuint ss3)
 
drm_intel_bo_reference(intelObj-mt-region-bo);
i915-state.tex_buffer[unit] = intelObj-mt-region-bo;
-   i915-state.tex_offset[unit] = 0; /* Always the origin of the miptree */
+   i915-state.tex_offset[unit] = intelObj-mt-offset;
 
format = translate_texture_format(firstImage-TexFormat,
 sampler-DepthMode);
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 26e65af..04ae6b2 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -736,7 +736,7 @@ brw_update_texture_surface( struct gl_context *ctx, GLuint 
unit )
sampler-sRGBDecode) 
   BRW_SURFACE_FORMAT_SHIFT));
 
-   surf[1] = intelObj-mt-region-bo-offset; /* reloc */
+   surf[1] = intelObj-mt-region-bo-offset + intelObj-mt-offset; /* reloc 
*/
 
surf[2] = ((intelObj-_MaxLevel - tObj-BaseLevel)  BRW_SURFACE_LOD_SHIFT 
|
  (width - 1)  BRW_SURFACE_WIDTH_SHIFT |
@@ -754,7 +754,8 @@ brw_update_texture_surface( struct gl_context *ctx, GLuint 
unit )
/* Emit relocation to surface contents */
drm_intel_bo_emit_reloc(brw-intel.batch.bo,
   brw-wm.surf_offset[surf_index] + 4,
-  intelObj-mt-region-bo, 0,
+  intelObj-mt-region-bo,
+   intelObj-mt-offset,
   I915_GEM_DOMAIN_SAMPLER, 0);
 }
 
diff --git a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c 
b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
index d34bf53..557f36f 100644
--- a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
@@ -273,7 +273,8 @@ gen7_update_texture_surface(struct gl_context *ctx, GLuint 
unit)
 * - render_cache_read_write (exists on gen6 but ignored here)
 */
 
-   surf-ss1.base_addr = intelObj-mt-region-bo-offset; /* reloc */
+   surf-ss1.base_addr =
+  intelObj-mt-region-bo-offset + intelObj-mt-offset; /* reloc */
 
surf-ss2.width = width - 1;
surf-ss2.height = height - 1;
@@ -303,7 +304,7 @@ gen7_update_texture_surface(struct gl_context *ctx, GLuint 
unit)
drm_intel_bo_emit_reloc(brw-intel.batch.bo,
   brw-wm.surf_offset[surf_index] +
   offsetof(struct gen7_surface_state, ss1),
-  intelObj-mt-region-bo, 0,
+  intelObj-mt-region-bo, intelObj-mt-offset,
   I915_GEM_DOMAIN_SAMPLER, 0);
 
gen7_check_surface_setup(surf, false /* is_render_target */);
diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c 
b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
index 7018c37..41d337f 100644
--- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
@@ -233,6 +233,7 @@ intel_miptree_create(struct intel_context *intel,
   mt-total_width,
   mt-total_height,
   expect_accelerated_upload);
+   mt-offset = 0;
 
if (!mt-region) {
intel_miptree_release(mt);
diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.h 
b/src/mesa/drivers/dri/intel/intel_mipmap_tree.h
index 5c57e02..564c6a4 100644
--- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.h
+++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.h
@@ -210,6 +210,10 @@ struct intel_mipmap_tree
 */
struct intel_region *region;
 
+   /* Offset into region bo where miptree starts:
+*/
+   uint32_t offset;
+
/**
 * \brief HiZ miptree
 *
diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c 
b/src/mesa/drivers/dri/intel/intel_tex_image.c
index 6e7e7018..0caa2e2 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_image.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_image.c
@@ -242,7 +242,8 @@ intel_set_texture_image_region(struct gl_context *ctx,
  

[Mesa-dev] [PATCH v2 4/8] intel: Implement __DRIimage::createSubImage and bump supported version to 5

2012-07-09 Thread Kristian Høgsberg
We use the new miptree offset to pick out the sub-image when we bind
the EGLImage to a texture.

Signed-off-by: Kristian Høgsberg k...@bitplanet.net
---
 src/mesa/drivers/dri/intel/intel_regions.h   |1 +
 src/mesa/drivers/dri/intel/intel_screen.c|   50 --
 src/mesa/drivers/dri/intel/intel_tex_image.c |2 +-
 3 files changed, 50 insertions(+), 3 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_regions.h 
b/src/mesa/drivers/dri/intel/intel_regions.h
index 18f8093..782d669 100644
--- a/src/mesa/drivers/dri/intel/intel_regions.h
+++ b/src/mesa/drivers/dri/intel/intel_regions.h
@@ -147,6 +147,7 @@ struct __DRIimageRec {
uint32_t usage;
uint32_t dri_format;
GLuint format;
+   uint32_t offset;
void *data;
 };
 
diff --git a/src/mesa/drivers/dri/intel/intel_screen.c 
b/src/mesa/drivers/dri/intel/intel_screen.c
index 9f31e87..a3ff8d8 100644
--- a/src/mesa/drivers/dri/intel/intel_screen.c
+++ b/src/mesa/drivers/dri/intel/intel_screen.c
@@ -185,6 +185,7 @@ intel_allocate_image(int dri_format, void *loaderPrivate)
return NULL;
 
 image-dri_format = dri_format;
+image-offset = 0;
 
 switch (dri_format) {
 case __DRI_IMAGE_FORMAT_RGB565:
@@ -267,6 +268,7 @@ intel_create_image_from_renderbuffer(__DRIcontext *context,
 
image-internal_format = rb-InternalFormat;
image-format = rb-Format;
+   image-offset = 0;
image-data = loaderPrivate;
intel_region_reference(image-region, irb-mt-region);
 
@@ -376,6 +378,7 @@ intel_dup_image(__DRIimage *orig_image, void *loaderPrivate)
image-usage   = orig_image-usage;
image-dri_format  = orig_image-dri_format;
image-format  = orig_image-format;
+   image-offset  = orig_image-offset;
image-data= loaderPrivate;

return image;
@@ -412,8 +415,50 @@ intel_image_write(__DRIimage *image, const void *buf, 
size_t count)
return 0;
 }
 
+static __DRIimage *
+intel_create_sub_image(__DRIimage *parent,
+   int width, int height, int dri_format,
+   int offset, int pitch, void *loaderPrivate)
+{
+__DRIimage *image;
+int cpp;
+uint32_t mask_x, mask_y;
+
+image = intel_allocate_image(dri_format, loaderPrivate);
+cpp = _mesa_get_format_bytes(image-format);
+if (offset + height * cpp * pitch  parent-region-bo-size) {
+   _mesa_warning(NULL, intel_create_sub_image: subimage out of bounds);
+   FREE(image);
+   return NULL;
+}
+
+intel_region_get_tile_masks(parent-region, mask_x, mask_y);
+if (offset  mask_x)
+   _mesa_warning(NULL,
+ intel_create_sub_image: offset not on tile boundary);
+
+image-region = calloc(sizeof(*image-region), 1);
+if (image-region == NULL) {
+   FREE(image);
+   return NULL;
+}
+
+image-region-cpp = _mesa_get_format_bytes(image-format);
+image-region-width = width;
+image-region-height = height;
+image-region-pitch = pitch;
+image-region-refcount = 1;
+image-region-bo = parent-region-bo;
+drm_intel_bo_reference(image-region-bo);
+image-region-tiling = parent-region-tiling;
+image-region-screen = parent-region-screen;
+image-offset = offset;
+
+return image;
+}
+
 static struct __DRIimageExtensionRec intelImageExtension = {
-{ __DRI_IMAGE, 4 },
+{ __DRI_IMAGE, 5 },
 intel_create_image_from_name,
 intel_create_image_from_renderbuffer,
 intel_destroy_image,
@@ -421,7 +466,8 @@ static struct __DRIimageExtensionRec intelImageExtension = {
 intel_query_image,
 intel_dup_image,
 intel_validate_usage,
-intel_image_write
+intel_image_write,
+intel_create_sub_image
 };
 
 static const __DRIextension *intelScreenExtensions[] = {
diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c 
b/src/mesa/drivers/dri/intel/intel_tex_image.c
index 0caa2e2..70fe762 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_image.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_image.c
@@ -350,7 +350,7 @@ intel_image_target_texture_2d(struct gl_context *ctx, 
GLenum target,
 
intel_set_texture_image_region(ctx, texImage, image-region,
  target, image-internal_format,
-  image-format, 0);
+  image-format, image-offset);
 }
 #endif
 
-- 
1.7.10.2

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


[Mesa-dev] [PATCH v2 5/8] wayland-drm: Pass struct wl_drm_buffer to the driver

2012-07-09 Thread Kristian Høgsberg
We're going to extend this to support multi-plane buffers, so pass this
to the driver so it can access the details.
---
 src/egl/drivers/dri2/egl_dri2.c|   33 +---
 src/egl/wayland/wayland-drm/wayland-drm.c  |   19 +++
 src/egl/wayland/wayland-drm/wayland-drm.h  |   18 ---
 .../egl/common/native_wayland_drm_bufmgr_helper.c  |   23 +++---
 .../egl/common/native_wayland_drm_bufmgr_helper.h  |8 ++---
 5 files changed, 49 insertions(+), 52 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index e2dee79..bb30e69 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1220,43 +1220,40 @@ dri2_export_drm_image_mesa(_EGLDriver *drv, _EGLDisplay 
*disp, _EGLImage *img,
 
 #ifdef HAVE_WAYLAND_PLATFORM
 
-static void *
+static void
 dri2_wl_reference_buffer(void *user_data, uint32_t name,
-int32_t width, int32_t height,
-uint32_t stride, uint32_t format)
+ struct wl_drm_buffer *buffer)
 {
_EGLDisplay *disp = user_data;
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
-   __DRIimage *image;
-   int dri_format;
 
-   switch (format) {
+   switch (buffer-format) {
case WL_DRM_FORMAT_ARGB:
-  dri_format =__DRI_IMAGE_FORMAT_ARGB;
+  buffer-driver_format =__DRI_IMAGE_FORMAT_ARGB;
   break;
case WL_DRM_FORMAT_XRGB:
-  dri_format = __DRI_IMAGE_FORMAT_XRGB;
+  buffer-driver_format = __DRI_IMAGE_FORMAT_XRGB;
   break;
default:
-  return NULL;
+  return;
}
 
-   image = dri2_dpy-image-createImageFromName(dri2_dpy-dri_screen,
-   width, height, 
-   dri_format, name, stride / 4,
-   NULL);
-
-   return image;
+   buffer-driver_buffer =
+  dri2_dpy-image-createImageFromName(dri2_dpy-dri_screen,
+   buffer-buffer.width,
+   buffer-buffer.height, 
+   buffer-driver_format, name,
+   buffer-stride0 / 4,
+   NULL);
 }
 
 static void
-dri2_wl_release_buffer(void *user_data, void *buffer)
+dri2_wl_release_buffer(void *user_data, struct wl_drm_buffer *buffer)
 {
_EGLDisplay *disp = user_data;
-   __DRIimage *image = buffer;
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
 
-   dri2_dpy-image-destroyImage(image);
+   dri2_dpy-image-destroyImage(buffer-driver_buffer);
 }
 
 static struct wayland_drm_callbacks wl_drm_callbacks = {
diff --git a/src/egl/wayland/wayland-drm/wayland-drm.c 
b/src/egl/wayland/wayland-drm/wayland-drm.c
index 5f831b3..af176b7 100644
--- a/src/egl/wayland/wayland-drm/wayland-drm.c
+++ b/src/egl/wayland/wayland-drm/wayland-drm.c
@@ -56,22 +56,13 @@ struct wl_drm {
struct wayland_drm_callbacks *callbacks;
 };
 
-struct wl_drm_buffer {
-   struct wl_buffer buffer;
-   struct wl_drm *drm;
-   uint32_t format;
-
-   void *driver_buffer;
-};
-
 static void
 destroy_buffer(struct wl_resource *resource)
 {
struct wl_drm_buffer *buffer = resource-data;
struct wl_drm *drm = buffer-drm;
 
-   drm-callbacks-release_buffer(drm-user_data,
-  buffer-driver_buffer);
+   drm-callbacks-release_buffer(drm-user_data, buffer);
free(buffer);
 }
 
@@ -129,12 +120,10 @@ drm_create_buffer(struct wl_client *client, struct 
wl_resource *resource,
buffer-buffer.width = width;
buffer-buffer.height = height;
buffer-format = format;
+   buffer-offset0 = 0;
+   buffer-stride0 = stride;
 
-   buffer-driver_buffer =
-   drm-callbacks-reference_buffer(drm-user_data, name,
-width, height,
-stride, format);
-
+drm-callbacks-reference_buffer(drm-user_data, name, buffer);
if (buffer-driver_buffer == NULL) {
wl_resource_post_error(resource,
   WL_DRM_ERROR_INVALID_NAME,
diff --git a/src/egl/wayland/wayland-drm/wayland-drm.h 
b/src/egl/wayland/wayland-drm/wayland-drm.h
index bec50a5..f3df7ee 100644
--- a/src/egl/wayland/wayland-drm/wayland-drm.h
+++ b/src/egl/wayland/wayland-drm/wayland-drm.h
@@ -9,14 +9,24 @@
 
 struct wl_drm;
 
+struct wl_drm_buffer {
+   struct wl_buffer buffer;
+   struct wl_drm *drm;
+   uint32_t format;
+   uint32_t driver_format;
+int32_t offset0;
+int32_t stride0;
+
+   void *driver_buffer;
+};
+
 struct wayland_drm_callbacks {
int (*authenticate)(void *user_data, uint32_t id);
 
-   void *(*reference_buffer)(void 

[Mesa-dev] [PATCH v2 6/8] wayland-drm: Add protocol to create planar buffers

2012-07-09 Thread Kristian Høgsberg
---
 src/egl/drivers/dri2/egl_dri2.c|   11 ++-
 .../wayland/wayland-drm/protocol/wayland-drm.xml   |   16 
 src/egl/wayland/wayland-drm/wayland-drm.c  |   79 +++-
 src/egl/wayland/wayland-drm/wayland-drm.h  |5 +-
 .../egl/common/native_wayland_drm_bufmgr_helper.c  |2 +-
 5 files changed, 91 insertions(+), 22 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index bb30e69..7ca9d61 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1234,6 +1234,15 @@ dri2_wl_reference_buffer(void *user_data, uint32_t name,
case WL_DRM_FORMAT_XRGB:
   buffer-driver_format = __DRI_IMAGE_FORMAT_XRGB;
   break;
+   case WL_DRM_FORMAT_YUV420:
+  buffer-driver_format =__DRI_IMAGE_FORMAT_NONE;
+  break;
+   case WL_DRM_FORMAT_NV12:
+  buffer-driver_format = __DRI_IMAGE_FORMAT_NONE;
+  break;
+   case WL_DRM_FORMAT_YUYV:
+  buffer-driver_format = __DRI_IMAGE_FORMAT_NONE;
+  break;
default:
   return;
}
@@ -1243,7 +1252,7 @@ dri2_wl_reference_buffer(void *user_data, uint32_t name,
buffer-buffer.width,
buffer-buffer.height, 
buffer-driver_format, name,
-   buffer-stride0 / 4,
+   buffer-stride[0] / 4,
NULL);
 }
 
diff --git a/src/egl/wayland/wayland-drm/protocol/wayland-drm.xml 
b/src/egl/wayland/wayland-drm/protocol/wayland-drm.xml
index 89fd8f0..265d4f8 100644
--- a/src/egl/wayland/wayland-drm/protocol/wayland-drm.xml
+++ b/src/egl/wayland/wayland-drm/protocol/wayland-drm.xml
@@ -119,6 +119,22 @@
   arg name=format type=uint/
 /request
 
+!-- Create a wayland buffer for the named DRM buffer.  The DRM
+ surface must have a name using the flink ioctl --
+request name=create_planar_buffer
+  arg name=id type=new_id interface=wl_buffer/
+  arg name=name type=uint/
+  arg name=width type=int/
+  arg name=height type=int/
+  arg name=format type=uint/
+  arg name=offset0 type=int/
+  arg name=stride0 type=int/
+  arg name=offset1 type=int/
+  arg name=stride1 type=int/
+  arg name=offset2 type=int/
+  arg name=stride2 type=int/
+/request
+
 !-- Notification of the path of the drm device which is used by
  the server.  The client should use this device for creating
  local buffers.  Only buffers created from this device should
diff --git a/src/egl/wayland/wayland-drm/wayland-drm.c 
b/src/egl/wayland/wayland-drm/wayland-drm.c
index af176b7..4e84818 100644
--- a/src/egl/wayland/wayland-drm/wayland-drm.c
+++ b/src/egl/wayland/wayland-drm/wayland-drm.c
@@ -92,24 +92,16 @@ const static struct wl_buffer_interface 
drm_buffer_interface = {
 };
 
 static void
-drm_create_buffer(struct wl_client *client, struct wl_resource *resource,
- uint32_t id, uint32_t name, int32_t width, int32_t height,
- uint32_t stride, uint32_t format)
+create_buffer(struct wl_client *client, struct wl_resource *resource,
+  uint32_t id, uint32_t name, int32_t width, int32_t height,
+  uint32_t format,
+  int32_t offset0, int32_t stride0,
+  int32_t offset1, int32_t stride1,
+  int32_t offset2, int32_t stride2)
 {
struct wl_drm *drm = resource-data;
struct wl_drm_buffer *buffer;
 
-   switch (format) {
-   case WL_DRM_FORMAT_ARGB:
-   case WL_DRM_FORMAT_XRGB:
-   break;
-   default:
-   wl_resource_post_error(resource,
-  WL_DRM_ERROR_INVALID_FORMAT,
-  invalid format);
-   return;
-   }
-
buffer = calloc(1, sizeof *buffer);
if (buffer == NULL) {
wl_resource_post_no_memory(resource);
@@ -120,8 +112,12 @@ drm_create_buffer(struct wl_client *client, struct 
wl_resource *resource,
buffer-buffer.width = width;
buffer-buffer.height = height;
buffer-format = format;
-   buffer-offset0 = 0;
-   buffer-stride0 = stride;
+   buffer-offset[0] = offset0;
+   buffer-stride[0] = stride0;
+   buffer-offset[1] = offset1;
+   buffer-stride[1] = stride1;
+   buffer-offset[2] = offset2;
+   buffer-stride[2] = stride2;
 
 drm-callbacks-reference_buffer(drm-user_data, name, buffer);
if (buffer-driver_buffer == NULL) {
@@ -144,6 +140,51 @@ drm_create_buffer(struct wl_client *client, struct 
wl_resource *resource,
 }
 
 static void
+drm_create_buffer(struct wl_client *client, struct wl_resource *resource,
+ uint32_t id, uint32_t name, int32_t width, int32_t height,
+ uint32_t stride, 

[Mesa-dev] [PATCH v2 7/8] egl: Add EGL_WAYLAND_PLANE_WL attribute

2012-07-09 Thread Kristian Høgsberg
This lets us specify the plane to create the image for for multiplanar
wl_buffers.

Signed-off-by: Kristian Høgsberg k...@bitplanet.net
---
 docs/WL_bind_wayland_display.spec |   19 +-
 include/EGL/eglmesaext.h  |1 +
 src/egl/drivers/dri2/egl_dri2.c   |  117 +++--
 src/egl/main/eglimage.c   |5 ++
 src/egl/main/eglimage.h   |3 +
 5 files changed, 137 insertions(+), 8 deletions(-)

diff --git a/docs/WL_bind_wayland_display.spec 
b/docs/WL_bind_wayland_display.spec
index e2fde3c..d9bfc66 100644
--- a/docs/WL_bind_wayland_display.spec
+++ b/docs/WL_bind_wayland_display.spec
@@ -62,6 +62,10 @@ New Tokens
 
 EGL_WAYLAND_BUFFER_WL   0x31D5
 
+Accepted in the attrib_list parameter of eglCreateImageKHR:
+
+EGL_WAYLAND_PLANE_WL0x31D6
+
 Additions to the EGL 1.4 Specification:
 
 To bind a server side wl_display to an EGLDisplay, call
@@ -80,9 +84,15 @@ Additions to the EGL 1.4 Specification:
 eglUnbindWaylandDisplayWL returns EGL_FALSE when there is no
 wl_display bound to the EGLDisplay currently otherwise EGL_TRUE.
 
-Import a wl_buffer by calling eglCreateImageKHR with
-wl_buffer as EGLClientBuffer, EGL_WAYLAND_BUFFER_WL as the target,
-NULL context and an empty attribute_list.
+Import a wl_buffer by calling eglCreateImageKHR with wl_buffer as
+EGLClientBuffer, EGL_WAYLAND_BUFFER_WL as the target, NULL context
+and an empty attribute_list.  For multi-planar buffers such as
+many YUV buffers, specify the plane to create the EGLImage for by
+using the EGL_WAYLAND_PLANE_WL attribute.  The value of the
+attribute is the index of the plane, as defined by the buffer
+format.  Writing to an EGLImage created from a wl_buffer in any
+way (such as glTexImage2D, binding the EGLImage as a renderbuffer
+etc) will result in undefined behavior.
 
 Issues
 
@@ -90,3 +100,6 @@ Revision History
 
 Version 1, March 1, 2011
 Initial draft (Benjamin Franzke)
+Version 2, July 5, 2012
+Add EGL_WAYLAND_PLANE_WL attribute to allow creating an EGLImage
+for different planes of planar buffer. (Kristian Høgsberg)
diff --git a/include/EGL/eglmesaext.h b/include/EGL/eglmesaext.h
index 52dd5b1..d291608 100644
--- a/include/EGL/eglmesaext.h
+++ b/include/EGL/eglmesaext.h
@@ -113,6 +113,7 @@ typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETDRMDISPLAYMESA) 
(int fd);
 #define EGL_WL_bind_wayland_display 1
 
 #define EGL_WAYLAND_BUFFER_WL  0x31D5 /* eglCreateImageKHR 
target */
+#define EGL_WAYLAND_PLANE_WL   0x31D6 /* eglCreateImageKHR 
target */
 struct wl_display;
 #ifdef EGL_EGLEXT_PROTOTYPES
 EGLAPI EGLBoolean EGLAPIENTRY eglBindWaylandDisplayWL(EGLDisplay dpy, struct 
wl_display *display);
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 7ca9d61..d003a9e 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1057,15 +1057,122 @@ dri2_create_image_wayland_wl_buffer(_EGLDisplay *disp, 
_EGLContext *ctx,
EGLClientBuffer _buffer,
const EGLint *attr_list)
 {
-   struct wl_buffer *buffer = (struct wl_buffer *) _buffer;
+   struct wl_drm_buffer *buffer = (struct wl_drm_buffer *) _buffer;
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
-   __DRIimage *dri_image, *source;
+   __DRIimage *dri_image;
+   _EGLImageAttribs attrs;
+   EGLint err;
+   uint32_t format;
+   int32_t offset, stride, plane, width, height;
+   int cpp;
 
-   if (!wayland_buffer_is_drm(buffer))
+   if (!wayland_buffer_is_drm(buffer-buffer))
return NULL;
 
-   source = wayland_drm_buffer_get_buffer(buffer);
-   dri_image = dri2_dpy-image-dupImage(source, NULL);
+   err = _eglParseImageAttribList(attrs, disp, attr_list);
+   plane = attrs.PlaneWL;
+   if (err != EGL_SUCCESS || plane  0) {
+  _eglError(EGL_BAD_PARAMETER, dri2_create_image_wayland_wl_buffer);
+  return NULL;
+   }
+
+   switch (buffer-format) {
+   case WL_DRM_FORMAT_ARGB:
+   case WL_DRM_FORMAT_XRGB:
+  if (plane  0) {
+ _eglError(EGL_BAD_PARAMETER, dri2_create_image_wayland_wl_buffer);
+ return NULL;
+  }
+  width = buffer-buffer.width;
+  height = buffer-buffer.height;
+  format = buffer-driver_format;
+  offset = buffer-offset[0];
+  stride = buffer-stride[0];
+  cpp = 4;
+  break;
+
+   case WL_DRM_FORMAT_YUV420:
+  if (plane  2) {
+ _eglError(EGL_BAD_PARAMETER, dri2_create_image_wayland_wl_buffer);
+ return NULL;
+  }
+
+  if (plane == 0) {
+ width = buffer-buffer.width;
+ height = buffer-buffer.height;
+  } else {
+ width = buffer-buffer.width / 2;
+ height = buffer-buffer.height / 2;
+  }
+
+  format = __DRI_IMAGE_FORMAT_R8;
+  offset = buffer-offset[plane];
+  

[Mesa-dev] [PATCH v2 8/8] egl_dri2: Set content type for wl_buffer

2012-07-09 Thread Kristian Høgsberg
This lets the compositor know about the structure of the wl_buffer, namely
which planes and components are available and in which order.
---
 src/egl/drivers/dri2/egl_dri2.c |5 +
 1 file changed, 5 insertions(+)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index d003a9e..05a5cea 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1337,18 +1337,23 @@ dri2_wl_reference_buffer(void *user_data, uint32_t name,
switch (buffer-format) {
case WL_DRM_FORMAT_ARGB:
   buffer-driver_format =__DRI_IMAGE_FORMAT_ARGB;
+  buffer-buffer.content = WL_BUFFER_CONTENT_RGBA;
   break;
case WL_DRM_FORMAT_XRGB:
   buffer-driver_format = __DRI_IMAGE_FORMAT_XRGB;
+  buffer-buffer.content = WL_BUFFER_CONTENT_RGB;
   break;
case WL_DRM_FORMAT_YUV420:
   buffer-driver_format =__DRI_IMAGE_FORMAT_NONE;
+  buffer-buffer.content = WL_BUFFER_CONTENT_Y_U_V;
   break;
case WL_DRM_FORMAT_NV12:
   buffer-driver_format = __DRI_IMAGE_FORMAT_NONE;
+  buffer-buffer.content = WL_BUFFER_CONTENT_Y_UV;
   break;
case WL_DRM_FORMAT_YUYV:
   buffer-driver_format = __DRI_IMAGE_FORMAT_NONE;
+  buffer-buffer.content = WL_BUFFER_CONTENT_Y_XUXV;
   break;
default:
   return;
-- 
1.7.10.2

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


Re: [Mesa-dev] [PATCH 3/8] i965/msaa: Allocate MCS buffer when CMS MSAA is in use.

2012-07-09 Thread Chad Versace
On 07/09/2012 02:00 PM, Paul Berry wrote:
 
 
 On 9 July 2012 13:36, Chad Versace chad.vers...@linux.intel.com
 mailto:chad.vers...@linux.intel.com wrote:
 
 On 07/06/2012 03:29 PM, Paul Berry wrote:
  To implement Gen7's CMS MSAA layout, we need an extra buffer, the MCS
  (Multisample Control Surface) buffer.  This patch introduces code for
  allocating and deallocating the buffer, and storing a pointer to it in
  the intel_mipmap_tree struct.
 
  No functional change, since the CMS layout is not enabled yet.
  ---
   src/mesa/drivers/dri/intel/intel_fbo.c |9 +
   src/mesa/drivers/dri/intel/intel_mipmap_tree.c |   45
 
   src/mesa/drivers/dri/intel/intel_mipmap_tree.h |   14 +++
   3 files changed, 68 insertions(+), 0 deletions(-)
 
  diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c
 b/src/mesa/drivers/dri/intel/intel_fbo.c
  index a801bb7..6530b99 100644
  --- a/src/mesa/drivers/dri/intel/intel_fbo.c
  +++ b/src/mesa/drivers/dri/intel/intel_fbo.c
  @@ -282,6 +282,15 @@ intel_alloc_renderbuffer_storage(struct gl_context 
 *
 ctx, struct gl_renderbuffer
 }
  }
 
  +   if (irb-mt-msaa_layout == INTEL_MSAA_LAYOUT_CMS) {
  +  bool ok = intel_miptree_alloc_mcs(intel, irb-mt, 
 rb-NumSamples);
  +  if (!ok) {
  + intel_miptree_release(irb-mt-hiz_mt);
  + intel_miptree_release(irb-mt);
  + return false;
  +  }
  +   }
  +
  return true;
   }
 
 FYI, though it causes no harm, there's no need to release the hiz miptree
 separately from its parent. The miptree's destructor takes care of that.
 
 
 Good point.  I'll remove it.
  
 
 
 
  +   /* From the Ivy Bridge PRM, Vol 2 Part 1 p326:
  +*
  +* When MCS buffer is enabled and bound to MSRT, it is required
 that it
  +* is cleared prior to any rendering.
  +*
  +* Since we don't use the MCS buffer for any purpose other than 
 rendering,
  +* it makes sense to just clear it immediately upon allocation.
  +*/
  +   void *data = intel_region_map(intel, mt-mcs_mt-region, 0);
  +   memset(data, 0, mt-mcs_mt-region-bo-size);
  +   intel_region_unmap(intel, mt-mcs_mt-region);
 
 But the clear value for a 4x MCS is 0xff. Am I missing something?
 
 
 Yes, you're right.  I had a convoluted reason for believing that initializing 
 to
 0 was better, but it's not standing up to scrutiny.  I'll change it to 0xff. 

Ok, then this is
Reviewed-by: Chad Versace chad.vers...@linux.intel.com


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


Re: [Mesa-dev] [PATCH 1/9] automake: convert libOSmesa building

2012-07-09 Thread nobled
On Mon, Jul 9, 2012 at 11:41 AM, Jon TURNEY jon.tur...@dronecode.org.uk wrote:
 From: Laurent Carlier lordhea...@gmail.com

 This also currently fix the installation of libOSmesa.

 v2: Remove old Makefile, libOSmesa is now versioned, fix typos
 v3: Keep config substitution alphabetized
 v4: Update .gitignore

 Reviewed-by: Jon TURNEY jon.tur...@dronecode.org.uk
 ---
  configure.ac|5 +++
  src/mesa/drivers/osmesa/.gitignore  |1 +
  src/mesa/drivers/osmesa/Makefile|   51 
 ---
  src/mesa/drivers/osmesa/Makefile.am |   50 ++
  4 files changed, 56 insertions(+), 51 deletions(-)
  create mode 100644 src/mesa/drivers/osmesa/.gitignore
  delete mode 100644 src/mesa/drivers/osmesa/Makefile
  create mode 100644 src/mesa/drivers/osmesa/Makefile.am

 diff --git a/configure.ac b/configure.ac
 index 46265a2..e5ac791 100644
 --- a/configure.ac
 +++ b/configure.ac
 @@ -1370,10 +1370,14 @@ if test x$enable_osmesa = xyes; then
  OSMESA_MESA_DEPS=
  OSMESA_PC_LIB_PRIV=-lm -lpthread $SELINUX_LIBS $DLOPEN_LIBS
  fi
 +
 +OSMESA_VERSION=`echo $VERSION | $SED 's/\./:/g'`
 +
  AC_SUBST([OSMESA_LIB_DEPS])
  AC_SUBST([OSMESA_MESA_DEPS])
  AC_SUBST([OSMESA_PC_REQ])
  AC_SUBST([OSMESA_PC_LIB_PRIV])
 +AC_SUBST([OSMESA_VERSION])

  dnl
  dnl gbm configuration
 @@ -2188,6 +2192,7 @@ AC_CONFIG_FILES([configs/current
 src/mesa/drivers/dri/r200/Makefile
 src/mesa/drivers/dri/radeon/Makefile
 src/mesa/drivers/dri/swrast/Makefile
 +   src/mesa/drivers/osmesa/Makefile
 src/mesa/drivers/x11/Makefile
 src/mesa/gl.pc
 src/mesa/osmesa.pc])
 diff --git a/src/mesa/drivers/osmesa/.gitignore 
 b/src/mesa/drivers/osmesa/.gitignore
 new file mode 100644
 index 000..5fc607b
 --- /dev/null
 +++ b/src/mesa/drivers/osmesa/.gitignore
 @@ -0,0 +1 @@
 +/Makefile
 diff --git a/src/mesa/drivers/osmesa/Makefile 
 b/src/mesa/drivers/osmesa/Makefile
 deleted file mode 100644
 index 39ab09a..000
 --- a/src/mesa/drivers/osmesa/Makefile
 +++ /dev/null
 @@ -1,51 +0,0 @@
 -# src/mesa/drivers/osmesa/Makefile for libOSMesa.so
 -
 -# Note that we may generate libOSMesa.so or libOSMesa16.so or libOSMesa32.so
 -# with this Makefile
 -
 -
 -TOP = ../../../..
 -
 -include $(TOP)/configs/current
 -
 -
 -
 -SOURCES = osmesa.c
 -
 -OBJECTS = $(SOURCES:.c=.o)
 -
 -INCLUDE_DIRS = \
 -   -I$(TOP)/include \
 -   -I$(TOP)/src/mapi \
 -   -I$(TOP)/src/mesa \
 -   -I$(TOP)/src/mesa/main
 -
 -CORE_MESA = \
 -   $(TOP)/src/mesa/libmesa.a \
 -   $(TOP)/src/mapi/glapi/libglapi.a \
 -   $(TOP)/src/glsl/libglsl.a
 -
 -.c.o:
 -   $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $ -o $@
 -
 -
 -default: $(TOP)/$(LIB_DIR)/$(OSMESA_LIB_NAME)
 -
 -
 -# libOSMesa can be used in conjuction with libGL or with all other Mesa
 -# sources. We can also build libOSMesa16/libOSMesa32 by setting
 -# -DCHAN_BITS=16/32.
 -$(TOP)/$(LIB_DIR)/$(OSMESA_LIB_NAME): $(OBJECTS) $(CORE_MESA)
 -   $(MKLIB) -o $(OSMESA_LIB) -linker '$(CXX)' -ldflags '$(LDFLAGS)' \
 -   -major $(MESA_MAJOR) -minor $(MESA_MINOR) -patch $(MESA_TINY) 
 \
 -   -install $(TOP)/$(LIB_DIR) -cplusplus $(MKLIB_OPTIONS) \
 -   -id $(INSTALL_LIB_DIR)/lib$(OSMESA_LIB).$(MESA_MAJOR).dylib \
 -   $(OSMESA_LIB_DEPS) $(OBJECTS) $(CORE_MESA)
 -
 -
 -
 -clean:
 -   -rm -f *.o *~
 -
 -
 -# XXX todo install rule?
 diff --git a/src/mesa/drivers/osmesa/Makefile.am 
 b/src/mesa/drivers/osmesa/Makefile.am
 new file mode 100644
 index 000..863c8f7
 --- /dev/null
 +++ b/src/mesa/drivers/osmesa/Makefile.am
 @@ -0,0 +1,50 @@
 +
 +
 +# Copyright © 2012 Laurent Carlier lordhea...@gmail.com
 +#
 +# 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.
 +
 +# Hack to make some of the non-automake variables work.
 

Re: [Mesa-dev] [PATCH 1/8] __DRIimage: version 5, add new formats and createSubImage

2012-07-09 Thread nobled
On Sat, Jul 7, 2012 at 1:40 AM, Kristian Høgsberg hoegsb...@gmail.com wrote:
 On Fri, Jul 06, 2012 at 02:10:57PM -0700, Eric Anholt wrote:
 Kristian Høgsberg k...@bitplanet.net writes:

  The additions in version 5 enables creating EGLImages for different planes
  of a YUV buffer.  createImageFromName is still used to create the 
  containing
  __DRIimage, and createSubImage can then be used no that __DRIimage to 
  create
  __DRIimages that correspond to the y, u, and v planes 
  (__DRI_IMAGE_FORMAT_R8)
  or the uv planes (__DRI_IMAGE_FORMAT_RG88) for formats such as NV12 where
  the u and v components are interleaved.  Packed formats such as YUYV etc
  doesn't require any special treatment, we just sample those as a regular
  ARGB texture.

 This patch series is making more sense to me than the last few yuv
 patchsets I've seen.

 Thanks for the feedback.  I wanted to mention that while it would be a
 lot easier to use different bo's for the different planes, we can't do
 that.  The decoder takes a base address for the destination buffer and
 then offsets relative to that to identify the various planes.  So it
 has to be all within the same bo and the patch series has to touch the
 miptree setup.

 Also, after I sent out the series I started working on YUYV support
 (which is what the SNB+ sprites take), and the sub-image feature turns
 out to be useful there as well.  We can create an RG88 texture for
 sampling the Y-component and then an RGBA texture for sampling the
 U and V channels, which means that we can texture from a YUYV buffer
 with bilinear filtering.

  Signed-off-by: Kristian Høgsberg k...@bitplanet.net
  ---
   include/GL/internal/dri_interface.h |   16 
   1 file changed, 16 insertions(+)
 
  diff --git a/include/GL/internal/dri_interface.h 
  b/include/GL/internal/dri_interface.h
  index e37917e..5dfe15b 100644
  --- a/include/GL/internal/dri_interface.h
  +++ b/include/GL/internal/dri_interface.h
  @@ -907,6 +907,10 @@ struct __DRIdri2ExtensionRec {
   #define __DRI_IMAGE_FORMAT_ARGB 0x1003
   #define __DRI_IMAGE_FORMAT_ABGR 0x1004
   #define __DRI_IMAGE_FORMAT_XBGR 0x1005
  +#define __DRI_IMAGE_FORMAT_R8   0x1006 /* Since version 5 */
  +#define __DRI_IMAGE_FORMAT_RG88 0x1007
  +#define __DRI_IMAGE_FORMAT_YUV420   0x1008
  +#define __DRI_IMAGE_FORMAT_NV12 0x1009

 Could we get just a couple notes on the yuv420/nv12 formats here?  Also,
 can one of these end up as an OES_EGL_image that someone might try to
 bind as a texture?  What should happen, if so?  (If it's possible, the
 MESA_FORMAT_NONE in the next patch would result in a bunch of
 _mesa_problem()s and failure)

 The __DRIimage we create with either of the YUV formats is never
 exposed as an EGLImage.  We hold on to it in the wl_buffer object and
 use it to create subimages of one of the types that we can actually
 texture from and those get exposed as EGLImages.  I had
 __DRI_IMAGE_FORMAT_NONE instead of the YUV formats, I think that may
 be clearer.

   #define __DRI_IMAGE_USE_SHARE  0x0001
   #define __DRI_IMAGE_USE_SCANOUT0x0002
  @@ -963,6 +967,18 @@ struct __DRIimageExtensionRec {
   * \since 4
   */
  int (*write)(__DRIimage *image, const void *buf, size_t count);
  +
  +   /**
  +* Create an image out of a sub-region of a parent image.  This
  +* entry point lets us create individual __DRIimages for different
  +* planes in a planar buffer (typically yuv), for example.
  +*
  +* \since 5
  +*/
  +__DRIimage *(*createSubImage)(__DRIimage *image,
  +  int width, int height, int format,
  +  int offset, int pitch,
  +  void *loaderPrivate);
   };

 Some notes about lifetime would be good here.  In the implementation you
 have, the subimage gets separated from the parent, so changing the
 storage of the parent (if that's a thing that's possible -- I don't
 understand egl image lifetimes) wouldn't be tracked in the child.  You
 could free the parent safely, as well.

 The lifetime rules are pretty simple; each subimage is an independent
 __DRIimage and its lifetime is not tied to the that of the parent.
 I'll put that in the docs.

 If the subimage can get bound as a render target, it won't be reliably
 synchronized with texturing from another subimage that overlaps it, and
 that seems like something to be noted.

 I didn't intend for the subimages to end up as render targets, but
 there's nothing in the API that prevents that.  I guess the semantics
 I have in mind are much like the image_external restrictions, where
 you can't write to the EGLImage in any way (no glTexImage2D or
 glTexSubImage2D, no binding as rendertarget, no rendering to the image
 in OpenVG etc).  I can add language to the wayland GLES2 extension
 that exposes the subimages to say that any such usage will result in
 undefined 

[Mesa-dev] [PATCH 3/5] i965/fs: Replace usage of is_tex() with regs_written() checks.

2012-07-09 Thread Eric Anholt
In these places, we care about any sort of send that hits more than one reg,
not just textures.  We don't yet have anything else returning more than one
reg, so there's no change.
---
 src/mesa/drivers/dri/i965/brw_fs.cpp |   16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp 
b/src/mesa/drivers/dri/i965/brw_fs.cpp
index c201f90..374a059 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -1063,8 +1063,10 @@ fs_visitor::split_virtual_grfs()
foreach_list(node, this-instructions) {
   fs_inst *inst = (fs_inst *)node;
 
-  /* Texturing produces 4 contiguous registers, so no splitting. */
-  if (inst-is_tex()) {
+  /* If there's a SEND message that requires contiguous destination
+   * registers, no splitting is allowed.
+   */
+  if (inst-regs_written()  1) {
 split_grf[inst-dst.reg] = false;
   }
}
@@ -1400,7 +1402,7 @@ fs_visitor::propagate_constants()
 if (scan_inst-dst.file == GRF 
 scan_inst-dst.reg == inst-dst.reg 
 (scan_inst-dst.reg_offset == inst-dst.reg_offset ||
- scan_inst-is_tex())) {
+ scan_inst-regs_written()  1)) {
break;
 }
   }
@@ -1602,14 +1604,14 @@ fs_visitor::register_coalesce()
 if (scan_inst-dst.file == GRF) {
if (scan_inst-dst.reg == inst-dst.reg 
(scan_inst-dst.reg_offset == inst-dst.reg_offset ||
-scan_inst-is_tex())) {
+scan_inst-regs_written()  1)) {
   interfered = true;
   break;
}
if (inst-src[0].file == GRF 
scan_inst-dst.reg == inst-src[0].reg 
(scan_inst-dst.reg_offset == inst-src[0].reg_offset ||
-scan_inst-is_tex())) {
+scan_inst-regs_written()  1)) {
   interfered = true;
   break;
}
@@ -1729,10 +1731,8 @@ fs_visitor::compute_to_mrf()
 * into a compute-to-MRF.
 */
 
+/* SENDs can only write to GRFs, so no compute-to-MRF. */
if (scan_inst-is_tex()) {
-  /* texturing writes several continuous regs, so we can't
-   * compute-to-mrf that.
-   */
   break;
}
 
-- 
1.7.10

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


[Mesa-dev] [PATCH 1/5] i965/fs: Move a block out of a loop in live variables setup.

2012-07-09 Thread Eric Anholt
This was accidentally copy-and-pasted inside.
---
 src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp |9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp
index 46408da..40e7ae5 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp
@@ -192,11 +192,12 @@ fs_visitor::calculate_live_intervals()
 
use[reg] = ip;
 }
-if (inst-dst.file == GRF) {
-   int reg = inst-dst.reg;
+  }
 
-   def[reg] = MIN2(def[reg], ip);
-}
+  if (inst-dst.file == GRF) {
+ int reg = inst-dst.reg;
+
+ def[reg] = MIN2(def[reg], ip);
   }
 
   ip++;
-- 
1.7.10

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


[Mesa-dev] [PATCH 5/5] i965/fs: Make register spill/unspill only do the regs for that instruction.

2012-07-09 Thread Eric Anholt
Previously, if we were spilling the result of a texture call, we would store
all 4 regs, then for each use of one of those regs as the source of an
instruction, we would unspill all 4 regs even though only one was needed.

In an app we're looking at, one shader goes from 2817 instructions to 2179,
and another one successfully compiles that didn't before.
---
 src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp |   56 ++---
 1 file changed, 28 insertions(+), 28 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp
index 3f10ca6..ebf5eaa 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp
@@ -281,24 +281,17 @@ fs_visitor::assign_regs()
 void
 fs_visitor::emit_unspill(fs_inst *inst, fs_reg dst, uint32_t spill_offset)
 {
-   int size = virtual_grf_sizes[dst.reg];
-   dst.reg_offset = 0;
-
-   for (int chan = 0; chan  size; chan++) {
-  fs_inst *unspill_inst = new(mem_ctx) fs_inst(FS_OPCODE_UNSPILL,
-  dst);
-  dst.reg_offset++;
-  unspill_inst-offset = spill_offset + chan * REG_SIZE;
-  unspill_inst-ir = inst-ir;
-  unspill_inst-annotation = inst-annotation;
-
-  /* Choose a MRF that won't conflict with an MRF that's live across the
-   * spill.  Nothing else will make it up to MRF 14/15.
-   */
-  unspill_inst-base_mrf = 14;
-  unspill_inst-mlen = 1; /* header contains offset */
-  inst-insert_before(unspill_inst);
-   }
+   fs_inst *unspill_inst = new(mem_ctx) fs_inst(FS_OPCODE_UNSPILL, dst);
+   unspill_inst-offset = spill_offset;
+   unspill_inst-ir = inst-ir;
+   unspill_inst-annotation = inst-annotation;
+
+   /* Choose a MRF that won't conflict with an MRF that's live across the
+* spill.  Nothing else will make it up to MRF 14/15.
+*/
+   unspill_inst-base_mrf = 14;
+   unspill_inst-mlen = 1; /* header contains offset */
+   inst-insert_before(unspill_inst);
 }
 
 int
@@ -322,14 +315,12 @@ fs_visitor::choose_spill_reg(struct ra_graph *g)
 
   for (unsigned int i = 0; i  3; i++) {
 if (inst-src[i].file == GRF) {
-   int size = virtual_grf_sizes[inst-src[i].reg];
-   spill_costs[inst-src[i].reg] += size * loop_scale;
+   spill_costs[inst-src[i].reg] += loop_scale;
 }
   }
 
   if (inst-dst.file == GRF) {
-int size = virtual_grf_sizes[inst-dst.reg];
-spill_costs[inst-dst.reg] += size * loop_scale;
+spill_costs[inst-dst.reg] += inst-regs_written() * loop_scale;
   }
 
   switch (inst-opcode) {
@@ -384,21 +375,30 @@ fs_visitor::spill_reg(int spill_reg)
   for (unsigned int i = 0; i  3; i++) {
 if (inst-src[i].file == GRF 
 inst-src[i].reg == spill_reg) {
-   inst-src[i].reg = virtual_grf_alloc(size);
-   emit_unspill(inst, inst-src[i], spill_offset);
+   inst-src[i].reg = virtual_grf_alloc(1);
+   emit_unspill(inst, inst-src[i],
+ spill_offset + REG_SIZE * inst-src[i].reg_offset);
 }
   }
 
   if (inst-dst.file == GRF 
  inst-dst.reg == spill_reg) {
-inst-dst.reg = virtual_grf_alloc(size);
+ int subset_spill_offset = (spill_offset +
+REG_SIZE * inst-dst.reg_offset);
+ inst-dst.reg = virtual_grf_alloc(inst-regs_written());
+ inst-dst.reg_offset = 0;
 
 /* Since we spill/unspill the whole thing even if we access
  * just a component, we may need to unspill before the
  * instruction we're spilling for.
  */
 if (size != 1 || inst-predicated) {
-   emit_unspill(inst, inst-dst, spill_offset);
+fs_reg unspill_reg = inst-dst;
+for (int chan = 0; chan  inst-regs_written(); chan++) {
+   emit_unspill(inst, unspill_reg,
+subset_spill_offset + REG_SIZE * chan);
+   unspill_reg.reg_offset++;
+}
 }
 
 fs_reg spill_src = inst-dst;
@@ -407,11 +407,11 @@ fs_visitor::spill_reg(int spill_reg)
 spill_src.negate = false;
 spill_src.smear = -1;
 
-for (int chan = 0; chan  size; chan++) {
+for (int chan = 0; chan  inst-regs_written(); chan++) {
fs_inst *spill_inst = new(mem_ctx) fs_inst(FS_OPCODE_SPILL,
   reg_null_f, spill_src);
spill_src.reg_offset++;
-   spill_inst-offset = spill_offset + chan * REG_SIZE;
+   spill_inst-offset = subset_spill_offset + chan * REG_SIZE;
spill_inst-ir = inst-ir;
spill_inst-annotation = inst-annotation;
spill_inst-base_mrf = 14;
-- 
1.7.10

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org

[Mesa-dev] [PATCH 4/5] i965/fs.h: Refactor tests for instructions modifying a register.

2012-07-09 Thread Eric Anholt
---
 src/mesa/drivers/dri/i965/brw_fs.cpp   |   25 ++--
 src/mesa/drivers/dri/i965/brw_fs.h |1 +
 .../drivers/dri/i965/brw_fs_copy_propagation.cpp   |   16 ++---
 src/mesa/drivers/dri/i965/brw_fs_cse.cpp   |8 +--
 4 files changed, 16 insertions(+), 34 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp 
b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 374a059..354134c 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -168,6 +168,15 @@ fs_inst::regs_written()
 }
 
 bool
+fs_inst::overwrites_reg(const fs_reg reg)
+{
+   return (reg.file == dst.file 
+   reg.reg == dst.reg 
+   reg.reg_offset = dst.reg_offset  
+   reg.reg_offset  dst.reg_offset + regs_written());
+}
+
+bool
 fs_inst::is_tex()
 {
return (opcode == SHADER_OPCODE_TEX ||
@@ -1400,9 +1409,7 @@ fs_visitor::propagate_constants()
 }
 
 if (scan_inst-dst.file == GRF 
-scan_inst-dst.reg == inst-dst.reg 
-(scan_inst-dst.reg_offset == inst-dst.reg_offset ||
- scan_inst-regs_written()  1)) {
+ scan_inst-overwrites_reg(inst-dst)) {
break;
 }
   }
@@ -1602,16 +1609,8 @@ fs_visitor::register_coalesce()
   !scan_inst-is_tail_sentinel();
   scan_inst = (fs_inst *)scan_inst-next) {
 if (scan_inst-dst.file == GRF) {
-   if (scan_inst-dst.reg == inst-dst.reg 
-   (scan_inst-dst.reg_offset == inst-dst.reg_offset ||
-scan_inst-regs_written()  1)) {
-  interfered = true;
-  break;
-   }
-   if (inst-src[0].file == GRF 
-   scan_inst-dst.reg == inst-src[0].reg 
-   (scan_inst-dst.reg_offset == inst-src[0].reg_offset ||
-scan_inst-regs_written()  1)) {
+   if (scan_inst-overwrites_reg(inst-dst) ||
+scan_inst-overwrites_reg(inst-src[0])) {
   interfered = true;
   break;
}
diff --git a/src/mesa/drivers/dri/i965/brw_fs.h 
b/src/mesa/drivers/dri/i965/brw_fs.h
index deb58d8..6e3c46a 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -150,6 +150,7 @@ public:
 
bool equals(fs_inst *inst);
int regs_written();
+   bool overwrites_reg(const fs_reg reg);
bool is_tex();
bool is_math();
 
diff --git a/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp
index 106964d..1870f43 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp
@@ -98,23 +98,11 @@ fs_visitor::opt_copy_propagate_local(void *mem_ctx,
 
   /* kill the destination from the ACP */
   if (inst-dst.file == GRF) {
-int start_offset = inst-dst.reg_offset;
-int end_offset = start_offset + inst-regs_written();
-
 foreach_list_safe(entry_node, acp) {
acp_entry *entry = (acp_entry *)entry_node;
 
-   if (entry-dst.file == GRF 
-   entry-dst.reg == inst-dst.reg 
-   entry-dst.reg_offset = start_offset 
-   entry-dst.reg_offset  end_offset) {
-  entry-remove();
-  continue;
-   }
-   if (entry-src.file == GRF 
-   entry-src.reg == inst-dst.reg 
-   entry-src.reg_offset = start_offset 
-   entry-src.reg_offset  end_offset) {
+   if (inst-overwrites_reg(entry-dst) ||
+inst-overwrites_reg(entry-src)) {
   entry-remove();
}
 }
diff --git a/src/mesa/drivers/dri/i965/brw_fs_cse.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_cse.cpp
index fd28e14..7bf6698 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_cse.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_cse.cpp
@@ -150,17 +150,11 @@ fs_visitor::opt_cse_local(fs_bblock *block, exec_list 
*aeb)
   }
 
   /* Kill all AEB entries that use the destination. */
-  int start_offset = inst-dst.reg_offset;
-  int end_offset = start_offset + inst-regs_written();
-
   foreach_list_safe(entry_node, aeb) {
 aeb_entry *entry = (aeb_entry *)entry_node;
 
 for (int i = 0; i  3; i++) {
-   if (entry-generator-src[i].file == inst-dst.file 
-   entry-generator-src[i].reg == inst-dst.reg 
-   entry-generator-src[i].reg_offset = start_offset 
-   entry-generator-src[i].reg_offset  end_offset) {
+if (inst-overwrites_reg(entry-generator-src[i])) {
   entry-remove();
   ralloc_free(entry);
   break;
-- 
1.7.10

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


[Mesa-dev] [PATCH 2/5] i965/fs: Rename virtual_grf_next to virtual_grf_count.

2012-07-09 Thread Eric Anholt
count is a more useful name, since most of the time we're using it for
looping over the variables.
---
 src/mesa/drivers/dri/i965/brw_fs.cpp   |9 
 src/mesa/drivers/dri/i965/brw_fs.h |2 +-
 .../drivers/dri/i965/brw_fs_live_variables.cpp |4 ++--
 src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp  |   24 ++--
 .../dri/i965/brw_fs_schedule_instructions.cpp  |2 +-
 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp   |2 +-
 6 files changed, 21 insertions(+), 22 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp 
b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 175e36e..c201f90 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -416,7 +416,7 @@ fs_visitor::implied_mrf_writes(fs_inst *inst)
 int
 fs_visitor::virtual_grf_alloc(int size)
 {
-   if (virtual_grf_array_size = virtual_grf_next) {
+   if (virtual_grf_array_size = virtual_grf_count) {
   if (virtual_grf_array_size == 0)
 virtual_grf_array_size = 16;
   else
@@ -424,8 +424,8 @@ fs_visitor::virtual_grf_alloc(int size)
   virtual_grf_sizes = reralloc(mem_ctx, virtual_grf_sizes, int,
   virtual_grf_array_size);
}
-   virtual_grf_sizes[virtual_grf_next] = size;
-   return virtual_grf_next++;
+   virtual_grf_sizes[virtual_grf_count] = size;
+   return virtual_grf_count++;
 }
 
 /** Fixed HW reg constructor. */
@@ -1037,7 +1037,7 @@ fs_visitor::assign_urb_setup()
 void
 fs_visitor::split_virtual_grfs()
 {
-   int num_vars = this-virtual_grf_next;
+   int num_vars = this-virtual_grf_count;
bool split_grf[num_vars];
int new_virtual_grf[num_vars];
 
@@ -2031,7 +2031,6 @@ fs_visitor::run()
 
   if (0) {
 /* Debug of register spilling: Go spill everything. */
-int virtual_grf_count = virtual_grf_next;
 for (int i = 0; i  virtual_grf_count; i++) {
spill_reg(i);
 }
diff --git a/src/mesa/drivers/dri/i965/brw_fs.h 
b/src/mesa/drivers/dri/i965/brw_fs.h
index 46579c2..deb58d8 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -351,7 +351,7 @@ public:
int param_offset[MAX_UNIFORMS * 4];
 
int *virtual_grf_sizes;
-   int virtual_grf_next;
+   int virtual_grf_count;
int virtual_grf_array_size;
int *virtual_grf_def;
int *virtual_grf_use;
diff --git a/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp
index 40e7ae5..40877c9 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp
@@ -137,7 +137,7 @@ fs_live_variables::fs_live_variables(fs_visitor *v, fs_cfg 
*cfg)
 {
mem_ctx = ralloc_context(cfg-mem_ctx);
 
-   num_vars = v-virtual_grf_next;
+   num_vars = v-virtual_grf_count;
bd = rzalloc_array(mem_ctx, struct block_data, cfg-num_blocks);
vars = rzalloc_array(mem_ctx, struct var, num_vars);
 
@@ -162,7 +162,7 @@ fs_live_variables::~fs_live_variables()
 void
 fs_visitor::calculate_live_intervals()
 {
-   int num_vars = this-virtual_grf_next;
+   int num_vars = this-virtual_grf_count;
 
if (this-live_intervals_valid)
   return;
diff --git a/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp
index 3a9a415..3f10ca6 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp
@@ -43,17 +43,17 @@ assign_reg(int *reg_hw_locations, fs_reg *reg, int 
reg_width)
 void
 fs_visitor::assign_regs_trivial()
 {
-   int hw_reg_mapping[this-virtual_grf_next + 1];
+   int hw_reg_mapping[this-virtual_grf_count + 1];
int i;
int reg_width = c-dispatch_width / 8;
 
/* Note that compressed instructions require alignment to 2 registers. */
hw_reg_mapping[0] = ALIGN(this-first_non_payload_grf, reg_width);
-   for (i = 1; i = this-virtual_grf_next; i++) {
+   for (i = 1; i = this-virtual_grf_count; i++) {
   hw_reg_mapping[i] = (hw_reg_mapping[i - 1] +
   this-virtual_grf_sizes[i - 1] * reg_width);
}
-   this-grf_used = hw_reg_mapping[this-virtual_grf_next];
+   this-grf_used = hw_reg_mapping[this-virtual_grf_count];
 
foreach_list(node, this-instructions) {
   fs_inst *inst = (fs_inst *)node;
@@ -155,7 +155,7 @@ fs_visitor::assign_regs()
 * for reg_width == 2.
 */
int reg_width = c-dispatch_width / 8;
-   int hw_reg_mapping[this-virtual_grf_next];
+   int hw_reg_mapping[this-virtual_grf_count];
int first_assigned_grf = ALIGN(this-first_non_payload_grf, reg_width);
int base_reg_count = (max_grf - first_assigned_grf) / reg_width;
int class_sizes[base_reg_count];
@@ -178,7 +178,7 @@ fs_visitor::assign_regs()
*/
   class_sizes[class_count++] = 2;
}
-   for (int r = 0; r  this-virtual_grf_next; r++) {
+   for (int r = 0; r  this-virtual_grf_count; r++) {
   

Re: [Mesa-dev] [PATCH] r600g: improve flushed depth texture handling v2

2012-07-09 Thread Vadim Girlin
On Sat, 2012-07-07 at 01:48 +0200, Marek Olšák wrote:
 On Wed, Jun 27, 2012 at 1:34 AM, Vadim Girlin vadimgir...@gmail.com wrote:
  Use r600_resource_texture::flished_depth_texture for GPU access, and
  allocate it in the VRAM. For transfers we'll allocate untiled texture in the
  GTT and store it in the r600_transfer::staging.
 
  Improves performance when flushed depth texture is frequently used by the
  GPU (about 30% for Lightsmark).
 
  Signed-off-by: Vadim Girlin vadimgir...@gmail.com
  ---
 
  Fixes fbo-clear-formats, fbo-generatemipmap-formats, no regressions on
  evergreen
 
 Hi,
 
 is there any reason this patch hasn't been committed yet?
 

Hi,

I have some doubts because it was benchmarked by phoronix and there were
regressions, though I suspect that something is wrong with the results:

http://www.phoronix.com/scan.php?page=articleitem=amd_r600g_texdepthnum=4

I was going to look into it but had no time yet. I'd like to be sure
that there are no regressions before committing.

Vadim





 Marek



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


Re: [Mesa-dev] [PATCH 3/5] i965/fs: Replace usage of is_tex() with regs_written() checks.

2012-07-09 Thread Kenneth Graunke
On 07/09/2012 03:40 PM, Eric Anholt wrote:
[snip]
 @@ -1729,10 +1731,8 @@ fs_visitor::compute_to_mrf()
* into a compute-to-MRF.
*/
  
 +/* SENDs can only write to GRFs, so no compute-to-MRF. */
   if (scan_inst-is_tex()) {
 -/* texturing writes several continuous regs, so we can't
 - * compute-to-mrf that.
 - */
  break;
   }

Based on your comment here, wouldn't it make more sense as

if (scan_inst-mlen)
   break;

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