Bug 1695660 - Remove layer parameter from DrawTarget and ReadTarget. r=gfx-reviewers,jrmuizel

Depends on D106796

Differential Revision: https://phabricator.services.mozilla.com/D106797
This commit is contained in:
Nicolas Silva 2021-03-02 16:54:21 +00:00
Родитель bdcb564f48
Коммит 83c0cc8556
5 изменённых файлов: 20 добавлений и 90 удалений

Просмотреть файл

@ -1154,8 +1154,6 @@ pub enum DrawTarget {
Texture {
/// Size of the texture in pixels
dimensions: DeviceIntSize,
/// The slice within the texture array to draw to
layer: LayerIndex,
/// Whether to draw with the texture's associated depth target
with_depth: bool,
/// Workaround buffers for devices with broken texture array copy implementation
@ -1200,7 +1198,6 @@ impl DrawTarget {
pub fn from_texture(
texture: &Texture,
layer: usize,
with_depth: bool,
) -> Self {
let fbo_id = if with_depth {
@ -1213,7 +1210,6 @@ impl DrawTarget {
dimensions: texture.get_dimensions(),
fbo_id,
with_depth,
layer,
blit_workaround_buffer: texture.blit_workaround_buffer,
id: texture.id,
target: texture.target,
@ -1309,7 +1305,6 @@ pub enum ReadTarget {
impl ReadTarget {
pub fn from_texture(
texture: &Texture,
_layer: usize,
) -> Self {
ReadTarget::Texture {
fbo_id: texture.fbo.unwrap(),
@ -2524,22 +2519,20 @@ impl Device {
);
}
} else {
for i in 0..depth as LayerIndex {
let src_offset = FramebufferIntPoint::new(src_x as i32, src_y as i32);
let dest_offset = FramebufferIntPoint::new(dest_x as i32, dest_y as i32);
let size = FramebufferIntSize::new(width as i32, height as i32);
let src_offset = FramebufferIntPoint::new(src_x as i32, src_y as i32);
let dest_offset = FramebufferIntPoint::new(dest_x as i32, dest_y as i32);
let size = FramebufferIntSize::new(width as i32, height as i32);
self.blit_render_target(
ReadTarget::from_texture(src_texture, src_z + i),
FramebufferIntRect::new(src_offset, size),
DrawTarget::from_texture(dest_texture, dest_z + i, false),
FramebufferIntRect::new(dest_offset, size),
// In most cases the filter shouldn't matter, as there is no scaling involved
// in the blit. We were previously using Linear, but this caused issues when
// blitting RGBAF32 textures on Mali, so use Nearest to be safe.
TextureFilter::Nearest,
);
}
self.blit_render_target(
ReadTarget::from_texture(src_texture),
FramebufferIntRect::new(src_offset, size),
DrawTarget::from_texture(dest_texture, false),
FramebufferIntRect::new(dest_offset, size),
// In most cases the filter shouldn't matter, as there is no scaling involved
// in the blit. We were previously using Linear, but this caused issues when
// blitting RGBAF32 textures on Mali, so use Nearest to be safe.
TextureFilter::Nearest,
);
}
}
@ -2714,60 +2707,9 @@ impl Device {
self.bind_read_target(src_target);
match dest_target {
DrawTarget::Texture { layer, blit_workaround_buffer, dimensions, id, target, .. } if layer != 0 &&
!self.capabilities.supports_blit_to_texture_array =>
{
// This should have been initialized in create_texture().
let (_rbo, fbo) = blit_workaround_buffer.expect("Blit workaround buffer has not been initialized.");
self.bind_draw_target(dest_target);
// Blit from read target to intermediate buffer.
self.bind_draw_target_impl(fbo);
self.blit_render_target_impl(
src_rect,
dest_rect,
filter
);
// dest_rect may be inverted, so min_x/y() might actually be the
// bottom-right, max_x/y() might actually be the top-left,
// and width/height might be negative. See servo/euclid#321.
// Calculate the non-inverted rect here.
let dest_bounds = DeviceIntRect::new(
DeviceIntPoint::new(
dest_rect.min_x().min(dest_rect.max_x()),
dest_rect.min_y().min(dest_rect.max_y()),
),
DeviceIntSize::new(
dest_rect.size.width.abs(),
dest_rect.size.height.abs(),
),
).intersection(&dimensions.into()).unwrap_or_else(DeviceIntRect::zero);
self.bind_read_target_impl(fbo, DeviceIntPoint::zero());
self.bind_texture_impl(
DEFAULT_TEXTURE,
id,
target,
None, // not depending on swizzle
);
// Copy from intermediate buffer to the texture layer.
self.gl.copy_tex_sub_image_3d(
target, 0,
dest_bounds.origin.x, dest_bounds.origin.y,
layer as _,
dest_bounds.origin.x, dest_bounds.origin.y,
dest_bounds.size.width, dest_bounds.size.height,
);
}
_ => {
self.bind_draw_target(dest_target);
self.blit_render_target_impl(src_rect, dest_rect, filter);
}
}
self.blit_render_target_impl(src_rect, dest_rect, filter);
}
/// Performs a blit while flipping vertically. Useful for blitting textures

Просмотреть файл

@ -364,7 +364,6 @@ impl GpuCacheTexture {
device.bind_draw_target(
DrawTarget::from_texture(
texture,
0,
false,
),
);
@ -513,7 +512,7 @@ impl super::Renderer {
let size = device_size_as_framebuffer_size(texture.get_dimensions());
let mut texels = vec![0; (size.width * size.height * 16) as usize];
self.device.begin_frame();
self.device.bind_read_target(ReadTarget::from_texture(texture, 0));
self.device.bind_read_target(ReadTarget::from_texture(texture));
self.device.read_pixels_into(
size.into(),
api::ImageFormat::RGBAF32,

Просмотреть файл

@ -2553,7 +2553,6 @@ impl Renderer {
// the GL call if the requested target is already bound.
let cache_draw_target = DrawTarget::from_texture(
cache_texture,
0,
false,
);
@ -2654,7 +2653,6 @@ impl Renderer {
let read_target = DrawTarget::from_texture(
texture,
0,
false,
);
@ -3849,7 +3847,6 @@ impl Renderer {
let draw_target = DrawTarget::from_texture(
texture,
0,
false,
);
self.device.bind_draw_target(draw_target);
@ -4397,7 +4394,6 @@ impl Renderer {
DrawTarget::from_texture(
texture,
0,
true,
)
}
@ -4468,7 +4464,6 @@ impl Renderer {
let draw_target = DrawTarget::from_texture(
alpha_tex,
0,
false,
);
@ -4509,7 +4504,6 @@ impl Renderer {
let draw_target = DrawTarget::from_texture(
color_tex,
0,
target.needs_depth(),
);
@ -4807,7 +4801,6 @@ impl Renderer {
read_target.to_framebuffer_rect(source_rect),
DrawTarget::from_texture(
self.zoom_debug_texture.as_ref().unwrap(),
0,
false,
),
texture_rect,
@ -4818,7 +4811,6 @@ impl Renderer {
self.device.blit_render_target(
ReadTarget::from_texture(
self.zoom_debug_texture.as_ref().unwrap(),
0,
),
texture_rect,
read_target,
@ -4932,7 +4924,7 @@ impl Renderer {
// Blit the contents of the texture.
let dest_rect = draw_target.to_framebuffer_rect(rect(x, image_y, size, size));
let read_target = ReadTarget::from_texture(texture, 0);
let read_target = ReadTarget::from_texture(texture);
if surface_origin_is_top_left {
device.blit_render_target(
@ -5179,7 +5171,6 @@ impl Renderer {
fn clear_texture(&mut self, texture: &Texture, color: [f32; 4]) {
self.device.bind_draw_target(DrawTarget::from_texture(
&texture,
0,
false,
));
self.device.clear_target(Some(color), None, None);

Просмотреть файл

@ -118,7 +118,6 @@ pub fn upload_to_texture_cache(
TextureUpdateSource::DebugClear => {
let draw_target = DrawTarget::from_texture(
texture,
0,
false,
);
renderer.device.bind_draw_target(draw_target);
@ -498,7 +497,6 @@ fn copy_from_staging_to_cache_using_draw_calls(
let draw_target = DrawTarget::from_texture(
dest_texture,
0,
false,
);
renderer.device.bind_draw_target(draw_target);

Просмотреть файл

@ -185,7 +185,7 @@ impl AsyncScreenshotGrabber {
0,
);
ReadTarget::from_texture(&self.scaling_textures[0], 0)
ReadTarget::from_texture(&self.scaling_textures[0])
}
AsyncScreenshotGrabberMode::CompositionRecorder => ReadTarget::Default,
@ -280,14 +280,14 @@ impl AsyncScreenshotGrabber {
);
(
ReadTarget::from_texture(&self.scaling_textures[level + 1], 0),
ReadTarget::from_texture(&self.scaling_textures[level + 1]),
DeviceIntRect::new(DeviceIntPoint::new(0, 0), dest_size * 2),
)
} else {
(read_target, read_target_rect)
};
let draw_target = DrawTarget::from_texture(&self.scaling_textures[level], 0 as _, false);
let draw_target = DrawTarget::from_texture(&self.scaling_textures[level], false);
let draw_target_rect = draw_target
.to_framebuffer_rect(DeviceIntRect::new(DeviceIntPoint::new(0, 0), dest_size));