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

Sync changes from mozilla-central gfx/wr #3872

Merged
merged 33 commits into from Mar 6, 2020
Merged
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
240b8ed
Bug 1510030 - Don't return the current opacity value from update_opac…
hiikezoe Feb 27, 2020
0809ea1
Bug 1510030 - Fix the comment for OpacityBinding::update(). r=gw
hiikezoe Feb 27, 2020
8aa347d
Bug 1510030 - Make prepare_prim_for_render private. r=gw
hiikezoe Feb 27, 2020
b2bc0a8
Bug 1510030 - Implement WebRender backend to run background color ani…
hiikezoe Feb 27, 2020
b0e0510
Backed out 6 changesets (bug 1510030) for webrender bustages CLOSED TREE
bogdantara Feb 27, 2020
8353c5a
Bug 1510030 - Don't return the current opacity value from update_opac…
hiikezoe Feb 27, 2020
6f45b76
Bug 1510030 - Fix the comment for OpacityBinding::update(). r=gw
hiikezoe Feb 27, 2020
d422aab
Bug 1510030 - Make prepare_prim_for_render private. r=gw
hiikezoe Feb 27, 2020
692bc61
Bug 1510030 - Implement WebRender backend to run background color ani…
hiikezoe Feb 27, 2020
1fc3512
Backed out 6 changesets (bug 1510030) for test_running_on_compositor.…
bogdantara Feb 27, 2020
13e86e2
Bug 1510030 - Don't return the current opacity value from update_opac…
hiikezoe Feb 27, 2020
ecd8232
Bug 1510030 - Fix the comment for OpacityBinding::update(). r=gw
hiikezoe Feb 27, 2020
b152ac5
Bug 1510030 - Make prepare_prim_for_render private. r=gw
hiikezoe Feb 27, 2020
7b1f4fa
Bug 1510030 - Implement WebRender backend to run background color ani…
hiikezoe Feb 27, 2020
1ee6c0f
Bug 1616995 - patch 2 - Support vertical skew for upright-vertical fo…
jfkthame Feb 29, 2020
85ccbbf
Bug 1596513: Part 1: Take scale factors into account when rendering d…
cbrewster Feb 29, 2020
142de92
Bug 1596513: Part 3: Ensure drop shadow blur radius does not exceed M…
cbrewster Feb 29, 2020
6cffb1b
Bug 1579235 - Part 6 - Support an opaque/alpha native surface per sli…
gw3583 Mar 2, 2020
54d5fe8
Bug 1579235 - Part 7 - Fix UV rect calculation for external textures.…
gw3583 Mar 2, 2020
ab7ca3e
Bug 1579235 - Part 8 - Remove overlay tiles, they can be alpha tiles …
gw3583 Mar 2, 2020
49df0ec
Bug 1619265 - Bump rust versions for github CI. r=jrmuizel
staktrace Mar 2, 2020
ad0cd12
Bug 1579235 - Part 9 - Optimize compositor surface overlays. r=Bert
gw3583 Mar 3, 2020
4d776c9
Bug 1613260 - Support per-task scale for local space rasterization r=…
bpeersmoz Mar 3, 2020
517a4b6
Bug 1619293 - Re-enable rust flags in github CI. r=jrmuizel
staktrace Mar 3, 2020
7ed1505
Bug 1613260 - Increase allowed fuzz on new tests so they pass in AppV…
staktrace Mar 4, 2020
bf01196
Bug 1618319: Segregate intern::UpdateList insertions and removals. r=gw
Mar 4, 2020
a1991bc
Bug 1579235 - Part 10 - Fix incorrect skipping of composites. r=Bert
gw3583 Mar 4, 2020
dab8afd
Bug 1619393 - Reftest improvements for fuzzy tests r=gw
bpeersmoz Mar 5, 2020
8d121d8
Bug 1616255 - Handle start and end offsets in conic-gradient WR shade…
nt1m Mar 5, 2020
256215e
Bug 1619393 - Increase fuzz by one to allow reftest to pass on AppVey…
staktrace Mar 6, 2020
5aad73f
Bug 1579235 - Part 11 - Refactor how external surfaces are composited…
gw3583 Mar 6, 2020
4236b41
Bug 1579235 - Part 12 - Support native compositor surfaces. r=Bert,so…
gw3583 Mar 6, 2020
51b4045
Bug 1618939 - Hit MOZ_CRASH(explicit panic) at gfx/wr/webrender/src/r…
bpeersmoz Mar 6, 2020
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Bug 1579235 - Part 7 - Fix UV rect calculation for external textures.…

… r=Bert

This patch fixes an oversight in part 5 of this patch series that
could result in an incorrect UV rect being used for an external
texture that uses a custom UV rect.

When the texture is an external texture, the UV rect is not known when
the external surface descriptor is created, because external textures
are not resolved until the lock() callback is invoked at the start of
the frame render. To handle this, query the texture resolver for the
UV rect if it's an external texture, otherwise use the default UV rect.

Differential Revision: https://phabricator.services.mozilla.com/D64687

[ghsync] From https://hg.mozilla.org/mozilla-central/rev/8f267ed8f2e3d09ced8c665af0a6db3694197116
  • Loading branch information
gw3583 authored and moz-gfx committed Mar 2, 2020
commit 54d5fe896e3326e703c3575dfe6ae1a3479d8efd
@@ -56,7 +56,7 @@ void main(void) {

write_uv_rect(
aUvRect0.xy,
aUvRect0.xy + aUvRect0.zw,
aUvRect0.zw,
aTextureLayers.x,
uv,
TEX_SIZE(sColor0),
@@ -65,7 +65,7 @@ void main(void) {
);
write_uv_rect(
aUvRect1.xy,
aUvRect1.xy + aUvRect1.zw,
aUvRect1.zw,
aTextureLayers.y,
uv,
TEX_SIZE(sColor1),
@@ -74,7 +74,7 @@ void main(void) {
);
write_uv_rect(
aUvRect2.xy,
aUvRect2.xy + aUvRect2.zw,
aUvRect2.zw,
aTextureLayers.z,
uv,
TEX_SIZE(sColor2),
@@ -4,7 +4,7 @@

use api::{ColorF, ImageKey, YuvColorSpace, YuvFormat, ImageRendering};
use api::units::{DeviceRect, DeviceIntSize, DeviceIntRect, DeviceIntPoint, WorldRect};
use api::units::{DevicePixelScale, DevicePoint, PictureRect};
use api::units::{DevicePixelScale, DevicePoint, PictureRect, TexelRect};
use crate::batch::{resolve_image, get_buffer_kind};
use crate::gpu_cache::GpuCache;
use crate::gpu_types::{ZBufferId, ZBufferIdGenerator};
@@ -116,15 +116,15 @@ pub struct ExternalSurfaceDescriptor {
pub struct YuvPlaneDescriptor {
pub texture: TextureSource,
pub texture_layer: i32,
pub uv_rect: DeviceRect,
pub uv_rect: TexelRect,
}

impl YuvPlaneDescriptor {
fn invalid() -> Self {
YuvPlaneDescriptor {
texture: TextureSource::Invalid,
texture_layer: 0,
uv_rect: DeviceRect::zero(),
uv_rect: TexelRect::invalid(),
}
}
}
@@ -491,7 +491,7 @@ impl CompositeState {
*plane = YuvPlaneDescriptor {
texture: cache_item.texture_id,
texture_layer: cache_item.texture_layer,
uv_rect: cache_item.uv_rect.to_f32(),
uv_rect: cache_item.uv_rect.into(),
};
}
}
@@ -486,21 +486,32 @@ pub struct ExternalTexture {
id: gl::GLuint,
target: gl::GLuint,
swizzle: Swizzle,
uv_rect: TexelRect,
}

impl ExternalTexture {
pub fn new(id: u32, target: TextureTarget, swizzle: Swizzle) -> Self {
pub fn new(
id: u32,
target: TextureTarget,
swizzle: Swizzle,
uv_rect: TexelRect,
) -> Self {
ExternalTexture {
id,
target: get_gl_target(target),
swizzle,
uv_rect,
}
}

#[cfg(feature = "replay")]
pub fn internal_id(&self) -> gl::GLuint {
self.id
}

pub fn get_uv_rect(&self) -> TexelRect {
self.uv_rect
}
}

bitflags! {
@@ -618,6 +629,13 @@ impl Texture {
id: self.id,
target: self.target,
swizzle: Swizzle::default(),
// TODO(gw): Support custom UV rect for external textures during captures
uv_rect: TexelRect::new(
0.0,
0.0,
self.size.width as f32,
self.size.height as f32,
),
};
self.id = 0; // don't complain, moved out
ext
@@ -255,7 +255,7 @@ pub struct CompositeInstance {
yuv_rescale: f32,

// UV rectangles (pixel space) for color / yuv texture planes
uv_rects: [DeviceRect; 3],
uv_rects: [TexelRect; 3],

// Texture array layers for color / yuv texture planes
texture_layers: [f32; 3],
@@ -278,7 +278,7 @@ impl CompositeInstance {
yuv_format: 0.0,
yuv_rescale: 0.0,
texture_layers: [layer, 0.0, 0.0],
uv_rects: [DeviceRect::zero(); 3],
uv_rects: [TexelRect::invalid(); 3],
}
}

@@ -290,7 +290,7 @@ impl CompositeInstance {
yuv_format: YuvFormat,
yuv_rescale: f32,
texture_layers: [f32; 3],
uv_rects: [DeviceRect; 3],
uv_rects: [TexelRect; 3],
) -> Self {
CompositeInstance {
rect,
@@ -1253,6 +1253,26 @@ impl TextureResolver {
}
}

// Retrieve the deferred / resolved UV rect if an external texture, otherwise
// return the default supplied UV rect.
fn get_uv_rect(
&self,
source: &TextureSource,
default_value: TexelRect,
) -> TexelRect {
match source {
TextureSource::External(ref external_image) => {
let texture = self.external_images
.get(&(external_image.id, external_image.channel_index))
.expect("BUG: External image should be resolved by now");
texture.get_uv_rect()
}
_ => {
default_value
}
}
}

fn report_memory(&self) -> MemoryReport {
let mut report = MemoryReport::default();

@@ -4373,6 +4393,17 @@ impl Renderer {
}
current_textures = textures;

// When the texture is an external texture, the UV rect is not known when
// the external surface descriptor is created, because external textures
// are not resolved until the lock() callback is invoked at the start of
// the frame render. To handle this, query the texture resolver for the
// UV rect if it's an external texture, otherwise use the default UV rect.
let uv_rects = [
self.texture_resolver.get_uv_rect(&textures.colors[0], surface.yuv_planes[0].uv_rect),
self.texture_resolver.get_uv_rect(&textures.colors[1], surface.yuv_planes[1].uv_rect),
self.texture_resolver.get_uv_rect(&textures.colors[2], surface.yuv_planes[2].uv_rect),
];

// Create the instance and add to current batch
let instance = CompositeInstance::new_yuv(
surface.device_rect,
@@ -4386,11 +4417,7 @@ impl Renderer {
surface.yuv_planes[1].texture_layer as f32,
surface.yuv_planes[2].texture_layer as f32,
],
[
surface.yuv_planes[0].uv_rect,
surface.yuv_planes[1].uv_rect,
surface.yuv_planes[2].uv_rect,
],
uv_rects,
);
instances.push(instance);
}
@@ -5149,7 +5176,12 @@ impl Renderer {

let texture = match image.source {
ExternalImageSource::NativeTexture(texture_id) => {
ExternalTexture::new(texture_id, texture_target, Swizzle::default())
ExternalTexture::new(
texture_id,
texture_target,
Swizzle::default(),
image.uv,
)
}
ExternalImageSource::Invalid => {
warn!("Invalid ext-image");
@@ -5159,7 +5191,12 @@ impl Renderer {
ext_image.channel_index
);
// Just use 0 as the gl handle for this failed case.
ExternalTexture::new(0, texture_target, Swizzle::default())
ExternalTexture::new(
0,
texture_target,
Swizzle::default(),
image.uv,
)
}
ExternalImageSource::RawData(_) => {
panic!("Raw external data is not expected for deferred resolves!");
@@ -170,6 +170,15 @@ impl TexelRect {
}
}

impl Into<TexelRect> for DeviceIntRect {
fn into(self) -> TexelRect {
TexelRect {
uv0: self.min().to_f32(),
uv1: self.max().to_f32(),
}
}
}

const MAX_AU_FLOAT: f32 = 1.0e6;

pub trait AuHelpers<T> {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.