Re: [Mesa-dev] [PATCH 5/9] glsl: Fix memcpy size in ir_constant

2014-02-09 Thread Juha-Pekka Heikkilä
The place which cause Klocwork to highlight this is at
src/mesa/main/ff_fragment_shader.cpp around line 897 where it says:

...
 float const_data[4] = {
float(1 << rgb_shift),
float(1 << rgb_shift),
float(1 << rgb_shift),
float(1 << alpha_shift)
 };
 shift = new(p->mem_ctx) ir_constant(glsl_type::vec4_type,
 (ir_constant_data *)const_data);
...

I don't know if this is the only place for such usage but it looks
reasonable to me.

If I fix this place instead of what my patch does Klocwork would tell
where is next similar usage for this ir_constant constructor, that is
if such exist.

/Juha-Pekka


On Sat, Feb 8, 2014 at 2:30 AM, Ian Romanick  wrote:
> On 02/07/2014 04:44 AM, Juha-Pekka Heikkila wrote:
>> ir_constant::ir_constant(const struct glsl_type,
>> const ir_constant_data *) was copying too much memory.
>
> The code looks correct as-is to me.  This copies one ir_constant_data
> union to another... they're declared as the same type, and they have the
> same size.  What is the actual error?  Is there some code somewhere
> that's casting a different type to ir_constant_data* to pass into this
> constructor?
>
>> Signed-off-by: Juha-Pekka Heikkila 
>> ---
>>  src/glsl/ir.cpp | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp
>> index 1a36bd6..abc5568 100644
>> --- a/src/glsl/ir.cpp
>> +++ b/src/glsl/ir.cpp
>> @@ -622,7 +622,7 @@ ir_constant::ir_constant(const struct glsl_type *type,
>>
>> this->ir_type = ir_type_constant;
>> this->type = type;
>> -   memcpy(& this->value, data, sizeof(this->value));
>> +   memcpy(& this->value, data, type->std140_size(false));
>>  }
>>
>>  ir_constant::ir_constant(float f, unsigned vector_elements)
>>
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 74727] Mesa 10.1: doesn't build with DRI3 enabled

2014-02-09 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=74727

--- Comment #1 from Keith Packard  ---
You need the xcb randr.h, not the Xlib randr.h. That should be in a
libxcb-randr development package. On debian, that's libxcb-randr0-dev.

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 74727] Mesa 10.1: doesn't build with DRI3 enabled

2014-02-09 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=74727

--- Comment #2 from Armin K  ---
The configure should really check for xcb-randr, too then.

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 74717] r600g: 'invalid read' linking geometry shader

2014-02-09 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=74717

--- Comment #3 from kwah...@wp.pl ---
G-truck samples don't work for me too (similar error for ether samples):

./gl-320-primitive-shading 
OpenGL Version Needed 3.2 ( 3.3 Found )
Shader Compiler: error(high) 2: 0:1(1): error: syntax error, unexpected $end
Shader Compiler: error(high) 3: 0:1(1): error: syntax error, unexpected $end
Shader Compiler: error(high) 4: 0:1(1): error: syntax error, unexpected $end
Compiling shader
gl-320/primitive-shading.vert...
0:1(1): error: syntax error, unexpected $end

Running Test
Test Ended


glxinfo | grep OpenGL
OpenGL vendor string: X.Org
OpenGL renderer string: Gallium 0.4 on AMD TURKS
OpenGL core profile version string: 3.3 (Core Profile) Mesa 10.2.0-devel
(git-020c43f saucy-oibaf-ppa)
OpenGL core profile shading language version string: 3.30
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 3.0 Mesa 10.2.0-devel (git-020c43f saucy-oibaf-ppa)
OpenGL shading language version string: 1.30
OpenGL context flags: (none)


01:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Turks
XT [Radeon HD 6670/7670]

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 74727] Mesa 10.1: doesn't build with DRI3 enabled

2014-02-09 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=74727

--- Comment #3 from Török Edwin  ---
(In reply to comment #2)
> The configure should really check for xcb-randr, too then.

(In reply to comment #1)
> You need the xcb randr.h, not the Xlib randr.h. That should be in a
> libxcb-randr development package. On debian, that's libxcb-randr0-dev.

Indeed, installing that package allowed me to build with DRI3, a configure
check would be nice.

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 74717] r600g: 'invalid read' linking geometry shader

2014-02-09 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=74717

--- Comment #4 from Török Edwin  ---
(In reply to comment #3)
> G-truck samples don't work for me too (similar error for ether samples):
> 
> ./gl-320-primitive-shading 
> OpenGL Version Needed 3.2 ( 3.3 Found )
> Shader Compiler: error(high) 2: 0:1(1): error: syntax error, unexpected $end
> Shader Compiler: error(high) 3: 0:1(1): error: syntax error, unexpected $end
> Shader Compiler: error(high) 4: 0:1(1): error: syntax error, unexpected $end

You need to run it from the source root, like this: 
$ build/build/release/gl-320-primitive-shading

Otherwise it can't find/load the shader, and thats a shortcoming in the
samples, not Mesa.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 74717] r600g: 'invalid read' linking geometry shader

2014-02-09 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=74717

--- Comment #5 from Török Edwin  ---
(In reply to comment #4)
> (In reply to comment #3)
> > G-truck samples don't work for me too (similar error for ether samples):
> > 
> > ./gl-320-primitive-shading 
> > OpenGL Version Needed 3.2 ( 3.3 Found )
> > Shader Compiler: error(high) 2: 0:1(1): error: syntax error, unexpected $end
> > Shader Compiler: error(high) 3: 0:1(1): error: syntax error, unexpected $end
> > Shader Compiler: error(high) 4: 0:1(1): error: syntax error, unexpected $end
> 
> You need to run it from the source root, like this: 
> $ build/build/release/gl-320-primitive-shading

build/release/gl-320-primitive-shading

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 13/22] st/vdpau: do not export VdpPresentationQueueTargetCreateX11

2014-02-09 Thread Christian König

Am 08.02.2014 17:03, schrieb Emil Velikov:

The function pointer is retrieved via VdpGetProcAddress just
like all the other vdpau functions and should not be exported.

Signed-off-by: Emil Velikov 


[PATCH 13/22] st/vdpau: do not export VdpPresentationQueueTargetCreateX11
[PATCH 14/22] st/vdpau: automake: export only PUBLIC symbols
[PATCH 15/22] targets/vdpau: automake: add exported symbol tests
[PATCH 19/22] omx: use VISIBILITY_CFLAGS to control exported symbols
[PATCH 22/22] targets/omx: automake: add symbol test

Those patches are: Reviewed-by: Christian König 


---
  src/gallium/state_trackers/vdpau/device.c| 2 +-
  src/gallium/state_trackers/vdpau/vdpau_private.h | 4 +++-
  2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/gallium/state_trackers/vdpau/device.c 
b/src/gallium/state_trackers/vdpau/device.c
index def1e2a..0cdda73 100644
--- a/src/gallium/state_trackers/vdpau/device.c
+++ b/src/gallium/state_trackers/vdpau/device.c
@@ -106,7 +106,7 @@ no_htab:
  /**
   * Create a VdpPresentationQueueTarget for use with X11.
   */
-PUBLIC VdpStatus
+VdpStatus
  vlVdpPresentationQueueTargetCreateX11(VdpDevice device, Drawable drawable,
VdpPresentationQueueTarget *target)
  {
diff --git a/src/gallium/state_trackers/vdpau/vdpau_private.h 
b/src/gallium/state_trackers/vdpau/vdpau_private.h
index 08afe60..2f4d651 100644
--- a/src/gallium/state_trackers/vdpau/vdpau_private.h
+++ b/src/gallium/state_trackers/vdpau/vdpau_private.h
@@ -436,7 +436,6 @@ boolean vlGetFuncFTAB(VdpFuncId function_id, void **func);
  
  /* Public functions */

  VdpDeviceCreateX11 vdp_imp_device_create_x11;
-VdpPresentationQueueTargetCreateX11 vlVdpPresentationQueueTargetCreateX11;
  
  void vlVdpDefaultSamplerViewTemplate(struct pipe_sampler_view *templ, struct pipe_resource *res);
  
@@ -507,6 +506,9 @@ VdpVideoMixerGetParameterValues vlVdpVideoMixerGetParameterValues;

  VdpVideoMixerGetAttributeValues vlVdpVideoMixerGetAttributeValues;
  VdpVideoMixerDestroy vlVdpVideoMixerDestroy;
  VdpGenerateCSCMatrix vlVdpGenerateCSCMatrix;
+/* Winsys specific internal function pointers */
+VdpPresentationQueueTargetCreateX11 vlVdpPresentationQueueTargetCreateX11;
+
  
  /* interop to mesa state tracker */

  VdpVideoSurfaceGallium vlVdpVideoSurfaceGallium;


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


[Mesa-dev] [Bug 74717] r600g: 'invalid read' linking geometry shader

2014-02-09 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=74717

--- Comment #6 from kwah...@wp.pl ---
(In reply to comment #5)
> > You need to run it from the source root, like this: 
> > $ build/build/release/gl-320-primitive-shading
> 
> build/release/gl-320-primitive-shading

Right, now the examples works. Except gl-320-primitive-shading 

./build/release/gl-320-primitive-shading 
OpenGL Version Needed 3.2 ( 3.3 Found )
Compiling shader
gl-320/primitive-shading.vert...

Compiling shader
gl-320/primitive-shading.geom...

Compiling shader
gl-320/primitive-shading.frag...

Segmentation fault

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 74760] New: Anno 1701 colors of textures are corrupted using Intel GM45 Express chipset

2014-02-09 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=74760

  Priority: medium
Bug ID: 74760
  Assignee: mesa-dev@lists.freedesktop.org
   Summary: Anno 1701 colors of textures are corrupted using Intel
GM45 Express chipset
  Severity: normal
Classification: Unclassified
OS: Linux (All)
  Reporter: chefche...@gmx.de
  Hardware: x86-64 (AMD64)
Status: NEW
   Version: 10.0
 Component: Other
   Product: Mesa

Created attachment 93722
  --> https://bugs.freedesktop.org/attachment.cgi?id=93722&action=edit
screenshot

Hi!

I'm running Anno 1701 on Linux (Open Suse 13.1) using wine (32bit). Mesa
version is 10.0.3.
However textures are broken for some reason (see screenshot).
Turning on normal maps helps somewhat, but the problem does not disappear
entirely.


Best regards

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 74760] Anno 1701 colors of textures are corrupted using Intel GM45 Express chipset

2014-02-09 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=74760

--- Comment #1 from chefche...@gmx.de ---
edit: you have to right click and choose save as to see the screenshot for some
reason.

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 74760] Anno 1701 colors of textures are corrupted using Intel GM45 Express chipset

2014-02-09 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=74760

Jan Vesely  changed:

   What|Removed |Added

  Attachment #93722|text/plain  |image/jpeg
  mime type||

--- Comment #2 from Jan Vesely  ---
Comment on attachment 93722
  --> https://bugs.freedesktop.org/attachment.cgi?id=93722
screenshot

Changed mimetype to image/jpeg

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 74760] Anno 1701 colors of textures are corrupted using Intel GM45 Express chipset

2014-02-09 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=74760

--- Comment #3 from Chris Forbes  ---
Can you provide an apitrace?

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 09/25] egl/dri2: Dispatch eglCreatePixmapSurface by display, not driver

2014-02-09 Thread Chad Versace
Add dri2_egl_display_vtbl::create_pbuffer_surface, set it for each
platform, and let egl_dri2 dispatch eglCreatePixmapSurface to that.

This prepares for the EGL platform extensions.

Signed-off-by: Chad Versace 
---
 src/egl/drivers/dri2/egl_dri2.c   | 11 +++
 src/egl/drivers/dri2/egl_dri2.h   |  5 +
 src/egl/drivers/dri2/egl_dri2_fallbacks.h |  9 +
 src/egl/drivers/dri2/platform_android.c   | 10 +-
 src/egl/drivers/dri2/platform_drm.c   |  1 +
 src/egl/drivers/dri2/platform_wayland.c   |  1 +
 src/egl/drivers/dri2/platform_x11.c   |  4 ++--
 7 files changed, 30 insertions(+), 11 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 872c4e4..2373eb4 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1022,6 +1022,16 @@ dri2_create_window_surface(_EGLDriver *drv, _EGLDisplay 
*dpy,
 attrib_list);
 }
 
+static _EGLSurface*
+dri2_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *dpy,
+   _EGLConfig *conf, EGLNativePixmapType pixmap,
+   const EGLint *attrib_list)
+{
+   struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy);
+   return dri2_dpy->vtbl->create_pixmap_surface(drv, dpy, conf, pixmap,
+attrib_list);
+}
+
 static EGLBoolean
 dri2_swap_interval(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
EGLint interval)
@@ -2066,6 +2076,7 @@ _eglBuiltInDriverDRI2(const char *args)
dri2_drv->base.API.DestroyContext = dri2_destroy_context;
dri2_drv->base.API.MakeCurrent = dri2_make_current;
dri2_drv->base.API.CreateWindowSurface = dri2_create_window_surface;
+   dri2_drv->base.API.CreatePixmapSurface = dri2_create_pixmap_surface;
dri2_drv->base.API.GetProcAddress = dri2_get_proc_address;
dri2_drv->base.API.WaitClient = dri2_wait_client;
dri2_drv->base.API.WaitNative = dri2_wait_native;
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index 0e1779f..161c948 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -93,6 +93,11 @@ struct dri2_egl_display_vtbl {
 _EGLConfig *config, EGLNativeWindowType window,
 const EGLint *attrib_list);
 
+   _EGLSurface*
+   (*create_pixmap_surface)(_EGLDriver *drv, _EGLDisplay *dpy,
+_EGLConfig *config, EGLNativePixmapType pixmap,
+const EGLint *attrib_list);
+
EGLBoolean
(*swap_interval)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
 EGLint interval);
diff --git a/src/egl/drivers/dri2/egl_dri2_fallbacks.h 
b/src/egl/drivers/dri2/egl_dri2_fallbacks.h
index 51c0a99..80dd4ac 100644
--- a/src/egl/drivers/dri2/egl_dri2_fallbacks.h
+++ b/src/egl/drivers/dri2/egl_dri2_fallbacks.h
@@ -26,6 +26,15 @@
 
 #include "egltypedefs.h"
 
+static inline _EGLSurface *
+dri2_fallback_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *disp,
+_EGLConfig *conf,
+EGLNativePixmapType pixmap,
+const EGLint *attrib_list)
+{
+   return NULL;
+}
+
 static inline EGLBoolean
 dri2_fallback_swap_interval(_EGLDriver *drv, _EGLDisplay *dpy,
 _EGLSurface *surf, EGLint interval)
diff --git a/src/egl/drivers/dri2/platform_android.c 
b/src/egl/drivers/dri2/platform_android.c
index e3ee3d6..c518048 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -262,14 +262,6 @@ droid_create_window_surface(_EGLDriver *drv, _EGLDisplay 
*disp,
 }
 
 static _EGLSurface *
-droid_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *disp,
-  _EGLConfig *conf, EGLNativePixmapType pixmap,
-  const EGLint *attrib_list)
-{
-   return NULL;
-}
-
-static _EGLSurface *
 droid_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *disp,
_EGLConfig *conf, const EGLint *attrib_list)
 {
@@ -431,7 +423,6 @@ droid_create_image_khr(_EGLDriver *drv, _EGLDisplay *disp,
 static void
 droid_init_driver_functions(_EGLDriver *drv)
 {
-   drv->API.CreatePixmapSurface = droid_create_pixmap_surface;
drv->API.CreatePbufferSurface = droid_create_pbuffer_surface;
drv->API.DestroySurface = droid_destroy_surface;
 
@@ -654,6 +645,7 @@ droid_log(EGLint level, const char *msg)
 static struct dri2_egl_display_vtbl droid_display_vtbl = {
.authenticate = NULL,
.create_window_surface = droid_create_window_surface,
+   .create_pixmap_surface = dri2_fallback_pixmap_surface,
.swap_interval = dri2_fallback_swap_interval,
.swap_buffers = droid_swap_buffers,
.swap_buffers_with_damage = dri2_fallback_swap_buffers_with_damage,
diff --git a/src/egl/drivers/dri2/pla

[Mesa-dev] [PATCH 01/25] egl: Update to revision 24567 of eglext.h

2014-02-09 Thread Chad Versace
This pulls in EGL_EXT_platform_base, EGL_EXT_platform_wayland,
EGL_EXT_platform_x11, and EGL_MESA_platform_gbm.

This patch has a lot of churn because Khronos recently changed its
method of generating headers. Khronos now generates it headers from XML.

Signed-off-by: Chad Versace 
---
 include/EGL/eglext.h | 960 +++
 1 file changed, 517 insertions(+), 443 deletions(-)

diff --git a/include/EGL/eglext.h b/include/EGL/eglext.h
index 1d68178..243da4a 100644
--- a/include/EGL/eglext.h
+++ b/include/EGL/eglext.h
@@ -1,12 +1,12 @@
 #ifndef __eglext_h_
-#define __eglext_h_
+#define __eglext_h_ 1
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 /*
-** Copyright (c) 2007-2013 The Khronos Group Inc.
+** Copyright (c) 2013 The Khronos Group Inc.
 **
 ** Permission is hereby granted, free of charge, to any person obtaining a
 ** copy of this software and/or associated documentation files (the
@@ -27,549 +27,623 @@ extern "C" {
 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
 */
+/*
+** This header is generated from the Khronos OpenGL / OpenGL ES XML
+** API Registry. The current version of the Registry, generator scripts
+** used to make the header, and the header can be found at
+**   http://www.opengl.org/registry/
+**
+** Khronos $Revision: 24567 $ on $Date: 2013-12-18 09:50:17 -0800 (Wed, 18 Dec 
2013) $
+*/
 
 #include 
 
-/*/
+#define EGL_EGLEXT_VERSION 20131218
 
-/* Header file version number */
-/* Current version at http://www.khronos.org/registry/egl/ */
-/* $Revision: 21254 $ on $Date: 2013-04-25 03:11:55 -0700 (Thu, 25 Apr 2013) $ 
*/
-#define EGL_EGLEXT_VERSION 16
+/* Generated C header for:
+ * API: egl
+ * Versions considered: .*
+ * Versions emitted: _nomatch_^
+ * Default extensions included: egl
+ * Additional extensions included: _nomatch_^
+ * Extensions removed: _nomatch_^
+ */
+
+#ifndef EGL_KHR_cl_event
+#define EGL_KHR_cl_event 1
+#define EGL_CL_EVENT_HANDLE_KHR   0x309C
+#define EGL_SYNC_CL_EVENT_KHR 0x30FE
+#define EGL_SYNC_CL_EVENT_COMPLETE_KHR0x30FF
+#endif /* EGL_KHR_cl_event */
+
+#ifndef EGL_KHR_cl_event2
+#define EGL_KHR_cl_event2 1
+typedef void *EGLSyncKHR;
+typedef intptr_t EGLAttribKHR;
+typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESYNC64KHRPROC) (EGLDisplay dpy, 
EGLenum type, const EGLAttribKHR *attrib_list);
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSync64KHR (EGLDisplay dpy, EGLenum 
type, const EGLAttribKHR *attrib_list);
+#endif
+#endif /* EGL_KHR_cl_event2 */
+
+#ifndef EGL_KHR_client_get_all_proc_addresses
+#define EGL_KHR_client_get_all_proc_addresses 1
+#endif /* EGL_KHR_client_get_all_proc_addresses */
 
 #ifndef EGL_KHR_config_attribs
 #define EGL_KHR_config_attribs 1
-#define EGL_CONFORMANT_KHR 0x3042  /* EGLConfig attribute 
*/
-#define EGL_VG_COLORSPACE_LINEAR_BIT_KHR   0x0020  /* EGL_SURFACE_TYPE 
bitfield */
-#define EGL_VG_ALPHA_FORMAT_PRE_BIT_KHR0x0040  /* 
EGL_SURFACE_TYPE bitfield */
-#endif
+#define EGL_CONFORMANT_KHR0x3042
+#define EGL_VG_COLORSPACE_LINEAR_BIT_KHR  0x0020
+#define EGL_VG_ALPHA_FORMAT_PRE_BIT_KHR   0x0040
+#endif /* EGL_KHR_config_attribs */
 
-#ifndef EGL_KHR_lock_surface
-#define EGL_KHR_lock_surface 1
-#define EGL_READ_SURFACE_BIT_KHR   0x0001  /* 
EGL_LOCK_USAGE_HINT_KHR bitfield */
-#define EGL_WRITE_SURFACE_BIT_KHR  0x0002  /* 
EGL_LOCK_USAGE_HINT_KHR bitfield */
-#define EGL_LOCK_SURFACE_BIT_KHR   0x0080  /* EGL_SURFACE_TYPE 
bitfield */
-#define EGL_OPTIMAL_FORMAT_BIT_KHR 0x0100  /* EGL_SURFACE_TYPE 
bitfield */
-#define EGL_MATCH_FORMAT_KHR   0x3043  /* EGLConfig attribute 
*/
-#define EGL_FORMAT_RGB_565_EXACT_KHR   0x30C0  /* EGL_MATCH_FORMAT_KHR 
value */
-#define EGL_FORMAT_RGB_565_KHR 0x30C1  /* EGL_MATCH_FORMAT_KHR 
value */
-#define EGL_FORMAT_RGBA__EXACT_KHR 0x30C2  /* EGL_MATCH_FORMAT_KHR 
value */
-#define EGL_FORMAT_RGBA__KHR   0x30C3  /* EGL_MATCH_FORMAT_KHR 
value */
-#define EGL_MAP_PRESERVE_PIXELS_KHR0x30C4  /* eglLockSurfaceKHR 
attribute */
-#define EGL_LOCK_USAGE_HINT_KHR0x30C5  /* 
eglLockSurfaceKHR attribute */
-#define EGL_BITMAP_POINTER_KHR 0x30C6  /* eglQuerySurface 
attribute */
-#define EGL_BITMAP_PITCH_KHR   0x30C7  /* eglQuerySurface 
attribute */
-#define EGL_BITMAP_ORIGIN_KHR  0x30C8  /* eglQuerySurface 
attribute */
-#define EGL_BITMAP_PIXEL_RED_OFFSET_KHR0x30C9  /* 
eglQuerySurface attribute */
-#define EGL_BITMAP_PIXEL_GREEN_OFFSET_KHR  0x30CA  /* eglQuerySurface 
attribute */
-#define EGL_BITMAP_PIXEL_BLUE_OFFSET_KHR   0x30CB  /* eglQuerySurface 
attribute */
-#define EGL_BITMAP_PIXEL_ALPHA_

[Mesa-dev] [PATCH 00/25] egl: Enable Linux platform extensions

2014-02-09 Thread Chad Versace
This series enable EGL_EXT_platform_base and the Linux platform extensions
layered atop it: EGL_EXT_platform_x11, EGL_EXT_platform_wayland, and
EGL_MESA_platform_gbm.

The series lives on my 'EGL_EXT_platform_base-v16' branch at
[git://people.freedesktop.org/~chadversary/mesa]. Accompanying Piglit tests
live on the same branch name at 
[git://people.freedesktop.org/~chadversary/piglit].

I regression tested the Mesa series by running Piglit an X11 session on
Ivybridge.  To get the EGL_EXT_platform_x11, EGL_EXT_platform_wayland, and
EGL_MESA_platform_gbm tests to pass with a single run of Piglit, I started
a windowed instance of Weston and the kernel had render nodes enabled.

I also smoke-tested the series by running weston-smoke in stand-alone Weston.

Patches 1-22 are largely mechanical refactorings. They should review quickly.
Patches 23-25 contain the real changes, but those patches are also quite small.

Chad Versace (25):
  egl: Update to revision 24567 of eglext.h
  egl/dri2: Move dri2_egl_display virtual funcs to vtbl
  egl/dri2: Put platform func names into proper namespaces
  egl/wl: Call dri2_swap_interval() statically
  egl/dri2: Dispatch eglSwapInterval by display, not driver
  egl/dri2: Dispatch eglSwapBuffers  by display, not driver
  egl/dri2: Dispatch eglSwapBuffersWithDamage by display, not driver
  egl/dri2: Dispatch eglCreateWindowSurface by display, not driver
  egl/dri2: Dispatch eglCreatePixmapSurface by display, not driver
  egl/dri2: Dispatch eglCreatePbufferSurface by display, not driver
  egl/dri2: Dispatch eglDestroySurface by display, not driver
  egl/dri2: Dispatch API.QueryBufferAge by display, not driver
  egl/dri2: Dispatch eglCopyBuffers by display, not driver
  egl/dri2: Dispatch eglSwapBuffersRegionNOK by display, not driver
  egl/dri2: Dispatch eglPostSubBufferNV by display, not driver
  egl/dri2/x11: Set dri2_dpy->own_device
  egl/dri2: Consolidate eglTerminate
  egl/dri2: Dispatch eglCreateWaylandBufferFromImageWL by display, not
driver
  egl/dri2/x11: Don't clobber _EGLDriver::API
  egl/dri2: Dispatch eglCreateImageKHR by display, not driver
  egl: Add STATIC_ASSERT() macro
  egl/main: Stop using EGLNative types internally
  egl/gbm: Emit EGL_BAD_PARAMETER for eglCreatePlatformPixmapSurface
  egl/wayland: Emit EGL_BAD_PARAMETER for eglCreatePlatformPixmapSurface
  egl/main: Enable Linux platform extensions

 include/EGL/eglext.h   | 960 +++--
 src/egl/drivers/dri2/egl_dri2.c| 172 +++-
 src/egl/drivers/dri2/egl_dri2.h|  64 +-
 src/egl/drivers/dri2/egl_dri2_fallbacks.h  | 100 +++
 src/egl/drivers/dri2/platform_android.c|  53 +-
 src/egl/drivers/dri2/platform_drm.c| 120 ++-
 src/egl/drivers/dri2/platform_wayland.c| 173 ++--
 src/egl/drivers/dri2/platform_x11.c| 231 +++--
 src/egl/main/eglapi.c  | 143 ++-
 src/egl/main/eglapi.h  |   6 +-
 src/egl/main/eglcompiler.h |   5 +
 src/egl/main/egldisplay.c  |  76 +-
 src/egl/main/egldisplay.h  |  22 +-
 src/egl/main/eglglobals.c  |  10 +-
 src/egl/main/eglglobals.h  |   4 +
 .../state_trackers/egl/common/egl_g3d_api.c|  18 +-
 16 files changed, 1421 insertions(+), 736 deletions(-)
 create mode 100644 src/egl/drivers/dri2/egl_dri2_fallbacks.h

-- 
1.8.5.3

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


[Mesa-dev] [PATCH 07/25] egl/dri2: Dispatch eglSwapBuffersWithDamage by display, not driver

2014-02-09 Thread Chad Versace
Add dri2_egl_display_vtbl::swap_buffers_with_damage, set it for each
platform, and let egl_dri2 dispatch eglSwapBuffersWithDamageEXT to that.

This prepares for the EGL platform extensions.

Signed-off-by: Chad Versace 
---
 src/egl/drivers/dri2/egl_dri2.c   | 11 +++
 src/egl/drivers/dri2/egl_dri2.h   |  5 +
 src/egl/drivers/dri2/egl_dri2_fallbacks.h |  8 
 src/egl/drivers/dri2/platform_android.c   |  1 +
 src/egl/drivers/dri2/platform_wayland.c   |  2 +-
 src/egl/drivers/dri2/platform_x11.c   |  1 +
 6 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 60365ee..b6b84bd 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1028,6 +1028,16 @@ dri2_swap_buffers(_EGLDriver *drv, _EGLDisplay *dpy, 
_EGLSurface *surf)
 }
 
 static EGLBoolean
+dri2_swap_buffers_with_damage(_EGLDriver *drv, _EGLDisplay *dpy,
+  _EGLSurface *surf,
+  const EGLint *rects, EGLint n_rects)
+{
+   struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy);
+   return dri2_dpy->vtbl->swap_buffers_with_damage(drv, dpy, surf,
+   rects, n_rects);
+}
+
+static EGLBoolean
 dri2_wait_client(_EGLDriver *drv, _EGLDisplay *disp, _EGLContext *ctx)
 {
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
@@ -2052,6 +2062,7 @@ _eglBuiltInDriverDRI2(const char *args)
dri2_drv->base.API.ReleaseTexImage = dri2_release_tex_image;
dri2_drv->base.API.SwapInterval = dri2_swap_interval;
dri2_drv->base.API.SwapBuffers = dri2_swap_buffers;
+   dri2_drv->base.API.SwapBuffersWithDamageEXT = dri2_swap_buffers_with_damage;
dri2_drv->base.API.CreateImageKHR = dri2_create_image_khr;
dri2_drv->base.API.DestroyImageKHR = dri2_destroy_image_khr;
 #ifdef HAVE_DRM_PLATFORM
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index 6c86c40..3ac8f28 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -94,6 +94,11 @@ struct dri2_egl_display_vtbl {
 
EGLBoolean
(*swap_buffers)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf);
+
+   EGLBoolean
+   (*swap_buffers_with_damage)(_EGLDriver *drv, _EGLDisplay *dpy,
+   _EGLSurface *surface,
+   const EGLint *rects, EGLint n_rects);
 };
 
 struct dri2_egl_display
diff --git a/src/egl/drivers/dri2/egl_dri2_fallbacks.h 
b/src/egl/drivers/dri2/egl_dri2_fallbacks.h
index e09a3b8..51c0a99 100644
--- a/src/egl/drivers/dri2/egl_dri2_fallbacks.h
+++ b/src/egl/drivers/dri2/egl_dri2_fallbacks.h
@@ -32,3 +32,11 @@ dri2_fallback_swap_interval(_EGLDriver *drv, _EGLDisplay 
*dpy,
 {
return EGL_FALSE;
 }
+
+static inline EGLBoolean
+dri2_fallback_swap_buffers_with_damage(_EGLDriver *drv, _EGLDisplay *dpy,
+  _EGLSurface *surf,
+  const EGLint *rects, EGLint n_rects)
+{
+   return EGL_FALSE;
+}
diff --git a/src/egl/drivers/dri2/platform_android.c 
b/src/egl/drivers/dri2/platform_android.c
index 7b4e0dc..d1e969d 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -656,6 +656,7 @@ static struct dri2_egl_display_vtbl droid_display_vtbl = {
.authenticate = NULL,
.swap_interval = dri2_fallback_swap_interval,
.swap_buffers = droid_swap_buffers,
+   .swap_buffers_with_damage = dri2_fallback_swap_buffers_with_damage,
 };
 
 EGLBoolean
diff --git a/src/egl/drivers/dri2/platform_wayland.c 
b/src/egl/drivers/dri2/platform_wayland.c
index f62b77b..348a25d 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -960,6 +960,7 @@ static struct dri2_egl_display_vtbl dri2_wl_display_vtbl = {
.authenticate = dri2_wl_authenticate,
.swap_interval = dri2_wl_swap_interval,
.swap_buffers = dri2_wl_swap_buffers,
+   .swap_buffers_with_damage = dri2_wl_swap_buffers_with_damage,
 };
 
 EGLBoolean
@@ -978,7 +979,6 @@ dri2_initialize_wayland(_EGLDriver *drv, _EGLDisplay *disp)
 
drv->API.CreateWindowSurface = dri2_wl_create_window_surface;
drv->API.DestroySurface = dri2_wl_destroy_surface;
-   drv->API.SwapBuffersWithDamageEXT = dri2_wl_swap_buffers_with_damage;
drv->API.Terminate = dri2_wl_terminate;
drv->API.QueryBufferAge = dri2_wl_query_buffer_age;
 
diff --git a/src/egl/drivers/dri2/platform_x11.c 
b/src/egl/drivers/dri2/platform_x11.c
index 38e8669..28bfc82 100644
--- a/src/egl/drivers/dri2/platform_x11.c
+++ b/src/egl/drivers/dri2/platform_x11.c
@@ -1002,6 +1002,7 @@ static struct dri2_egl_display_vtbl dri2_x11_display_vtbl 
= {
.authenticate = dri2_x11_authenticate,
.swap_interval = dri2_x11_swap_interval,
.swap_buffers = dri2_x11_swap_buffers,
+   .swap_buffers_with_damage = dri2_fallback_swap_buffers_with_damage,
 };
 
 static EGLBoo

[Mesa-dev] [PATCH 02/25] egl/dri2: Move dri2_egl_display virtual funcs to vtbl

2014-02-09 Thread Chad Versace
dri2_egl_display has only one virtual function, 'authenticate'.  Define
dri2_egl_display::vtbl and move 'authenticate' there.

This prepares for the EGL platform extensions, which will add many
more virtual functions to dri2_egl_display.

Signed-off-by: Chad Versace 
---
 src/egl/drivers/dri2/egl_dri2.c |  2 +-
 src/egl/drivers/dri2/egl_dri2.h |  9 +++--
 src/egl/drivers/dri2/platform_android.c |  9 +
 src/egl/drivers/dri2/platform_drm.c | 10 +-
 src/egl/drivers/dri2/platform_wayland.c | 10 +-
 src/egl/drivers/dri2/platform_x11.c | 20 ++--
 6 files changed, 53 insertions(+), 7 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 892f1f4..308b49b 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1879,7 +1879,7 @@ dri2_bind_wayland_display_wl(_EGLDriver *drv, _EGLDisplay 
*disp,
   return EGL_FALSE;
 
wl_drm_callbacks.authenticate =
-  (int(*)(void *, uint32_t)) dri2_dpy->authenticate;
+  (int(*)(void *, uint32_t)) dri2_dpy->vtbl->authenticate;
 
ret = drmGetCap(dri2_dpy->fd, DRM_CAP_PRIME, &cap);
if (ret == 0 && cap == (DRM_PRIME_CAP_IMPORT | DRM_PRIME_CAP_EXPORT) &&
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index dfc5927..3411883 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -84,8 +84,15 @@ struct dri2_egl_driver
void (*glFlush)(void);
 };
 
+struct dri2_egl_display_vtbl {
+   int
+   (*authenticate)(_EGLDisplay *disp, uint32_t id);
+};
+
 struct dri2_egl_display
 {
+   const struct dri2_egl_display_vtbl *vtbl;
+
int   dri2_major;
int   dri2_minor;
__DRIscreen  *dri_screen;
@@ -134,8 +141,6 @@ struct dri2_egl_display
int  formats;
uint32_t  capabilities;
 #endif
-
-   int (*authenticate) (_EGLDisplay *disp, uint32_t id);
 };
 
 struct dri2_egl_context
diff --git a/src/egl/drivers/dri2/platform_android.c 
b/src/egl/drivers/dri2/platform_android.c
index 4a201c8..73aff4f 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -652,6 +652,10 @@ droid_log(EGLint level, const char *msg)
}
 }
 
+static struct dri2_egl_display_vtbl droid_display_vtbl = {
+   .authenticate = NULL,
+};
+
 EGLBoolean
 dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *dpy)
 {
@@ -716,6 +720,11 @@ dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *dpy)
 
droid_init_driver_functions(drv);
 
+   /* Fill vtbl last to prevent accidentally calling virtual function during
+* initialization.
+*/
+   dri2_dpy->vtbl = &droid_display_vtbl;
+
return EGL_TRUE;
 
 cleanup_screen:
diff --git a/src/egl/drivers/dri2/platform_drm.c 
b/src/egl/drivers/dri2/platform_drm.c
index a2b387d..c082df7 100644
--- a/src/egl/drivers/dri2/platform_drm.c
+++ b/src/egl/drivers/dri2/platform_drm.c
@@ -440,6 +440,10 @@ dri2_drm_authenticate(_EGLDisplay *disp, uint32_t id)
return drmAuthMagic(dri2_dpy->fd, id);
 }
 
+static struct dri2_egl_display_vtbl dri2_drm_display_vtbl = {
+   .authenticate = dri2_drm_authenticate,
+};
+
 EGLBoolean
 dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)
 {
@@ -543,11 +547,15 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)
 #ifdef HAVE_WAYLAND_PLATFORM
disp->Extensions.WL_bind_wayland_display = EGL_TRUE;
 #endif
-   dri2_dpy->authenticate = dri2_drm_authenticate;
 
/* we're supporting EGL 1.4 */
disp->VersionMajor = 1;
disp->VersionMinor = 4;
 
+   /* Fill vtbl last to prevent accidentally calling virtual function during
+* initialization.
+*/
+   dri2_dpy->vtbl = &dri2_drm_display_vtbl;
+
return EGL_TRUE;
 }
diff --git a/src/egl/drivers/dri2/platform_wayland.c 
b/src/egl/drivers/dri2/platform_wayland.c
index 50750a9..6622808 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -951,6 +951,10 @@ dri2_setup_swap_interval(struct dri2_egl_display *dri2_dpy)
}
 }
 
+static struct dri2_egl_display_vtbl dri2_wl_display_vtbl = {
+   .authenticate = dri2_wayland_authenticate,
+};
+
 EGLBoolean
 dri2_initialize_wayland(_EGLDriver *drv, _EGLDisplay *disp)
 {
@@ -1061,7 +1065,6 @@ dri2_initialize_wayland(_EGLDriver *drv, _EGLDisplay 
*disp)
disp->Extensions.WL_bind_wayland_display = EGL_TRUE;
disp->Extensions.WL_create_wayland_buffer_from_image = EGL_TRUE;
disp->Extensions.EXT_buffer_age = EGL_TRUE;
-   dri2_dpy->authenticate = dri2_wayland_authenticate;
 
disp->Extensions.EXT_swap_buffers_with_damage = EGL_TRUE;
 
@@ -1069,6 +1072,11 @@ dri2_initialize_wayland(_EGLDriver *drv, _EGLDisplay 
*disp)
disp->VersionMajor = 1;
disp->VersionMinor = 4;
 
+   /* Fill vtbl last to prevent accidentally calling virtual function during
+* initialization.
+*/
+   dri2_dpy->vtbl = &dri2_wl_display_

[Mesa-dev] [PATCH 03/25] egl/dri2: Put platform func names into proper namespaces

2014-02-09 Thread Chad Versace
Each of the egl_dri2 platforms (except Android) prefix their function
names with "dri2", not "dri2_${platform}". This means many function
names have three separate definitions in the egl_dri2 directory: one in
each of platform_drm.c, platform_wayland.c, and platform_x11.c. For
example, each of the three files defines dri2_create_window_surface().

The name collisions make it difficult to review patches for correctness
("Is this patch hunk calling a platform_x11 function or a global
egl_dri2 function?"), complicate debugging, and confuse code navigation
tools.

For each function in platform_x11.c prefixed with 'dri2', this patch
changes its prefix to 'dri2_x11'. Likewise for platform_drm.c and
'dri2_drm'; and platform_wayland.c and 'dri2_wl'.

Signed-off-by: Chad Versace 
---
 src/egl/drivers/dri2/platform_drm.c |  80 
 src/egl/drivers/dri2/platform_wayland.c | 108 ++---
 src/egl/drivers/dri2/platform_x11.c | 161 +---
 3 files changed, 178 insertions(+), 171 deletions(-)

diff --git a/src/egl/drivers/dri2/platform_drm.c 
b/src/egl/drivers/dri2/platform_drm.c
index c082df7..a387417 100644
--- a/src/egl/drivers/dri2/platform_drm.c
+++ b/src/egl/drivers/dri2/platform_drm.c
@@ -86,9 +86,9 @@ has_free_buffers(struct gbm_surface *_surf)
 }
 
 static _EGLSurface *
-dri2_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type,
-   _EGLConfig *conf, EGLNativeWindowType window,
-   const EGLint *attrib_list)
+dri2_drm_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type,
+_EGLConfig *conf, EGLNativeWindowType window,
+const EGLint *attrib_list)
 {
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
struct dri2_egl_config *dri2_conf = dri2_egl_config(conf);
@@ -139,16 +139,16 @@ dri2_create_surface(_EGLDriver *drv, _EGLDisplay *disp, 
EGLint type,
 }
 
 static _EGLSurface *
-dri2_create_window_surface(_EGLDriver *drv, _EGLDisplay *disp,
-  _EGLConfig *conf, EGLNativeWindowType window,
-  const EGLint *attrib_list)
+dri2_drm_create_window_surface(_EGLDriver *drv, _EGLDisplay *disp,
+   _EGLConfig *conf, EGLNativeWindowType window,
+   const EGLint *attrib_list)
 {
-   return dri2_create_surface(drv, disp, EGL_WINDOW_BIT, conf,
- window, attrib_list);
+   return dri2_drm_create_surface(drv, disp, EGL_WINDOW_BIT, conf,
+  window, attrib_list);
 }
 
 static EGLBoolean
-dri2_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf)
+dri2_drm_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf)
 {
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf);
@@ -248,7 +248,7 @@ get_aux_bo(struct dri2_egl_surface *dri2_surf,
 }
 
 static __DRIbuffer *
-dri2_get_buffers_with_format(__DRIdrawable *driDrawable,
+dri2_drm_get_buffers_with_format(__DRIdrawable *driDrawable,
 int *width, int *height,
 unsigned int *attachments, int count,
 int *out_count, void *loaderPrivate)
@@ -290,10 +290,10 @@ dri2_get_buffers_with_format(__DRIdrawable *driDrawable,
 }
 
 static __DRIbuffer *
-dri2_get_buffers(__DRIdrawable * driDrawable,
-int *width, int *height,
-unsigned int *attachments, int count,
-int *out_count, void *loaderPrivate)
+dri2_drm_get_buffers(__DRIdrawable * driDrawable,
+ int *width, int *height,
+ unsigned int *attachments, int count,
+ int *out_count, void *loaderPrivate)
 {
unsigned int *attachments_with_format;
__DRIbuffer *buffer;
@@ -312,10 +312,10 @@ dri2_get_buffers(__DRIdrawable * driDrawable,
}
 
buffer =
-  dri2_get_buffers_with_format(driDrawable,
-  width, height,
-  attachments_with_format, count,
-  out_count, loaderPrivate);
+  dri2_drm_get_buffers_with_format(driDrawable,
+   width, height,
+   attachments_with_format, count,
+   out_count, loaderPrivate);
 
free(attachments_with_format);
 
@@ -323,12 +323,12 @@ dri2_get_buffers(__DRIdrawable * driDrawable,
 }
 
 static int
-dri_image_get_buffers(__DRIdrawable *driDrawable,
-  unsigned int format,
-  uint32_t *stamp,
-  void *loaderPrivate,
-  uint32_t buffer_mask,
-  struct __DRIimageList *buffers)
+dri2_drm_image_get_buffers(__DRIdrawable *driDrawable,
+   unsigned int format,
+ 

[Mesa-dev] [PATCH 04/25] egl/wl: Call dri2_swap_interval() statically

2014-02-09 Thread Chad Versace
Don't call it through the driver dispatch table. Just call it
statically.

This prepares for the EGL platform extensions.

Signed-off-by: Chad Versace 
---
 src/egl/drivers/dri2/platform_wayland.c | 6 +-
 src/egl/drivers/dri2/platform_x11.c | 6 +-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/egl/drivers/dri2/platform_wayland.c 
b/src/egl/drivers/dri2/platform_wayland.c
index 93f560a..f710efa 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -47,6 +47,10 @@ enum wl_drm_format_flags {
HAS_RGB565 = 4,
 };
 
+static EGLBoolean
+dri2_wl_swap_interval(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf,
+  EGLint interval);
+
 static void
 sync_callback(void *data, struct wl_callback *callback, uint32_t serial)
 {
@@ -191,7 +195,7 @@ dri2_wl_create_window_surface(_EGLDriver *drv, _EGLDisplay 
*disp,
  window, attrib_list);
 
if (surf != NULL)
-  drv->API.SwapInterval(drv, disp, surf, dri2_dpy->default_swap_interval);
+  dri2_wl_swap_interval(drv, disp, surf, dri2_dpy->default_swap_interval);
 
return surf;
 }
diff --git a/src/egl/drivers/dri2/platform_x11.c 
b/src/egl/drivers/dri2/platform_x11.c
index eb15650..ea871fd 100644
--- a/src/egl/drivers/dri2/platform_x11.c
+++ b/src/egl/drivers/dri2/platform_x11.c
@@ -41,6 +41,10 @@
 
 #include "egl_dri2.h"
 
+static EGLBoolean
+dri2_x11_swap_interval(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf,
+   EGLint interval);
+
 static void
 swrastCreateDrawable(struct dri2_egl_display * dri2_dpy,
  struct dri2_egl_surface * dri2_surf,
@@ -287,7 +291,7 @@ dri2_x11_create_window_surface(_EGLDriver *drv, _EGLDisplay 
*disp,
   surf->SwapInterval = 1;
 
   /* Override that with a driconf-set value. */
-  drv->API.SwapInterval(drv, disp, surf, dri2_dpy->default_swap_interval);
+  dri2_x11_swap_interval(drv, disp, surf, dri2_dpy->default_swap_interval);
}
 
return surf;
-- 
1.8.5.3

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


[Mesa-dev] [PATCH 05/25] egl/dri2: Dispatch eglSwapInterval by display, not driver

2014-02-09 Thread Chad Versace
Add dri2_egl_display_vtbl::swap_interval, set it for each platform, and
let egl_dri2 dispatch eglSwapInterval to that.

This prepares for the EGL platform extensions.

Signed-off-by: Chad Versace 
---
 src/egl/drivers/dri2/egl_dri2.c   |  9 
 src/egl/drivers/dri2/egl_dri2.h   |  4 
 src/egl/drivers/dri2/egl_dri2_fallbacks.h | 34 +++
 src/egl/drivers/dri2/platform_android.c   |  2 ++
 src/egl/drivers/dri2/platform_drm.c   |  2 ++
 src/egl/drivers/dri2/platform_wayland.c   |  3 ++-
 src/egl/drivers/dri2/platform_x11.c   |  4 +++-
 7 files changed, 56 insertions(+), 2 deletions(-)
 create mode 100644 src/egl/drivers/dri2/egl_dri2_fallbacks.h

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 308b49b..0e3a4ea 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1013,6 +1013,14 @@ dri2_get_proc_address(_EGLDriver *drv, const char 
*procname)
 }
 
 static EGLBoolean
+dri2_swap_interval(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
+   EGLint interval)
+{
+   struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy);
+   return dri2_dpy->vtbl->swap_interval(drv, dpy, surf, interval);
+}
+
+static EGLBoolean
 dri2_wait_client(_EGLDriver *drv, _EGLDisplay *disp, _EGLContext *ctx)
 {
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
@@ -2035,6 +2043,7 @@ _eglBuiltInDriverDRI2(const char *args)
dri2_drv->base.API.WaitNative = dri2_wait_native;
dri2_drv->base.API.BindTexImage = dri2_bind_tex_image;
dri2_drv->base.API.ReleaseTexImage = dri2_release_tex_image;
+   dri2_drv->base.API.SwapInterval = dri2_swap_interval;
dri2_drv->base.API.CreateImageKHR = dri2_create_image_khr;
dri2_drv->base.API.DestroyImageKHR = dri2_destroy_image_khr;
 #ifdef HAVE_DRM_PLATFORM
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index 3411883..a521c7e 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -87,6 +87,10 @@ struct dri2_egl_driver
 struct dri2_egl_display_vtbl {
int
(*authenticate)(_EGLDisplay *disp, uint32_t id);
+
+   EGLBoolean
+   (*swap_interval)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
+EGLint interval);
 };
 
 struct dri2_egl_display
diff --git a/src/egl/drivers/dri2/egl_dri2_fallbacks.h 
b/src/egl/drivers/dri2/egl_dri2_fallbacks.h
new file mode 100644
index 000..e09a3b8
--- /dev/null
+++ b/src/egl/drivers/dri2/egl_dri2_fallbacks.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2014 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.
+ */
+
+#pragma once
+
+#include "egltypedefs.h"
+
+static inline EGLBoolean
+dri2_fallback_swap_interval(_EGLDriver *drv, _EGLDisplay *dpy,
+_EGLSurface *surf, EGLint interval)
+{
+   return EGL_FALSE;
+}
diff --git a/src/egl/drivers/dri2/platform_android.c 
b/src/egl/drivers/dri2/platform_android.c
index 73aff4f..b03cca3 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -36,6 +36,7 @@
 
 #include "loader.h"
 #include "egl_dri2.h"
+#include "egl_dri2_fallbacks.h"
 #include "gralloc_drm.h"
 
 static int
@@ -654,6 +655,7 @@ droid_log(EGLint level, const char *msg)
 
 static struct dri2_egl_display_vtbl droid_display_vtbl = {
.authenticate = NULL,
+   .swap_interval = dri2_fallback_swap_interval,
 };
 
 EGLBoolean
diff --git a/src/egl/drivers/dri2/platform_drm.c 
b/src/egl/drivers/dri2/platform_drm.c
index a387417..8544bf5 100644
--- a/src/egl/drivers/dri2/platform_drm.c
+++ b/src/egl/drivers/dri2/platform_drm.c
@@ -36,6 +36,7 @@
 #include 
 
 #include "egl_dri2.h"
+#include "egl_dri2_fallbacks.h"
 #include "loader.h"
 
 static struct gbm_bo *
@@ -442,6 +443,7 @@ dri2_drm_authenticate(_EGLDisplay *disp, uint32_t id)
 
 static struct dri2_egl_display_vtbl

[Mesa-dev] [PATCH 08/25] egl/dri2: Dispatch eglCreateWindowSurface by display, not driver

2014-02-09 Thread Chad Versace
Add dri2_egl_display_vtbl::create_window_surface, set it for each
platform, and let egl_dri2 dispatch eglCreateWindowSurface to that.

This prepares for the EGL platform extensions.

Signed-off-by: Chad Versace 
---
 src/egl/drivers/dri2/egl_dri2.c | 11 +++
 src/egl/drivers/dri2/egl_dri2.h |  5 +
 src/egl/drivers/dri2/platform_android.c |  2 +-
 src/egl/drivers/dri2/platform_drm.c |  3 ++-
 src/egl/drivers/dri2/platform_wayland.c |  2 +-
 src/egl/drivers/dri2/platform_x11.c |  4 ++--
 6 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index b6b84bd..872c4e4 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1012,6 +1012,16 @@ dri2_get_proc_address(_EGLDriver *drv, const char 
*procname)
return dri2_drv->get_proc_address(procname);
 }
 
+static _EGLSurface*
+dri2_create_window_surface(_EGLDriver *drv, _EGLDisplay *dpy,
+   _EGLConfig *conf, EGLNativeWindowType window,
+   const EGLint *attrib_list)
+{
+   struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy);
+   return dri2_dpy->vtbl->create_window_surface(drv, dpy, conf, window,
+attrib_list);
+}
+
 static EGLBoolean
 dri2_swap_interval(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
EGLint interval)
@@ -2055,6 +2065,7 @@ _eglBuiltInDriverDRI2(const char *args)
dri2_drv->base.API.CreateContext = dri2_create_context;
dri2_drv->base.API.DestroyContext = dri2_destroy_context;
dri2_drv->base.API.MakeCurrent = dri2_make_current;
+   dri2_drv->base.API.CreateWindowSurface = dri2_create_window_surface;
dri2_drv->base.API.GetProcAddress = dri2_get_proc_address;
dri2_drv->base.API.WaitClient = dri2_wait_client;
dri2_drv->base.API.WaitNative = dri2_wait_native;
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index 3ac8f28..0e1779f 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -88,6 +88,11 @@ struct dri2_egl_display_vtbl {
int
(*authenticate)(_EGLDisplay *disp, uint32_t id);
 
+   _EGLSurface*
+   (*create_window_surface)(_EGLDriver *drv, _EGLDisplay *dpy,
+_EGLConfig *config, EGLNativeWindowType window,
+const EGLint *attrib_list);
+
EGLBoolean
(*swap_interval)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
 EGLint interval);
diff --git a/src/egl/drivers/dri2/platform_android.c 
b/src/egl/drivers/dri2/platform_android.c
index d1e969d..e3ee3d6 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -431,7 +431,6 @@ droid_create_image_khr(_EGLDriver *drv, _EGLDisplay *disp,
 static void
 droid_init_driver_functions(_EGLDriver *drv)
 {
-   drv->API.CreateWindowSurface = droid_create_window_surface;
drv->API.CreatePixmapSurface = droid_create_pixmap_surface;
drv->API.CreatePbufferSurface = droid_create_pbuffer_surface;
drv->API.DestroySurface = droid_destroy_surface;
@@ -654,6 +653,7 @@ droid_log(EGLint level, const char *msg)
 
 static struct dri2_egl_display_vtbl droid_display_vtbl = {
.authenticate = NULL,
+   .create_window_surface = droid_create_window_surface,
.swap_interval = dri2_fallback_swap_interval,
.swap_buffers = droid_swap_buffers,
.swap_buffers_with_damage = dri2_fallback_swap_buffers_with_damage,
diff --git a/src/egl/drivers/dri2/platform_drm.c 
b/src/egl/drivers/dri2/platform_drm.c
index e39cb79..8dff369 100644
--- a/src/egl/drivers/dri2/platform_drm.c
+++ b/src/egl/drivers/dri2/platform_drm.c
@@ -443,8 +443,10 @@ dri2_drm_authenticate(_EGLDisplay *disp, uint32_t id)
 
 static struct dri2_egl_display_vtbl dri2_drm_display_vtbl = {
.authenticate = dri2_drm_authenticate,
+   .create_window_surface = dri2_drm_create_window_surface,
.swap_interval = dri2_fallback_swap_interval,
.swap_buffers = dri2_drm_swap_buffers,
+   .swap_buffers_with_damage = dri2_fallback_swap_buffers_with_damage,
 };
 
 EGLBoolean
@@ -539,7 +541,6 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)
   i + 1, EGL_WINDOW_BIT, attr_list, NULL);
}
 
-   drv->API.CreateWindowSurface = dri2_drm_create_window_surface;
drv->API.DestroySurface = dri2_drm_destroy_surface;
drv->API.CreateImageKHR = dri2_drm_create_image_khr;
drv->API.QueryBufferAge = dri2_drm_query_buffer_age;
diff --git a/src/egl/drivers/dri2/platform_wayland.c 
b/src/egl/drivers/dri2/platform_wayland.c
index 348a25d..8457813 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -958,6 +958,7 @@ dri2_wl_setup_swap_interval(struct dri2_egl_display 
*dri2_dpy)
 
 static struct dri2_egl_display_vtbl dri2_wl_display_vtbl = {
.authenticate = dri2_wl_authenticate,
+   .create_window_surf

[Mesa-dev] [PATCH 06/25] egl/dri2: Dispatch eglSwapBuffers by display, not driver

2014-02-09 Thread Chad Versace
Add dri2_egl_display_vtbl::swap_buffers, set it for each platform, and
let egl_dri2 dispatch eglSwapBuffers to that.

This prepares for the EGL platform extensions.

Signed-off-by: Chad Versace 
---
 src/egl/drivers/dri2/egl_dri2.c | 8 
 src/egl/drivers/dri2/egl_dri2.h | 3 +++
 src/egl/drivers/dri2/platform_android.c | 2 +-
 src/egl/drivers/dri2/platform_drm.c | 2 +-
 src/egl/drivers/dri2/platform_wayland.c | 2 +-
 src/egl/drivers/dri2/platform_x11.c | 4 ++--
 6 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 0e3a4ea..60365ee 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1021,6 +1021,13 @@ dri2_swap_interval(_EGLDriver *drv, _EGLDisplay *dpy, 
_EGLSurface *surf,
 }
 
 static EGLBoolean
+dri2_swap_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf)
+{
+   struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy);
+   return dri2_dpy->vtbl->swap_buffers(drv, dpy, surf);
+}
+
+static EGLBoolean
 dri2_wait_client(_EGLDriver *drv, _EGLDisplay *disp, _EGLContext *ctx)
 {
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
@@ -2044,6 +2051,7 @@ _eglBuiltInDriverDRI2(const char *args)
dri2_drv->base.API.BindTexImage = dri2_bind_tex_image;
dri2_drv->base.API.ReleaseTexImage = dri2_release_tex_image;
dri2_drv->base.API.SwapInterval = dri2_swap_interval;
+   dri2_drv->base.API.SwapBuffers = dri2_swap_buffers;
dri2_drv->base.API.CreateImageKHR = dri2_create_image_khr;
dri2_drv->base.API.DestroyImageKHR = dri2_destroy_image_khr;
 #ifdef HAVE_DRM_PLATFORM
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index a521c7e..6c86c40 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -91,6 +91,9 @@ struct dri2_egl_display_vtbl {
EGLBoolean
(*swap_interval)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
 EGLint interval);
+
+   EGLBoolean
+   (*swap_buffers)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf);
 };
 
 struct dri2_egl_display
diff --git a/src/egl/drivers/dri2/platform_android.c 
b/src/egl/drivers/dri2/platform_android.c
index b03cca3..7b4e0dc 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -435,7 +435,6 @@ droid_init_driver_functions(_EGLDriver *drv)
drv->API.CreatePixmapSurface = droid_create_pixmap_surface;
drv->API.CreatePbufferSurface = droid_create_pbuffer_surface;
drv->API.DestroySurface = droid_destroy_surface;
-   drv->API.SwapBuffers = droid_swap_buffers;
 
drv->API.CreateImageKHR = droid_create_image_khr;
 }
@@ -656,6 +655,7 @@ droid_log(EGLint level, const char *msg)
 static struct dri2_egl_display_vtbl droid_display_vtbl = {
.authenticate = NULL,
.swap_interval = dri2_fallback_swap_interval,
+   .swap_buffers = droid_swap_buffers,
 };
 
 EGLBoolean
diff --git a/src/egl/drivers/dri2/platform_drm.c 
b/src/egl/drivers/dri2/platform_drm.c
index 8544bf5..e39cb79 100644
--- a/src/egl/drivers/dri2/platform_drm.c
+++ b/src/egl/drivers/dri2/platform_drm.c
@@ -444,6 +444,7 @@ dri2_drm_authenticate(_EGLDisplay *disp, uint32_t id)
 static struct dri2_egl_display_vtbl dri2_drm_display_vtbl = {
.authenticate = dri2_drm_authenticate,
.swap_interval = dri2_fallback_swap_interval,
+   .swap_buffers = dri2_drm_swap_buffers,
 };
 
 EGLBoolean
@@ -540,7 +541,6 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)
 
drv->API.CreateWindowSurface = dri2_drm_create_window_surface;
drv->API.DestroySurface = dri2_drm_destroy_surface;
-   drv->API.SwapBuffers = dri2_drm_swap_buffers;
drv->API.CreateImageKHR = dri2_drm_create_image_khr;
drv->API.QueryBufferAge = dri2_drm_query_buffer_age;
 
diff --git a/src/egl/drivers/dri2/platform_wayland.c 
b/src/egl/drivers/dri2/platform_wayland.c
index e5f9c9a..f62b77b 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -959,6 +959,7 @@ dri2_wl_setup_swap_interval(struct dri2_egl_display 
*dri2_dpy)
 static struct dri2_egl_display_vtbl dri2_wl_display_vtbl = {
.authenticate = dri2_wl_authenticate,
.swap_interval = dri2_wl_swap_interval,
+   .swap_buffers = dri2_wl_swap_buffers,
 };
 
 EGLBoolean
@@ -977,7 +978,6 @@ dri2_initialize_wayland(_EGLDriver *drv, _EGLDisplay *disp)
 
drv->API.CreateWindowSurface = dri2_wl_create_window_surface;
drv->API.DestroySurface = dri2_wl_destroy_surface;
-   drv->API.SwapBuffers = dri2_wl_swap_buffers;
drv->API.SwapBuffersWithDamageEXT = dri2_wl_swap_buffers_with_damage;
drv->API.Terminate = dri2_wl_terminate;
drv->API.QueryBufferAge = dri2_wl_query_buffer_age;
diff --git a/src/egl/drivers/dri2/platform_x11.c 
b/src/egl/drivers/dri2/platform_x11.c
index 9bc2afb..38e8669 100644
--- a/src/egl/drivers/dri2/platform_x11.c
+++ b/src/egl/drivers/dri2/platform_x11.c
@@ -995,11 +995,13 @@

[Mesa-dev] [PATCH 11/25] egl/dri2: Dispatch eglDestroySurface by display, not driver

2014-02-09 Thread Chad Versace
Add dri2_egl_display_vtbl::destroy_surface, set it for each
platform, and let egl_dri2 dispatch eglDestroySurface to that.

This prepares for the EGL platform extensions.

Signed-off-by: Chad Versace 
---
 src/egl/drivers/dri2/egl_dri2.c | 8 
 src/egl/drivers/dri2/egl_dri2.h | 3 +++
 src/egl/drivers/dri2/platform_android.c | 3 +--
 src/egl/drivers/dri2/platform_drm.c | 2 +-
 src/egl/drivers/dri2/platform_wayland.c | 2 +-
 src/egl/drivers/dri2/platform_x11.c | 4 ++--
 6 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 906b959..3526aa7 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1041,6 +1041,13 @@ dri2_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay 
*dpy,
 }
 
 static EGLBoolean
+dri2_destroy_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf)
+{
+   struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy);
+   return dri2_dpy->vtbl->destroy_surface(drv, dpy, surf);
+}
+
+static EGLBoolean
 dri2_swap_interval(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
EGLint interval)
 {
@@ -2086,6 +2093,7 @@ _eglBuiltInDriverDRI2(const char *args)
dri2_drv->base.API.CreateWindowSurface = dri2_create_window_surface;
dri2_drv->base.API.CreatePixmapSurface = dri2_create_pixmap_surface;
dri2_drv->base.API.CreatePbufferSurface = dri2_create_pbuffer_surface;
+   dri2_drv->base.API.DestroySurface = dri2_destroy_surface;
dri2_drv->base.API.GetProcAddress = dri2_get_proc_address;
dri2_drv->base.API.WaitClient = dri2_wait_client;
dri2_drv->base.API.WaitNative = dri2_wait_native;
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index ebab005..fe779df 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -103,6 +103,9 @@ struct dri2_egl_display_vtbl {
  _EGLConfig *config, const EGLint *attrib_list);
 
EGLBoolean
+   (*destroy_surface)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface);
+
+   EGLBoolean
(*swap_interval)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
 EGLint interval);
 
diff --git a/src/egl/drivers/dri2/platform_android.c 
b/src/egl/drivers/dri2/platform_android.c
index 7efc91a..eb5706c 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -423,8 +423,6 @@ droid_create_image_khr(_EGLDriver *drv, _EGLDisplay *disp,
 static void
 droid_init_driver_functions(_EGLDriver *drv)
 {
-   drv->API.DestroySurface = droid_destroy_surface;
-
drv->API.CreateImageKHR = droid_create_image_khr;
 }
 
@@ -646,6 +644,7 @@ static struct dri2_egl_display_vtbl droid_display_vtbl = {
.create_window_surface = droid_create_window_surface,
.create_pixmap_surface = dri2_fallback_pixmap_surface,
.create_pbuffer_surface = droid_create_pbuffer_surface,
+   .destroy_surface = droid_destroy_surface,
.swap_interval = dri2_fallback_swap_interval,
.swap_buffers = droid_swap_buffers,
.swap_buffers_with_damage = dri2_fallback_swap_buffers_with_damage,
diff --git a/src/egl/drivers/dri2/platform_drm.c 
b/src/egl/drivers/dri2/platform_drm.c
index 2fb20ff..b380c42 100644
--- a/src/egl/drivers/dri2/platform_drm.c
+++ b/src/egl/drivers/dri2/platform_drm.c
@@ -446,6 +446,7 @@ static struct dri2_egl_display_vtbl dri2_drm_display_vtbl = 
{
.create_window_surface = dri2_drm_create_window_surface,
.create_pixmap_surface = dri2_fallback_create_pixmap_surface,
.create_pbuffer_surface = dri2_fallback_create_pbuffer_surface,
+   .destroy_surface = dri2_drm_destroy_surface,
.swap_interval = dri2_fallback_swap_interval,
.swap_buffers = dri2_drm_swap_buffers,
.swap_buffers_with_damage = dri2_fallback_swap_buffers_with_damage,
@@ -543,7 +544,6 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)
   i + 1, EGL_WINDOW_BIT, attr_list, NULL);
}
 
-   drv->API.DestroySurface = dri2_drm_destroy_surface;
drv->API.CreateImageKHR = dri2_drm_create_image_khr;
drv->API.QueryBufferAge = dri2_drm_query_buffer_age;
 
diff --git a/src/egl/drivers/dri2/platform_wayland.c 
b/src/egl/drivers/dri2/platform_wayland.c
index c0ba345..e23c117 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -961,6 +961,7 @@ static struct dri2_egl_display_vtbl dri2_wl_display_vtbl = {
.create_window_surface = dri2_wl_create_window_surface,
.create_pixmap_surface = dri2_fallback_create_pixmap_surface,
.create_pbuffer_surface = dri2_fallback_create_pbuffer_surface,
+   .destroy_surface = dri2_wl_destroy_surface,
.swap_interval = dri2_wl_swap_interval,
.swap_buffers = dri2_wl_swap_buffers,
.swap_buffers_with_damage = dri2_wl_swap_buffers_with_damage,
@@ -980,7 +981,6 @@ dri2_initialize_wayland(_EGLDriver *drv, _EGLDisplay *disp)
 
loader_set_logger

[Mesa-dev] [PATCH 25/25] egl/main: Enable Linux platform extensions

2014-02-09 Thread Chad Versace
Enable EGL_EXT_platform_base and the Linux platform extensions layered
atop it: EGL_EXT_platform_x11, EGL_EXT_platform_wayland,
and EGL_MESA_platform_gbm.

Tested with Piglit's EGL_EXT_platform_base tests under an X11 session.
To enable running the Wayland and GBM tests, windowed Weston was running
and the kernel had render nodes enabled.

Also tested by running weston-smoke in stand-alone Weston.

Signed-off-by: Chad Versace 
---
 src/egl/main/eglapi.c | 132 ++
 src/egl/main/egldisplay.c |  72 +
 src/egl/main/egldisplay.h |  20 +++
 src/egl/main/eglglobals.c |  10 +++-
 src/egl/main/eglglobals.h |   4 ++
 5 files changed, 215 insertions(+), 23 deletions(-)

diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index 8a64f8a..d40fe1b 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -308,6 +308,36 @@ eglGetDisplay(EGLNativeDisplayType nativeDisplay)
return _eglGetDisplayHandle(dpy);
 }
 
+EGLDisplay EGLAPIENTRY
+eglGetPlatformDisplayEXT(EGLenum platform, void *native_display,
+ const EGLint *attrib_list)
+{
+   _EGLDisplay *dpy;
+
+   switch (platform) {
+#ifdef HAVE_X11_PLATFORM
+   case EGL_PLATFORM_X11_EXT:
+  dpy = _eglGetX11Display((Display*) native_display, attrib_list);
+  break;
+#endif
+#ifdef HAVE_DRM_PLATFORM
+   case EGL_PLATFORM_GBM_MESA:
+  dpy = _eglGetGbmDisplay((struct gbm_device*) native_display,
+  attrib_list);
+  break;
+#endif
+#ifdef HAVE_WAYLAND_PLATFORM
+   case EGL_PLATFORM_WAYLAND_EXT:
+  dpy = _eglGetWaylandDisplay((struct wl_display*) native_display,
+  attrib_list);
+  break;
+#endif
+   default:
+  RETURN_EGL_ERROR(NULL, EGL_BAD_PARAMETER, NULL);
+   }
+
+   return _eglGetDisplayHandle(dpy);
+}
 
 /**
  * This is typically the second EGL function that an application calls.
@@ -530,25 +560,17 @@ eglQueryContext(EGLDisplay dpy, EGLContext ctx,
 }
 
 
-EGLSurface EGLAPIENTRY
-eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config,
-   EGLNativeWindowType window, const EGLint *attrib_list)
+static EGLSurface
+_eglCreateWindowSurfaceCommon(_EGLDisplay *disp, EGLConfig config,
+  void *native_window, const EGLint *attrib_list)
 {
-   _EGLDisplay *disp = _eglLockDisplay(dpy);
_EGLConfig *conf = _eglLookupConfig(config, disp);
_EGLDriver *drv;
_EGLSurface *surf;
EGLSurface ret;
-   void *native_window_ptr;
-
-   STATIC_ASSERT(sizeof(void*) == sizeof(window));
-   native_window_ptr = (void*) window;
 
_EGL_CHECK_CONFIG(disp, conf, EGL_NO_SURFACE, drv);
-   if (disp->Platform != _eglGetNativePlatform(disp->PlatformDisplay))
-  RETURN_EGL_ERROR(disp, EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE);
-
-   surf = drv->API.CreateWindowSurface(drv, disp, conf, native_window_ptr,
+   surf = drv->API.CreateWindowSurface(drv, disp, conf, native_window,
attrib_list);
ret = (surf) ? _eglLinkSurface(surf) : EGL_NO_SURFACE;
 
@@ -557,24 +579,52 @@ eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config,
 
 
 EGLSurface EGLAPIENTRY
-eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config,
-   EGLNativePixmapType pixmap, const EGLint *attrib_list)
+eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config,
+   EGLNativeWindowType window, const EGLint *attrib_list)
 {
_EGLDisplay *disp = _eglLockDisplay(dpy);
+   STATIC_ASSERT(sizeof(void*) == sizeof(window));
+   return _eglCreateWindowSurfaceCommon(disp, config, (void*) window,
+attrib_list);
+}
+
+
+EGLSurface EGLAPIENTRY
+eglCreatePlatformWindowSurfaceEXT(EGLDisplay dpy, EGLConfig config,
+  void *native_window,
+  const EGLint *attrib_list)
+{
+   _EGLDisplay *disp = _eglLockDisplay(dpy);
+
+#ifdef HAVE_X11_PLATFORM
+   if (disp->Platform == _EGL_PLATFORM_X11 && native_window != NULL) {
+  /* The `native_window` parameter for the X11 platform differs between
+   * eglCreateWindowSurface() and eglCreatePlatformPixmapSurfaceEXT(). In
+   * eglCreateWindowSurface(), the type of `native_window` is an Xlib
+   * `Window`. In eglCreatePlatformWindowSurfaceEXT(), the type is
+   * `Window*`.  Convert `Window*` to `Window` because that's what
+   * dri2_x11_create_window_surface() expects.
+   */
+  native_window = (void*) (* (Window*) native_window);
+   }
+#endif
+
+   return _eglCreateWindowSurfaceCommon(disp, config, native_window,
+attrib_list);
+}
+
+
+static EGLSurface
+_eglCreatePixmapSurfaceCommon(_EGLDisplay *disp, EGLConfig config,
+  void *native_pixmap, const EGLint *attrib_list)
+{
_EGLConfig *conf = _eglLookupConfig(config, disp);
_EGLDriver *drv;
_EGLSurface *surf;

[Mesa-dev] [PATCH 22/25] egl/main: Stop using EGLNative types internally

2014-02-09 Thread Chad Versace
Internally, much of the EGL code uses EGLNativeDisplayType,
EGLNativeWindowType, and EGLPixmapType. However, the EGLNative type
often does not match the variable's actual type.

The concept of EGLNative types are a bad match for Linux, as explained
below. And the EGL platform extensions don't use EGLNative types at all.
Those extensions attempt to solve cross-platform issues by moving the
EGL API away from the EGLNative types.

The core of the problem is that eglplatform.h can define each EGLNative
type once only, but Linux supports multiple EGL platforms.

To work around the problem, Mesa's eglplatform.h contains multiple
definitions of each EGLNative type, selected by feature macros. Mesa
expects EGL clients to set the feature macro approrpiately. But the
feature macros don't work when a single codebase must be built with
support for multiple EGL platforms, *such as Mesa itself*.

When building libEGL, autotools chooses the EGLNative typedefs based on
the first element of '--with-egl-platforms'. For example,
'--with-egl-platforms=x11,drm,wayland' defines the following:

typedef Display* EGLNativeDisplayType;
typedef Window   EGLNativeWindowType;
typedef Pixmap   EGLNativePixmapType;

Clearly, this doesn't work well for Wayland and GBM.  Mesa works around
the problem by casting the EGLNative types to different things in
different files.

For sanity's sake, and to prepare for the EGL platform extensions, this
patch removes from egl/main and egl/dri2 all internal use of the
EGLNative types. It replaces them with 'void*' and checks each explicit
cast with a static assertion. Also, the patch touches egl_gallium the
minimal amount to keep it compatible with eglapi.h.

Signed-off-by: Chad Versace 
---
 src/egl/drivers/dri2/egl_dri2.c| 12 -
 src/egl/drivers/dri2/egl_dri2.h|  6 ++---
 src/egl/drivers/dri2/egl_dri2_fallbacks.h  |  4 +--
 src/egl/drivers/dri2/platform_android.c| 10 ---
 src/egl/drivers/dri2/platform_drm.c|  9 ---
 src/egl/drivers/dri2/platform_wayland.c|  9 ---
 src/egl/drivers/dri2/platform_x11.c| 24 ++---
 src/egl/main/eglapi.c  | 31 ++
 src/egl/main/eglapi.h  |  6 ++---
 src/egl/main/egldisplay.c  |  4 +--
 src/egl/main/egldisplay.h  |  2 +-
 .../state_trackers/egl/common/egl_g3d_api.c| 18 ++---
 12 files changed, 89 insertions(+), 46 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index fcf4acf..12b0dc2 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1025,21 +1025,21 @@ dri2_get_proc_address(_EGLDriver *drv, const char 
*procname)
 
 static _EGLSurface*
 dri2_create_window_surface(_EGLDriver *drv, _EGLDisplay *dpy,
-   _EGLConfig *conf, EGLNativeWindowType window,
+   _EGLConfig *conf, void *native_window,
const EGLint *attrib_list)
 {
struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy);
-   return dri2_dpy->vtbl->create_window_surface(drv, dpy, conf, window,
+   return dri2_dpy->vtbl->create_window_surface(drv, dpy, conf, native_window,
 attrib_list);
 }
 
 static _EGLSurface*
 dri2_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *dpy,
-   _EGLConfig *conf, EGLNativePixmapType pixmap,
+   _EGLConfig *conf, void *native_pixmap,
const EGLint *attrib_list)
 {
struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy);
-   return dri2_dpy->vtbl->create_pixmap_surface(drv, dpy, conf, pixmap,
+   return dri2_dpy->vtbl->create_pixmap_surface(drv, dpy, conf, native_pixmap,
 attrib_list);
 }
 
@@ -1101,10 +1101,10 @@ dri2_post_sub_buffer(_EGLDriver *drv, _EGLDisplay *dpy, 
_EGLSurface *surf,
 
 static EGLBoolean
 dri2_copy_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
-  EGLNativePixmapType target)
+  void *native_pixmap_target)
 {
struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy);
-   return dri2_dpy->vtbl->copy_buffers(drv, dpy, surf, target);
+   return dri2_dpy->vtbl->copy_buffers(drv, dpy, surf, native_pixmap_target);
 }
 
 static EGLint
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index 35115bc..aaa20e0 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -92,12 +92,12 @@ struct dri2_egl_display_vtbl {
 
_EGLSurface*
(*create_window_surface)(_EGLDriver *drv, _EGLDisplay *dpy,
-_EGLConfig *config, EGLNativeWindowType window,
+_EGLConfig *config, void *native_window,

[Mesa-dev] [PATCH 13/25] egl/dri2: Dispatch eglCopyBuffers by display, not driver

2014-02-09 Thread Chad Versace
Add dri2_egl_display_vtbl::copy_buffers, set it for each
platform, and let egl_dri2 dispatch eglCopyBuffers to that.

This prepares for the EGL platform extensions.

Signed-off-by: Chad Versace 
---
 src/egl/drivers/dri2/egl_dri2.c   | 9 +
 src/egl/drivers/dri2/egl_dri2.h   | 5 +
 src/egl/drivers/dri2/egl_dri2_fallbacks.h | 8 
 src/egl/drivers/dri2/platform_android.c   | 1 +
 src/egl/drivers/dri2/platform_drm.c   | 1 +
 src/egl/drivers/dri2/platform_wayland.c   | 1 +
 src/egl/drivers/dri2/platform_x11.c   | 5 ++---
 7 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index f6fd94b..1874db3 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1072,6 +1072,14 @@ dri2_swap_buffers_with_damage(_EGLDriver *drv, 
_EGLDisplay *dpy,
rects, n_rects);
 }
 
+static EGLBoolean
+dri2_copy_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
+  EGLNativePixmapType target)
+{
+   struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy);
+   return dri2_dpy->vtbl->copy_buffers(drv, dpy, surf, target);
+}
+
 static EGLint
 dri2_query_buffer_age(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf)
 {
@@ -2109,6 +2117,7 @@ _eglBuiltInDriverDRI2(const char *args)
dri2_drv->base.API.SwapInterval = dri2_swap_interval;
dri2_drv->base.API.SwapBuffers = dri2_swap_buffers;
dri2_drv->base.API.SwapBuffersWithDamageEXT = dri2_swap_buffers_with_damage;
+   dri2_drv->base.API.CopyBuffers = dri2_copy_buffers,
dri2_drv->base.API.QueryBufferAge = dri2_query_buffer_age;
dri2_drv->base.API.CreateImageKHR = dri2_create_image_khr;
dri2_drv->base.API.DestroyImageKHR = dri2_destroy_image_khr;
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index 2adb862..3140b29 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -116,6 +116,11 @@ struct dri2_egl_display_vtbl {
(*swap_buffers_with_damage)(_EGLDriver *drv, _EGLDisplay *dpy,
_EGLSurface *surface,
const EGLint *rects, EGLint n_rects);
+
+   EGLBoolean
+   (*copy_buffers)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
+   EGLNativePixmapType target);
+
EGLint
(*query_buffer_age)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf);
 };
diff --git a/src/egl/drivers/dri2/egl_dri2_fallbacks.h 
b/src/egl/drivers/dri2/egl_dri2_fallbacks.h
index f903998..f9f1a55 100644
--- a/src/egl/drivers/dri2/egl_dri2_fallbacks.h
+++ b/src/egl/drivers/dri2/egl_dri2_fallbacks.h
@@ -58,6 +58,14 @@ dri2_fallback_swap_buffers_with_damage(_EGLDriver *drv, 
_EGLDisplay *dpy,
return EGL_FALSE;
 }
 
+static inline EGLBoolean
+dri2_fallback_copy_buffers(_EGLDriver *drv, _EGLDisplay *dpy,
+   _EGLSurface *surf,
+   EGLNativePixmapType target)
+{
+   return EGL_FALSE;
+}
+
 static inline EGLint
 dri2_fallback_query_buffer_age(_EGLDriver *drv, _EGLDisplay *dpy,
_EGLSurface *surf)
diff --git a/src/egl/drivers/dri2/platform_android.c 
b/src/egl/drivers/dri2/platform_android.c
index d60e54e..8b8cd11 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -648,6 +648,7 @@ static struct dri2_egl_display_vtbl droid_display_vtbl = {
.swap_interval = dri2_fallback_swap_interval,
.swap_buffers = droid_swap_buffers,
.swap_buffers_with_damage = dri2_fallback_swap_buffers_with_damage,
+   .copy_buffers = dri2_fallback_copy_buffers,
.query_buffer_age = dri2_fallback_query_buffer_age,
 };
 
diff --git a/src/egl/drivers/dri2/platform_drm.c 
b/src/egl/drivers/dri2/platform_drm.c
index 45c856b..5f52332 100644
--- a/src/egl/drivers/dri2/platform_drm.c
+++ b/src/egl/drivers/dri2/platform_drm.c
@@ -450,6 +450,7 @@ static struct dri2_egl_display_vtbl dri2_drm_display_vtbl = 
{
.swap_interval = dri2_fallback_swap_interval,
.swap_buffers = dri2_drm_swap_buffers,
.swap_buffers_with_damage = dri2_fallback_swap_buffers_with_damage,
+   .copy_buffers = dri2_fallback_copy_buffers,
.query_buffer_age = dri2_drm_query_buffer_age,
 };
 
diff --git a/src/egl/drivers/dri2/platform_wayland.c 
b/src/egl/drivers/dri2/platform_wayland.c
index c2b39d6..0a7e628 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -965,6 +965,7 @@ static struct dri2_egl_display_vtbl dri2_wl_display_vtbl = {
.swap_interval = dri2_wl_swap_interval,
.swap_buffers = dri2_wl_swap_buffers,
.swap_buffers_with_damage = dri2_wl_swap_buffers_with_damage,
+   .copy_buffers = dri2_fallback_copy_buffers,
.query_buffer_age = dri2_wl_query_buffer_age,
 };
 
diff --git a/src/egl/drivers/dri2/platform_x11.c 
b/src/egl/drivers/dri2/platform_x11.c
index 2427d6a..200d8

[Mesa-dev] [PATCH 12/25] egl/dri2: Dispatch API.QueryBufferAge by display, not driver

2014-02-09 Thread Chad Versace
Add dri2_egl_display_vtbl::query_buffer_age, set it for each
platform, and let egl_dri2 dispatch API.QueryBufferAge to that.

This prepares for the EGL platform extensions.

Signed-off-by: Chad Versace 
---
 src/egl/drivers/dri2/egl_dri2.c   | 8 
 src/egl/drivers/dri2/egl_dri2.h   | 2 ++
 src/egl/drivers/dri2/egl_dri2_fallbacks.h | 7 +++
 src/egl/drivers/dri2/platform_android.c   | 1 +
 src/egl/drivers/dri2/platform_drm.c   | 2 +-
 src/egl/drivers/dri2/platform_wayland.c   | 2 +-
 src/egl/drivers/dri2/platform_x11.c   | 2 ++
 7 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 3526aa7..f6fd94b 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1072,6 +1072,13 @@ dri2_swap_buffers_with_damage(_EGLDriver *drv, 
_EGLDisplay *dpy,
rects, n_rects);
 }
 
+static EGLint
+dri2_query_buffer_age(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf)
+{
+   struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy);
+   return dri2_dpy->vtbl->query_buffer_age(drv, dpy, surf);
+}
+
 static EGLBoolean
 dri2_wait_client(_EGLDriver *drv, _EGLDisplay *disp, _EGLContext *ctx)
 {
@@ -2102,6 +2109,7 @@ _eglBuiltInDriverDRI2(const char *args)
dri2_drv->base.API.SwapInterval = dri2_swap_interval;
dri2_drv->base.API.SwapBuffers = dri2_swap_buffers;
dri2_drv->base.API.SwapBuffersWithDamageEXT = dri2_swap_buffers_with_damage;
+   dri2_drv->base.API.QueryBufferAge = dri2_query_buffer_age;
dri2_drv->base.API.CreateImageKHR = dri2_create_image_khr;
dri2_drv->base.API.DestroyImageKHR = dri2_destroy_image_khr;
 #ifdef HAVE_DRM_PLATFORM
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index fe779df..2adb862 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -116,6 +116,8 @@ struct dri2_egl_display_vtbl {
(*swap_buffers_with_damage)(_EGLDriver *drv, _EGLDisplay *dpy,
_EGLSurface *surface,
const EGLint *rects, EGLint n_rects);
+   EGLint
+   (*query_buffer_age)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf);
 };
 
 struct dri2_egl_display
diff --git a/src/egl/drivers/dri2/egl_dri2_fallbacks.h 
b/src/egl/drivers/dri2/egl_dri2_fallbacks.h
index a416157..f903998 100644
--- a/src/egl/drivers/dri2/egl_dri2_fallbacks.h
+++ b/src/egl/drivers/dri2/egl_dri2_fallbacks.h
@@ -57,3 +57,10 @@ dri2_fallback_swap_buffers_with_damage(_EGLDriver *drv, 
_EGLDisplay *dpy,
 {
return EGL_FALSE;
 }
+
+static inline EGLint
+dri2_fallback_query_buffer_age(_EGLDriver *drv, _EGLDisplay *dpy,
+   _EGLSurface *surf)
+{
+   return 0;
+}
diff --git a/src/egl/drivers/dri2/platform_android.c 
b/src/egl/drivers/dri2/platform_android.c
index eb5706c..d60e54e 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -648,6 +648,7 @@ static struct dri2_egl_display_vtbl droid_display_vtbl = {
.swap_interval = dri2_fallback_swap_interval,
.swap_buffers = droid_swap_buffers,
.swap_buffers_with_damage = dri2_fallback_swap_buffers_with_damage,
+   .query_buffer_age = dri2_fallback_query_buffer_age,
 };
 
 EGLBoolean
diff --git a/src/egl/drivers/dri2/platform_drm.c 
b/src/egl/drivers/dri2/platform_drm.c
index b380c42..45c856b 100644
--- a/src/egl/drivers/dri2/platform_drm.c
+++ b/src/egl/drivers/dri2/platform_drm.c
@@ -450,6 +450,7 @@ static struct dri2_egl_display_vtbl dri2_drm_display_vtbl = 
{
.swap_interval = dri2_fallback_swap_interval,
.swap_buffers = dri2_drm_swap_buffers,
.swap_buffers_with_damage = dri2_fallback_swap_buffers_with_damage,
+   .query_buffer_age = dri2_drm_query_buffer_age,
 };
 
 EGLBoolean
@@ -545,7 +546,6 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)
}
 
drv->API.CreateImageKHR = dri2_drm_create_image_khr;
-   drv->API.QueryBufferAge = dri2_drm_query_buffer_age;
 
disp->Extensions.EXT_buffer_age = EGL_TRUE;
 
diff --git a/src/egl/drivers/dri2/platform_wayland.c 
b/src/egl/drivers/dri2/platform_wayland.c
index e23c117..c2b39d6 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -965,6 +965,7 @@ static struct dri2_egl_display_vtbl dri2_wl_display_vtbl = {
.swap_interval = dri2_wl_swap_interval,
.swap_buffers = dri2_wl_swap_buffers,
.swap_buffers_with_damage = dri2_wl_swap_buffers_with_damage,
+   .query_buffer_age = dri2_wl_query_buffer_age,
 };
 
 EGLBoolean
@@ -982,7 +983,6 @@ dri2_initialize_wayland(_EGLDriver *drv, _EGLDisplay *disp)
loader_set_logger(_eglLog);
 
drv->API.Terminate = dri2_wl_terminate;
-   drv->API.QueryBufferAge = dri2_wl_query_buffer_age;
 
drv->API.CreateWaylandBufferFromImageWL =
   dri2_wl_create_wayland_buffer_from_image_wl;
diff --git a/src/egl/drivers/dri2/platform_x11.

[Mesa-dev] [PATCH 15/25] egl/dri2: Dispatch eglPostSubBufferNV by display, not driver

2014-02-09 Thread Chad Versace
Add dri2_egl_display_vtbl::post_sub_buffer, set it for each
platform, and let egl_dri2 dispatch eglPostSubBufferNV to that.

This prepares for the EGL platform extensions.

Signed-off-by: Chad Versace 
---
 src/egl/drivers/dri2/egl_dri2.c   | 9 +
 src/egl/drivers/dri2/egl_dri2.h   | 4 
 src/egl/drivers/dri2/egl_dri2_fallbacks.h | 8 
 src/egl/drivers/dri2/platform_android.c   | 1 +
 src/egl/drivers/dri2/platform_drm.c   | 1 +
 src/egl/drivers/dri2/platform_wayland.c   | 1 +
 src/egl/drivers/dri2/platform_x11.c   | 3 ++-
 7 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 2a2525e..a3abe83 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1081,6 +1081,14 @@ dri2_swap_buffers_region(_EGLDriver *drv, _EGLDisplay 
*dpy, _EGLSurface *surf,
 }
 
 static EGLBoolean
+dri2_post_sub_buffer(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
+ EGLint x, EGLint y, EGLint width, EGLint height)
+{
+   struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy);
+   return dri2_dpy->vtbl->post_sub_buffer(drv, dpy, surf, x, y, width, height);
+}
+
+static EGLBoolean
 dri2_copy_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
   EGLNativePixmapType target)
 {
@@ -2126,6 +2134,7 @@ _eglBuiltInDriverDRI2(const char *args)
dri2_drv->base.API.SwapBuffers = dri2_swap_buffers;
dri2_drv->base.API.SwapBuffersWithDamageEXT = dri2_swap_buffers_with_damage;
dri2_drv->base.API.SwapBuffersRegionNOK = dri2_swap_buffers_region;
+   dri2_drv->base.API.PostSubBufferNV = dri2_post_sub_buffer;
dri2_drv->base.API.CopyBuffers = dri2_copy_buffers,
dri2_drv->base.API.QueryBufferAge = dri2_query_buffer_age;
dri2_drv->base.API.CreateImageKHR = dri2_create_image_khr;
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index e7ac7a0..250d209 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -122,6 +122,10 @@ struct dri2_egl_display_vtbl {
   EGLint numRects, const EGLint *rects);
 
EGLBoolean
+   (*post_sub_buffer)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
+  EGLint x, EGLint y, EGLint width, EGLint height);
+
+   EGLBoolean
(*copy_buffers)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
EGLNativePixmapType target);
 
diff --git a/src/egl/drivers/dri2/egl_dri2_fallbacks.h 
b/src/egl/drivers/dri2/egl_dri2_fallbacks.h
index b5eb5b7..00e955a 100644
--- a/src/egl/drivers/dri2/egl_dri2_fallbacks.h
+++ b/src/egl/drivers/dri2/egl_dri2_fallbacks.h
@@ -67,6 +67,14 @@ dri2_fallback_swap_buffers_region(_EGLDriver *drv, 
_EGLDisplay *dpy,
 }
 
 static inline EGLBoolean
+dri2_fallback_post_sub_buffer(_EGLDriver *drv, _EGLDisplay *dpy,
+  _EGLSurface *draw,
+  EGLint x, EGLint y, EGLint width, EGLint height)
+{
+   return EGL_FALSE;
+}
+
+static inline EGLBoolean
 dri2_fallback_copy_buffers(_EGLDriver *drv, _EGLDisplay *dpy,
_EGLSurface *surf,
EGLNativePixmapType target)
diff --git a/src/egl/drivers/dri2/platform_android.c 
b/src/egl/drivers/dri2/platform_android.c
index dc6e2df..eddf33c 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -649,6 +649,7 @@ static struct dri2_egl_display_vtbl droid_display_vtbl = {
.swap_buffers = droid_swap_buffers,
.swap_buffers_with_damage = dri2_fallback_swap_buffers_with_damage,
.swap_buffers_region = dri2_fallback_swap_buffers_region,
+   .post_sub_buffer = dri2_fallback_post_sub_buffer,
.copy_buffers = dri2_fallback_copy_buffers,
.query_buffer_age = dri2_fallback_query_buffer_age,
 };
diff --git a/src/egl/drivers/dri2/platform_drm.c 
b/src/egl/drivers/dri2/platform_drm.c
index e078ddf..18eca19 100644
--- a/src/egl/drivers/dri2/platform_drm.c
+++ b/src/egl/drivers/dri2/platform_drm.c
@@ -451,6 +451,7 @@ static struct dri2_egl_display_vtbl dri2_drm_display_vtbl = 
{
.swap_buffers = dri2_drm_swap_buffers,
.swap_buffers_with_damage = dri2_fallback_swap_buffers_with_damage,
.swap_buffers_region = dri2_fallback_swap_buffers_region,
+   .post_sub_buffer = dri2_fallback_post_sub_buffer,
.copy_buffers = dri2_fallback_copy_buffers,
.query_buffer_age = dri2_drm_query_buffer_age,
 };
diff --git a/src/egl/drivers/dri2/platform_wayland.c 
b/src/egl/drivers/dri2/platform_wayland.c
index 0bec563..ebd104f 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -966,6 +966,7 @@ static struct dri2_egl_display_vtbl dri2_wl_display_vtbl = {
.swap_buffers = dri2_wl_swap_buffers,
.swap_buffers_with_damage = dri2_wl_swap_buffers_with_damage,
.swap_buffers_region = dri2_fallback_swap_buffers_region,
+   .post_sub

[Mesa-dev] [PATCH 14/25] egl/dri2: Dispatch eglSwapBuffersRegionNOK by display, not driver

2014-02-09 Thread Chad Versace
Add dri2_egl_display_vtbl::swap_buffers_region, set it for each
platform, and let egl_dri2 dispatch eglSwapBuffersRegionNOK to that.

This prepares for the EGL platform extensions.

Signed-off-by: Chad Versace 
---
 src/egl/drivers/dri2/egl_dri2.c   | 9 +
 src/egl/drivers/dri2/egl_dri2.h   | 4 
 src/egl/drivers/dri2/egl_dri2_fallbacks.h | 8 
 src/egl/drivers/dri2/platform_android.c   | 1 +
 src/egl/drivers/dri2/platform_drm.c   | 1 +
 src/egl/drivers/dri2/platform_wayland.c   | 1 +
 src/egl/drivers/dri2/platform_x11.c   | 4 ++--
 7 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 1874db3..2a2525e 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1073,6 +1073,14 @@ dri2_swap_buffers_with_damage(_EGLDriver *drv, 
_EGLDisplay *dpy,
 }
 
 static EGLBoolean
+dri2_swap_buffers_region(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
+ EGLint numRects, const EGLint *rects)
+{
+   struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy);
+   return dri2_dpy->vtbl->swap_buffers_region(drv, dpy, surf, numRects, rects);
+}
+
+static EGLBoolean
 dri2_copy_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
   EGLNativePixmapType target)
 {
@@ -2117,6 +2125,7 @@ _eglBuiltInDriverDRI2(const char *args)
dri2_drv->base.API.SwapInterval = dri2_swap_interval;
dri2_drv->base.API.SwapBuffers = dri2_swap_buffers;
dri2_drv->base.API.SwapBuffersWithDamageEXT = dri2_swap_buffers_with_damage;
+   dri2_drv->base.API.SwapBuffersRegionNOK = dri2_swap_buffers_region;
dri2_drv->base.API.CopyBuffers = dri2_copy_buffers,
dri2_drv->base.API.QueryBufferAge = dri2_query_buffer_age;
dri2_drv->base.API.CreateImageKHR = dri2_create_image_khr;
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index 3140b29..e7ac7a0 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -118,6 +118,10 @@ struct dri2_egl_display_vtbl {
const EGLint *rects, EGLint n_rects);
 
EGLBoolean
+   (*swap_buffers_region)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
+  EGLint numRects, const EGLint *rects);
+
+   EGLBoolean
(*copy_buffers)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
EGLNativePixmapType target);
 
diff --git a/src/egl/drivers/dri2/egl_dri2_fallbacks.h 
b/src/egl/drivers/dri2/egl_dri2_fallbacks.h
index f9f1a55..b5eb5b7 100644
--- a/src/egl/drivers/dri2/egl_dri2_fallbacks.h
+++ b/src/egl/drivers/dri2/egl_dri2_fallbacks.h
@@ -59,6 +59,14 @@ dri2_fallback_swap_buffers_with_damage(_EGLDriver *drv, 
_EGLDisplay *dpy,
 }
 
 static inline EGLBoolean
+dri2_fallback_swap_buffers_region(_EGLDriver *drv, _EGLDisplay *dpy,
+  _EGLSurface *surf,
+  EGLint numRects, const EGLint *rects)
+{
+   return EGL_FALSE;
+}
+
+static inline EGLBoolean
 dri2_fallback_copy_buffers(_EGLDriver *drv, _EGLDisplay *dpy,
_EGLSurface *surf,
EGLNativePixmapType target)
diff --git a/src/egl/drivers/dri2/platform_android.c 
b/src/egl/drivers/dri2/platform_android.c
index 8b8cd11..dc6e2df 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -648,6 +648,7 @@ static struct dri2_egl_display_vtbl droid_display_vtbl = {
.swap_interval = dri2_fallback_swap_interval,
.swap_buffers = droid_swap_buffers,
.swap_buffers_with_damage = dri2_fallback_swap_buffers_with_damage,
+   .swap_buffers_region = dri2_fallback_swap_buffers_region,
.copy_buffers = dri2_fallback_copy_buffers,
.query_buffer_age = dri2_fallback_query_buffer_age,
 };
diff --git a/src/egl/drivers/dri2/platform_drm.c 
b/src/egl/drivers/dri2/platform_drm.c
index 5f52332..e078ddf 100644
--- a/src/egl/drivers/dri2/platform_drm.c
+++ b/src/egl/drivers/dri2/platform_drm.c
@@ -450,6 +450,7 @@ static struct dri2_egl_display_vtbl dri2_drm_display_vtbl = 
{
.swap_interval = dri2_fallback_swap_interval,
.swap_buffers = dri2_drm_swap_buffers,
.swap_buffers_with_damage = dri2_fallback_swap_buffers_with_damage,
+   .swap_buffers_region = dri2_fallback_swap_buffers_region,
.copy_buffers = dri2_fallback_copy_buffers,
.query_buffer_age = dri2_drm_query_buffer_age,
 };
diff --git a/src/egl/drivers/dri2/platform_wayland.c 
b/src/egl/drivers/dri2/platform_wayland.c
index 0a7e628..0bec563 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -965,6 +965,7 @@ static struct dri2_egl_display_vtbl dri2_wl_display_vtbl = {
.swap_interval = dri2_wl_swap_interval,
.swap_buffers = dri2_wl_swap_buffers,
.swap_buffers_with_damage = dri2_wl_swap_buffers_with_damage,
+   .swap_buffers_region = dri2_fallback_sw

[Mesa-dev] [PATCH 24/25] egl/wayland: Emit EGL_BAD_PARAMETER for eglCreatePlatformPixmapSurface

2014-02-09 Thread Chad Versace
>From the EGL_EXT_wayland_spec, version 3:

  It is not valid to call eglCreatePlatformPixmapSurfaceEXT with a 
  that belongs to Wayland. Any such call fails and generates
  EGL_BAD_PARAMETER.

Signed-off-by: Chad Versace 
---
 src/egl/drivers/dri2/platform_wayland.c | 18 +-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/src/egl/drivers/dri2/platform_wayland.c 
b/src/egl/drivers/dri2/platform_wayland.c
index 9602d67..123f83a 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -202,6 +202,22 @@ dri2_wl_create_window_surface(_EGLDriver *drv, _EGLDisplay 
*disp,
return surf;
 }
 
+static _EGLSurface *
+dri2_wl_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *disp,
+  _EGLConfig *conf, void *native_window,
+  const EGLint *attrib_list)
+{
+   /* From the EGL_EXT_platform_wayland spec, version 3:
+*
+*   It is not valid to call eglCreatePlatformPixmapSurfaceEXT with a 
+*   that belongs to Wayland. Any such call fails and generates
+*   EGL_BAD_PARAMETER.
+*/
+   _eglError(EGL_BAD_PARAMETER, "cannot create EGL pixmap surfaces on "
+ "Wayland");
+   return NULL;
+}
+
 /**
  * Called via eglDestroySurface(), drv->API.DestroySurface().
  */
@@ -935,7 +951,7 @@ dri2_wl_setup_swap_interval(struct dri2_egl_display 
*dri2_dpy)
 static struct dri2_egl_display_vtbl dri2_wl_display_vtbl = {
.authenticate = dri2_wl_authenticate,
.create_window_surface = dri2_wl_create_window_surface,
-   .create_pixmap_surface = dri2_fallback_create_pixmap_surface,
+   .create_pixmap_surface = dri2_wl_create_pixmap_surface,
.create_pbuffer_surface = dri2_fallback_create_pbuffer_surface,
.destroy_surface = dri2_wl_destroy_surface,
.create_image = dri2_create_image_khr,
-- 
1.8.5.3

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


[Mesa-dev] [PATCH 21/25] egl: Add STATIC_ASSERT() macro

2014-02-09 Thread Chad Versace
Signed-off-by: Chad Versace 
---
 src/egl/main/eglcompiler.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/src/egl/main/eglcompiler.h b/src/egl/main/eglcompiler.h
index 2499172..53dab54 100644
--- a/src/egl/main/eglcompiler.h
+++ b/src/egl/main/eglcompiler.h
@@ -89,4 +89,9 @@
 #  define __FUNCTION__ __func__
 #endif
 
+#define STATIC_ASSERT(COND) \
+   do { \
+  (void) sizeof(char [1 - 2*!(COND)]); \
+   } while (0)
+
 #endif /* EGLCOMPILER_INCLUDED */
-- 
1.8.5.3

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


[Mesa-dev] [PATCH 19/25] egl/dri2/x11: Don't clobber _EGLDriver::API

2014-02-09 Thread Chad Versace
dri2_initialize_x11_swrast() does a strange thing. For some extensions
it doesn't support, it sets the corresponding functions in
_EGLDriver::API to NULL. The intention here is clear, but misplaced.

NULL or not, the function pointers never get called because their
extensions aren't supported.

Signed-off-by: Chad Versace 
---
 src/egl/drivers/dri2/platform_x11.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/src/egl/drivers/dri2/platform_x11.c 
b/src/egl/drivers/dri2/platform_x11.c
index e41758b..3c97a95 100644
--- a/src/egl/drivers/dri2/platform_x11.c
+++ b/src/egl/drivers/dri2/platform_x11.c
@@ -1029,11 +1029,6 @@ dri2_initialize_x11_swrast(_EGLDriver *drv, _EGLDisplay 
*disp)
 {
struct dri2_egl_display *dri2_dpy;
 
-   drv->API.CreateImageKHR  = NULL;
-   drv->API.DestroyImageKHR = NULL;
-   drv->API.CreateDRMImageMESA = NULL;
-   drv->API.ExportDRMImageMESA = NULL;
-
dri2_dpy = calloc(1, sizeof *dri2_dpy);
if (!dri2_dpy)
   return _eglError(EGL_BAD_ALLOC, "eglInitialize");
-- 
1.8.5.3

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


[Mesa-dev] [PATCH 23/25] egl/gbm: Emit EGL_BAD_PARAMETER for eglCreatePlatformPixmapSurface

2014-02-09 Thread Chad Versace
>From the EGL_MESA_platform_gbm spec, version 5:

  It is not valid to call eglCreatePlatformPixmapSurfaceEXT with a 
  that belongs to the GBM platform. Any such call fails and generates
  EGL_BAD_PARAMETER.

Signed-off-by: Chad Versace 
---
 src/egl/drivers/dri2/platform_drm.c | 17 -
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/egl/drivers/dri2/platform_drm.c 
b/src/egl/drivers/dri2/platform_drm.c
index 2e6e725..dc9bc5a 100644
--- a/src/egl/drivers/dri2/platform_drm.c
+++ b/src/egl/drivers/dri2/platform_drm.c
@@ -149,6 +149,21 @@ dri2_drm_create_window_surface(_EGLDriver *drv, 
_EGLDisplay *disp,
   native_window, attrib_list);
 }
 
+static _EGLSurface *
+dri2_drm_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *disp,
+   _EGLConfig *conf, void *native_window,
+   const EGLint *attrib_list)
+{
+   /* From the EGL_MESA_platform_gbm spec, version 5:
+*
+*  It is not valid to call eglCreatePlatformPixmapSurfaceEXT with a 
+*  that belongs to the GBM platform. Any such call fails and generates
+*  EGL_BAD_PARAMETER.
+*/
+   _eglError(EGL_BAD_PARAMETER, "cannot create EGL pixmap surfaces on GBM");
+   return NULL;
+}
+
 static EGLBoolean
 dri2_drm_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf)
 {
@@ -445,7 +460,7 @@ dri2_drm_authenticate(_EGLDisplay *disp, uint32_t id)
 static struct dri2_egl_display_vtbl dri2_drm_display_vtbl = {
.authenticate = dri2_drm_authenticate,
.create_window_surface = dri2_drm_create_window_surface,
-   .create_pixmap_surface = dri2_fallback_create_pixmap_surface,
+   .create_pixmap_surface = dri2_drm_create_pixmap_surface,
.create_pbuffer_surface = dri2_fallback_create_pbuffer_surface,
.destroy_surface = dri2_drm_destroy_surface,
.create_image = dri2_drm_create_image_khr,
-- 
1.8.5.3

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


[Mesa-dev] [PATCH 10/25] egl/dri2: Dispatch eglCreatePbufferSurface by display, not driver

2014-02-09 Thread Chad Versace
Add dri2_egl_display_vtbl::create_pbuffer_surface, set it for each
platform, and let egl_dri2 dispatch eglCreatePbufferSurface to that.

This prepares for the EGL platform extensions.

Signed-off-by: Chad Versace 
---
 src/egl/drivers/dri2/egl_dri2.c   | 9 +
 src/egl/drivers/dri2/egl_dri2.h   | 4 
 src/egl/drivers/dri2/egl_dri2_fallbacks.h | 8 
 src/egl/drivers/dri2/platform_android.c   | 2 +-
 src/egl/drivers/dri2/platform_drm.c   | 1 +
 src/egl/drivers/dri2/platform_wayland.c   | 1 +
 src/egl/drivers/dri2/platform_x11.c   | 4 ++--
 7 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 2373eb4..906b959 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1032,6 +1032,14 @@ dri2_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay 
*dpy,
 attrib_list);
 }
 
+static _EGLSurface*
+dri2_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *dpy,
+   _EGLConfig *conf, const EGLint *attrib_list)
+{
+   struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy);
+   return dri2_dpy->vtbl->create_pbuffer_surface(drv, dpy, conf, attrib_list);
+}
+
 static EGLBoolean
 dri2_swap_interval(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
EGLint interval)
@@ -2077,6 +2085,7 @@ _eglBuiltInDriverDRI2(const char *args)
dri2_drv->base.API.MakeCurrent = dri2_make_current;
dri2_drv->base.API.CreateWindowSurface = dri2_create_window_surface;
dri2_drv->base.API.CreatePixmapSurface = dri2_create_pixmap_surface;
+   dri2_drv->base.API.CreatePbufferSurface = dri2_create_pbuffer_surface;
dri2_drv->base.API.GetProcAddress = dri2_get_proc_address;
dri2_drv->base.API.WaitClient = dri2_wait_client;
dri2_drv->base.API.WaitNative = dri2_wait_native;
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index 161c948..ebab005 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -98,6 +98,10 @@ struct dri2_egl_display_vtbl {
 _EGLConfig *config, EGLNativePixmapType pixmap,
 const EGLint *attrib_list);
 
+   _EGLSurface*
+   (*create_pbuffer_surface)(_EGLDriver *drv, _EGLDisplay *dpy,
+ _EGLConfig *config, const EGLint *attrib_list);
+
EGLBoolean
(*swap_interval)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
 EGLint interval);
diff --git a/src/egl/drivers/dri2/egl_dri2_fallbacks.h 
b/src/egl/drivers/dri2/egl_dri2_fallbacks.h
index 80dd4ac..a416157 100644
--- a/src/egl/drivers/dri2/egl_dri2_fallbacks.h
+++ b/src/egl/drivers/dri2/egl_dri2_fallbacks.h
@@ -35,6 +35,14 @@ dri2_fallback_create_pixmap_surface(_EGLDriver *drv, 
_EGLDisplay *disp,
return NULL;
 }
 
+static inline _EGLSurface *
+dri2_fallback_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *disp,
+ _EGLConfig *conf,
+ const EGLint *attrib_list)
+{
+   return NULL;
+}
+
 static inline EGLBoolean
 dri2_fallback_swap_interval(_EGLDriver *drv, _EGLDisplay *dpy,
 _EGLSurface *surf, EGLint interval)
diff --git a/src/egl/drivers/dri2/platform_android.c 
b/src/egl/drivers/dri2/platform_android.c
index c518048..7efc91a 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -423,7 +423,6 @@ droid_create_image_khr(_EGLDriver *drv, _EGLDisplay *disp,
 static void
 droid_init_driver_functions(_EGLDriver *drv)
 {
-   drv->API.CreatePbufferSurface = droid_create_pbuffer_surface;
drv->API.DestroySurface = droid_destroy_surface;
 
drv->API.CreateImageKHR = droid_create_image_khr;
@@ -646,6 +645,7 @@ static struct dri2_egl_display_vtbl droid_display_vtbl = {
.authenticate = NULL,
.create_window_surface = droid_create_window_surface,
.create_pixmap_surface = dri2_fallback_pixmap_surface,
+   .create_pbuffer_surface = droid_create_pbuffer_surface,
.swap_interval = dri2_fallback_swap_interval,
.swap_buffers = droid_swap_buffers,
.swap_buffers_with_damage = dri2_fallback_swap_buffers_with_damage,
diff --git a/src/egl/drivers/dri2/platform_drm.c 
b/src/egl/drivers/dri2/platform_drm.c
index bf492ce..2fb20ff 100644
--- a/src/egl/drivers/dri2/platform_drm.c
+++ b/src/egl/drivers/dri2/platform_drm.c
@@ -445,6 +445,7 @@ static struct dri2_egl_display_vtbl dri2_drm_display_vtbl = 
{
.authenticate = dri2_drm_authenticate,
.create_window_surface = dri2_drm_create_window_surface,
.create_pixmap_surface = dri2_fallback_create_pixmap_surface,
+   .create_pbuffer_surface = dri2_fallback_create_pbuffer_surface,
.swap_interval = dri2_fallback_swap_interval,
.swap_buffers = dri2_drm_swap_buffers,
.swap_buffers_with_damage = dri2_fallback_swap_buffers_with_damage,
diff

[Mesa-dev] [PATCH 16/25] egl/dri2/x11: Set dri2_dpy->own_device

2014-02-09 Thread Chad Versace
When the user calls eglGetDisplay(EGL_DEFAULT_DISPLAY), the Wayland and
DRM platforms set dri2_dpy->own_device=true. This patch makes the X11
platform do the same for consistency.

Signed-off-by: Chad Versace 
---
 src/egl/drivers/dri2/platform_x11.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/egl/drivers/dri2/platform_x11.c 
b/src/egl/drivers/dri2/platform_x11.c
index f5b17de..f6378f4 100644
--- a/src/egl/drivers/dri2/platform_x11.c
+++ b/src/egl/drivers/dri2/platform_x11.c
@@ -25,6 +25,7 @@
  *Kristian Høgsberg 
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -1038,6 +1039,7 @@ dri2_initialize_x11_swrast(_EGLDriver *drv, _EGLDisplay 
*disp)
disp->DriverData = (void *) dri2_dpy;
if (disp->PlatformDisplay == NULL) {
   dri2_dpy->conn = xcb_connect(0, 0);
+  dri2_dpy->own_device = true;
} else {
   dri2_dpy->conn = XGetXCBConnection((Display *) disp->PlatformDisplay);
}
@@ -1153,6 +1155,7 @@ dri2_initialize_x11_dri2(_EGLDriver *drv, _EGLDisplay 
*disp)
disp->DriverData = (void *) dri2_dpy;
if (disp->PlatformDisplay == NULL) {
   dri2_dpy->conn = xcb_connect(0, 0);
+  dri2_dpy->own_device = true;
} else {
   dri2_dpy->conn = XGetXCBConnection((Display *) disp->PlatformDisplay);
}
-- 
1.8.5.3

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


[Mesa-dev] [PATCH 20/25] egl/dri2: Dispatch eglCreateImageKHR by display, not driver

2014-02-09 Thread Chad Versace
Add dri2_egl_display_vtbl::create_image, set it for each platform, and
let egl_dri2 dispatch eglCreateImageKHR to that.

To remove ambiguity, rename egl_dri2.c:dri2_create_image() to
dri2_create_image_from_dri().

This prepares for the EGL platform extensions.

Signed-off-by: Chad Versace 
---
 src/egl/drivers/dri2/egl_dri2.c | 22 --
 src/egl/drivers/dri2/egl_dri2.h |  5 +
 src/egl/drivers/dri2/platform_android.c |  9 +
 src/egl/drivers/dri2/platform_drm.c |  3 +--
 src/egl/drivers/dri2/platform_wayland.c |  1 +
 src/egl/drivers/dri2/platform_x11.c | 13 +++--
 6 files changed, 35 insertions(+), 18 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index e0d4b6c..fcf4acf 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1219,8 +1219,18 @@ dri2_release_tex_image(_EGLDriver *drv,
return EGL_TRUE;
 }
 
+static _EGLImage*
+dri2_create_image(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx,
+  EGLenum target, EGLClientBuffer buffer,
+  const EGLint *attr_list)
+{
+   struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy);
+   return dri2_dpy->vtbl->create_image(drv, dpy, ctx, target, buffer,
+   attr_list);
+}
+
 static _EGLImage *
-dri2_create_image(_EGLDisplay *disp, __DRIimage *dri_image)
+dri2_create_image_from_dri(_EGLDisplay *disp, __DRIimage *dri_image)
 {
struct dri2_egl_image *dri2_img;
 
@@ -1264,7 +1274,7 @@ dri2_create_image_khr_renderbuffer(_EGLDisplay *disp, 
_EGLContext *ctx,
   dri2_dpy->image->createImageFromRenderbuffer(dri2_ctx->dri_context,
renderbuffer, NULL);
 
-   return dri2_create_image(disp, dri_image);
+   return dri2_create_image_from_dri(disp, dri_image);
 }
 
 #ifdef HAVE_DRM_PLATFORM
@@ -1310,7 +1320,7 @@ dri2_create_image_mesa_drm_buffer(_EGLDisplay *disp, 
_EGLContext *ctx,
   pitch,
   NULL);
 
-   return dri2_create_image(disp, dri_image);
+   return dri2_create_image_from_dri(disp, dri_image);
 }
 #endif
 
@@ -1373,7 +1383,7 @@ dri2_create_image_wayland_wl_buffer(_EGLDisplay *disp, 
_EGLContext *ctx,
   return NULL;
}
 
-   return dri2_create_image(disp, dri_image);
+   return dri2_create_image_from_dri(disp, dri_image);
 }
 #endif
 
@@ -1743,7 +1753,7 @@ dri2_create_image_dma_buf(_EGLDisplay *disp, _EGLContext 
*ctx,
if (!dri_image)
   return EGL_NO_IMAGE_KHR;
 
-   res = dri2_create_image(disp, dri_image);
+   res = dri2_create_image_from_dri(disp, dri_image);
if (res)
   dri2_take_dma_buf_ownership(fds, num_fds);
 
@@ -2156,7 +2166,7 @@ _eglBuiltInDriverDRI2(const char *args)
dri2_drv->base.API.PostSubBufferNV = dri2_post_sub_buffer;
dri2_drv->base.API.CopyBuffers = dri2_copy_buffers,
dri2_drv->base.API.QueryBufferAge = dri2_query_buffer_age;
-   dri2_drv->base.API.CreateImageKHR = dri2_create_image_khr;
+   dri2_drv->base.API.CreateImageKHR = dri2_create_image;
dri2_drv->base.API.DestroyImageKHR = dri2_destroy_image_khr;
dri2_drv->base.API.CreateWaylandBufferFromImageWL = 
dri2_create_wayland_buffer_from_image;
 #ifdef HAVE_DRM_PLATFORM
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index 8f3ed9d..35115bc 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -107,6 +107,11 @@ struct dri2_egl_display_vtbl {
EGLBoolean
(*destroy_surface)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface);
 
+   _EGLImage*
+   (*create_image)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx,
+   EGLenum target, EGLClientBuffer buffer,
+   const EGLint *attr_list);
+
EGLBoolean
(*swap_interval)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
 EGLint interval);
diff --git a/src/egl/drivers/dri2/platform_android.c 
b/src/egl/drivers/dri2/platform_android.c
index 0aa0fa4..3020af7 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -421,12 +421,6 @@ droid_create_image_khr(_EGLDriver *drv, _EGLDisplay *disp,
 }
 
 static void
-droid_init_driver_functions(_EGLDriver *drv)
-{
-   drv->API.CreateImageKHR = droid_create_image_khr;
-}
-
-static void
 droid_flush_front_buffer(__DRIdrawable * driDrawable, void *loaderPrivate)
 {
 }
@@ -645,6 +639,7 @@ static struct dri2_egl_display_vtbl droid_display_vtbl = {
.create_pixmap_surface = dri2_fallback_pixmap_surface,
.create_pbuffer_surface = droid_create_pbuffer_surface,
.destroy_surface = droid_destroy_surface,
+   .create_image = droid_create_image_khr,
.swap_interval = dri2_fallback_swap_interval,
.swap_buffers = droid_swap_buffers,
.swap_buffers_with_damage = dri2_fallback_swap_buffers_with_damage,
@@ -717,8 +712,6 @@ dri2_initialize_androi

[Mesa-dev] [PATCH 18/25] egl/dri2: Dispatch eglCreateWaylandBufferFromImageWL by display, not driver

2014-02-09 Thread Chad Versace
Add dri2_egl_display_vtbl::create_wayland_buffer_from_image, set it for
each platform, and let egl_dri2 dispatch
eglCreateWaylandBufferFromImageWL to that.

This prepares for the EGL platform extensions.

Signed-off-by: Chad Versace 
---
 src/egl/drivers/dri2/egl_dri2.c   |  9 +
 src/egl/drivers/dri2/egl_dri2.h   |  6 ++
 src/egl/drivers/dri2/egl_dri2_fallbacks.h | 10 ++
 src/egl/drivers/dri2/platform_android.c   |  1 +
 src/egl/drivers/dri2/platform_drm.c   |  1 +
 src/egl/drivers/dri2/platform_wayland.c   | 10 --
 src/egl/drivers/dri2/platform_x11.c   |  2 ++
 7 files changed, 33 insertions(+), 6 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index d1b15f7..e0d4b6c 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1486,6 +1486,14 @@ dri2_create_image_khr_texture(_EGLDisplay *disp, 
_EGLContext *ctx,
return &dri2_img->base;
 }
 
+static struct wl_buffer*
+dri2_create_wayland_buffer_from_image(_EGLDriver *drv, _EGLDisplay *dpy,
+  _EGLImage *img)
+{
+   struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy);
+   return dri2_dpy->vtbl->create_wayland_buffer_from_image(drv, dpy, img);
+}
+
 #ifdef HAVE_DRM_PLATFORM
 static EGLBoolean
 dri2_check_dma_buf_attribs(const _EGLImageAttribs *attrs)
@@ -2150,6 +2158,7 @@ _eglBuiltInDriverDRI2(const char *args)
dri2_drv->base.API.QueryBufferAge = dri2_query_buffer_age;
dri2_drv->base.API.CreateImageKHR = dri2_create_image_khr;
dri2_drv->base.API.DestroyImageKHR = dri2_destroy_image_khr;
+   dri2_drv->base.API.CreateWaylandBufferFromImageWL = 
dri2_create_wayland_buffer_from_image;
 #ifdef HAVE_DRM_PLATFORM
dri2_drv->base.API.CreateDRMImageMESA = dri2_create_drm_image_mesa;
dri2_drv->base.API.ExportDRMImageMESA = dri2_export_drm_image_mesa;
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index 250d209..8f3ed9d 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -75,6 +75,8 @@
 
 #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
 
+struct wl_buffer;
+
 struct dri2_egl_driver
 {
_EGLDriver base;
@@ -131,6 +133,10 @@ struct dri2_egl_display_vtbl {
 
EGLint
(*query_buffer_age)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf);
+
+   struct wl_buffer*
+   (*create_wayland_buffer_from_image)(_EGLDriver *drv, _EGLDisplay *dpy,
+   _EGLImage *img);
 };
 
 struct dri2_egl_display
diff --git a/src/egl/drivers/dri2/egl_dri2_fallbacks.h 
b/src/egl/drivers/dri2/egl_dri2_fallbacks.h
index 00e955a..80ed26d 100644
--- a/src/egl/drivers/dri2/egl_dri2_fallbacks.h
+++ b/src/egl/drivers/dri2/egl_dri2_fallbacks.h
@@ -26,6 +26,8 @@
 
 #include "egltypedefs.h"
 
+struct wl_buffer;
+
 static inline _EGLSurface *
 dri2_fallback_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *disp,
 _EGLConfig *conf,
@@ -88,3 +90,11 @@ dri2_fallback_query_buffer_age(_EGLDriver *drv, _EGLDisplay 
*dpy,
 {
return 0;
 }
+
+static inline struct wl_buffer*
+dri2_fallback_create_wayland_buffer_from_image(_EGLDriver *drv,
+   _EGLDisplay *dpy,
+   _EGLImage *img)
+{
+   return NULL;
+}
diff --git a/src/egl/drivers/dri2/platform_android.c 
b/src/egl/drivers/dri2/platform_android.c
index eddf33c..0aa0fa4 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -652,6 +652,7 @@ static struct dri2_egl_display_vtbl droid_display_vtbl = {
.post_sub_buffer = dri2_fallback_post_sub_buffer,
.copy_buffers = dri2_fallback_copy_buffers,
.query_buffer_age = dri2_fallback_query_buffer_age,
+   .create_wayland_buffer_from_image = 
dri2_fallback_create_wayland_buffer_from_image,
 };
 
 EGLBoolean
diff --git a/src/egl/drivers/dri2/platform_drm.c 
b/src/egl/drivers/dri2/platform_drm.c
index 18eca19..89222bf 100644
--- a/src/egl/drivers/dri2/platform_drm.c
+++ b/src/egl/drivers/dri2/platform_drm.c
@@ -454,6 +454,7 @@ static struct dri2_egl_display_vtbl dri2_drm_display_vtbl = 
{
.post_sub_buffer = dri2_fallback_post_sub_buffer,
.copy_buffers = dri2_fallback_copy_buffers,
.query_buffer_age = dri2_drm_query_buffer_age,
+   .create_wayland_buffer_from_image = 
dri2_fallback_create_wayland_buffer_from_image,
 };
 
 EGLBoolean
diff --git a/src/egl/drivers/dri2/platform_wayland.c 
b/src/egl/drivers/dri2/platform_wayland.c
index 8dc2893..a875656 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -685,9 +685,9 @@ dri2_wl_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, 
_EGLSurface *draw)
 }
 
 static struct wl_buffer *
-dri2_wl_create_wayland_buffer_from_image_wl(_EGLDriver *drv,
-_EGLDisplay *disp,
-  

[Mesa-dev] [PATCH 17/25] egl/dri2: Consolidate eglTerminate

2014-02-09 Thread Chad Versace
egl_dri2.c:dri2_terminate() handled terminating X11 and DRM displays.
The Wayland platform implemented its own dri2_wl_terminate(), which was
nearly a copy of the common one.

To implement the EGL platform extensions, we either need to dispatch
eglTerminate per display or define a common implementation for all
platforms. This patch chooses consolidation.  It removes
dri2_wl_terminate() by folding it into the common dri2_terminate().

It was necessary to invert the `if (disp->PlatformDisplay == NULL)` and
the switch statement because, unlike DRM and X11, Wayland's terminator
performed action even when EGL didn't own the native display. In the
inversion, I replaced `disp->PlatformDisplay == NULL` with
`dri2_dpy->own_device` because the two expressions are synonymous, but
the latter's meaning is clearer.

Signed-off-by: Chad Versace 
---
 src/egl/drivers/dri2/egl_dri2.c | 37 +
 src/egl/drivers/dri2/platform_wayland.c | 27 
 2 files changed, 24 insertions(+), 40 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index a3abe83..d1b15f7 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -25,6 +25,8 @@
  *Kristian Høgsberg 
  */
 
+#define WL_HIDE_DEPRECATED
+
 #include 
 #include 
 #include 
@@ -42,12 +44,13 @@
 #include 
 #include 
 
-#include "egl_dri2.h"
-
 #ifdef HAVE_WAYLAND_PLATFORM
 #include "wayland-drm.h"
+#include "wayland-drm-client-protocol.h"
 #endif
 
+#include "egl_dri2.h"
+
 const __DRIuseInvalidateExtension use_invalidate = {
{ __DRI_USE_INVALIDATE, 1 }
 };
@@ -671,23 +674,31 @@ dri2_terminate(_EGLDriver *drv, _EGLDisplay *disp)
   dlclose(dri2_dpy->driver);
free(dri2_dpy->device_name);
 
-   if (disp->PlatformDisplay == NULL) {
-  switch (disp->Platform) {
+   switch (disp->Platform) {
 #ifdef HAVE_X11_PLATFORM
-  case _EGL_PLATFORM_X11:
+   case _EGL_PLATFORM_X11:
+  if (dri2_dpy->own_device) {
  xcb_disconnect(dri2_dpy->conn);
- break;
+  }
+  break;
 #endif
 #ifdef HAVE_DRM_PLATFORM
-  case _EGL_PLATFORM_DRM:
- if (dri2_dpy->own_device) {
-gbm_device_destroy(&dri2_dpy->gbm_dri->base.base);
- }
- break;
+   case _EGL_PLATFORM_DRM:
+  if (dri2_dpy->own_device) {
+ gbm_device_destroy(&dri2_dpy->gbm_dri->base.base);
+  }
+  break;
 #endif
-  default:
- break;
+#ifdef HAVE_WAYLAND_PLATFORM
+   case _EGL_PLATFORM_WAYLAND:
+  wl_drm_destroy(dri2_dpy->wl_drm);
+  if (dri2_dpy->own_device) {
+ wl_display_disconnect(dri2_dpy->wl_dpy);
   }
+  break;
+#endif
+   default:
+  break;
}
 
free(dri2_dpy);
diff --git a/src/egl/drivers/dri2/platform_wayland.c 
b/src/egl/drivers/dri2/platform_wayland.c
index ebd104f..8dc2893 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -780,31 +780,6 @@ dri2_wl_authenticate(_EGLDisplay *disp, uint32_t id)
return ret;
 }
 
-/**
- * Called via eglTerminate(), drv->API.Terminate().
- */
-static EGLBoolean
-dri2_wl_terminate(_EGLDriver *drv, _EGLDisplay *disp)
-{
-   struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
-
-   _eglReleaseDisplayResources(drv, disp);
-   _eglCleanupDisplay(disp);
-
-   dri2_dpy->core->destroyScreen(dri2_dpy->dri_screen);
-   close(dri2_dpy->fd);
-   dlclose(dri2_dpy->driver);
-   free(dri2_dpy->driver_name);
-   free(dri2_dpy->device_name);
-   wl_drm_destroy(dri2_dpy->wl_drm);
-   if (dri2_dpy->own_device)
-  wl_display_disconnect(dri2_dpy->wl_dpy);
-   free(dri2_dpy);
-   disp->DriverData = NULL;
-
-   return EGL_TRUE;
-}
-
 static void
 drm_handle_device(void *data, struct wl_drm *drm, const char *device)
 {
@@ -985,8 +960,6 @@ dri2_initialize_wayland(_EGLDriver *drv, _EGLDisplay *disp)
 
loader_set_logger(_eglLog);
 
-   drv->API.Terminate = dri2_wl_terminate;
-
drv->API.CreateWaylandBufferFromImageWL =
   dri2_wl_create_wayland_buffer_from_image_wl;
 
-- 
1.8.5.3

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


[Mesa-dev] [PATCH v3] gallium: add geometry shader output limits

2014-02-09 Thread Grigori Goronzy
v2: adjust limits for radeonsi and llvmpipe
v3: add documentation

Cc: "10.1" 
---
 src/gallium/docs/source/screen.rst   | 6 ++
 src/gallium/drivers/freedreno/freedreno_screen.c | 5 +
 src/gallium/drivers/i915/i915_screen.c   | 5 +
 src/gallium/drivers/ilo/ilo_screen.c | 3 +++
 src/gallium/drivers/llvmpipe/lp_screen.c | 3 +++
 src/gallium/drivers/nouveau/nv30/nv30_screen.c   | 2 ++
 src/gallium/drivers/nouveau/nv50/nv50_screen.c   | 3 +++
 src/gallium/drivers/nouveau/nvc0/nvc0_screen.c   | 3 +++
 src/gallium/drivers/r300/r300_screen.c   | 2 ++
 src/gallium/drivers/r600/r600_pipe.c | 6 ++
 src/gallium/drivers/radeonsi/si_pipe.c   | 6 ++
 src/gallium/drivers/softpipe/sp_screen.c | 3 +++
 src/gallium/drivers/svga/svga_screen.c   | 2 ++
 src/gallium/include/pipe/p_defines.h | 4 +++-
 src/mesa/state_tracker/st_extensions.c   | 2 ++
 15 files changed, 54 insertions(+), 1 deletion(-)

diff --git a/src/gallium/docs/source/screen.rst 
b/src/gallium/docs/source/screen.rst
index ed8e832..6598045 100644
--- a/src/gallium/docs/source/screen.rst
+++ b/src/gallium/docs/source/screen.rst
@@ -176,6 +176,12 @@ The integer capabilities:
   ARB_framebuffer_object is provided.
 * ``PIPE_CAP_TGSI_VS_LAYER``: Whether TGSI_SEMANTIC_LAYER is supported
   as a vertex shader output.
+* ``PIPE_CAP_MAX_GEOMETRY_OUTPUT_VERTICES``: The maximum number of vertices
+  output by a single invocation of a geometry shader.
+* ``PIPE_CAP_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS``: The maximum number of
+  vertex components output by a single invocation of a geometry shader.
+  This is the product of the number of attribute components per vertex and
+  the number of output vertices.
 
 
 .. _pipe_capf:
diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c 
b/src/gallium/drivers/freedreno/freedreno_screen.c
index aa294b3..e1b5dae 100644
--- a/src/gallium/drivers/freedreno/freedreno_screen.c
+++ b/src/gallium/drivers/freedreno/freedreno_screen.c
@@ -212,6 +212,11 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum 
pipe_cap param)
case PIPE_CAP_MAX_STREAM_OUTPUT_INTERLEAVED_COMPONENTS:
return 0;
 
+   /* Geometry shader output, unsupported. */
+   case PIPE_CAP_MAX_GEOMETRY_OUTPUT_VERTICES:
+   case PIPE_CAP_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS:
+   return 0;
+
/* Texturing. */
case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
diff --git a/src/gallium/drivers/i915/i915_screen.c 
b/src/gallium/drivers/i915/i915_screen.c
index a658b1b..9f08f86 100644
--- a/src/gallium/drivers/i915/i915_screen.c
+++ b/src/gallium/drivers/i915/i915_screen.c
@@ -257,6 +257,11 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap 
cap)
case PIPE_CAP_MAX_RENDER_TARGETS:
   return 1;
 
+   /* Geometry shader output, unsupported. */
+   case PIPE_CAP_MAX_GEOMETRY_OUTPUT_VERTICES:
+   case PIPE_CAP_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS:
+  return 0;
+
/* Fragment coordinate conventions. */
case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT:
case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER:
diff --git a/src/gallium/drivers/ilo/ilo_screen.c 
b/src/gallium/drivers/ilo/ilo_screen.c
index bc8f62d..9c363ac 100644
--- a/src/gallium/drivers/ilo/ilo_screen.c
+++ b/src/gallium/drivers/ilo/ilo_screen.c
@@ -372,6 +372,9 @@ ilo_get_param(struct pipe_screen *screen, enum pipe_cap 
param)
   return ILO_MAX_SO_BINDINGS / ILO_MAX_SO_BUFFERS;
case PIPE_CAP_MAX_STREAM_OUTPUT_INTERLEAVED_COMPONENTS:
   return ILO_MAX_SO_BINDINGS;
+   case PIPE_CAP_MAX_GEOMETRY_OUTPUT_VERTICES:
+   case PIPE_CAP_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS:
+  return 0;
case PIPE_CAP_STREAM_OUTPUT_PAUSE_RESUME:
   if (is->dev.gen >= ILO_GEN(7))
  return is->dev.has_gen7_sol_reset;
diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c 
b/src/gallium/drivers/llvmpipe/lp_screen.c
index 3f84d74..43142e7 100644
--- a/src/gallium/drivers/llvmpipe/lp_screen.c
+++ b/src/gallium/drivers/llvmpipe/lp_screen.c
@@ -187,6 +187,9 @@ llvmpipe_get_param(struct pipe_screen *screen, enum 
pipe_cap param)
case PIPE_CAP_MAX_STREAM_OUTPUT_SEPARATE_COMPONENTS:
case PIPE_CAP_MAX_STREAM_OUTPUT_INTERLEAVED_COMPONENTS:
   return 16*4;
+   case PIPE_CAP_MAX_GEOMETRY_OUTPUT_VERTICES:
+   case PIPE_CAP_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS:
+  return 1024;
case PIPE_CAP_STREAM_OUTPUT_PAUSE_RESUME:
   return 1;
case PIPE_CAP_TGSI_CAN_COMPACT_CONSTANTS:
diff --git a/src/gallium/drivers/nouveau/nv30/nv30_screen.c 
b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
index 787802d..9e2a90c 100644
--- a/src/gallium/drivers/nouveau/nv30/nv30_screen.c
+++ b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
@@ -106,6 +106,8 @@ nv30_screen_get_param(struct pipe_screen *pscreen, enum 
pipe_cap param)
case PIPE_CAP_MAX_TEXEL_OFFSET:
case PIPE_CAP_

Re: [Mesa-dev] [PATCH v3] gallium: add geometry shader output limits

2014-02-09 Thread Marek Olšák
Pushed, thanks.

Marek

On Sun, Feb 9, 2014 at 10:56 PM, Grigori Goronzy  wrote:
> v2: adjust limits for radeonsi and llvmpipe
> v3: add documentation
>
> Cc: "10.1" 
> ---
>  src/gallium/docs/source/screen.rst   | 6 ++
>  src/gallium/drivers/freedreno/freedreno_screen.c | 5 +
>  src/gallium/drivers/i915/i915_screen.c   | 5 +
>  src/gallium/drivers/ilo/ilo_screen.c | 3 +++
>  src/gallium/drivers/llvmpipe/lp_screen.c | 3 +++
>  src/gallium/drivers/nouveau/nv30/nv30_screen.c   | 2 ++
>  src/gallium/drivers/nouveau/nv50/nv50_screen.c   | 3 +++
>  src/gallium/drivers/nouveau/nvc0/nvc0_screen.c   | 3 +++
>  src/gallium/drivers/r300/r300_screen.c   | 2 ++
>  src/gallium/drivers/r600/r600_pipe.c | 6 ++
>  src/gallium/drivers/radeonsi/si_pipe.c   | 6 ++
>  src/gallium/drivers/softpipe/sp_screen.c | 3 +++
>  src/gallium/drivers/svga/svga_screen.c   | 2 ++
>  src/gallium/include/pipe/p_defines.h | 4 +++-
>  src/mesa/state_tracker/st_extensions.c   | 2 ++
>  15 files changed, 54 insertions(+), 1 deletion(-)
>
> diff --git a/src/gallium/docs/source/screen.rst 
> b/src/gallium/docs/source/screen.rst
> index ed8e832..6598045 100644
> --- a/src/gallium/docs/source/screen.rst
> +++ b/src/gallium/docs/source/screen.rst
> @@ -176,6 +176,12 @@ The integer capabilities:
>ARB_framebuffer_object is provided.
>  * ``PIPE_CAP_TGSI_VS_LAYER``: Whether TGSI_SEMANTIC_LAYER is supported
>as a vertex shader output.
> +* ``PIPE_CAP_MAX_GEOMETRY_OUTPUT_VERTICES``: The maximum number of vertices
> +  output by a single invocation of a geometry shader.
> +* ``PIPE_CAP_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS``: The maximum number of
> +  vertex components output by a single invocation of a geometry shader.
> +  This is the product of the number of attribute components per vertex and
> +  the number of output vertices.
>
>
>  .. _pipe_capf:
> diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c 
> b/src/gallium/drivers/freedreno/freedreno_screen.c
> index aa294b3..e1b5dae 100644
> --- a/src/gallium/drivers/freedreno/freedreno_screen.c
> +++ b/src/gallium/drivers/freedreno/freedreno_screen.c
> @@ -212,6 +212,11 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum 
> pipe_cap param)
> case PIPE_CAP_MAX_STREAM_OUTPUT_INTERLEAVED_COMPONENTS:
> return 0;
>
> +   /* Geometry shader output, unsupported. */
> +   case PIPE_CAP_MAX_GEOMETRY_OUTPUT_VERTICES:
> +   case PIPE_CAP_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS:
> +   return 0;
> +
> /* Texturing. */
> case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
> case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
> diff --git a/src/gallium/drivers/i915/i915_screen.c 
> b/src/gallium/drivers/i915/i915_screen.c
> index a658b1b..9f08f86 100644
> --- a/src/gallium/drivers/i915/i915_screen.c
> +++ b/src/gallium/drivers/i915/i915_screen.c
> @@ -257,6 +257,11 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap 
> cap)
> case PIPE_CAP_MAX_RENDER_TARGETS:
>return 1;
>
> +   /* Geometry shader output, unsupported. */
> +   case PIPE_CAP_MAX_GEOMETRY_OUTPUT_VERTICES:
> +   case PIPE_CAP_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS:
> +  return 0;
> +
> /* Fragment coordinate conventions. */
> case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT:
> case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER:
> diff --git a/src/gallium/drivers/ilo/ilo_screen.c 
> b/src/gallium/drivers/ilo/ilo_screen.c
> index bc8f62d..9c363ac 100644
> --- a/src/gallium/drivers/ilo/ilo_screen.c
> +++ b/src/gallium/drivers/ilo/ilo_screen.c
> @@ -372,6 +372,9 @@ ilo_get_param(struct pipe_screen *screen, enum pipe_cap 
> param)
>return ILO_MAX_SO_BINDINGS / ILO_MAX_SO_BUFFERS;
> case PIPE_CAP_MAX_STREAM_OUTPUT_INTERLEAVED_COMPONENTS:
>return ILO_MAX_SO_BINDINGS;
> +   case PIPE_CAP_MAX_GEOMETRY_OUTPUT_VERTICES:
> +   case PIPE_CAP_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS:
> +  return 0;
> case PIPE_CAP_STREAM_OUTPUT_PAUSE_RESUME:
>if (is->dev.gen >= ILO_GEN(7))
>   return is->dev.has_gen7_sol_reset;
> diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c 
> b/src/gallium/drivers/llvmpipe/lp_screen.c
> index 3f84d74..43142e7 100644
> --- a/src/gallium/drivers/llvmpipe/lp_screen.c
> +++ b/src/gallium/drivers/llvmpipe/lp_screen.c
> @@ -187,6 +187,9 @@ llvmpipe_get_param(struct pipe_screen *screen, enum 
> pipe_cap param)
> case PIPE_CAP_MAX_STREAM_OUTPUT_SEPARATE_COMPONENTS:
> case PIPE_CAP_MAX_STREAM_OUTPUT_INTERLEAVED_COMPONENTS:
>return 16*4;
> +   case PIPE_CAP_MAX_GEOMETRY_OUTPUT_VERTICES:
> +   case PIPE_CAP_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS:
> +  return 1024;
> case PIPE_CAP_STREAM_OUTPUT_PAUSE_RESUME:
>return 1;
> case PIPE_CAP_TGSI_CAN_COMPACT_CONSTANTS:
> diff --git a/src/gallium/drivers/nouveau/nv30/nv30_screen.c 
> b/src/gallium/drivers/nouveau/nv30/nv30_s

[Mesa-dev] [PATCH 3/3] i965: Program 2x MSAA sample positions.

2014-02-09 Thread Kenneth Graunke
There are only two sensible placements for 2x MSAA samples - and one is
the mirror image of the other.  I chose (0.25, 0.25) and (0.75, 0.75).

Signed-off-by: Kenneth Graunke 
---
 src/mesa/drivers/dri/i965/brw_multisample_state.h  | 11 +++
 src/mesa/drivers/dri/i965/gen6_multisample_state.c |  3 +++
 src/mesa/drivers/dri/i965/gen8_multisample_state.c |  6 ++
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_multisample_state.h 
b/src/mesa/drivers/dri/i965/brw_multisample_state.h
index 2e02500..26633e7 100644
--- a/src/mesa/drivers/dri/i965/brw_multisample_state.h
+++ b/src/mesa/drivers/dri/i965/brw_multisample_state.h
@@ -24,6 +24,17 @@
 #include 
 
 /**
+ * 1x MSAA has a single sample at the center: (0.5, 0.5) -> (0x8, 0x8).
+ *
+ * 2x MSAA sample positions are (0.25, 0.25) and (0.75, 0.75):
+ *   4 c
+ * 4 0
+ * c   1
+ */
+static const uint32_t
+brw_multisample_positions_1x_2x = 0x0088cc44;
+
+/**
  * Sample positions:
  *   2 6 a e
  * 2   0
diff --git a/src/mesa/drivers/dri/i965/gen6_multisample_state.c 
b/src/mesa/drivers/dri/i965/gen6_multisample_state.c
index cdc9ef8..5d65453 100644
--- a/src/mesa/drivers/dri/i965/gen6_multisample_state.c
+++ b/src/mesa/drivers/dri/i965/gen6_multisample_state.c
@@ -38,6 +38,9 @@ gen6_get_sample_position(struct gl_context *ctx,
case 1:
   result[0] = result[1] = 0.5f;
   return;
+   case 2:
+  bits = brw_multisample_positions_1x_2x >> (8 * index);
+  break;
case 4:
   bits = brw_multisample_positions_4x >> (8 * index);
   break;
diff --git a/src/mesa/drivers/dri/i965/gen8_multisample_state.c 
b/src/mesa/drivers/dri/i965/gen8_multisample_state.c
index e137efe..64c7208 100644
--- a/src/mesa/drivers/dri/i965/gen8_multisample_state.c
+++ b/src/mesa/drivers/dri/i965/gen8_multisample_state.c
@@ -87,10 +87,8 @@ gen8_emit_3dstate_sample_pattern(struct brw_context *brw)
/* 4x MSAA */
OUT_BATCH(brw_multisample_positions_4x);
 
-   /* 2x and 1x MSAA patterns
-* XXX: need to program 2x.
-*/
-   OUT_BATCH(0x0088);
+   /* 1x and 2x MSAA */
+   OUT_BATCH(brw_multisample_positions_1x_2x);
ADVANCE_BATCH();
 }
 
-- 
1.8.5.2

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


[Mesa-dev] [PATCH 1/3] i965: Duplicate less code in GetSamplePositions driver hook.

2014-02-09 Thread Kenneth Graunke
The 4x and 8x cases contained identical code for extracting the X and
Y sample offset values and converting them from U0.4 back to float.

Without this refactoring, we'd have to duplicate it a third time in
order to support 2x MSAA.

Signed-off-by: Kenneth Graunke 
---
 src/mesa/drivers/dri/i965/gen6_multisample_state.c | 23 +++---
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/gen6_multisample_state.c 
b/src/mesa/drivers/dri/i965/gen6_multisample_state.c
index f28e880..fd3dd0e 100644
--- a/src/mesa/drivers/dri/i965/gen6_multisample_state.c
+++ b/src/mesa/drivers/dri/i965/gen6_multisample_state.c
@@ -32,25 +32,26 @@ gen6_get_sample_position(struct gl_context *ctx,
  struct gl_framebuffer *fb,
  GLuint index, GLfloat *result)
 {
+   uint8_t bits;
+
switch (fb->Visual.samples) {
case 1:
   result[0] = result[1] = 0.5f;
+  return;
+   case 4:
+  bits = brw_multisample_positions_4x[0] >> (8 * index);
   break;
-   case 4: {
-  uint8_t val = (uint8_t)(brw_multisample_positions_4x[0] >> (8*index));
-  result[0] = ((val >> 4) & 0xf) / 16.0f;
-  result[1] = (val & 0xf) / 16.0f;
-  break;
-   }
-   case 8: {
-  uint8_t val = (uint8_t)(brw_multisample_positions_8x[index>>2] >> 
(8*(index & 3)));
-  result[0] = ((val >> 4) & 0xf) / 16.0f;
-  result[1] = (val & 0xf) / 16.0f;
+   case 8:
+  bits = brw_multisample_positions_8x[index >> 2] >> (8 * (index & 3));
   break;
-   }
default:
   assert(!"Not implemented");
+  return;
}
+
+   /* Convert from U0.4 back to a floating point coordinate. */
+   result[0] = ((bits >> 4) & 0xf) / 16.0f;
+   result[1] = (bits & 0xf) / 16.0f;
 }
 
 /**
-- 
1.8.5.2

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


[Mesa-dev] [PATCH 2/3] i965: Store 4x MSAA sample positions in a scalar value, not an array.

2014-02-09 Thread Kenneth Graunke
Storing a single value in an array is rather pointless.

Signed-off-by: Kenneth Graunke 
---
 src/mesa/drivers/dri/i965/brw_multisample_state.h  | 2 +-
 src/mesa/drivers/dri/i965/gen6_multisample_state.c | 4 ++--
 src/mesa/drivers/dri/i965/gen8_multisample_state.c | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_multisample_state.h 
b/src/mesa/drivers/dri/i965/brw_multisample_state.h
index 79566f0..2e02500 100644
--- a/src/mesa/drivers/dri/i965/brw_multisample_state.h
+++ b/src/mesa/drivers/dri/i965/brw_multisample_state.h
@@ -32,7 +32,7 @@
  * e 3
  */
 static const uint32_t
-brw_multisample_positions_4x[] = { 0xae2ae662 };
+brw_multisample_positions_4x = 0xae2ae662;
 
 /**
  * Sample positions are based on a solution to the "8 queens" puzzle.
diff --git a/src/mesa/drivers/dri/i965/gen6_multisample_state.c 
b/src/mesa/drivers/dri/i965/gen6_multisample_state.c
index fd3dd0e..cdc9ef8 100644
--- a/src/mesa/drivers/dri/i965/gen6_multisample_state.c
+++ b/src/mesa/drivers/dri/i965/gen6_multisample_state.c
@@ -39,7 +39,7 @@ gen6_get_sample_position(struct gl_context *ctx,
   result[0] = result[1] = 0.5f;
   return;
case 4:
-  bits = brw_multisample_positions_4x[0] >> (8 * index);
+  bits = brw_multisample_positions_4x >> (8 * index);
   break;
case 8:
   bits = brw_multisample_positions_8x[index >> 2] >> (8 * (index & 3));
@@ -74,7 +74,7 @@ gen6_emit_3dstate_multisample(struct brw_context *brw,
   break;
case 4:
   number_of_multisamples = MS_NUMSAMPLES_4;
-  sample_positions_3210 = brw_multisample_positions_4x[0];
+  sample_positions_3210 = brw_multisample_positions_4x;
   break;
case 8:
   number_of_multisamples = MS_NUMSAMPLES_8;
diff --git a/src/mesa/drivers/dri/i965/gen8_multisample_state.c 
b/src/mesa/drivers/dri/i965/gen8_multisample_state.c
index ad273e4..e137efe 100644
--- a/src/mesa/drivers/dri/i965/gen8_multisample_state.c
+++ b/src/mesa/drivers/dri/i965/gen8_multisample_state.c
@@ -85,7 +85,7 @@ gen8_emit_3dstate_sample_pattern(struct brw_context *brw)
OUT_BATCH(brw_multisample_positions_8x[0]); /* sample positions 3210 */
 
/* 4x MSAA */
-   OUT_BATCH(brw_multisample_positions_4x[0]);
+   OUT_BATCH(brw_multisample_positions_4x);
 
/* 2x and 1x MSAA patterns
 * XXX: need to program 2x.
-- 
1.8.5.2

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


Re: [Mesa-dev] [PATCH 1/3] mesa: remove _mesa_ prefix from some static functions

2014-02-09 Thread Ian Romanick
Series is

Reviewed-by: Ian Romanick 

Another nice clean-up would be to enable GL_KHR_debug on ES contexts.
Then all of the 'if (!_mesa_is_desktop_gl(ctx)) goto
invalid_enum_error;' noise could go away.  Less code, more
functionality. :)  That might even be a good newbie project...

On 02/07/2014 04:43 PM, Brian Paul wrote:
> ---
>  src/mesa/main/errors.c |   50 
> ++--
>  1 file changed, 23 insertions(+), 27 deletions(-)
> 
> diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c
> index 28357e0..f84a3c1 100644
> --- a/src/mesa/main/errors.c
> +++ b/src/mesa/main/errors.c
> @@ -346,9 +346,9 @@ remap_severity(GLenum severity) {
>   * the null terminator this time.
>   */
>  static void
> -_mesa_log_msg(struct gl_context *ctx, enum mesa_debug_source source,
> -  enum mesa_debug_type type, GLuint id,
> -  enum mesa_debug_severity severity, GLint len, const char *buf)
> +log_msg(struct gl_context *ctx, enum mesa_debug_source source,
> +enum mesa_debug_type type, GLuint id,
> +enum mesa_debug_severity severity, GLint len, const char *buf)
>  {
> GLint nextEmpty;
> struct gl_debug_msg *emptySlot;
> @@ -400,9 +400,9 @@ _mesa_log_msg(struct gl_context *ctx, enum 
> mesa_debug_source source,
>   * indicates failure.
>   */
>  static GLsizei
> -_mesa_get_msg(struct gl_context *ctx, GLenum *source, GLenum *type,
> -  GLuint *id, GLenum *severity, GLsizei bufSize, char *buf,
> -  unsigned caller)
> +get_msg(struct gl_context *ctx, GLenum *source, GLenum *type,
> +GLuint *id, GLenum *severity, GLsizei bufSize, char *buf,
> +unsigned caller)
>  {
> struct gl_debug_msg *msg;
> GLsizei length;
> @@ -681,10 +681,10 @@ message_insert(GLenum source, GLenum type, GLuint id,
>return;
> }
>  
> -   _mesa_log_msg(ctx,
> - gl_enum_to_debug_source(source),
> - gl_enum_to_debug_type(type), id,
> - gl_enum_to_debug_severity(severity), length, buf);
> +   log_msg(ctx,
> +   gl_enum_to_debug_source(source),
> +   gl_enum_to_debug_type(type), id,
> +   gl_enum_to_debug_severity(severity), length, buf);
>  }
>  
>  /**
> @@ -711,8 +711,8 @@ get_message_log(GLuint count, GLsizei logSize, GLenum* 
> sources,
> }
>  
> for (ret = 0; ret < count; ret++) {
> -  GLsizei written = _mesa_get_msg(ctx, sources, types, ids, severities,
> -  logSize, messageLog, caller);
> +  GLsizei written = get_msg(ctx, sources, types, ids, severities,
> +logSize, messageLog, caller);
>if (!written)
>   break;
>  
> @@ -893,7 +893,7 @@ _mesa_PushDebugGroup(GLenum source, GLuint id, GLsizei 
> length,
>  }
>  
>  void GLAPIENTRY
> -_mesa_PopDebugGroup()
> +_mesa_PopDebugGroup(void)
>  {
> const char *callerstr = "glPopDebugGroup";
> struct gl_debug_msg *gdmessage;
> @@ -910,14 +910,14 @@ _mesa_PopDebugGroup()
> ctx->Debug.GroupStackDepth--;
>  
> gdmessage = &ctx->Debug.DebugGroupMsgs[prevStackDepth];
> -   /* using _mesa_log_msg() directly here as verification of parameters
> +   /* using log_msg() directly here as verification of parameters
>  * already done in push
>  */
> -   _mesa_log_msg(ctx, gdmessage->source,
> - gl_enum_to_debug_type(GL_DEBUG_TYPE_POP_GROUP),
> - gdmessage->id,
> - gl_enum_to_debug_severity(GL_DEBUG_SEVERITY_NOTIFICATION),
> - gdmessage->length, gdmessage->message);
> +   log_msg(ctx, gdmessage->source,
> +   gl_enum_to_debug_type(GL_DEBUG_TYPE_POP_GROUP),
> +   gdmessage->id,
> +   gl_enum_to_debug_severity(GL_DEBUG_SEVERITY_NOTIFICATION),
> +   gdmessage->length, gdmessage->message);
>  
> if (gdmessage->message != (char*)out_of_memory)
>free(gdmessage->message);
> @@ -1202,8 +1202,7 @@ _mesa_gl_debug(struct gl_context *ctx,
> len = _mesa_vsnprintf(s, MAX_DEBUG_MESSAGE_LENGTH, fmtString, args);
> va_end(args);
>  
> -   _mesa_log_msg(ctx, MESA_DEBUG_SOURCE_API, type,
> - *id, severity, len, s);
> +   log_msg(ctx, MESA_DEBUG_SOURCE_API, type, *id, severity, len, s);
>  }
>  
>  
> @@ -1268,11 +1267,8 @@ _mesa_error( struct gl_context *ctx, GLenum error, 
> const char *fmtString, ... )
>  
>/* Log the error via ARB_debug_output if needed.*/
>if (do_log) {
> - _mesa_log_msg(ctx,
> -   MESA_DEBUG_SOURCE_API,
> -   MESA_DEBUG_TYPE_ERROR,
> -   error_msg_id,
> -   MESA_DEBUG_SEVERITY_HIGH, len, s2);
> + log_msg(ctx, MESA_DEBUG_SOURCE_API, MESA_DEBUG_TYPE_ERROR,
> + error_msg_id, MESA_DEBUG_SEVERITY_HIGH, len, s2);
>}
> }
>  
> @@ -1329,7 +1325,7 @@ _mesa_shader_debug( struct gl_context *ctx, GLenum 
> type, GLuint *id,
> 

[Mesa-dev] [Bug 74723] main/shaderapi.c:407: detach_shader: Assertion `shProg->Shaders[j]->Type == 0x8B31 || shProg->Shaders[j]->Type == 0x8B30' failed.

2014-02-09 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=74723

--- Comment #6 from Ian Romanick  ---
Comment on attachment 93676
  --> https://bugs.freedesktop.org/attachment.cgi?id=93676
update assertion for GS

Review of attachment 93676:
-

That patch looks good.  I'm surprised we've never hit this before... seems we
need a piglit test (since most developers use debug builds).

Reviewed-by: Ian Romanick 

A good follow-up patch would remove the extra { } and fix the indentation. :)

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/3] i965: Duplicate less code in GetSamplePositions driver hook.

2014-02-09 Thread Ian Romanick
On 02/09/2014 04:56 PM, Kenneth Graunke wrote:
> The 4x and 8x cases contained identical code for extracting the X and
> Y sample offset values and converting them from U0.4 back to float.
> 
> Without this refactoring, we'd have to duplicate it a third time in
> order to support 2x MSAA.
> 
> Signed-off-by: Kenneth Graunke 

Series is

Reviewed-by: Ian Romanick 

> ---
>  src/mesa/drivers/dri/i965/gen6_multisample_state.c | 23 
> +++---
>  1 file changed, 12 insertions(+), 11 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/gen6_multisample_state.c 
> b/src/mesa/drivers/dri/i965/gen6_multisample_state.c
> index f28e880..fd3dd0e 100644
> --- a/src/mesa/drivers/dri/i965/gen6_multisample_state.c
> +++ b/src/mesa/drivers/dri/i965/gen6_multisample_state.c
> @@ -32,25 +32,26 @@ gen6_get_sample_position(struct gl_context *ctx,
>   struct gl_framebuffer *fb,
>   GLuint index, GLfloat *result)
>  {
> +   uint8_t bits;
> +
> switch (fb->Visual.samples) {
> case 1:
>result[0] = result[1] = 0.5f;
> +  return;
> +   case 4:
> +  bits = brw_multisample_positions_4x[0] >> (8 * index);
>break;
> -   case 4: {
> -  uint8_t val = (uint8_t)(brw_multisample_positions_4x[0] >> (8*index));
> -  result[0] = ((val >> 4) & 0xf) / 16.0f;
> -  result[1] = (val & 0xf) / 16.0f;
> -  break;
> -   }
> -   case 8: {
> -  uint8_t val = (uint8_t)(brw_multisample_positions_8x[index>>2] >> 
> (8*(index & 3)));
> -  result[0] = ((val >> 4) & 0xf) / 16.0f;
> -  result[1] = (val & 0xf) / 16.0f;
> +   case 8:
> +  bits = brw_multisample_positions_8x[index >> 2] >> (8 * (index & 3));
>break;
> -   }
> default:
>assert(!"Not implemented");
> +  return;
> }
> +
> +   /* Convert from U0.4 back to a floating point coordinate. */
> +   result[0] = ((bits >> 4) & 0xf) / 16.0f;
> +   result[1] = (bits & 0xf) / 16.0f;
>  }
>  
>  /**
> 

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


Re: [Mesa-dev] [PATCH 00/22] Exported symbols cleanup and tests

2014-02-09 Thread Ian Romanick
On 02/08/2014 08:03 AM, Emil Velikov wrote:
> Hello list,
> 
> Continuing with another not so interesting area of mesa - cleaning up
> the exported symbols and adding make check tests.
> 
> Note: Most of these patches are rather dull and may cause boredom or
> sleepiness :-)
> 
> Before proceeding make sure that with-llvm-shared-libs is set, otherwise
> the modules will export every llvm symbol imaginable and make check will
> fail. The above option will default to enabled/with with mesa 10.1 and
> later once patch is commited.

If the other option is selected, is it possible for 'make check' to not
explode?  I haven't looked at the tests yet, so that may be a dumb question.

> Brief/highlights:
>  - Cleans up symbols that has been incorrectly marked as PUBLIC.
>  - Adds VISIBILITY_CFLAGS on a handful of places within automake.
>  - Adds tests so that make check shouts loudly if we're exporting too
> many symbols.
>  - Mainly T symbols are checked, due to the reasons listed in the next
>  point.
>  - Drivers using stl (r600 and nouveau I'm looking at you), provide a
> handfull of exported weak symbols due to gcc design feature [1]. Those
> have been left as is.
>  - Finally VISIBILITY_CFLAGS has been compacted into DEFINES. The cases
> that break (if any) should be fixed approapriately.
>  - There is a few more places that could use similar treatment. To be
> continued ...
> 
> As usual a branch cleanup-exported-symbols-v2 can be found over at 
> https://github.com/evelikov/Mesa/
> 
> 
> Runtime tested on my rusty old nv96 (nouveau), using the dri and vdpau
> state-trackers.
> make check tested for every possible test, with swrast, nouveau and r600.
> 
> Feel free to take a look and more importantly _please_ give them a test.
> 
> Thanks
> Emil
> 
> [1] http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36022
> 
> Emil Velikov (22):
>   auxiliary/pipe-loader: automake: avoid exporting all symbols
>   targets/pipe-loader: automake: drop obsolete version-script
>   st/gbm: automake: do not export gbm_gallium_drm_device_create
>   gbm: automake: add VISIBILITY_CFLAGS
>   gbm: do not export _gbm_mesa_get_device
>   targets/gbm: automake: do not export internal symbols
>   gbm: automake: add symbol tests
>   targets/egl-static: automake: don't export local symbols
>   st/egl: automake: avoid exporting all symbols
>   wayland-egl: automake: add symbol test
>   egl: automake: add symbol test
>   targets/egl-static: automake: drop obsolete version-script
>   st/vdpau: do not export VdpPresentationQueueTargetCreateX11
>   st/vdpau: automake: export only PUBLIC symbols
>   targets/vdpau: automake: add exported symbol tests
>   targets/dri: automake: add test for exported symbols
>   targets/xvmc: add automake test to check for exported symbols
>   osmesa: drop obsolete AM_CXXFLAGS
>   omx: use VISIBILITY_CFLAGS to control exported symbols
>   st/clover: use VISIBILITY_CXXFLAGS where approapriate
>   automake: fold VISIBILITY_CFLAGS within DEFINES
>   targets/omx: automake: add symbol test
> 
>   59 files changed, 369 insertions(+), 70 deletions(-)
> 
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
> 

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


Re: [Mesa-dev] [PATCH 11/22] egl: automake: add symbol test

2014-02-09 Thread Ian Romanick
On 02/08/2014 08:03 AM, Emil Velikov wrote:
> Signed-off-by: Emil Velikov 
> ---
>  src/egl/main/Makefile.am   |   2 +
>  src/egl/main/egl-symbols-check | 109 
> +
>  2 files changed, 111 insertions(+)
>  create mode 100755 src/egl/main/egl-symbols-check
> 
> diff --git a/src/egl/main/Makefile.am b/src/egl/main/Makefile.am
> index 46e890a..7d9748f 100644
> --- a/src/egl/main/Makefile.am
> +++ b/src/egl/main/Makefile.am
> @@ -124,3 +124,5 @@ egl_HEADERS = \
>   $(top_srcdir)/include/EGL/egl.h \
>   $(top_srcdir)/include/EGL/eglmesaext.h \
>   $(top_srcdir)/include/EGL/eglplatform.h
> +
> +TESTS = egl-symbols-check
> \ No newline at end of file

Perhaps add a newline? :)

> diff --git a/src/egl/main/egl-symbols-check b/src/egl/main/egl-symbols-check
> new file mode 100755
> index 000..fc69369
> --- /dev/null
> +++ b/src/egl/main/egl-symbols-check
> @@ -0,0 +1,109 @@
> +#!/bin/bash
> +
> +# XXX: the private _egl* symbols are exported for egl backends like 
> egl_gallium
> +
> +FUNCS=$(nm -D --defined-only ${1-.libs/libEGL.so} | grep -o "T .*" | cut -c 
> 3- | while read func; do
> +( grep -q "^$func$" || echo $func )  < +eglBindAPI
> +eglBindTexImage
> +eglBindWaylandDisplayWL
> +eglChooseConfig
> +eglChooseModeMESA
> +eglClientWaitSyncKHR

Are we supposed to export extension functions?  I thought that's what
eglGetProcAddress was for... I'd swear there was an "implementer's
guide" or some such from Khronos that gave some guidance here.

> +eglCopyBuffers
> +eglCopyContextMESA
> +eglCreateContext
> +eglCreateDRMImageMESA
> +eglCreateImageKHR
> +eglCreatePbufferFromClientBuffer
> +eglCreatePbufferSurface
> +eglCreatePixmapSurface
> +eglCreateScreenSurfaceMESA
> +eglCreateSyncKHR
> +eglCreateWaylandBufferFromImageWL
> +eglCreateWindowSurface
> +eglDestroyContext
> +eglDestroyImageKHR
> +eglDestroySurface
> +eglDestroySyncKHR
> +eglExportDRMImageMESA
> +eglGetConfigAttrib
> +eglGetConfigs
> +eglGetCurrentContext
> +eglGetCurrentDisplay
> +eglGetCurrentSurface
> +eglGetDisplay
> +eglGetDRMDisplayMESA
> +eglGetError
> +eglGetModeAttribMESA
> +eglGetModesMESA
> +eglGetProcAddress
> +eglGetScreensMESA
> +eglGetSyncAttribKHR
> +eglInitialize
> +eglMakeCurrent
> +eglPostSubBufferNV
> +eglQueryAPI
> +eglQueryContext
> +eglQueryModeStringMESA
> +eglQueryScreenMESA
> +eglQueryScreenModeMESA
> +eglQueryScreenSurfaceMESA
> +eglQueryString
> +eglQuerySurface
> +eglQueryWaylandBufferWL
> +eglReleaseTexImage
> +eglReleaseThread
> +eglScreenPositionMESA
> +eglShowScreenSurfaceMESA
> +eglSignalSyncKHR
> +eglSurfaceAttrib
> +eglSwapBuffers
> +eglSwapBuffersRegionNOK
> +eglSwapBuffersWithDamageEXT
> +eglSwapInterval
> +eglTerminate
> +eglUnbindWaylandDisplayWL
> +eglWaitClient
> +eglWaitGL
> +eglWaitNative
> +_eglBindContext
> +_eglBindTexImage
> +_eglCheckResource
> +_eglCleanupDisplay
> +_eglCompareConfigs
> +_eglDestroyArray
> +_eglError
> +_eglFilterArray
> +_eglFilterConfigArray
> +_eglGetAPIContext
> +_eglGetCurrentContext
> +_eglGetCurrentThread
> +_eglGetResource
> +_eglInitConfig
> +_eglInitContext
> +_eglInitDriverFallbacks
> +_eglInitImage
> +_eglInitScreen
> +_eglInitSurface
> +_eglInitSync
> +_eglLinkConfig
> +_eglLinkScreen
> +_eglLog
> +_eglMatchConfig
> +_eglParseConfigAttribList
> +_eglParseImageAttribList
> +_eglPutResource
> +_eglReleaseDisplayResources
> +_eglSearchPathForEach
> +_eglSetLogLevel
> +_eglSetLogProc
> +_eglValidateConfig
> +_fini
> +_init
> +EOF
> +done)
> +
> +test ! -n "$FUNCS" || echo $FUNCS
> +test ! -n "$FUNCS"
> +
> 

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


Re: [Mesa-dev] [PATCH 00/22] Exported symbols cleanup and tests

2014-02-09 Thread Emil Velikov
On 10/02/14 01:24, Ian Romanick wrote:
>> > Before proceeding make sure that with-llvm-shared-libs is set, otherwise
>> > the modules will export every llvm symbol imaginable and make check will
>> > fail. The above option will default to enabled/with with mesa 10.1 and
>> > later once patch is commited.
> If the other option is selected, is it possible for 'make check' to not
> explode?  I haven't looked at the tests yet, so that may be a dumb question.
> 
With the above options set, everything will pass. Without it, every test
I've added will fail :]

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


Re: [Mesa-dev] [PATCH 11/22] egl: automake: add symbol test

2014-02-09 Thread Emil Velikov
On 10/02/14 01:26, Ian Romanick wrote:
> On 02/08/2014 08:03 AM, Emil Velikov wrote:
>> Signed-off-by: Emil Velikov 
>> ---
>>  src/egl/main/Makefile.am   |   2 +
>>  src/egl/main/egl-symbols-check | 109 
>> +
>>  2 files changed, 111 insertions(+)
>>  create mode 100755 src/egl/main/egl-symbols-check
>>
>> diff --git a/src/egl/main/Makefile.am b/src/egl/main/Makefile.am
>> index 46e890a..7d9748f 100644
>> --- a/src/egl/main/Makefile.am
>> +++ b/src/egl/main/Makefile.am
>> @@ -124,3 +124,5 @@ egl_HEADERS = \
>>  $(top_srcdir)/include/EGL/egl.h \
>>  $(top_srcdir)/include/EGL/eglmesaext.h \
>>  $(top_srcdir)/include/EGL/eglplatform.h
>> +
>> +TESTS = egl-symbols-check
>> \ No newline at end of file
> 
> Perhaps add a newline? :)
> 
>> diff --git a/src/egl/main/egl-symbols-check b/src/egl/main/egl-symbols-check
>> new file mode 100755
>> index 000..fc69369
>> --- /dev/null
>> +++ b/src/egl/main/egl-symbols-check
>> @@ -0,0 +1,109 @@
>> +#!/bin/bash
>> +
>> +# XXX: the private _egl* symbols are exported for egl backends like 
>> egl_gallium
>> +
>> +FUNCS=$(nm -D --defined-only ${1-.libs/libEGL.so} | grep -o "T .*" | cut -c 
>> 3- | while read func; do
>> +( grep -q "^$func$" || echo $func )  <> +eglBindAPI
>> +eglBindTexImage
>> +eglBindWaylandDisplayWL
>> +eglChooseConfig
>> +eglChooseModeMESA
>> +eglClientWaitSyncKHR
> 
> Are we supposed to export extension functions?  I thought that's what
> eglGetProcAddress was for... I'd swear there was an "implementer's
> guide" or some such from Khronos that gave some guidance here.
> 
Those are the functions we currently export, regardless of what the spec
says. I'll have to go through it and explicitly denote some of the
symbols, but I believe that this may brake ABI compatibility of existing
apps.

Turns out it was to get people looking in this direction :)

-Emil
>> +eglCopyBuffers
>> +eglCopyContextMESA
>> +eglCreateContext
>> +eglCreateDRMImageMESA
>> +eglCreateImageKHR
>> +eglCreatePbufferFromClientBuffer
>> +eglCreatePbufferSurface
>> +eglCreatePixmapSurface
>> +eglCreateScreenSurfaceMESA
>> +eglCreateSyncKHR
>> +eglCreateWaylandBufferFromImageWL
>> +eglCreateWindowSurface
>> +eglDestroyContext
>> +eglDestroyImageKHR
>> +eglDestroySurface
>> +eglDestroySyncKHR
>> +eglExportDRMImageMESA
>> +eglGetConfigAttrib
>> +eglGetConfigs
>> +eglGetCurrentContext
>> +eglGetCurrentDisplay
>> +eglGetCurrentSurface
>> +eglGetDisplay
>> +eglGetDRMDisplayMESA
>> +eglGetError
>> +eglGetModeAttribMESA
>> +eglGetModesMESA
>> +eglGetProcAddress
>> +eglGetScreensMESA
>> +eglGetSyncAttribKHR
>> +eglInitialize
>> +eglMakeCurrent
>> +eglPostSubBufferNV
>> +eglQueryAPI
>> +eglQueryContext
>> +eglQueryModeStringMESA
>> +eglQueryScreenMESA
>> +eglQueryScreenModeMESA
>> +eglQueryScreenSurfaceMESA
>> +eglQueryString
>> +eglQuerySurface
>> +eglQueryWaylandBufferWL
>> +eglReleaseTexImage
>> +eglReleaseThread
>> +eglScreenPositionMESA
>> +eglShowScreenSurfaceMESA
>> +eglSignalSyncKHR
>> +eglSurfaceAttrib
>> +eglSwapBuffers
>> +eglSwapBuffersRegionNOK
>> +eglSwapBuffersWithDamageEXT
>> +eglSwapInterval
>> +eglTerminate
>> +eglUnbindWaylandDisplayWL
>> +eglWaitClient
>> +eglWaitGL
>> +eglWaitNative
>> +_eglBindContext
>> +_eglBindTexImage
>> +_eglCheckResource
>> +_eglCleanupDisplay
>> +_eglCompareConfigs
>> +_eglDestroyArray
>> +_eglError
>> +_eglFilterArray
>> +_eglFilterConfigArray
>> +_eglGetAPIContext
>> +_eglGetCurrentContext
>> +_eglGetCurrentThread
>> +_eglGetResource
>> +_eglInitConfig
>> +_eglInitContext
>> +_eglInitDriverFallbacks
>> +_eglInitImage
>> +_eglInitScreen
>> +_eglInitSurface
>> +_eglInitSync
>> +_eglLinkConfig
>> +_eglLinkScreen
>> +_eglLog
>> +_eglMatchConfig
>> +_eglParseConfigAttribList
>> +_eglParseImageAttribList
>> +_eglPutResource
>> +_eglReleaseDisplayResources
>> +_eglSearchPathForEach
>> +_eglSetLogLevel
>> +_eglSetLogProc
>> +_eglValidateConfig
>> +_fini
>> +_init
>> +EOF
>> +done)
>> +
>> +test ! -n "$FUNCS" || echo $FUNCS
>> +test ! -n "$FUNCS"
>> +
>>
> 

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


Re: [Mesa-dev] [PATCH 1/3] i965: Duplicate less code in GetSamplePositions driver hook.

2014-02-09 Thread Chris Forbes
For the series:

Reviewed-by: Chris Forbes 

On Mon, Feb 10, 2014 at 1:56 PM, Kenneth Graunke  wrote:
> The 4x and 8x cases contained identical code for extracting the X and
> Y sample offset values and converting them from U0.4 back to float.
>
> Without this refactoring, we'd have to duplicate it a third time in
> order to support 2x MSAA.
>
> Signed-off-by: Kenneth Graunke 
> ---
>  src/mesa/drivers/dri/i965/gen6_multisample_state.c | 23 
> +++---
>  1 file changed, 12 insertions(+), 11 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/gen6_multisample_state.c 
> b/src/mesa/drivers/dri/i965/gen6_multisample_state.c
> index f28e880..fd3dd0e 100644
> --- a/src/mesa/drivers/dri/i965/gen6_multisample_state.c
> +++ b/src/mesa/drivers/dri/i965/gen6_multisample_state.c
> @@ -32,25 +32,26 @@ gen6_get_sample_position(struct gl_context *ctx,
>   struct gl_framebuffer *fb,
>   GLuint index, GLfloat *result)
>  {
> +   uint8_t bits;
> +
> switch (fb->Visual.samples) {
> case 1:
>result[0] = result[1] = 0.5f;
> +  return;
> +   case 4:
> +  bits = brw_multisample_positions_4x[0] >> (8 * index);
>break;
> -   case 4: {
> -  uint8_t val = (uint8_t)(brw_multisample_positions_4x[0] >> (8*index));
> -  result[0] = ((val >> 4) & 0xf) / 16.0f;
> -  result[1] = (val & 0xf) / 16.0f;
> -  break;
> -   }
> -   case 8: {
> -  uint8_t val = (uint8_t)(brw_multisample_positions_8x[index>>2] >> 
> (8*(index & 3)));
> -  result[0] = ((val >> 4) & 0xf) / 16.0f;
> -  result[1] = (val & 0xf) / 16.0f;
> +   case 8:
> +  bits = brw_multisample_positions_8x[index >> 2] >> (8 * (index & 3));
>break;
> -   }
> default:
>assert(!"Not implemented");
> +  return;
> }
> +
> +   /* Convert from U0.4 back to a floating point coordinate. */
> +   result[0] = ((bits >> 4) & 0xf) / 16.0f;
> +   result[1] = (bits & 0xf) / 16.0f;
>  }
>
>  /**
> --
> 1.8.5.2
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 11/22] egl: automake: add symbol test

2014-02-09 Thread Emil Velikov
On 10/02/14 01:35, Emil Velikov wrote:
> 
> Turns out it was to get people looking in this direction :)

s/it was/it was a nice idea/

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


Re: [Mesa-dev] [PATCH 1/2] gallium: add texture gather support to gallium

2014-02-09 Thread Dave Airlie
On Sat, Feb 8, 2014 at 10:22 PM, Christoph Bumiller
 wrote:
> On 07.02.2014 23:25, Dave Airlie wrote:
 Doh, yes because GL has ARB_texture_gather then has stuff hidden away
 in ARB_gpu_shader5 I forgot to add the extra bits which I suppose we 
 should do.

 So I've reposted with the component selection in src1 now.
>>> Hmm seems a bit excessive to use an extra reg for that (gather4 but only
>>> in d3d11 form uses a src_sel on the sampler reg, but that might not work).
>>> I realize this is actually more messy than I thought, since the initial
>>> ARB_texture_gather had the ability to query if multi-channel formats are
>>> allowed, but had no way to select the channel (somewhat relying on
>>> ARB_texture_swizzle to do it, though of course you can't issue multiple
>>> gathers with the same texture to get different channels that way).
>>> But glsl 4.00 version could select the channel.
>>> Is the ARB_texture_gather version actually all that useful or could you
>>> merge the two caps? That is, if you have the ability to fetch from
>>> multi-channel textures, assume you can also select the channel. The sm4
>>> version of gather4 also has the single-channel format restriction - I
>>> guess though some hw really can do 4 channels without channel selection.
>> Yeah I think I'll rethink this stuff, it looks like two caps, one for
>> MAX_COMPONENTS for ARB_texture_gather4, and just one cap for
>> TEXTURE_GATHER_SM5 support which would denote support for all the
>> ARB_GPU_shader5 bits.
>>
>>> Other than that, what about shadow samplers? Gather4 of course can't do
>>> it (because the d3d10-style opcodes have different opcodes for shadow
>>> comparisons), but the GL style opcodes are usually the same if shadow
>>> samplers or not are used. Maybe you don't want to handle that right now,
>>> just saying that if you'd want to use the same opcode you'd be missing a
>>> component in case of texture cube arrays... Since this can't be used for
>>> fixed function though I'd guess nothing would stop you from using a
>>> different opcode for shadow samplers.
>>
>> I've gotten shadow samplers to work with the current opcodes, though I
>> have to see about cube arrays if we have the running out of space to
>> put everything.
>>
>> Also the GPU_shader5 spec has a few more oddities, so you have
>> textureGatherOffset which can take a non-constant set of offset values
>> to apply to all 4 texels, then you have textureGatherOffsets which
>> only takes constants again, but 4 of them, one per texel. Looking at
>> radeon hw it appears fglrx decomposes textureGatherOffsets into
>> multiple gather instructions at the hw level but using the
>> non-constant hw support to do this. So I'm not sure if the gallium
>> interface should just support non-constant for all offsets and just
>> restrict the GL.
>
> Fwiw Fermi+ support 4 different non-constant offsets, since they're
> passed in a register anyway.
>

The problem with textureGatherOffsets is that it takes 4 constant offset pairs,
but it only samples for i0,j0 for each, unlike textureGather and
textureGatherOffset
which take a single offset and sample from the i0, j0->i1, j1.

So I'd really need to know if any hw can do this effectively, if so
we'd have to bake the
gallium TG4 instruction as being

a) no SM5 available - no component, no shadow, no non-consts, just
takes a single constant texture offset.

b) SM5 CAP available, shadow, component, single non-constant offset
gets i0,j0->i1,j1 behaviour, and multiple non-constant offsets get
i0,j0 behaviour.

We could in theory lower the textureGatherOffsets into 4
textureGatherOffset just sampling the i0,j0 of each and putting it
into a different channel of the dst and this is what AMD hw does
anyways, so I've done it in r600g. But maybe we could/should lower
this at a higher level, though to be honest I kinda suck at writing
lowering passes for GLSL or TGSI.

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


Re: [Mesa-dev] "glsl: Vectorize multiple scalar assignments" (mesa 4bd6e0d) breaks League of Legends on wine

2014-02-09 Thread Matt Turner
On Sat, Feb 8, 2014 at 5:29 AM, Andrew Guertin  wrote:
> On 02/08/2014 02:41 AM, Matt Turner wrote:
>>
>> On Fri, Feb 7, 2014 at 10:22 PM, Andrew Guertin 
>> wrote:
>>>
>>> Hi,
>>>
>>> I updated mesa and started getting some bad behavior in League of Legends
>>> (played through wine). After starting a game, upon hovering any of the
>>> skill
>>> buttons, instead of an info tooltip appearing, the whole screen is
>>> covered
>>> in grey. Some other problems are visible too, like the options menu
>>> missing
>>> most of its text.
>>>
>>> I bisected down to
>>>
>>> 4bd6e0d7c69b304be88996a6c2b96ce7d996e627 is the first bad commit
>>> commit 4bd6e0d7c69b304be88996a6c2b96ce7d996e627
>>> Author: Matt Turner 
>>> Date:   Sat Dec 21 11:28:05 2013 -0800
>>>
>>>  glsl: Vectorize multiple scalar assignments
>>>
>>>  Reduces vertex shader instruction counts in DOTA2 by 6.42%, L4D2 by
>>>  4.61%, and CS:GO by 5.71%.
>>>
>>>  total instructions in shared programs: 1500153 -> 1498191 (-0.13%)
>>>  instructions in affected programs: 59919 -> 57957 (-3.27%)
>>>
>>>  Reviewed-by: Ian Romanick 
>>>
>>>
>>> System info:
>>> CPU: i7-3770
>>> GPU: HD 4000
>>> Kernel: 3.12
>>>
>>> I am not subscribed to this mailing list, so please keep me cc'd.
>>>
>>> Thanks,
>>> --Andrew
>>
>>
>> Presumably you have the following commits on top of that, and none of
>> them affect it?
>>
>> 8e2b8bd0
>> 37f1903e
>> 60654421
>
>
> Yes, I was up to date with master when I first noticed this, probably
> 882e98e5, so all of those were included.
>
>
>> Could you send me (privately) or file a bug report with the output of
>> the game running with MESA_GLSL=dump ?
>
>
> I've just spent about an hour trying to do this and failing. I get none of
> the output when running League of Legends. I get output when running
> glxgears, and when running FurMark through wine, but none with LoL. I also
> tried MESA_GLSL=log, which again worked with FurMark but had no result with
> LoL.
>
> --Andrew

Okay. Maybe you can capture an apitrace that shows the problem? I'd be
able to extract the shaders from it.

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


Re: [Mesa-dev] [PATCH] R600/SI: Make sure M0 is always initialized when DS instructions are used

2014-02-09 Thread Michel Dänzer
On Fre, 2014-02-07 at 13:54 -0800, Tom Stellard wrote:
> On Fri, Feb 07, 2014 at 11:46:55AM +0900, Michel Dänzer wrote:
> > On Don, 2014-02-06 at 09:40 -0800, Tom Stellard wrote:
> > > From: Tom Stellard 
> > > 
> > > DS instructions that access local memory can only uses addresses that
> > > are less than or equal to the value of M0.  When M0 is uninitialized,
> > > then we experience undefined behavior.
> > 
> > [...]
> > 
> > > @@ -488,10 +490,6 @@ bool 
> > > SILowerControlFlowPass::runOnMachineFunction(MachineFunction &MF) {
> > >  
> > >  case AMDGPU::DS_READ_B32:
> > >NeedWQM = true;
> > > -  // Fall through
> > > -case AMDGPU::DS_WRITE_B32:
> > > -case AMDGPU::DS_ADD_U32_RTN:
> > > -  NeedM0 = true;
> > >break;
> > >  
> > >  case AMDGPU::V_INTERP_P1_F32:
> > 
> > It might make sense to set NeedWQM for all DS instructions as well. But
> > if you do that, please also fix the test at the end of this function to
> > only emit S_WQM_B64 for pixel shaders.
> 
> Sure, I can do that.

Thanks. BTW, feel free to do that in a separate change, of course. This
change is

Reviewed-by: Michel Dänzer 

as it is.


> Do we use LDS instructions at all for vertex or geometry shaders?

Not that I know of.


-- 
Earthling Michel Dänzer|  http://www.amd.com
Libre software enthusiast  |Mesa and X developer

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