Re: xwayland + radeon = consistent filesystem corruption Re: I'm the only one getting hard drive errors, right?

2012-09-03 Thread Michel Dänzer
On Mon, 2012-09-03 at 15:15 -0400, dar...@chaosreigns.com wrote: 
> 
> I had the latest get masters of everything as of 2012-09-03 08:36 -0400.  
> weston commit 8538b22ff4ad8879b4e3288be053508167562859
> wayland commit 2be6e0ed142bac669398a9ad26d33fa53216
> raof's xf86-video-ati xwayland branch commit 
> 8dc07e63eaf8909f7046bf746a119ec749352441

What about Mesa, the kernel and libdrm?


-- 
Earthling Michel Dänzer   |   http://www.amd.com
Libre software enthusiast |  Debian, X and DRI developer
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH] Wayland X server uses xwayand.conf instead of xorg.conf

2012-09-03 Thread Pekka Paalanen
On Mon, 03 Sep 2012 13:36:47 -0700
Bill Spitzak  wrote:

> I think changing the name at the lowest level as I did it is the correct 
> solution. I see no way anybody can use this unless they can tell the x 
> server to ignore any existing xorg.conf file. Changing it at the final 
> program seems much cleaner than requiring every wrapping program to pass 
> a --config switch.

Btw. did you ever test that your config name changes work also with
config dirs, like /etc/X11/xorg.conf.d/?

Don't take this as on opinion about what is the right approach, only
X.org server devs can take a stand (i.e. the discussion should be cc'd
to the appropriate mailing list). This is just a detail that came to my
mind.


Thanks,
pq
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH] Wayland X server uses xwayand.conf instead of xorg.conf

2012-09-03 Thread Bill Spitzak

On 08/31/2012 06:31 PM, Scott Moreau wrote:

Perhaps an immediate solution would be to allow a way to pass an option
to weston containing the path to search for the config file or an
absolute /path/to/config/file.name . Weston would in
turn parse this and pass it as an arg to the xwayland server.


This is certainly possible, but all that is going to happen is that 
weston-launch will have to pass the switch. And then we will have to 
tell people they must provide the switch to weston-launch.


I think changing the name at the lowest level as I did it is the correct 
solution. I see no way anybody can use this unless they can tell the x 
server to ignore any existing xorg.conf file. Changing it at the final 
program seems much cleaner than requiring every wrapping program to pass 
a --config switch.




___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: How to debug the xserver?

2012-09-03 Thread Bill Spitzak

On 09/02/2012 11:06 PM, Scott Moreau wrote:

On Mon, Sep 3, 2012 at 12:01 AM, Bill Spitzak mailto:spit...@gmail.com>> wrote:

On 08/31/2012 05:03 AM, Tiago Vignatti wrote:

you need to update your xtrans library:

http://lists.freedesktop.org/__archives/wayland-devel/2012-__August/005157.html




I tried guessing at the name of the git repository but am not having
much luck in figuring this out. Can you supply some more hints on
how I get the updated xtrans library?


The repo is here git://anongit.freedesktop.org/xorg/lib/libxtrans

http://cgit.freedesktop.org/xorg/lib/libxtrans


Thanks, it seems to be working now.

For X I'm getting a lot of black windows that only occasionally update, 
drawing pieces of their contents as those areas are drawn. Also if you 
try to resize the top edge of the window it instead resizes as though 
you are moving the bottom edge in the opposite direction. There also 
isn't any close box or other toytoolkit decorations. I assume these are 
all known bugs but want to make sure they are not some problem with my 
version?



___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


xwayland + radeon = consistent filesystem corruption Re: I'm the only one getting hard drive errors, right?

2012-09-03 Thread darxus
[732715.730069] EXT4-fs error (device sda1): ext4_ext_search_left:1275: inode 
#21374007: comm flush-8:0: ix (10742) != EXT_FIRST_INDEX (0) (depth 1)!
[732715.730084] Aborting journal on device sda1-8.
[732715.730269] EXT4-fs (sda1): Remounting filesystem read-only
[732715.730278] EXT4-fs error (device sda1) in ext4_da_writepages:3033: IO 
failure
[732715.730440] EXT4-fs (sda1): ext4_da_writepages: jbd2_start: 589 pages, ino 
21374007; err -30

This hasn't happened in three months.  The last time I saw it was the
last time I ran xwayland.  While correlation does not imply causation,
and it *could* be a coincidence, I'm really not willing to entertain
that possibility as realistic.

This time I used RAOF's X DDX (and updated the xwayland instructions
for Radeon / ATI to use it).  Last time I was using timon37's DDX.  I don't
know if they share code.  I don't know if they're at fault.

I was using the DRM backend.  I ran "make install" as a non-root user, and
then set weston-launch as owned by root and +s, and ran weston-launch.  I
did not have xserver set suid root.

I was playing a video on youtube in chromium vix xwayland when X crashed
(taking firefox, the only other X client I was running, out with it.)
And was chatting with folks in IRC about X's failure to respawn when I
realized my filesystem had been remounted readonly.  Then dug the above
output out of dmesg.

I was working on updating my "state of wayland" page to say that wayland
was looking pretty usable now :/

fsck said lots of scary things after rebooting, I had to manually confirm
it wanted to do many of them.  I have photos if anyone is interested
in details.  Lots of "Free blocks count wrong for group... Fix(y)?" and
"Free inodes count wrong for group... Fix(y)?"  A "Block bitmap
differences..."

I don't know for sure if I lost anything, but have not yet
seen evidence that I did.  I have pretty good backups.


12:15 < pq> either xwayland triggers some fs bug, or triggers a gfx driver
bug, which then scribbles over kernel memory - or faulty hw. Can't know.
12:16 < soreau> either way, it's a fairly serious problem

I agree with this assessment.


So far, I think it has only affected the filesystem I was using at the time
(I basically only use one partition per linux install).  So I may be
willing to do more testing on a dedicated testing partition.

This graphics card needed to go on ubuntu's grub gfxpayload blacklist,
because for some reason retaining the graphics mode from grub to X breaks
on some graphics cards, including this one.  Seems unlikely to be directly
related, just trying to provide all possibly relevant info I have.  The bug
for this was:  https://bugs.launchpad.net/ubuntu/+source/linux/+bug/971204

I was running an up to date ubuntu oneric install.  

lspci output:

05:00.0 VGA compatible controller: Advanced Micro Devices [AMD] nee ATI Barts 
XT [Radeon HD 6800 Series] (prog-if 00 [VGA controller])
Subsystem: Hightech Information System Ltd. Device 2010
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- 
Stepping- SERR+ FastB2B- DisINTx+
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- SERR- 
Kernel driver in use: radeon
Kernel modules: radeon


I had the latest get masters of everything as of 2012-09-03 08:36 -0400.  
weston commit 8538b22ff4ad8879b4e3288be053508167562859
wayland commit 2be6e0ed142bac669398a9ad26d33fa53216
raof's xf86-video-ati xwayland branch commit 
8dc07e63eaf8909f7046bf746a119ec749352441

On 05/30, dar...@chaosreigns.com wrote:
> I was just playing with weston master under X, and timon37's radeon ddx,
> weston crashed, when I tried to delete the wayland lock I got an error
> that the filesystem was readonly, dmesg said:
> 
> [  496.347230] EXT4-fs error (device sda1): ext4_ext_search_left:1275: inode 
> #21374007: comm flush-8:0:ix (10742) != EXT_FIRST_INDEX (0) (depth 1)!
> [  496.347236] Aborting journal on device sda1-8.
> [  496.347383] EXT4-fs (sda1): Remounting filesystem read-only
> 
> Which is pretty scary.  
> 
> I feel like this *might* have happened before when I was playing with
> weston, but I definitely don't have enough information to suggest there is
> any real correlation.  Or knowledge of what exactly is going on here to
> know if a correlation is even possible.
> 
> I had xserver set suid root, out of habit from before I fixed the bug
> complaining about not getting master, which seems like it might have made
> something like this possible.  
> 
> I do have good backups.  

-- 
"If you would be a real seeker after truth, it is necessary that at
least once in your life you doubt, as far as possible, all things."
- Rene Descartes
http://www.ChaosReigns.com
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston] compositor: Fix xwayland surface alpha.

2012-09-03 Thread Scott Moreau
>
>
> NAK, I'm developing a proper fix, that removes
> weston_surface::opaque_rect completely.
>
> Now that we can paint opaque regions independently from non-opaques, we
> can set the shader for opaque regions to the RGBX shader, which forces
> the sampled alpha to 1.0. That way we can keep the shaders simple.
>
>
> Thanks,
> pq
>

Yes, this is the proper fix. It will start something like this, sans the
needed shader usage. Thanks for fixing it up Pekaa.

Scott



diff --git a/src/compositor.c b/src/compositor.c
index 9ce44d4..5e9a0c2 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -243,10 +243,6 @@ weston_surface_create(struct weston_compositor *compositor)

surface->compositor = compositor;
surface->alpha = 1.0;
-   surface->opaque_rect[0] = 0.0;
-   surface->opaque_rect[1] = 0.0;
-   surface->opaque_rect[2] = 0.0;
-   surface->opaque_rect[3] = 0.0;
surface->pitch = 1;

surface->num_textures = 0;
diff --git a/src/compositor.h b/src/compositor.h
index 96a0477..38c2657 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -399,7 +399,6 @@ struct weston_surface {
struct wl_list layer_link;
struct weston_shader *shader;
GLfloat color[4];
-   GLfloat opaque_rect[4];
GLfloat alpha;
struct weston_plane *plane;

diff --git a/src/xwayland/window-manager.c b/src/xwayland/window-manager.c
index e705fec..d960185 100644
--- a/src/xwayland/window-manager.c
+++ b/src/xwayland/window-manager.c
@@ -720,14 +720,8 @@ weston_wm_window_draw_decoration(void *data)
/* We leave an extra pixel around the X window area to
 * make sure we don't sample from the undefined alpha
 * channel when filtering. */
-   window->surface->opaque_rect[0] =
-   (double) (x - 1) / width;
-   window->surface->opaque_rect[1] =
-   (double) (x + window->width + 1) / width;
-   window->surface->opaque_rect[2] =
-   (double) (y - 1) / height;
-   window->surface->opaque_rect[3] =
-   (double) (y + window->height + 1) / height;
+   pixman_region32_init_rect(&window->surface->opaque, x - 1, y - 
1,
+   window->width + 1, window->height + 1);

pixman_region32_init_rect(&window->surface->input,
  t->margin, t->margin,
@@ -743,10 +737,8 @@ weston_wm_window_schedule_repaint(struct
weston_wm_window *window)

if (window->frame_id == XCB_WINDOW_NONE) {
if (window->surface != NULL) {
-   window->surface->opaque_rect[0] = 0.0;
-   window->surface->opaque_rect[1] = 1.0;
-   window->surface->opaque_rect[2] = 0.0;
-   window->surface->opaque_rect[3] = 1.0;
+   pixman_region32_init_rect(&window->surface->opaque,
+   0, 0, window->width, window->height);
}
return;
}
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 2/3] compositor: paint opaque regions with RGBX shader

2012-09-03 Thread Pekka Paalanen
weston_surface_draw() is restructured so that it will always use the
RGBX shader for opaque regions, if the surface is assigned the RGBA
shader.

Previously for opaque regions, we simply assumed, that the texture alpha
would be 1.0. If it was not (which really is an application bug), the
region would be misrendered. The RGBX shader forces the texture alpha to
1.0.

Xwayland surfaces may have bad alpha data in the opaque client area. If
blending was enabled, the bad alpha would be used with the RGBA shader.
This patch fixes rendering opaque xwayland windows with full-surface
alpha applied.

Test case: xterm, with full-surface alpha one step below 1.0. Before,
black text was fully transparent, now it is correctly only slightly
transparent.

Signed-off-by: Pekka Paalanen 
---
 src/compositor.c |   74 ++
 1 files changed, 52 insertions(+), 22 deletions(-)

diff --git a/src/compositor.c b/src/compositor.c
index 5e9a0c2..918b455 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -1317,6 +1317,32 @@ repaint_region(struct weston_surface *es, 
pixman_region32_t *region,
ec->vtxcnt.size = 0;
 }
 
+static void
+weston_compositor_use_shader(struct weston_compositor *compositor,
+struct weston_shader *shader)
+{
+   if (compositor->current_shader == shader)
+   return;
+
+   glUseProgram(shader->program);
+   compositor->current_shader = shader;
+}
+
+static void
+weston_shader_uniforms(struct weston_shader *shader,
+  struct weston_surface *surface,
+  struct weston_output *output)
+{
+   int i;
+
+   glUniformMatrix4fv(shader->proj_uniform,
+  1, GL_FALSE, output->matrix.d);
+   glUniform4fv(shader->color_uniform, 1, surface->color);
+   glUniform1f(shader->alpha_uniform, surface->alpha);
+
+   for (i = 0; i < surface->num_textures; i++)
+   glUniform1i(shader->tex_uniforms[i], i);
+}
 
 WL_EXPORT void
 weston_surface_draw(struct weston_surface *es, struct weston_output *output,
@@ -1331,8 +1357,6 @@ weston_surface_draw(struct weston_surface *es, struct 
weston_output *output,
int i;
 
pixman_region32_init(&repaint);
-   pixman_region32_init(&surface_blend);
-
pixman_region32_intersect(&repaint,
  &es->transform.boundingbox, damage);
pixman_region32_subtract(&repaint, &repaint, &es->clip);
@@ -1345,22 +1369,8 @@ weston_surface_draw(struct weston_surface *es, struct 
weston_output *output,
 
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
 
-   /* blended region is whole surface minus opaque region: */
-   pixman_region32_init_rect(&surface_blend, 0, 0,
- es->geometry.width, es->geometry.height);
-   if (es->alpha >= 1.0)
-   pixman_region32_subtract(&surface_blend, &surface_blend,
-&es->opaque);
-
-   if (ec->current_shader != es->shader) {
-   glUseProgram(es->shader->program);
-   ec->current_shader = es->shader;
-   }
-
-   glUniformMatrix4fv(es->shader->proj_uniform,
-  1, GL_FALSE, output->matrix.d);
-   glUniform4fv(es->shader->color_uniform, 1, es->color);
-   glUniform1f(es->shader->alpha_uniform, es->alpha);
+   weston_compositor_use_shader(ec, es->shader);
+   weston_shader_uniforms(es->shader, es, output);
 
if (es->transform.enabled || output->zoom.active)
filter = GL_LINEAR;
@@ -1368,26 +1378,46 @@ weston_surface_draw(struct weston_surface *es, struct 
weston_output *output,
filter = GL_NEAREST;
 
for (i = 0; i < es->num_textures; i++) {
-   glUniform1i(es->shader->tex_uniforms[i], i);
glActiveTexture(GL_TEXTURE0 + i);
glBindTexture(es->target, es->textures[i]);
glTexParameteri(es->target, GL_TEXTURE_MIN_FILTER, filter);
glTexParameteri(es->target, GL_TEXTURE_MAG_FILTER, filter);
}
 
-   if (pixman_region32_not_empty(&es->opaque) && es->alpha >= 1.0) {
-   glDisable(GL_BLEND);
+   /* blended region is whole surface minus opaque region: */
+   pixman_region32_init_rect(&surface_blend, 0, 0,
+ es->geometry.width, es->geometry.height);
+   pixman_region32_subtract(&surface_blend, &surface_blend, &es->opaque);
+
+   if (pixman_region32_not_empty(&es->opaque)) {
+   if (es->shader == &ec->texture_shader_rgba) {
+   /* Special case for RGBA textures with possibly
+* bad data in alpha channel: use the shader
+* that forces texture alpha = 1.0.
+* Xwayland surfaces need this.
+*/
+   weston_compositor_use_shader(ec, 
&ec->tex

[PATCH weston 3/3] compositor: fix fan_debug mode

2012-09-03 Thread Pekka Paalanen
- make it respect output transforms by making sure the uniforms are
  up-to-date

- properly restore the current shader program, in case it was
  overridden

Signed-off-by: Pekka Paalanen 
---
 src/compositor.c |7 ++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/src/compositor.c b/src/compositor.c
index 918b455..4288e89 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -1269,7 +1269,7 @@ triangle_fan_debug(struct weston_surface *surface, int 
first, int count)
glUniform4fv(compositor->solid_shader.color_uniform, 1,
color[color_idx++ % ARRAY_SIZE(color)]);
glDrawElements(GL_LINES, nelems, GL_UNSIGNED_SHORT, buffer);
-   glUseProgram(surface->shader->program);
+   glUseProgram(compositor->current_shader->program);
free(buffer);
 }
 
@@ -1369,6 +1369,11 @@ weston_surface_draw(struct weston_surface *es, struct 
weston_output *output,
 
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
 
+   if (ec->fan_debug) {
+   weston_compositor_use_shader(ec, &ec->solid_shader);
+   weston_shader_uniforms(&ec->solid_shader, es, output);
+   }
+
weston_compositor_use_shader(ec, es->shader);
weston_shader_uniforms(es->shader, es, output);
 
-- 
1.7.8.6

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 1/3] xwayland: replace opaque_rect, fix an alpha problem

2012-09-03 Thread Pekka Paalanen
Remove weston_surface::opaque_rect completely.

Instead, set the opaque region in xwayland.

Before this patch, black text in xterm was transparent. Now it is not.

However, this patch fixes only a part of the alpha problem. If you apply
full-surface alpha with super+alt+wheel, the problem reappears. This
problem is still due to bad alpha channel contents on xwayland windows.

Signed-off-by: Pekka Paalanen 
---
 src/compositor.c  |4 
 src/compositor.h  |1 -
 src/xwayland/window-manager.c |   28 
 3 files changed, 16 insertions(+), 17 deletions(-)

diff --git a/src/compositor.c b/src/compositor.c
index 9ce44d4..5e9a0c2 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -243,10 +243,6 @@ weston_surface_create(struct weston_compositor *compositor)
 
surface->compositor = compositor;
surface->alpha = 1.0;
-   surface->opaque_rect[0] = 0.0;
-   surface->opaque_rect[1] = 0.0;
-   surface->opaque_rect[2] = 0.0;
-   surface->opaque_rect[3] = 0.0;
surface->pitch = 1;
 
surface->num_textures = 0;
diff --git a/src/compositor.h b/src/compositor.h
index 96a0477..38c2657 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -399,7 +399,6 @@ struct weston_surface {
struct wl_list layer_link;
struct weston_shader *shader;
GLfloat color[4];
-   GLfloat opaque_rect[4];
GLfloat alpha;
struct weston_plane *plane;
 
diff --git a/src/xwayland/window-manager.c b/src/xwayland/window-manager.c
index e705fec..65eb11a 100644
--- a/src/xwayland/window-manager.c
+++ b/src/xwayland/window-manager.c
@@ -717,17 +717,19 @@ weston_wm_window_draw_decoration(void *data)
cairo_destroy(cr);
 
if (window->surface) {
+   pixman_region32_fini(&window->surface->opaque);
+   pixman_region32_init_rect(&window->surface->opaque, 0, 0,
+ width, height);
+
/* We leave an extra pixel around the X window area to
 * make sure we don't sample from the undefined alpha
 * channel when filtering. */
-   window->surface->opaque_rect[0] =
-   (double) (x - 1) / width;
-   window->surface->opaque_rect[1] =
-   (double) (x + window->width + 1) / width;
-   window->surface->opaque_rect[2] =
-   (double) (y - 1) / height;
-   window->surface->opaque_rect[3] =
-   (double) (y + window->height + 1) / height;
+   pixman_region32_intersect_rect(&window->surface->opaque,
+  &window->surface->opaque,
+  x - 1, y - 1,
+  window->width + 2,
+  window->height + 2);
+   window->surface->geometry.dirty = 1;
 
pixman_region32_init_rect(&window->surface->input,
  t->margin, t->margin,
@@ -740,13 +742,15 @@ static void
 weston_wm_window_schedule_repaint(struct weston_wm_window *window)
 {
struct weston_wm *wm = window->wm;
+   int width, height;
 
if (window->frame_id == XCB_WINDOW_NONE) {
if (window->surface != NULL) {
-   window->surface->opaque_rect[0] = 0.0;
-   window->surface->opaque_rect[1] = 1.0;
-   window->surface->opaque_rect[2] = 0.0;
-   window->surface->opaque_rect[3] = 1.0;
+   weston_wm_window_get_frame_size(window, &width, 
&height);
+   pixman_region32_fini(&window->surface->opaque);
+   pixman_region32_init_rect(&window->surface->opaque, 0, 
0,
+ width, height);
+   window->surface->geometry.dirty = 1;
}
return;
}
-- 
1.7.8.6

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston] xwayland: replace opaque_rect

2012-09-03 Thread Pekka Paalanen
On Mon,  3 Sep 2012 14:15:44 +0300
Pekka Paalanen  wrote:

> Remove weston_surface::opaque_rect completely.
> 
> Instead, set the opaque region in xwayland.
> 
> This seems to fix all the alpha problems I could see with xterm, where
> the text was semi-transparent.
> 
> Signed-off-by: Pekka Paalanen 
> ---
>  src/compositor.c  |4 
>  src/compositor.h  |1 -
>  src/xwayland/window-manager.c |   28 
>  3 files changed, 16 insertions(+), 17 deletions(-)
> 
> diff --git a/src/compositor.c b/src/compositor.c
> index 9ce44d4..5e9a0c2 100644
> --- a/src/compositor.c
> +++ b/src/compositor.c
> @@ -243,10 +243,6 @@ weston_surface_create(struct weston_compositor 
> *compositor)
>  
>   surface->compositor = compositor;
>   surface->alpha = 1.0;
> - surface->opaque_rect[0] = 0.0;
> - surface->opaque_rect[1] = 0.0;
> - surface->opaque_rect[2] = 0.0;
> - surface->opaque_rect[3] = 0.0;
>   surface->pitch = 1;
>  
>   surface->num_textures = 0;
> diff --git a/src/compositor.h b/src/compositor.h
> index 96a0477..38c2657 100644
> --- a/src/compositor.h
> +++ b/src/compositor.h
> @@ -399,7 +399,6 @@ struct weston_surface {
>   struct wl_list layer_link;
>   struct weston_shader *shader;
>   GLfloat color[4];
> - GLfloat opaque_rect[4];
>   GLfloat alpha;
>   struct weston_plane *plane;
>  
> diff --git a/src/xwayland/window-manager.c b/src/xwayland/window-manager.c
> index e705fec..9c0410f 100644
> --- a/src/xwayland/window-manager.c
> +++ b/src/xwayland/window-manager.c
> @@ -717,17 +717,20 @@ weston_wm_window_draw_decoration(void *data)
>   cairo_destroy(cr);
>  
>   if (window->surface) {
> + pixman_region32_fini(&window->surface->opaque);
> + pixman_region32_init_rect(&window->surface->opaque, 0, 0,
> +   window->surface->geometry.width,
> +   window->surface->geometry.height);
> +
>   /* We leave an extra pixel around the X window area to
>* make sure we don't sample from the undefined alpha
>* channel when filtering. */
> - window->surface->opaque_rect[0] =
> - (double) (x - 1) / width;
> - window->surface->opaque_rect[1] =
> - (double) (x + window->width + 1) / width;
> - window->surface->opaque_rect[2] =
> - (double) (y - 1) / height;
> - window->surface->opaque_rect[3] =
> - (double) (y + window->height + 1) / height;
> + pixman_region32_intersect_rect(&window->surface->opaque,
> +&window->surface->opaque,
> +x - 1, y - 1,
> +window->width + 2,
> +window->height + 2);
> + window->surface->geometry.dirty = 1;
>  
>   pixman_region32_init_rect(&window->surface->input,
> t->margin, t->margin,
> @@ -743,10 +746,11 @@ weston_wm_window_schedule_repaint(struct 
> weston_wm_window *window)
>  
>   if (window->frame_id == XCB_WINDOW_NONE) {
>   if (window->surface != NULL) {
> - window->surface->opaque_rect[0] = 0.0;
> - window->surface->opaque_rect[1] = 1.0;
> - window->surface->opaque_rect[2] = 0.0;
> - window->surface->opaque_rect[3] = 1.0;
> + pixman_region32_fini(&window->surface->opaque);
> + pixman_region32_init_rect(&window->surface->opaque, 0, 
> 0,
> +   
> window->surface->geometry.width,
> +   
> window->surface->geometry.height);
> + window->surface->geometry.dirty = 1;
>   }
>   return;
>   }

Eh, I forgot to use the right(?) width, height variables. Anyway, this
is the idea. Now I just need to fix the shader usage in compositor.c.

I'll send a remake of this patch, and the shader change, later.


Thanks,
pq
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston] xwayland: replace opaque_rect

2012-09-03 Thread Pekka Paalanen
Remove weston_surface::opaque_rect completely.

Instead, set the opaque region in xwayland.

This seems to fix all the alpha problems I could see with xterm, where
the text was semi-transparent.

Signed-off-by: Pekka Paalanen 
---
 src/compositor.c  |4 
 src/compositor.h  |1 -
 src/xwayland/window-manager.c |   28 
 3 files changed, 16 insertions(+), 17 deletions(-)

diff --git a/src/compositor.c b/src/compositor.c
index 9ce44d4..5e9a0c2 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -243,10 +243,6 @@ weston_surface_create(struct weston_compositor *compositor)
 
surface->compositor = compositor;
surface->alpha = 1.0;
-   surface->opaque_rect[0] = 0.0;
-   surface->opaque_rect[1] = 0.0;
-   surface->opaque_rect[2] = 0.0;
-   surface->opaque_rect[3] = 0.0;
surface->pitch = 1;
 
surface->num_textures = 0;
diff --git a/src/compositor.h b/src/compositor.h
index 96a0477..38c2657 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -399,7 +399,6 @@ struct weston_surface {
struct wl_list layer_link;
struct weston_shader *shader;
GLfloat color[4];
-   GLfloat opaque_rect[4];
GLfloat alpha;
struct weston_plane *plane;
 
diff --git a/src/xwayland/window-manager.c b/src/xwayland/window-manager.c
index e705fec..9c0410f 100644
--- a/src/xwayland/window-manager.c
+++ b/src/xwayland/window-manager.c
@@ -717,17 +717,20 @@ weston_wm_window_draw_decoration(void *data)
cairo_destroy(cr);
 
if (window->surface) {
+   pixman_region32_fini(&window->surface->opaque);
+   pixman_region32_init_rect(&window->surface->opaque, 0, 0,
+ window->surface->geometry.width,
+ window->surface->geometry.height);
+
/* We leave an extra pixel around the X window area to
 * make sure we don't sample from the undefined alpha
 * channel when filtering. */
-   window->surface->opaque_rect[0] =
-   (double) (x - 1) / width;
-   window->surface->opaque_rect[1] =
-   (double) (x + window->width + 1) / width;
-   window->surface->opaque_rect[2] =
-   (double) (y - 1) / height;
-   window->surface->opaque_rect[3] =
-   (double) (y + window->height + 1) / height;
+   pixman_region32_intersect_rect(&window->surface->opaque,
+  &window->surface->opaque,
+  x - 1, y - 1,
+  window->width + 2,
+  window->height + 2);
+   window->surface->geometry.dirty = 1;
 
pixman_region32_init_rect(&window->surface->input,
  t->margin, t->margin,
@@ -743,10 +746,11 @@ weston_wm_window_schedule_repaint(struct weston_wm_window 
*window)
 
if (window->frame_id == XCB_WINDOW_NONE) {
if (window->surface != NULL) {
-   window->surface->opaque_rect[0] = 0.0;
-   window->surface->opaque_rect[1] = 1.0;
-   window->surface->opaque_rect[2] = 0.0;
-   window->surface->opaque_rect[3] = 1.0;
+   pixman_region32_fini(&window->surface->opaque);
+   pixman_region32_init_rect(&window->surface->opaque, 0, 
0,
+ 
window->surface->geometry.width,
+ 
window->surface->geometry.height);
+   window->surface->geometry.dirty = 1;
}
return;
}
-- 
1.7.8.6

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston] compositor: Fix xwayland surface alpha.

2012-09-03 Thread Pekka Paalanen
On Sat,  1 Sep 2012 21:58:45 -0600
Scott Moreau  wrote:

> Re-add the opaque_rect hack back to shaders so xwayland surfaces are not 
> broken. xwm
> is the only one that uses weston_surface::opaque_rect, specifically for this 
> reason.
> It was removed by 0e5a2d02191 - "compositor: simplify shaders", which 
> simplified them
> a bit too much.
> ---
>  src/compositor.c | 6 ++
>  src/compositor.h | 1 +
>  2 files changed, 7 insertions(+)
> 
> diff --git a/src/compositor.c b/src/compositor.c
> index 9ce44d4..b19cbaf 100644
> --- a/src/compositor.c
> +++ b/src/compositor.c
> @@ -1365,6 +1365,7 @@ weston_surface_draw(struct weston_surface *es, struct 
> weston_output *output,
>  1, GL_FALSE, output->matrix.d);
>   glUniform4fv(es->shader->color_uniform, 1, es->color);
>   glUniform1f(es->shader->alpha_uniform, es->alpha);
> + glUniform4fv(es->shader->opaque_uniform, 1, es->opaque_rect);
>  
>   if (es->transform.enabled || output->zoom.active)
>   filter = GL_LINEAR;
> @@ -3247,9 +3248,13 @@ static const char texture_fragment_shader_rgba[] =
>   "varying vec2 v_texcoord;\n"
>   "uniform sampler2D tex;\n"
>   "uniform float alpha;\n"
> + "uniform vec4 opaque;\n"
>   "void main()\n"
>   "{\n"
>   "   gl_FragColor = alpha * texture2D(tex, v_texcoord)\n;"
> + "   if (opaque.x <= v_texcoord.x && v_texcoord.x < opaque.y &&\n"
> + "   opaque.z <= v_texcoord.y && v_texcoord.y < opaque.w)\n"
> + "   gl_FragColor.a = alpha;\n"
>   "}\n";
>  
>  static const char texture_fragment_shader_rgbx[] =
> @@ -3375,6 +3380,7 @@ weston_shader_init(struct weston_shader *shader,
>   shader->tex_uniforms[2] = glGetUniformLocation(shader->program, "tex2");
>   shader->alpha_uniform = glGetUniformLocation(shader->program, "alpha");
>   shader->color_uniform = glGetUniformLocation(shader->program, "color");
> + shader->opaque_uniform = glGetUniformLocation(shader->program, 
> "opaque");
>  
>   return 0;
>  }
> diff --git a/src/compositor.h b/src/compositor.h
> index 96a0477..13ee804 100644
> --- a/src/compositor.h
> +++ b/src/compositor.h
> @@ -248,6 +248,7 @@ struct weston_shader {
>   GLint tex_uniforms[3];
>   GLint alpha_uniform;
>   GLint color_uniform;
> + GLint opaque_uniform;
>  };
>  
>  enum {

NAK, I'm developing a proper fix, that removes
weston_surface::opaque_rect completely.

Now that we can paint opaque regions independently from non-opaques, we
can set the shader for opaque regions to the RGBX shader, which forces
the sampled alpha to 1.0. That way we can keep the shaders simple.


Thanks,
pq
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston] compositor: Fix xwayland surface alpha.

2012-09-03 Thread Tiago Vignatti


On 09/02/2012 06:58 AM, Scott Moreau wrote:

Re-add the opaque_rect hack back to shaders so xwayland surfaces are not 
broken. xwm
is the only one that uses weston_surface::opaque_rect, specifically for this 
reason.
It was removed by 0e5a2d02191 - "compositor: simplify shaders", which 
simplified them
a bit too much.


Reviewed-by: Tiago Vignatti 
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel