Re: [Mesa-dev] [PATCH] GLSL: fix too eager constant variable optimization

2013-03-02 Thread Aras Pranckevicius
 Now, looking further this optimization pass should also not mark variables
 as const if there was a dereference of them before that first assignment. I
 had code to do this (a hashtable that would track dereferences before
 assignment is done). But couldn't come up with a test case that would break
 the whole set of optimizations that Mesa does (lower jumps, or inlining,
 ... were getting in the way and hide the bug).


 I'm not sure I agree with this.  The real problem with the example code
 you showed above is that there's an implicit write to the variable c at the
 top of the function, so c is not in fact constant--it's written twice.
 What we should really do is modify the optimization pass so that it's aware
 of the implicit write that happens in in and inout function args.
 If we resolve the implicit write issue, there should be no harm in marking
 variables as const if there's a dereference of them before the first
 assignment, because a dereference of a variable before the first assignment
 is undefined.


Right. I'm not sure what's the correct way of making constant variable pass
robust, all I know is that in it's current form it is clearly wrong.

If function arguments do get marked as one write, that effectively means
they will be excluded from actual optimization until the function is
inlined? Maybe that's okay, no sure.


-- 
Aras Pranckevičius
work: http://unity3d.com
home: http://aras-p.info
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/2] st/mesa: add switch case for ir_txf_ms to silence warning

2013-03-02 Thread Marek Olšák
On Sat, Mar 2, 2013 at 3:02 AM, Roland Scheidegger srol...@vmware.com wrote:
 Am 02.03.2013 01:36, schrieb Brian Paul:
 ---
  src/mesa/state_tracker/st_glsl_to_tgsi.cpp |3 +++
  1 files changed, 3 insertions(+), 0 deletions(-)

 diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
 b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
 index 8e3e3b8..c41b583 100644
 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
 +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
 @@ -2746,6 +2746,9 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir)
offset = this-result;
}
break;
 +   case ir_txf_ms:
 +  assert(!Unexpected ir_txf_ms opcode);
 +  break;
 }

 if (ir-projector) {


 Series looks good to me. I guess we need a new opcode like
 (TGSI_OPCODE_TXF_MS?), unless we switch everything over and only use the
 new sample style opcodes which already have that (SAMPLE_I_MS) :-).

Not sure if you noticed, but MSAA texturing has already been
implemented in Gallium [1][2] and some drivers (r600g, nouveau) for
quite some time. This opcode is implemented with TGSI_OPCODE_TXF and
the texture target set to TGSI_TEXTURE_2D_MSAA or
TGSI_TEXTURE_2D_ARRAY_MSAA. There are already sample shaders in
auxiliary/util/u_simple_shaders.c, which are used by u_blitter to blit
between two MSAA resources, which is required by glBlitFramebuffer
from GL_ARB_framebuffer_object.

Therefore, the MSAA texture support is somewhat required to fully
implement even the basic GL3.0 MSAA.

[1] 
http://cgit.freedesktop.org/mesa/mesa/commit/?id=dacf5dc9ac1a700b86e0dc385513afaff41e7aea
[2] 
http://cgit.freedesktop.org/mesa/mesa/commit/?id=825b45366d5308fd3e8e71c0c1943cb6ca8f69ea

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


[Mesa-dev] [Bug 59729] clover: Upstream LLVM removed LinkInFile member from class LLVM::Linker

2013-03-02 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=59729

Johannes Obermayr johannesoberm...@gmx.de changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #1 from Johannes Obermayr johannesoberm...@gmx.de ---
http://cgit.freedesktop.org/mesa/mesa/commit/?id=aa1c734b3ca445b5af743b9bad6a48ca7ba21f3c

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


[Mesa-dev] remove mfeatures.h, take two

2013-03-02 Thread Brian Paul
I've respun my remove-mfeatures branch as remove-mfeatures-2.  It's in 
my repo on freedesktop.org


This removes the mfeatures.h file and the last of the #ifdef FEATURE_x 
code from core Mesa.


Note, however, that the scons/makefiles still define FEATURE_GL, 
FEATURE_ES1, FEATURE_ES2, etc. because that controls whether some 
source files are built and in some places (like egl-static/egl_st.c) 
we need to test those symbols to avoid calling non-existant functions.


If a few people can test, that'd be great.

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


[Mesa-dev] [Bug 61395] glEdgeFlag can't be set to false

2013-03-02 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=61395

--- Comment #6 from Blaž Hrastnik speed.the.b...@gmail.com ---
Brian, has the patch been merged yet?

-- 
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 61361] Version mismatch error. This is libtool 2.4.2, but the definition of this LT_INIT comes from libtool 2.2.8.

2013-03-02 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=61361

--- Comment #8 from Dennis Heuer dh-b...@online.de ---
found the log:

src/glsl/test-suite.log

=
   Mesa 9.2.0: src/glsl/test-suite.log
=

# TOTAL: 4
# PASS:  3
# SKIP:  0
# XFAIL: 0
# FAIL:  1
# XPASS: 0
# ERROR: 0

.. contents:: :depth: 2

FAIL: glcpp/tests/glcpp-test


== Testing for correctness ==
Testing ./glcpp/tests/000-content-with-spaces.c/glcpp/tests/glcpp-test: 64:
arith: syntax error: total+1

-- 
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 59187] [Steam] Implement GLSL 1.30 (for older chipsets than SandyBridge)

2013-03-02 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=59187

imamdxl8...@gmail.com changed:

   What|Removed |Added

 CC||imamdxl8...@gmail.com

-- 
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 59187] [Steam] Implement GLSL 1.30 (for older chipsets than SandyBridge)

2013-03-02 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=59187

--- Comment #10 from imamdxl8...@gmail.com ---
I would like to see this on my Intel GMA 4500, that would be great

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


Re: [Mesa-dev] r600g: status of my work on the shader optimization

2013-03-02 Thread Vadim Girlin

On 03/02/2013 10:06 AM, Sebastien Caty wrote:

On March 1, 2013 06:24:01 PM Matt Turner wrote:

On Fri, Mar 1, 2013 at 5:15 PM, Sebastien Caty sc...@dcinformatique.com

wrote:

Trying to dig more and found out which shader is causing trouble but I
haven't found out how to run a specific test with piglit. Documentation
isn't to friendly...Id appreciate some help with this.


If you click the test {pass,fail,crash} in the generated html summary
it will contain the command used to run the test.


Doh! Thanks that will do. All the piglit regression I had found so far pass
when I run them alone, one by one.

Went back to Serious Sam 3 to isolate a shader that's causing problems. Found
one, shader 35. I get several errors like this :

error at : DOT4 __,t113@R14.x, t114F@R125.x
   : expected operand value t113@R14.x, gpr contains R11.x.3||FP@R14.x
error at : DOT4 __,t85@R14.x, t86F@R124.x
   : expected operand value t85@R14.x, gpr contains R11.x.3||FP@R14.x
error at : DOT4 __,t87@R13.y, t88F@R124.y
   : expected operand value t87@R13.y, gpr contains R12.x.5||FP@R13.y


I've pushed the fix for this issue.

Vadim


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


[Mesa-dev] [PATCH v2 3/5] gallium: Implement DRIimageExtension.duplicateImage

2013-03-02 Thread John Kåre Alsaker
---
 src/gallium/include/state_tracker/st_api.h |  1 +
 src/gallium/state_trackers/dri/common/dri_screen.c |  1 +
 src/gallium/state_trackers/dri/common/dri_screen.h |  1 +
 src/gallium/state_trackers/dri/drm/dri2.c  | 39 +-
 src/mesa/state_tracker/st_manager.c|  4 +++
 5 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/src/gallium/include/state_tracker/st_api.h 
b/src/gallium/include/state_tracker/st_api.h
index 9f3d2a1..1e63ed3 100644
--- a/src/gallium/include/state_tracker/st_api.h
+++ b/src/gallium/include/state_tracker/st_api.h
@@ -203,6 +203,7 @@ struct st_egl_image
 {
/* this is owned by the caller */
struct pipe_resource *texture;
+   enum pipe_format format;
 
unsigned level;
unsigned layer;
diff --git a/src/gallium/state_trackers/dri/common/dri_screen.c 
b/src/gallium/state_trackers/dri/common/dri_screen.c
index a908e28..92abaf9 100644
--- a/src/gallium/state_trackers/dri/common/dri_screen.c
+++ b/src/gallium/state_trackers/dri/common/dri_screen.c
@@ -315,6 +315,7 @@ dri_get_egl_image(struct st_manager *smapi,
 
stimg-texture = NULL;
pipe_resource_reference(stimg-texture, img-texture);
+   stimg-format = img-format;
stimg-level = img-level;
stimg-layer = img-layer;
 
diff --git a/src/gallium/state_trackers/dri/common/dri_screen.h 
b/src/gallium/state_trackers/dri/common/dri_screen.h
index 181b22f..d37c393 100644
--- a/src/gallium/state_trackers/dri/common/dri_screen.h
+++ b/src/gallium/state_trackers/dri/common/dri_screen.h
@@ -84,6 +84,7 @@ dri_screen(__DRIscreen * sPriv)
 
 struct __DRIimageRec {
struct pipe_resource *texture;
+   enum pipe_format format;
unsigned level;
unsigned layer;
uint32_t dri_format;
diff --git a/src/gallium/state_trackers/dri/drm/dri2.c 
b/src/gallium/state_trackers/dri/drm/dri2.c
index f8d311c..54339fe 100644
--- a/src/gallium/state_trackers/dri/drm/dri2.c
+++ b/src/gallium/state_trackers/dri/drm/dri2.c
@@ -658,6 +658,7 @@ dri2_dup_image(__DRIimage *image, void *loaderPrivate)
pipe_resource_reference(img-texture, image-texture);
img-level = image-level;
img-layer = image-layer;
+   img-format = image-format;
/* This should be 0 for sub images, but dup is also used for base images. */
img-dri_components = image-dri_components;
img-loader_private = loaderPrivate;
@@ -749,6 +750,40 @@ dri2_from_planar(__DRIimage *image, int plane, void 
*loaderPrivate)
return img;
 }
 
+static __DRIimage *
+dri2_duplicate_image(__DRIscreen *_screen, __DRIimage *image,
+ unsigned int flags, void *loaderPrivate)
+{
+   enum pipe_format format;
+   struct dri_screen *screen = dri_screen(_screen);
+   __DRIimage *img = NULL;
+
+   if((flags  __DRI_IMAGE_FLAG_SRGB_VIEW)  (flags  
__DRI_IMAGE_FLAG_LINEAR_VIEW))
+  return NULL;
+
+   if(flags  (__DRI_IMAGE_FLAG_SRGB_VIEW | __DRI_IMAGE_FLAG_LINEAR_VIEW)) {
+  if(!image-texture)
+ return NULL;
+
+  if(flags  __DRI_IMAGE_FLAG_SRGB_VIEW)
+ format = util_format_srgb(image-texture-format);
+  else
+ format = util_format_linear(image-texture-format);
+
+  if(!screen-base.screen-is_format_supported(screen-base.screen, 
format, PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW))
+ return NULL;
+
+  img = dri2_dup_image(image, loaderPrivate);
+
+  if (img)
+ img-format = format;
+   } else if (flags == 0) {
+  img = dri2_dup_image(image, loaderPrivate);
+   }
+
+   return img;
+}
+
 static void
 dri2_destroy_image(__DRIimage *img)
 {
@@ -757,7 +792,7 @@ dri2_destroy_image(__DRIimage *img)
 }
 
 static struct __DRIimageExtensionRec dri2ImageExtension = {
-{ __DRI_IMAGE, 5 },
+{ __DRI_IMAGE, 7 },
 dri2_create_image_from_name,
 dri2_create_image_from_renderbuffer,
 dri2_destroy_image,
@@ -767,6 +802,8 @@ static struct __DRIimageExtensionRec dri2ImageExtension = {
 dri2_validate_usage,
 dri2_from_names,
 dri2_from_planar,
+NULL,
+dri2_duplicate_image,
 };
 
 /*
diff --git a/src/mesa/state_tracker/st_manager.c 
b/src/mesa/state_tracker/st_manager.c
index a3a6771..3659499 100644
--- a/src/mesa/state_tracker/st_manager.c
+++ b/src/mesa/state_tracker/st_manager.c
@@ -810,6 +810,10 @@ st_manager_get_egl_image_surface(struct st_context *st, 
void *eglimg)
   return NULL;
 
u_surface_default_template(surf_tmpl, stimg.texture);
+
+   if(stimg.format != PIPE_FORMAT_NONE)
+  surf_tmpl.format = stimg.format;
+
surf_tmpl.u.tex.level = stimg.level;
surf_tmpl.u.tex.first_layer = stimg.layer;
surf_tmpl.u.tex.last_layer = stimg.layer;
-- 
1.8.1.4

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


[Mesa-dev] [PATCH v2 4/5] egl: Add MESA_image_sRGB extension.

2013-03-02 Thread John Kåre Alsaker
This gives applications access to use DRIimage.duplicateImage to create
sRGB and linear views from EGL images.
---
 include/EGL/eglmesaext.h|   7 ++
 src/egl/drivers/dri2/egl_dri2.c | 168 
 src/egl/drivers/dri2/egl_dri2.h |   6 +-
 src/egl/drivers/dri2/platform_android.c |  36 +++
 src/egl/drivers/dri2/platform_drm.c |  36 +++
 src/egl/drivers/dri2/platform_x11.c |  37 +++
 src/egl/main/eglcurrent.c   |   3 +
 src/egl/main/egldisplay.h   |   1 +
 src/egl/main/eglimage.c |   6 ++
 src/egl/main/eglimage.h |   3 +
 src/egl/main/eglmisc.c  |   1 +
 11 files changed, 173 insertions(+), 131 deletions(-)

diff --git a/include/EGL/eglmesaext.h b/include/EGL/eglmesaext.h
index d476d18..59f903a 100644
--- a/include/EGL/eglmesaext.h
+++ b/include/EGL/eglmesaext.h
@@ -109,6 +109,13 @@ typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETDRMDISPLAYMESA) 
(int fd);
 #endif
 #endif
 
+#ifndef EGL_MESA_image_sRGB
+#define EGL_MESA_image_sRGB 1
+#define EGL_GAMMA_MESA 0x3290 /* eglCreateImageKHR attribute */
+#define EGL_DEFAULT_MESA 0x3291
+#define EGL_BAD_VIEW_MESA 0x3292
+#endif
+
 #ifndef EGL_WL_bind_wayland_display
 #define EGL_WL_bind_wayland_display 1
 
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index b774919..9e0658f 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -507,6 +507,10 @@ dri2_setup_screen(_EGLDisplay *disp)
  disp-Extensions.KHR_gl_texture_2D_image = EGL_TRUE;
  disp-Extensions.KHR_gl_texture_cubemap_image = EGL_TRUE;
   }
+  if (dri2_dpy-image-base.version = 7 
+  dri2_dpy-image-duplicateImage) {
+ disp-Extensions.MESA_image_sRGB = EGL_TRUE;
+  }
}
 }
 
@@ -1077,9 +1081,52 @@ dri2_release_tex_image(_EGLDriver *drv,
return EGL_TRUE;
 }
 
-static _EGLImage *
-dri2_create_image(_EGLDisplay *disp, __DRIimage *dri_image)
+static EGLBoolean
+dri2_process_dri_image(_EGLDisplay *disp, __DRIimage **dri_image,
+  const _EGLImageAttribs *attrs)
+{
+   struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+   __DRIimage *result;
+
+   if (attrs-GammaMESA == EGL_DEFAULT_MESA) {
+  return EGL_TRUE;
+   }
+
+   if(!disp-Extensions.MESA_image_sRGB) {
+  goto bad_view;
+   }
+
+   if (attrs-GammaMESA != EGL_COLORSPACE_sRGB 
+   attrs-GammaMESA != EGL_COLORSPACE_LINEAR) {
+  goto bad_view;
+   }
+
+   result = dri2_dpy-image-duplicateImage(dri2_dpy-dri_screen,
+  *dri_image,
+  attrs-GammaMESA == EGL_COLORSPACE_sRGB ?
+ __DRI_IMAGE_FLAG_SRGB_VIEW :
+ __DRI_IMAGE_FLAG_LINEAR_VIEW, NULL);
+
+   if (result == NULL) {
+  goto bad_view;
+   }
+
+   dri2_dpy-image-destroyImage(*dri_image);
+
+   *dri_image = result;
+
+   return EGL_TRUE;
+
+bad_view:
+   _eglError(EGL_BAD_VIEW_MESA, dri2_create_image);
+   return EGL_FALSE;
+}
+
+_EGLImage *
+dri2_create_image(_EGLDisplay *disp, __DRIimage *dri_image,
+  const _EGLImageAttribs *attrs)
 {
+   struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
struct dri2_egl_image *dri2_img;
 
if (dri_image == NULL) {
@@ -1087,26 +1134,35 @@ dri2_create_image(_EGLDisplay *disp, __DRIimage 
*dri_image)
   return NULL;
}
 
+   if (!dri2_process_dri_image(disp, dri_image, attrs)) {
+  goto error;
+   }
+
dri2_img = malloc(sizeof *dri2_img);
if (!dri2_img) {
   _eglError(EGL_BAD_ALLOC, dri2_create_image);
-  return NULL;
+  goto error;
}
 
if (!_eglInitImage(dri2_img-base, disp)) {
+  _eglError(EGL_BAD_ALLOC, dri2_create_image);
   free(dri2_img);
-  return NULL;
+  goto error;
}
 
dri2_img-dri_image = dri_image;
 
return dri2_img-base;
+
+error:
+   dri2_dpy-image-destroyImage(dri_image);
+   return NULL;
 }
 
 static _EGLImage *
 dri2_create_image_khr_renderbuffer(_EGLDisplay *disp, _EGLContext *ctx,
   EGLClientBuffer buffer,
-  const EGLint *attr_list)
+  const _EGLImageAttribs *attrs)
 {
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
struct dri2_egl_context *dri2_ctx = dri2_egl_context(ctx);
@@ -1122,35 +1178,31 @@ 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(disp, dri_image, attrs);
 }
 
 static _EGLImage *
 dri2_create_image_mesa_drm_buffer(_EGLDisplay *disp, _EGLContext *ctx,
- EGLClientBuffer buffer, const EGLint 
*attr_list)
+ EGLClientBuffer buffer,
+ 

[Mesa-dev] [PATCH v2 piglit 5/5] egl: Add test for MESA_image_srgb

2013-03-02 Thread John Kåre Alsaker
---
 tests/egl/CMakeLists.gl.txt |   2 +
 tests/egl/egl-mesa-image-srgb.c | 111 
 2 files changed, 113 insertions(+)
 create mode 100644 tests/egl/egl-mesa-image-srgb.c

diff --git a/tests/egl/CMakeLists.gl.txt b/tests/egl/CMakeLists.gl.txt
index 03b2ae0..7d163ab 100644
--- a/tests/egl/CMakeLists.gl.txt
+++ b/tests/egl/CMakeLists.gl.txt
@@ -16,6 +16,8 @@ IF(${CMAKE_SYSTEM_NAME} MATCHES Linux)
target_link_libraries(egl-nok-swap-region pthread ${X11_X11_LIB})
piglit_add_executable (egl-nok-texture-from-pixmap egl-util.c 
egl-nok-texture-from-pixmap.c)
target_link_libraries(egl-nok-texture-from-pixmap pthread 
${X11_X11_LIB})
+   piglit_add_executable (egl-mesa-image-srgb egl-util.c 
egl-mesa-image-srgb.c)
+   target_link_libraries(egl-mesa-image-srgb pthread ${X11_X11_LIB})
piglit_add_executable (egl-create-surface egl-util.c 
egl-create-surface.c)
target_link_libraries(egl-create-surface pthread ${X11_X11_LIB})
piglit_add_executable (egl-query-surface egl-util.c egl-query-surface.c)
diff --git a/tests/egl/egl-mesa-image-srgb.c b/tests/egl/egl-mesa-image-srgb.c
new file mode 100644
index 000..4e04be4
--- /dev/null
+++ b/tests/egl/egl-mesa-image-srgb.c
@@ -0,0 +1,111 @@
+/*
+ * Copyright © 2010 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.
+ *
+ * Authors:
+ *John Kåre Alsaker john.kare.alsa...@gmail.com
+ *Kristian Høgsberg k...@bitplanet.net
+ */
+
+/** @file egl-mesa-image-srgb.c
+ *
+ * Test EGL_MESA_image_sRGB
+ */
+
+#include piglit-util-gl-common.h
+#include egl-util.h
+
+#if defined(EGL_MESA_image_sRGB)  defined(EGL_KHR_image_pixmap)
+
+const char *extensions[] = { EGL_MESA_image_sRGB, EGL_KHR_image_pixmap, 
NULL };
+
+static const EGLint default_attribs[] = {
+   EGL_GAMMA_MESA, EGL_DEFAULT_MESA,
+   EGL_NONE
+};
+
+static const EGLint bad_attribs[] = {
+   EGL_GAMMA_MESA, EGL_BAD_ATTRIBUTE,
+   EGL_NONE
+};
+
+static enum piglit_result
+draw(struct egl_state *state)
+{
+   Pixmap pixmap;
+   EGLImageKHR img;
+   PFNEGLCREATEIMAGEKHRPROC create_image_khr;
+
+   create_image_khr = (PFNEGLCREATEIMAGEKHRPROC)
+   eglGetProcAddress(eglCreateImageKHR);
+
+   if (create_image_khr == NULL) {
+   fprintf(stderr, could not getproc eglCreateImageKHR);
+   piglit_report_result(PIGLIT_FAIL);
+   }
+
+   pixmap = XCreatePixmap(state-dpy, state-win, 1, 1, state-depth);
+
+   img = create_image_khr(state-egl_dpy, state-ctx,
+ EGL_NATIVE_PIXMAP_KHR,
+ (EGLClientBuffer)pixmap,
+ default_attribs);
+   if (!img) {
+   fprintf(stderr, default view eglCreateImageKHR() failed\n);
+   piglit_report_result(PIGLIT_FAIL);
+   }
+
+   img = create_image_khr(state-egl_dpy, state-ctx,
+ EGL_NATIVE_PIXMAP_KHR,
+ (EGLClientBuffer)pixmap,
+ bad_attribs);
+
+   if (img || (eglGetError() != EGL_BAD_VIEW_MESA)) {
+   fprintf(stderr, unsupported view eglCreateImageKHR() 
failed\n);
+   piglit_report_result(PIGLIT_FAIL);
+   }
+
+   return PIGLIT_PASS;
+}
+
+int
+main(int argc, char *argv[])
+{
+   struct egl_test test;
+
+   egl_init_test(test);
+   test.extensions = extensions;
+   test.draw = draw;
+
+   return egl_util_run(test, argc, argv);
+}
+
+#else
+
+int
+main(int argc, char *argv[])
+{
+   piglit_report_result(PIGLIT_SKIP);
+
+   return 0;
+}
+
+#endif
-- 
1.8.1.4

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


[Mesa-dev] [PATCH v2 2/5 fixed] dri: Add another duplicateImage to DRIimageExtension

2013-03-02 Thread John Kåre Alsaker
duplicateImage will allow you to create a linear or sRGB view into a
DRIimage you have access to. This is useful because compositors may want
a specific view which doesn't correspond to the one used by
applications.
---
 include/GL/internal/dri_interface.h | 20 +++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/include/GL/internal/dri_interface.h 
b/include/GL/internal/dri_interface.h
index 42147e9..2921293 100644
--- a/include/GL/internal/dri_interface.h
+++ b/include/GL/internal/dri_interface.h
@@ -938,7 +938,7 @@ struct __DRIdri2ExtensionRec {
  * extensions.
  */
 #define __DRI_IMAGE DRI_IMAGE
-#define __DRI_IMAGE_VERSION 6
+#define __DRI_IMAGE_VERSION 7
 
 /**
  * These formats correspond to the similarly named MESA_FORMAT_*
@@ -1009,6 +1009,15 @@ struct __DRIdri2ExtensionRec {
 #define __DRI_IMAGE_COMPONENTS_Y_UV0x3004
 #define __DRI_IMAGE_COMPONENTS_Y_XUXV  0x3005
 
+/**
+ * Flags for duplicateImage.
+ *
+ * \since 7
+ */
+
+#define __DRI_IMAGE_FLAG_SRGB_VIEW 0x0001
+#define __DRI_IMAGE_FLAG_LINEAR_VIEW   0x0002
+
 
 /**
  * queryImage attributes
@@ -1117,6 +1126,15 @@ struct __DRIimageExtensionRec {
  int level,
  unsigned *error,
  void *loaderPrivate);
+
+   /**
+* The new __DRIimage will share the raw content with the old one,
+* but it might have a different format.
+*
+* \since 7
+*/
+__DRIimage *(*duplicateImage)(__DRIscreen *screen, __DRIimage *image,
+  unsigned int flags, void *loaderPrivate);
 };
 
 
-- 
1.8.1.4

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