Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prim_shared: Fix clip mask perspective interpolation. #3145

Merged
merged 2 commits into from Oct 1, 2018
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Next

prim_shared: Fix clip mask perspective interpolation.

This was really hard to track down, the comment there really convinced me that
the code was correct, so I ended up looking at everything else before that...

This fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1494453.
  • Loading branch information
emilio committed Sep 30, 2018
commit 919498085a94b615f61498446010331f2450a818
@@ -241,8 +241,7 @@ float do_clip() {
return 1.0;
}
// anything outside of the mask is considered transparent
//Note: we assume gl_FragCoord.w == interpolated(1 / vClipMaskUv.w)
vec2 mask_uv = vClipMaskUv.xy * gl_FragCoord.w;
vec2 mask_uv = vClipMaskUv.xy / vClipMaskUv.w;

This comment has been minimized.

@kvark

kvark Oct 1, 2018

Member

did you figure out why my comment was wrong?

This comment has been minimized.

@emilio

emilio Oct 1, 2018

Author Member

I don't know what would guarantee that given write_vertex has:

    gl_Position = uTransform * vec4(final_pos, z, 1.0);

This comment has been minimized.

@kvark

kvark Oct 1, 2018

Member

write_vertex also is not supposed to be used for transforms that have any perspective, hence both vClipMaskUv.w == 1.0 and gl_FragCoord.w == 1.0, so the assumption still stands.

This comment has been minimized.

@emilio

emilio Oct 1, 2018

Author Member

Well, in this test-case we're definitely hitting write_vertex, with a world_pos with the w component different than 1. We're still writing 1.0 in gl_Position, but vClipMaskUv.w == world_pos.w, which is not one..

This comment has been minimized.

@emilio

emilio Oct 1, 2018

Author Member

The rest of write_vertex also doesn't seem to assume world_pos.w == 1.0, fwiw.

bvec2 left = lessThanEqual(vClipMaskUvBounds.xy, mask_uv); // inclusive
bvec2 right = greaterThan(vClipMaskUvBounds.zw, mask_uv); // non-inclusive
// bail out if the pixel is outside the valid bounds
Binary file not shown.
@@ -0,0 +1,25 @@
---
root:
items:
-
type: stacking-context
bounds: [0, 0, 0, 0]
perspective: [1, 0, 0, 0, 0, 1, 0, 0, -300, -250, 1, -0.5, 0, 0, 0, 1]
items:
-
bounds: [0, 0, 0, 0]
type: stacking-context
transform: [10, 0, 0, 0, 0, 10, 0, 0, 0, 0, 1, 0, -5382, -3222, -18, 1]
items:
-
bounds: [0, 0, 100, 100]
type: rect
color: red
-
bounds: [0, 0, 100, 100]
type: rect
color: green
complex-clip:
rect: [0, 0, 100, 100]
radius: 16

Binary file not shown.
@@ -0,0 +1,23 @@
---
root:
items:
-
type: stacking-context
bounds: [0, 0, 0, 0]
transform: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 139, 0, 1]
perspective: [1, 0, 0, 0, 0, 1, 0, 0, -299, -250, 1, -0.5, 0, 0, 0, 1]
items:
-
bounds: [0, 0, 0, 0]
type: stacking-context
transform: [10, 0, 0, 0, 0, 10, 0, 0, 0, 0, 1, 0, -5382, -3222, -18, 1]
items:
-
type: box-shadow
bounds: [548, 200, 100, 100]
color: 0 0 0 0.7020
blur-radius: 20
-
bounds: [548, 200, 100, 100]
type: rect
color: 0 255 0 1.0000
@@ -23,5 +23,7 @@ platform(linux,mac) == perspective-mask.yaml perspective-mask.png
rotate-clip.yaml rotate-clip-ref.yaml
clip-translate.yaml clip-translate-ref.yaml
platform(linux,mac) == perspective-clip.yaml perspective-clip.png
platform(linux,mac) == perspective-clip-1.yaml perspective-clip-1.png
platform(linux,mac) == perspective-shadow.yaml perspective-shadow.png
== complex-preserve-3d.yaml blank.yaml
platform(linux,mac) fuzzy(9,348) == perspective-border-radius.yaml perspective-border-radius.png
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.